Feat:展开所有和收起所有的命令支持指定节点的uid
This commit is contained in:
parent
8f8c6c9d95
commit
5014a2feb7
@ -1606,40 +1606,53 @@ class Render {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 展开所有
|
// 展开所有
|
||||||
expandAllNode() {
|
expandAllNode(uid = '') {
|
||||||
if (!this.renderTree) return
|
if (!this.renderTree) return
|
||||||
walk(
|
|
||||||
this.renderTree,
|
const _walk = (node, enableExpand) => {
|
||||||
null,
|
// 如果该节点为目标节点,那么修改允许展开的标志
|
||||||
node => {
|
if (!enableExpand && node.data.uid === uid) {
|
||||||
if (!node.data.expand) {
|
enableExpand = true
|
||||||
node.data.expand = true
|
}
|
||||||
}
|
if (enableExpand && !node.data.expand) {
|
||||||
},
|
node.data.expand = true
|
||||||
null,
|
}
|
||||||
true,
|
if (node.children && node.children.length > 0) {
|
||||||
0,
|
node.children.forEach(child => {
|
||||||
0
|
_walk(child, enableExpand)
|
||||||
)
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_walk(this.renderTree, !uid)
|
||||||
|
|
||||||
this.mindMap.render()
|
this.mindMap.render()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 收起所有
|
// 收起所有
|
||||||
unexpandAllNode(isSetRootNodeCenter = true) {
|
unexpandAllNode(isSetRootNodeCenter = true, uid = '') {
|
||||||
if (!this.renderTree) return
|
if (!this.renderTree) return
|
||||||
walk(
|
|
||||||
this.renderTree,
|
const _walk = (node, isRoot, enableUnExpand) => {
|
||||||
null,
|
// 如果该节点为目标节点,那么修改允许展开的标志
|
||||||
(node, parent, isRoot) => {
|
if (!enableUnExpand && node.data.uid === uid) {
|
||||||
if (!isRoot && node.children && node.children.length > 0) {
|
enableUnExpand = true
|
||||||
node.data.expand = false
|
}
|
||||||
}
|
if (
|
||||||
},
|
enableUnExpand &&
|
||||||
null,
|
!isRoot &&
|
||||||
true,
|
node.children &&
|
||||||
0,
|
node.children.length > 0
|
||||||
0
|
) {
|
||||||
)
|
node.data.expand = false
|
||||||
|
}
|
||||||
|
if (node.children && node.children.length > 0) {
|
||||||
|
node.children.forEach(child => {
|
||||||
|
_walk(child, false, enableUnExpand)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_walk(this.renderTree, true, !uid)
|
||||||
|
|
||||||
this.mindMap.render(() => {
|
this.mindMap.render(() => {
|
||||||
if (isSetRootNodeCenter) {
|
if (isSetRootNodeCenter) {
|
||||||
this.setRootNodeCenter()
|
this.setRootNodeCenter()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user