提交代码
This commit is contained in:
86
src/stores/menuList/index.ts
Normal file
86
src/stores/menuList/index.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
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: '',
|
||||
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) {
|
||||
item.name = val
|
||||
}
|
||||
})
|
||||
},
|
||||
// 放置kid
|
||||
placeKid(id: String) {
|
||||
this.identifying = id
|
||||
},
|
||||
setUpPath(data: String) {
|
||||
this.dataTree.forEach((item: any) => {
|
||||
if (item.kId == this.identifying) {
|
||||
item.path = data
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user