data(){
loadNodeMap: new Map(),
}
// 加载子节点
loadChild (tree, treeNode, resolve) {
this.loadNodeMap.set(tree.id, {tree, treeNode, resolve})
。。。。省略
resolve(children)
},
增加:新增节点一级可直接刷新;
新增二级根据当前节点获取请求数据后
this.currentRow.hasChildren = true
this.$set(this.$refs.table.store.states.lazyTreeNodeMap, this.currentRow.id, 根据当前节点查找接口返回来的children)
更新:当前节点一级可直接刷新;
非一级获取父级节点
this.$set(this.$refs.table.store.states.lazyTreeNodeMap, this.currentRow.parentId, 根据当前节点父节点查找接口返回来的children)
删除:当前节点一级可直接刷新;
非一级获取父级节点
this.$set(this.$refs.table.store.states.lazyTreeNodeMap, this.currentRow.parentId, 根据当前节点父节点查找接口返回来的children)
const {tree, treeNode, resolve} = this.loadNodeMap.get(this.currentRow.parentId)
resolve(根据当前节点父节点查找接口返回来的children)
if (children.length < 1) {
tree.hasChildren = false
}