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