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
|
2025-03-13 18:26:03 +08:00
|
|
|
pid: string
|
2024-02-29 09:37:31 +08:00
|
|
|
lineIds: string[]
|
|
|
|
|
showCheckBox: boolean
|
2025-04-16 09:43:27 +08:00
|
|
|
comFlag: number
|
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: '',
|
2025-03-13 18:26:03 +08:00
|
|
|
pid: '',
|
2024-02-29 09:37:31 +08:00
|
|
|
lineIds: [],
|
2025-04-16 09:43:27 +08:00
|
|
|
showCheckBox: false,
|
|
|
|
|
comFlag: 0
|
2024-02-22 14:51:05 +08:00
|
|
|
})
|
2025-04-16 09:43:27 +08:00
|
|
|
const setValue = (
|
|
|
|
|
key: keyof Pick<MonitoringPoint, 'lineId' | 'lineName' | 'lineIds' | 'pid' | 'comFlag'>,
|
|
|
|
|
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]
|
|
|
|
|
}
|
|
|
|
|
state.showCheckBox = val
|
|
|
|
|
}
|
2026-01-12 11:22:42 +08:00
|
|
|
|
2024-02-29 09:37:31 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
)
|