Feat:改为通过节点uid比对节点
This commit is contained in:
parent
c77c7403da
commit
fefbcfbbee
@ -160,7 +160,7 @@ class CatalogOrganization extends Base {
|
|||||||
if (node.parent) {
|
if (node.parent) {
|
||||||
let childrenList = node.parent.children
|
let childrenList = node.parent.children
|
||||||
let index = childrenList.findIndex(item => {
|
let index = childrenList.findIndex(item => {
|
||||||
return item === node
|
return item.uid === node.uid
|
||||||
})
|
})
|
||||||
childrenList.forEach((item, _index) => {
|
childrenList.forEach((item, _index) => {
|
||||||
if (item.hasCustomPosition() || _index <= index) {
|
if (item.hasCustomPosition() || _index <= index) {
|
||||||
@ -183,7 +183,7 @@ class CatalogOrganization extends Base {
|
|||||||
if (node.parent && !node.parent.isRoot) {
|
if (node.parent && !node.parent.isRoot) {
|
||||||
let childrenList = node.parent.children
|
let childrenList = node.parent.children
|
||||||
let index = childrenList.findIndex(item => {
|
let index = childrenList.findIndex(item => {
|
||||||
return item === node
|
return item.uid === node.uid
|
||||||
})
|
})
|
||||||
childrenList.forEach((item, _index) => {
|
childrenList.forEach((item, _index) => {
|
||||||
if (item.hasCustomPosition()) {
|
if (item.hasCustomPosition()) {
|
||||||
|
|||||||
@ -194,7 +194,7 @@ class Fishbone extends Base {
|
|||||||
if (node.parent && !node.parent.isRoot) {
|
if (node.parent && !node.parent.isRoot) {
|
||||||
let childrenList = node.parent.children
|
let childrenList = node.parent.children
|
||||||
let index = childrenList.findIndex(item => {
|
let index = childrenList.findIndex(item => {
|
||||||
return item === node
|
return item.uid === node.uid
|
||||||
})
|
})
|
||||||
childrenList.forEach((item, _index) => {
|
childrenList.forEach((item, _index) => {
|
||||||
if (item.hasCustomPosition()) {
|
if (item.hasCustomPosition()) {
|
||||||
|
|||||||
@ -238,7 +238,7 @@ class Fishbone extends Base {
|
|||||||
if (node.parent && !node.parent.isRoot) {
|
if (node.parent && !node.parent.isRoot) {
|
||||||
let childrenList = node.parent.children
|
let childrenList = node.parent.children
|
||||||
let index = childrenList.findIndex(item => {
|
let index = childrenList.findIndex(item => {
|
||||||
return item === node
|
return item.uid === node.uid
|
||||||
})
|
})
|
||||||
childrenList.forEach((item, _index) => {
|
childrenList.forEach((item, _index) => {
|
||||||
if (item.hasCustomPosition()) {
|
if (item.hasCustomPosition()) {
|
||||||
|
|||||||
@ -207,7 +207,7 @@ class Fishbone extends Base {
|
|||||||
if (node.parent && !node.parent.isRoot) {
|
if (node.parent && !node.parent.isRoot) {
|
||||||
let childrenList = node.parent.children
|
let childrenList = node.parent.children
|
||||||
let index = childrenList.findIndex(item => {
|
let index = childrenList.findIndex(item => {
|
||||||
return item === node
|
return item.uid === node.uid
|
||||||
})
|
})
|
||||||
childrenList.forEach((item, _index) => {
|
childrenList.forEach((item, _index) => {
|
||||||
if (item.hasCustomPosition()) {
|
if (item.hasCustomPosition()) {
|
||||||
|
|||||||
@ -125,10 +125,10 @@ class LogicalStructure extends Base {
|
|||||||
if (node.parent) {
|
if (node.parent) {
|
||||||
let childrenList = node.parent.children
|
let childrenList = node.parent.children
|
||||||
let index = childrenList.findIndex(item => {
|
let index = childrenList.findIndex(item => {
|
||||||
return item === node
|
return item.uid === node.uid
|
||||||
})
|
})
|
||||||
childrenList.forEach((item, _index) => {
|
childrenList.forEach((item, _index) => {
|
||||||
if (item === node || item.hasCustomPosition()) {
|
if (item.uid === node.uid || item.hasCustomPosition()) {
|
||||||
// 适配自定义位置
|
// 适配自定义位置
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -172,7 +172,7 @@ class MindMap extends Base {
|
|||||||
return item.dir === node.dir
|
return item.dir === node.dir
|
||||||
})
|
})
|
||||||
let index = childrenList.findIndex(item => {
|
let index = childrenList.findIndex(item => {
|
||||||
return item === node
|
return item.uid === node.uid
|
||||||
})
|
})
|
||||||
childrenList.forEach((item, _index) => {
|
childrenList.forEach((item, _index) => {
|
||||||
if (item.hasCustomPosition()) {
|
if (item.hasCustomPosition()) {
|
||||||
|
|||||||
@ -126,7 +126,7 @@ class OrganizationStructure extends Base {
|
|||||||
if (node.parent) {
|
if (node.parent) {
|
||||||
let childrenList = node.parent.children
|
let childrenList = node.parent.children
|
||||||
let index = childrenList.findIndex(item => {
|
let index = childrenList.findIndex(item => {
|
||||||
return item === node
|
return item.uid === node.uid
|
||||||
})
|
})
|
||||||
childrenList.forEach((item, _index) => {
|
childrenList.forEach((item, _index) => {
|
||||||
if (item.hasCustomPosition()) {
|
if (item.hasCustomPosition()) {
|
||||||
|
|||||||
@ -209,7 +209,7 @@ class Timeline extends Base {
|
|||||||
if (node.parent && !node.parent.isRoot) {
|
if (node.parent && !node.parent.isRoot) {
|
||||||
let childrenList = node.parent.children
|
let childrenList = node.parent.children
|
||||||
let index = childrenList.findIndex(item => {
|
let index = childrenList.findIndex(item => {
|
||||||
return item === node
|
return item.uid === node.uid
|
||||||
})
|
})
|
||||||
childrenList.forEach((item, _index) => {
|
childrenList.forEach((item, _index) => {
|
||||||
if (item.hasCustomPosition()) {
|
if (item.hasCustomPosition()) {
|
||||||
|
|||||||
@ -156,13 +156,13 @@ class VerticalTimeline extends Base {
|
|||||||
if (node.parent) {
|
if (node.parent) {
|
||||||
let childrenList = node.parent.children
|
let childrenList = node.parent.children
|
||||||
let index = childrenList.findIndex(item => {
|
let index = childrenList.findIndex(item => {
|
||||||
return item === node
|
return item.uid === node.uid
|
||||||
})
|
})
|
||||||
childrenList.forEach((item, _index) => {
|
childrenList.forEach((item, _index) => {
|
||||||
// 自定义节点位置
|
// 自定义节点位置
|
||||||
if (item.hasCustomPosition()) return
|
if (item.hasCustomPosition()) return
|
||||||
// 三级或三级以下节点自身位置不需要动
|
// 三级或三级以下节点自身位置不需要动
|
||||||
if (!node.parent.isRoot && item === node) return
|
if (!node.parent.isRoot && item.uid === node.uid) return
|
||||||
let _offset = 0
|
let _offset = 0
|
||||||
// 二级节点上面的兄弟节点不需要移动,自身需要往下移动
|
// 二级节点上面的兄弟节点不需要移动,自身需要往下移动
|
||||||
if (node.parent.isRoot) {
|
if (node.parent.isRoot) {
|
||||||
@ -202,7 +202,7 @@ class VerticalTimeline extends Base {
|
|||||||
if (node.parent && !node.parent.isRoot) {
|
if (node.parent && !node.parent.isRoot) {
|
||||||
let childrenList = node.parent.children
|
let childrenList = node.parent.children
|
||||||
let index = childrenList.findIndex(item => {
|
let index = childrenList.findIndex(item => {
|
||||||
return item === node
|
return item.uid === node.uid
|
||||||
})
|
})
|
||||||
childrenList.forEach((item, _index) => {
|
childrenList.forEach((item, _index) => {
|
||||||
if (item.hasCustomPosition()) {
|
if (item.hasCustomPosition()) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user