Pre Merge pull request !523 from 口口口/N/A

pull/523/MERGE
口口口 2025-12-13 02:34:18 +00:00 committed by Gitee
commit 17781ffac1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 11 additions and 2 deletions

View File

@ -374,6 +374,7 @@ export const treeToString = (tree: any[], nodeId) => {
return node.name return node.name
} }
let str = '' let str = ''
let list = <any[]>[]
function performAThoroughValidation(arr) { function performAThoroughValidation(arr) {
if (typeof arr === 'undefined' || !Array.isArray(arr) || arr.length === 0) { if (typeof arr === 'undefined' || !Array.isArray(arr) || arr.length === 0) {
@ -381,11 +382,13 @@ export const treeToString = (tree: any[], nodeId) => {
} }
for (const item of arr) { for (const item of arr) {
if (item.id === nodeId) { if (item.id === nodeId) {
str += ` / ${item.name}` list.push(item.name)
// str += ` / ${item.name}`
return true return true
} else if (typeof item.children !== 'undefined' && item.children.length !== 0) { } else if (typeof item.children !== 'undefined' && item.children.length !== 0) {
str += ` / ${item.name}` // str += ` / ${item.name}`
if (performAThoroughValidation(item.children)) { if (performAThoroughValidation(item.children)) {
list.push(item.name)
return true return true
} }
} }
@ -394,10 +397,16 @@ export const treeToString = (tree: any[], nodeId) => {
} }
for (const item of tree) { for (const item of tree) {
list = []
str = `${item.name}` str = `${item.name}`
if (performAThoroughValidation(item.children)) { if (performAThoroughValidation(item.children)) {
break break
} }
} }
if (list.length > 0) {
list.reverse().forEach((name) => {
str += ` / ${name}`
})
}
return str return str
} }