46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { reactive } from 'vue'
|
|
import { defineStore } from 'pinia'
|
|
interface MonitoringPoint {
|
|
lineId: string
|
|
lineName: string
|
|
pid: string
|
|
lineIds: string[]
|
|
showCheckBox: boolean
|
|
comFlag: number
|
|
}
|
|
|
|
export const useMonitoringPoint = defineStore(
|
|
'monitoringPoint',
|
|
() => {
|
|
const state: MonitoringPoint = reactive({
|
|
lineId: '',
|
|
lineName: '',
|
|
pid: '',
|
|
lineIds: [],
|
|
showCheckBox: false,
|
|
comFlag: 0
|
|
})
|
|
const setValue = (
|
|
key: keyof Pick<MonitoringPoint, 'lineId' | 'lineName' | 'lineIds' | 'pid' | 'comFlag'>,
|
|
val: any
|
|
) => {
|
|
state[key] = val
|
|
}
|
|
const setShowCheckBox = (val: boolean) => {
|
|
if (val && state.lineIds.length === 0) {
|
|
state.lineIds = [state.lineId]
|
|
// console.log('====================================')
|
|
// console.log(state.lineIds)
|
|
// console.log('====================================')
|
|
}
|
|
state.showCheckBox = val
|
|
}
|
|
return { state, setValue, setShowCheckBox }
|
|
},
|
|
{
|
|
persist: {
|
|
paths: ['state.lineId', 'state.lineName']
|
|
}
|
|
}
|
|
)
|