Files
cdTestPlant3/cdTMP/src/store/project/treeData.js

34 lines
1021 B
JavaScript
Raw Normal View History

2023-06-19 19:51:12 +08:00
import { defineStore } from "pinia"
import projectApi from "@/api/project/project"
const useTreeDataStore = defineStore("treeDataStore", {
state: () => {
return {
treeData: [],
originTreeData: [],
currentNode: undefined
}
},
actions: {
// 不能使用箭头函数无法绑定this
async initTreeData(projectId) {
if (this.treeData.length === 0) {
const roundData = await projectApi.getRoundInfo(projectId)
2023-06-28 21:02:31 +08:00
this.treeData = roundData.data
this.originTreeData = roundData.data
2023-06-19 19:51:12 +08:00
}
},
2023-06-28 21:02:31 +08:00
// 用于新增轮次后显示
async resetTreeData(projectId) {
const roundData = await projectApi.getRoundInfo(projectId)
this.treeData = roundData.data
this.originTreeData = roundData.data
},
2023-06-19 19:51:12 +08:00
setCurrentNode(nodeKey) {
this.currentNode = nodeKey
}
}
})
export default useTreeDataStore