import type { ICarPerson, IListItem, IOutCheckArea, IPicArea } from '@/types/service' import { defineStore } from 'pinia' import { store } from '@/store' interface ServiceState { currentOutCheckArea: null | IOutCheckArea currentCar: null | IListItem currentCarPerson: null | ICarPerson jcxdh: string currentPicArea: IPicArea | null kssj: string checkedOk: boolean wgjykssj: string } export const useServiceStore = defineStore({ id: 'service', state: (): ServiceState => ({ currentOutCheckArea: null, // 当前选中的外检区域 currentCar: null, // 当前车辆信息 currentCarPerson: null, // 当前引车员 jcxdh: '', // 检测线代号 currentPicArea: null, kssj: '', // 开始时间 checkedOk: true, // 检验是否有不合格的 wgjykssj: '', // 外观检验开始时间 }), getters: { // 获取检测机构编码 getCurrentCheckAreaCode({ currentOutCheckArea }) { return currentOutCheckArea?.wjqbh || '' }, }, actions: { setWgjykssj(time: string) { this.wgjykssj = time }, setCheckOK(isOk: boolean) { this.checkedOk = isOk }, // 设置开始时间 setKssj(time: string) { this.kssj = time }, // 设置检测线代号 setJcxdh(jcxdh: string) { this.jcxdh = jcxdh }, // 设置当前选中的外检区域 setCurrentOutCheckArea(item: IOutCheckArea) { this.currentOutCheckArea = item || null }, // 设置当前选中的外检区域 setCurrentCarPerson(item: ICarPerson) { this.currentCarPerson = item || null }, // 设置当前的车辆信息 setCurrentCar(carItem: IListItem) { this.currentCar = carItem || null }, // 设置当前整车拍照检验区域 setCurrentPicArea(picArea: IPicArea) { this.currentPicArea = picArea || null }, }, }) // Need to be used outside the setup export function useServiceStoreWidthOut() { return useServiceStore(store) }