修复子节点收起状态复制时丢失的问题
This commit is contained in:
parent
b6c15164ac
commit
5cbe5d2906
@ -658,7 +658,7 @@ class Render {
|
|||||||
if (this.activeNodeList.length <= 0) {
|
if (this.activeNodeList.length <= 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return copyNodeTree({}, this.activeNodeList[0])
|
return copyNodeTree({}, this.activeNodeList[0], true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -674,7 +674,7 @@ class Render {
|
|||||||
if (node.isRoot) {
|
if (node.isRoot) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
let copyData = copyNodeTree({}, node)
|
let copyData = copyNodeTree({}, node, true)
|
||||||
this.removeActiveNode(node)
|
this.removeActiveNode(node)
|
||||||
this.removeOneNode(node)
|
this.removeOneNode(node)
|
||||||
this.mindMap.emit('node_active', null, this.activeNodeList)
|
this.mindMap.emit('node_active', null, this.activeNodeList)
|
||||||
|
|||||||
@ -147,13 +147,19 @@ export const copyRenderTree = (tree, root) => {
|
|||||||
* @Date: 2021-05-04 14:40:11
|
* @Date: 2021-05-04 14:40:11
|
||||||
* @Desc: 复制节点树数据
|
* @Desc: 复制节点树数据
|
||||||
*/
|
*/
|
||||||
export const copyNodeTree = (tree, root) => {
|
export const copyNodeTree = (tree, root, removeActiveState = false) => {
|
||||||
tree.data = simpleDeepClone(root.nodeData.data)
|
tree.data = simpleDeepClone(root.nodeData ? root.nodeData.data : root.data)
|
||||||
// tree.data.isActive = false
|
if (removeActiveState) {
|
||||||
|
tree.data.isActive = false
|
||||||
|
}
|
||||||
tree.children = []
|
tree.children = []
|
||||||
if (root.children && root.children.length > 0) {
|
if (root.children && root.children.length > 0) {
|
||||||
root.children.forEach((item, index) => {
|
root.children.forEach((item, index) => {
|
||||||
tree.children[index] = copyNodeTree({}, item)
|
tree.children[index] = copyNodeTree({}, item, removeActiveState)
|
||||||
|
})
|
||||||
|
} else if (root.nodeData && root.nodeData.children && root.nodeData.children.length > 0) {
|
||||||
|
root.nodeData.children.forEach((item, index) => {
|
||||||
|
tree.children[index] = copyNodeTree({}, item, removeActiveState)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return tree;
|
return tree;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user