feat(树节点们): #1002979 树状结构只能一层层收起,改成外层收起时收起全部

【7.树状结构只能一层层收起,改成外层收起时收起全部】https://www.tapd.cn/55049933/prong/stories/view/1155049933001002979
This commit is contained in:
song-tianyang 2021-09-15 20:09:34 +08:00 committed by 刘瑞斌
parent c6f281b023
commit 86e0e64975
1 changed files with 30 additions and 0 deletions

View File

@ -101,6 +101,7 @@ export default {
result: {},
filterText: "",
expandedNode: [],
reloaded: false,
defaultProps: {
children: "children",
label: "label"
@ -200,6 +201,35 @@ export default {
if (data.id) {
this.expandedNode.splice(this.expandedNode.indexOf(data.id), 1);
}
// this.reloaded = false;
this.$nextTick(() => {
let node = this.$refs.tree.getNode(data);
if(node){
node.expanded = false;
}
if (data.children && data.children.length > 0) {
this.changeTreeNodeStatus(data);
}
});
},
//
changeTreeNodeStatus (parentData) {
for (let i = 0; i < parentData.children.length; i++) {
let data = parentData.children[i];
if (data.id) {
this.expandedNode.splice(this.expandedNode.indexOf(data.id), 1);
}
let node = this.$refs.tree.getNode(data);
if(node){
node.expanded = false;
}
//
if (data.children && data.children.length > 0) {
this.changeTreeNodeStatus(data)
}
}
},
edit(node, data, isAppend) {
this.$set(data, 'isEdit', true);