feat(树节点们): #1002979 树状结构只能一层层收起,改成外层收起时收起全部
【7.树状结构只能一层层收起,改成外层收起时收起全部】https://www.tapd.cn/55049933/prong/stories/view/1155049933001002979
This commit is contained in:
parent
c6f281b023
commit
86e0e64975
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue