2025-09-25 11:34:55 +08:00
|
|
|
|
import { defineStore } from 'pinia'
|
|
|
|
|
|
import type { DataStoreState } from './types'
|
|
|
|
|
|
// 图例
|
|
|
|
|
|
export const useDataStore = defineStore('data-store', {
|
|
|
|
|
|
state: (): DataStoreState => {
|
|
|
|
|
|
return {
|
|
|
|
|
|
dataTree: [],
|
|
|
|
|
|
pid: '',
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
identifying: '0',
|
|
|
|
|
|
mqttID: '',
|
|
|
|
|
|
preview: '',
|
2025-11-14 14:08:01 +08:00
|
|
|
|
keyName: '', //选中的name
|
2025-09-25 11:34:55 +08:00
|
|
|
|
wxqr: '',
|
|
|
|
|
|
loading: true,
|
|
|
|
|
|
display: false, //无锡项目进去是true,其他项目是false 控制预览的时候返回按钮的展示
|
|
|
|
|
|
graphicDisplay: 'zl' //无锡项目进去是true,其他项目是false 控制点击设计的时候左侧列表数据绑定图元的展示
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
actions: {
|
|
|
|
|
|
set(key: keyof DataStoreState, val: any) {
|
|
|
|
|
|
;(this as any)[key] = val
|
|
|
|
|
|
},
|
|
|
|
|
|
setmqttID(val: string) {
|
|
|
|
|
|
this.mqttID = val
|
|
|
|
|
|
},
|
|
|
|
|
|
//
|
|
|
|
|
|
interface(val: any) {
|
|
|
|
|
|
this.dataTree = val
|
|
|
|
|
|
},
|
|
|
|
|
|
// 追加
|
|
|
|
|
|
append(val: string) {
|
|
|
|
|
|
this.dataTree.push({
|
|
|
|
|
|
pid: this.pid,
|
|
|
|
|
|
kId: Math.random(),
|
|
|
|
|
|
name: val,
|
|
|
|
|
|
path: JSON.stringify({
|
|
|
|
|
|
canvasCfg: {
|
|
|
|
|
|
width: 1920,
|
|
|
|
|
|
height: 1080,
|
|
|
|
|
|
scale: 1,
|
|
|
|
|
|
color: '',
|
|
|
|
|
|
img: '',
|
|
|
|
|
|
guide: true,
|
|
|
|
|
|
adsorp: true,
|
|
|
|
|
|
adsorp_diff: 5,
|
|
|
|
|
|
transform_origin: {
|
|
|
|
|
|
x: 0,
|
|
|
|
|
|
y: 0
|
|
|
|
|
|
},
|
|
|
|
|
|
drag_offset: {
|
|
|
|
|
|
x: 0,
|
|
|
|
|
|
y: 0
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
gridCfg: {
|
|
|
|
|
|
enabled: true,
|
|
|
|
|
|
align: true,
|
|
|
|
|
|
size: 10
|
|
|
|
|
|
},
|
|
|
|
|
|
json: []
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
// console.log(this.dataTree, 123)
|
|
|
|
|
|
},
|
|
|
|
|
|
// 修改
|
|
|
|
|
|
modify(kId: number, val: string) {
|
|
|
|
|
|
this.dataTree.forEach((item: any) => {
|
|
|
|
|
|
if (item.kId == kId) {
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 放置kid
|
|
|
|
|
|
placeKid(id: String) {
|
|
|
|
|
|
this.identifying = id
|
2025-11-14 14:08:01 +08:00
|
|
|
|
this.keyName = ''
|
|
|
|
|
|
this.dataTree.forEach((item: any) => {
|
2025-11-12 09:52:48 +08:00
|
|
|
|
if (item.kId == id) {
|
|
|
|
|
|
this.keyName = item.name
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2025-09-25 11:34:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
setUpPath(data: String) {
|
|
|
|
|
|
this.dataTree.forEach((item: any) => {
|
|
|
|
|
|
if (item.kId == this.identifying) {
|
|
|
|
|
|
item.path = data
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|