[update 拆分排序] 调整拖拽,传最底层的最后一个节点的序号
This commit is contained in:
@@ -386,10 +386,18 @@ export default {
|
||||
// 拖拽到某个节点下方,就取该节点的序号
|
||||
if (dropPos > nodePos) {
|
||||
params.displaySeq = info.node.dataRef.displaySeq
|
||||
// 递归拿到最内层的最后一个节点的序号
|
||||
if (info.node.dataRef.children && info.node.dataRef.children.length) {
|
||||
params.displaySeq = this.getLastLeafNode(info.node.dataRef.children)
|
||||
}
|
||||
} else {
|
||||
// 拖拽到某个节点之上,就要找到上一个节点的序号,如果没有就传0
|
||||
const preNodeData = this.getPrevNode(this.treeData, info.node.eventKey)
|
||||
params.displaySeq = preNodeData ? preNodeData.displaySeq : 0
|
||||
// 递归拿到最内层的最后一个节点的序号
|
||||
if (preNodeData && preNodeData.children && preNodeData.children.length) {
|
||||
params.displaySeq = this.getLastLeafNode(preNodeData.children)
|
||||
}
|
||||
}
|
||||
params.sourceId = info.dragNode.eventKey
|
||||
// 拖拽到节点的父节点id
|
||||
@@ -418,6 +426,19 @@ export default {
|
||||
}
|
||||
this.treeNodeSort({ sourceId, targetId, displaySeq })
|
||||
},
|
||||
// 获取最底层叶子节点的序号
|
||||
getLastLeafNode (children) {
|
||||
let displaySeq = 0
|
||||
while (true) {
|
||||
if (children && children.length) {
|
||||
displaySeq = children[children.length - 1].displaySeq
|
||||
children = children[children.length - 1].children || []
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return displaySeq
|
||||
},
|
||||
// 发请求
|
||||
treeNodeSort (params) {
|
||||
this.loading = true
|
||||
|
||||
Reference in New Issue
Block a user