diff --git a/components/SelectTree/Basic/index.js b/components/SelectTree/Basic/index.js index dee0a44..7748cc4 100644 --- a/components/SelectTree/Basic/index.js +++ b/components/SelectTree/Basic/index.js @@ -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 处理树数据 @@ -40,22 +40,25 @@ function BasicSelectTree(props) { if (getDataType(value) === "Array") { const parentNodes = []; for (let i = 0; i < value.length; i++) { + const targetId = (restProps.labelInValue || restProps.treeCheckStrictly) ? value[i].value : value[i]; const currentParentNodes = getTreeNodePaths({ data: treeData, - targetId: value[i], + targetId, idKey, childrenKey, isIncludeOneself: onGetNodePathsIsIncludeOneself, }); parentNodes.push(...currentParentNodes); } - onGetNodePaths?.(arrayObjectDeduplication(parentNodes, idKey)); - onGetLabel?.(label); + const deduplicationParentNodes = arrayObjectDeduplication(parentNodes, idKey); + onGetNodePaths?.(deduplicationParentNodes); + onGetLabel?.((restProps.labelInValue || restProps.treeCheckStrictly) ? value.map(item => item.label) : label); } else { + const targetId = (restProps.labelInValue || restProps.treeCheckStrictly) ? value.value : value; const parentNodes = getTreeNodePaths({ data: treeData, - targetId: value, + targetId, idKey, childrenKey, isIncludeOneself: onGetNodePathsIsIncludeOneself, @@ -68,7 +71,7 @@ function BasicSelectTree(props) { onGetNodePaths?.([]); onGetLabel?.(""); } - onChange?.(value, label, extra); + onChange?.((restProps.labelInValue || restProps.treeCheckStrictly) ? value.map(item => item.value) : value, label, extra); }; useEffect(() => { @@ -88,6 +91,7 @@ function BasicSelectTree(props) { treeData={processedTreeData} fieldNames={{ label: nameKey, value: idKey, children: childrenKey }} treeNodeFilterProp={nameKey} + showCheckedStrategy={TreeSelect.SHOW_ALL} {...restProps} /> );