优化代码:使用getNodeDataIndex工具函数去除render类重复逻辑
This commit is contained in:
parent
0a36555343
commit
c17e5430ed
@ -520,9 +520,7 @@ class Render {
|
|||||||
? defaultInsertSecondLevelNodeText
|
? defaultInsertSecondLevelNodeText
|
||||||
: defaultInsertBelowSecondLevelNodeText
|
: defaultInsertBelowSecondLevelNodeText
|
||||||
// 计算插入位置
|
// 计算插入位置
|
||||||
const index = parent.nodeData.children.findIndex(item => {
|
const index = getNodeDataIndex(node)
|
||||||
return item.data.uid === node.uid
|
|
||||||
})
|
|
||||||
const newNodeData = {
|
const newNodeData = {
|
||||||
inserting: handleMultiNodes ? false : openEdit, // 如果同时对多个节点插入子节点,那么无需进入编辑模式,
|
inserting: handleMultiNodes ? false : openEdit, // 如果同时对多个节点插入子节点,那么无需进入编辑模式,
|
||||||
data: {
|
data: {
|
||||||
@ -565,9 +563,7 @@ class Render {
|
|||||||
}
|
}
|
||||||
const parent = node.parent
|
const parent = node.parent
|
||||||
// 计算插入位置
|
// 计算插入位置
|
||||||
const index = parent.nodeData.children.findIndex(item => {
|
const index = getNodeDataIndex(node)
|
||||||
return item.data.uid === node.uid
|
|
||||||
})
|
|
||||||
const newNodeList = createUidForAppointNodes(
|
const newNodeList = createUidForAppointNodes(
|
||||||
simpleDeepClone(nodeList),
|
simpleDeepClone(nodeList),
|
||||||
true
|
true
|
||||||
@ -711,9 +707,7 @@ class Render {
|
|||||||
}
|
}
|
||||||
const parent = node.parent
|
const parent = node.parent
|
||||||
// 获取当前节点所在位置
|
// 获取当前节点所在位置
|
||||||
const index = parent.nodeData.children.findIndex(item => {
|
const index = getNodeDataIndex(node)
|
||||||
return item.data.uid === node.uid
|
|
||||||
})
|
|
||||||
parent.nodeData.children.splice(index, 1, newNode)
|
parent.nodeData.children.splice(index, 1, newNode)
|
||||||
})
|
})
|
||||||
// 如果同时对多个节点插入子节点,需要清除原来激活的节点
|
// 如果同时对多个节点插入子节点,需要清除原来激活的节点
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user