You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					82 lines
				
				2.2 KiB
			
		
		
			
		
	
	
					82 lines
				
				2.2 KiB
			| 
											2 weeks ago
										 | import { defineStore } from 'pinia' | ||
|  | import { store } from '@/store' | ||
|  | import { HandDetector, HandDetectorApi } from '@/api/gas/handdetector' | ||
|  | import { Type, TypeApi } from '@/api/gas/gastype' | ||
|  | import { Fence, FenceApi } from '@/api/gas/fence' | ||
|  | import { AlarmType, AlarmTypeApi } from '@/api/gas/alarmtype' | ||
|  | 
 | ||
|  | export const useHandDetectorStore = defineStore('handDetector', { | ||
|  |   state() { | ||
|  |     return { | ||
|  |       handDetectorList: [] as HandDetector[], | ||
|  |       gasTypes: [] as Type[], | ||
|  |       fences: [] as Fence[], | ||
|  |       alarmTypes: [] as AlarmType[] | ||
|  |     } | ||
|  |   }, | ||
|  |   getters: { | ||
|  |     getHandDetectorList(): HandDetector[] { | ||
|  |       return this.handDetectorList | ||
|  |     }, | ||
|  |     getGasTypes(): Type[] { | ||
|  |       return this.gasTypes | ||
|  |     }, | ||
|  |     getFences(): Fence[] { | ||
|  |       return this.fences | ||
|  |     }, | ||
|  |     getAlarmTypes(): AlarmType[] { | ||
|  |       return this.alarmTypes | ||
|  |     } | ||
|  |   }, | ||
|  |   actions: { | ||
|  |     async getAllHandDetector(refresh: boolean = false) { | ||
|  |       if (refresh || this.handDetectorList.length === 0) { | ||
|  |         const data = await HandDetectorApi.getHandDetectorPage({ | ||
|  |           pageNo: 1, | ||
|  |           pageSize: 100 | ||
|  |         }) | ||
|  |         this.handDetectorList = data.list | ||
|  |         return this.handDetectorList | ||
|  |       } else { | ||
|  |         return this.handDetectorList | ||
|  |       } | ||
|  |     }, | ||
|  |     async getAllFences(refresh: boolean = false) { | ||
|  |       if (refresh || this.fences.length === 0) { | ||
|  |         const data = await FenceApi.getFencePage({ | ||
|  |           pageNo: 1, | ||
|  |           pageSize: 100 | ||
|  |         }) | ||
|  |         this.fences = data.list | ||
|  |         return this.fences | ||
|  |       } else { | ||
|  |         return this.fences | ||
|  |       } | ||
|  |     }, | ||
|  |     async getAllGasTypes(refresh: boolean = false) { | ||
|  |       if (refresh || this.gasTypes.length === 0) { | ||
|  |         const data = await TypeApi.getTypePage({ | ||
|  |           pageNo: 1, | ||
|  |           pageSize: 100 | ||
|  |         }) | ||
|  |         this.gasTypes = data.list | ||
|  |         return this.gasTypes | ||
|  |       } else { | ||
|  |         return this.gasTypes | ||
|  |       } | ||
|  |     }, | ||
|  |     async getAllAlarmTypes(refresh: boolean = false) { | ||
|  |       if (refresh || this.alarmTypes.length === 0) { | ||
|  |         const data = await AlarmTypeApi.getAlarmTypePage({ | ||
|  |           pageNo: 1, | ||
|  |           pageSize: 100 | ||
|  |         }) | ||
|  |         this.alarmTypes = data.list | ||
|  |         return this.alarmTypes | ||
|  |       } else { | ||
|  |         return this.alarmTypes | ||
|  |       } | ||
|  |     } | ||
|  |   } | ||
|  | }) |