默认展开第一级
updated() {
if (this.isExpand) {
this.expandAll()
this.isExpand = false
}
},
expandAll() {
const els = this.$el.getElementsByClassName('el-table__expand-icon')
for (let i = 0; i < els.length; i++) {
els[i].click()
}
},
加载树表格数据
load(tree, treeNode, resolve) {
const pid = tree.id;
this.maps.set(pid, { tree, treeNode, resolve })
tree.hasChildren = true
resolve(data)
- 更新数据
if (this.maps.get(pId)) {
const { tree, treeNode, resolve } = this.maps.get(pId)
// let source = this.$refs.singleTable.store.states.lazyTreeNodeMap[pid]
// this.$set(this.$refs.singleTable.store.states.lazyTreeNodeMap, pid, [...source, ...data])
this.$set(this.$refs.singleTable.store.states.lazyTreeNodeMap, pid, []) //delete
this.load(tree, treeNode, resolve);
}