Files
admin-sjzx/src/stores/monitoringPoint.ts

39 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-02-22 14:51:05 +08:00
import { reactive } from 'vue'
import { defineStore } from 'pinia'
interface MonitoringPoint {
lineId: string
2024-02-26 10:43:33 +08:00
lineName: string
2024-02-29 09:37:31 +08:00
lineIds: string[]
showCheckBox: boolean
2024-02-22 14:51:05 +08:00
}
export const useMonitoringPoint = defineStore(
'monitoringPoint',
() => {
const state: MonitoringPoint = reactive({
2024-02-26 10:43:33 +08:00
lineId: '',
lineName: '',
2024-02-29 09:37:31 +08:00
lineIds: [],
showCheckBox: false
2024-02-22 14:51:05 +08:00
})
2024-02-29 09:37:31 +08:00
const setValue = (key: keyof Pick<MonitoringPoint, 'lineId' | 'lineName' | 'lineIds'>, val: any) => {
2024-02-22 14:51:05 +08:00
state[key] = val
}
2024-02-29 09:37:31 +08:00
const setShowCheckBox = (val: boolean) => {
2024-02-29 10:31:32 +08:00
if (val && state.lineIds.length === 0) {
2024-02-29 09:37:31 +08:00
state.lineIds = [state.lineId]
2024-02-29 16:29:34 +08:00
console.log('====================================');
console.log(state.lineIds);
console.log('====================================');
2024-02-29 09:37:31 +08:00
}
state.showCheckBox = val
}
return { state, setValue, setShowCheckBox }
2024-02-26 10:43:33 +08:00
},
{
2024-02-29 10:31:32 +08:00
persist: {
paths: ['state.lineId', 'state.lineName']
}
2024-02-22 14:51:05 +08:00
}
)