| | |
| | | export interface CheckTypeSimpleVO { |
| | | value: number |
| | | name: string |
| | | displayBarcode: number |
| | | notes: string |
| | | } |
| | | export interface CheckTypeState { |
| | | checkTypeMap: Map<number, string> |
| | | checkTypeMap: Map<number, CheckTypeSimpleVO> |
| | | isSetCheckType: boolean |
| | | } |
| | | |
| | | export const useCheckTypeStore = defineStore('checktype ', { |
| | | state: (): CheckTypeState => ({ |
| | | checkTypeMap: new Map<number, string>(), |
| | | checkTypeMap: new Map<number, CheckTypeSimpleVO>(), |
| | | isSetCheckType: false |
| | | }), |
| | | getters: { |
| | |
| | | } else { |
| | | const res = await CheckTypeApi.getSimpleCheckTypeList() |
| | | // 设置数据 |
| | | const checkTypeMap = new Map<number, string>() |
| | | const checkTypeMap = new Map<number, CheckTypeSimpleVO>() |
| | | res.forEach((simpleVO: CheckTypeSimpleVO) => { |
| | | // 获得 dictType 层级 |
| | | const enumValueObj = checkTypeMap[simpleVO.value] |
| | | if (!enumValueObj) { |
| | | checkTypeMap[simpleVO.value] = simpleVO.name |
| | | checkTypeMap[simpleVO.value] = simpleVO |
| | | } |
| | | }) |
| | | this.checkTypeMap = checkTypeMap |
| | |
| | | if (!this.isSetCheckType) { |
| | | this.setCheckTypeMap() |
| | | } |
| | | return this.checkTypeMap[type] |
| | | return this.checkTypeMap[type].name |
| | | }, |
| | | getCheckTypeOptions() { |
| | | if (!this.isSetCheckType) { |
| | |
| | | return Object.keys(this.checkTypeMap).map((key) => { |
| | | return { |
| | | value: parseInt(key, 10), |
| | | label: this.checkTypeMap[key] |
| | | label: this.checkTypeMap[key].name |
| | | } |
| | | }); |
| | | }, |
| | | getCheckTypeDispBarCode(type: number) { |
| | | if (!this.isSetCheckType) { |
| | | this.setCheckTypeMap() |
| | | } |
| | | return this.checkTypeMap[type].displayBarcode |
| | | }, |
| | | getCheckTypeNotes(type: number) { |
| | | if (!this.isSetCheckType) { |
| | | this.setCheckTypeMap() |
| | | } |
| | | return this.checkTypeMap[type].notes |
| | | }, |
| | | async resetCheckTypeInfo() { |
| | | wsCache.delete(CACHE_KEY.CHECKTYPE_CACHE) |
| | | const res = await CheckTypeApi.getSimpleCheckTypeList() |
| | | // 设置数据 |
| | | const checkTypeMap = new Map<number, string>() |
| | | const checkTypeMap = new Map<number, CheckTypeSimpleVO>() |
| | | res.forEach((simpleVO: CheckTypeSimpleVO) => { |
| | | // 获得 dictType 层级 |
| | | const enumValueObj = checkTypeMap[simpleVO.value] |
| | | if (!enumValueObj) { |
| | | checkTypeMap[simpleVO.value] = simpleVO.name |
| | | checkTypeMap[simpleVO.value] = simpleVO |
| | | } |
| | | }) |
| | | this.checkTypeMap = checkTypeMap |