Feat:改为通过节点uid比对节点

This commit is contained in:
wanglin2 2023-09-18 16:30:45 +08:00
parent c77c7403da
commit fefbcfbbee
9 changed files with 13 additions and 13 deletions

View File

@ -160,7 +160,7 @@ class CatalogOrganization extends Base {
if (node.parent) {
let childrenList = node.parent.children
let index = childrenList.findIndex(item => {
return item === node
return item.uid === node.uid
})
childrenList.forEach((item, _index) => {
if (item.hasCustomPosition() || _index <= index) {
@ -183,7 +183,7 @@ class CatalogOrganization extends Base {
if (node.parent && !node.parent.isRoot) {
let childrenList = node.parent.children
let index = childrenList.findIndex(item => {
return item === node
return item.uid === node.uid
})
childrenList.forEach((item, _index) => {
if (item.hasCustomPosition()) {

View File

@ -194,7 +194,7 @@ class Fishbone extends Base {
if (node.parent && !node.parent.isRoot) {
let childrenList = node.parent.children
let index = childrenList.findIndex(item => {
return item === node
return item.uid === node.uid
})
childrenList.forEach((item, _index) => {
if (item.hasCustomPosition()) {

View File

@ -238,7 +238,7 @@ class Fishbone extends Base {
if (node.parent && !node.parent.isRoot) {
let childrenList = node.parent.children
let index = childrenList.findIndex(item => {
return item === node
return item.uid === node.uid
})
childrenList.forEach((item, _index) => {
if (item.hasCustomPosition()) {

View File

@ -207,7 +207,7 @@ class Fishbone extends Base {
if (node.parent && !node.parent.isRoot) {
let childrenList = node.parent.children
let index = childrenList.findIndex(item => {
return item === node
return item.uid === node.uid
})
childrenList.forEach((item, _index) => {
if (item.hasCustomPosition()) {

View File

@ -125,10 +125,10 @@ class LogicalStructure extends Base {
if (node.parent) {
let childrenList = node.parent.children
let index = childrenList.findIndex(item => {
return item === node
return item.uid === node.uid
})
childrenList.forEach((item, _index) => {
if (item === node || item.hasCustomPosition()) {
if (item.uid === node.uid || item.hasCustomPosition()) {
// 适配自定义位置
return
}

View File

@ -172,7 +172,7 @@ class MindMap extends Base {
return item.dir === node.dir
})
let index = childrenList.findIndex(item => {
return item === node
return item.uid === node.uid
})
childrenList.forEach((item, _index) => {
if (item.hasCustomPosition()) {

View File

@ -126,7 +126,7 @@ class OrganizationStructure extends Base {
if (node.parent) {
let childrenList = node.parent.children
let index = childrenList.findIndex(item => {
return item === node
return item.uid === node.uid
})
childrenList.forEach((item, _index) => {
if (item.hasCustomPosition()) {

View File

@ -209,7 +209,7 @@ class Timeline extends Base {
if (node.parent && !node.parent.isRoot) {
let childrenList = node.parent.children
let index = childrenList.findIndex(item => {
return item === node
return item.uid === node.uid
})
childrenList.forEach((item, _index) => {
if (item.hasCustomPosition()) {

View File

@ -156,13 +156,13 @@ class VerticalTimeline extends Base {
if (node.parent) {
let childrenList = node.parent.children
let index = childrenList.findIndex(item => {
return item === node
return item.uid === node.uid
})
childrenList.forEach((item, _index) => {
// 自定义节点位置
if (item.hasCustomPosition()) return
// 三级或三级以下节点自身位置不需要动
if (!node.parent.isRoot && item === node) return
if (!node.parent.isRoot && item.uid === node.uid) return
let _offset = 0
// 二级节点上面的兄弟节点不需要移动,自身需要往下移动
if (node.parent.isRoot) {
@ -202,7 +202,7 @@ class VerticalTimeline extends Base {
if (node.parent && !node.parent.isRoot) {
let childrenList = node.parent.children
let index = childrenList.findIndex(item => {
return item === node
return item.uid === node.uid
})
childrenList.forEach((item, _index) => {
if (item.hasCustomPosition()) {