优化BasicSelectTree
parent
f97b308764
commit
9674bbe71c
|
|
@ -1,6 +1,6 @@
|
|||
import { TreeSelect } from "antd";
|
||||
import { useEffect } from "react";
|
||||
import { getTreeNodePaths, processTreeDataByLevel, processTreeDataForOnlyLastLevel } from "../../../utils";
|
||||
import { arrayObjectDeduplication, getDataType, getTreeNodePaths, processTreeDataByLevel, processTreeDataForOnlyLastLevel } from "../../../utils";
|
||||
|
||||
/**
|
||||
* 基础下拉树组件(不建议直接使用此组件,二次继承使用)
|
||||
|
|
@ -37,6 +37,22 @@ function BasicSelectTree(props) {
|
|||
|
||||
const handleChange = (value, label, extra) => {
|
||||
if (value) {
|
||||
if (getDataType(value) === "Array") {
|
||||
const parentNodes = [];
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
const currentParentNodes = getTreeNodePaths({
|
||||
data: treeData,
|
||||
targetId: value[i],
|
||||
idKey,
|
||||
childrenKey,
|
||||
isIncludeOneself: onGetNodePathsIsIncludeOneself,
|
||||
});
|
||||
parentNodes.push(...currentParentNodes);
|
||||
}
|
||||
onGetNodePaths?.(arrayObjectDeduplication(parentNodes, idKey));
|
||||
onGetLabel?.(label);
|
||||
return;
|
||||
}
|
||||
const parentNodes = getTreeNodePaths({
|
||||
data: treeData,
|
||||
targetId: value,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ function getService(service, getExtraParams = {}, transform, usePermission) {
|
|||
}
|
||||
|
||||
if (usePermission)
|
||||
params.menuPath = window.location.pathname
|
||||
params.menuPath = window.location.pathname;
|
||||
|
||||
// 发起请求
|
||||
const res = await service(params);
|
||||
|
|
|
|||
Loading…
Reference in New Issue