优化BasicSelectTree

master
LiuJiaNan 2025-12-08 10:56:59 +08:00
parent 20f3ff46a9
commit 25371cab89
1 changed files with 16 additions and 15 deletions

View File

@ -25,11 +25,11 @@ function BasicSelectTree(props) {
// 根据 level 处理树数据
let processedTreeData = level
? processTreeDataByLevel({
data: treeData,
level,
childrenKey,
currentLevel: 1,
})
data: treeData,
level,
childrenKey,
currentLevel: 1,
})
: treeData;
// 根据 onlyLastLevel 处理树数据
@ -51,17 +51,18 @@ function BasicSelectTree(props) {
}
onGetNodePaths?.(arrayObjectDeduplication(parentNodes, idKey));
onGetLabel?.(label);
return;
}
const parentNodes = getTreeNodePaths({
data: treeData,
targetId: value,
idKey,
childrenKey,
isIncludeOneself: onGetNodePathsIsIncludeOneself,
});
onGetNodePaths?.(parentNodes);
onGetLabel?.(parentNodes[parentNodes.length - 1][nameKey]);
else {
const parentNodes = getTreeNodePaths({
data: treeData,
targetId: value,
idKey,
childrenKey,
isIncludeOneself: onGetNodePathsIsIncludeOneself,
});
onGetNodePaths?.(parentNodes);
onGetLabel?.(parentNodes[parentNodes.length - 1][nameKey]);
}
}
else {
onGetNodePaths?.([]);