优化BasicSelectTree
parent
f97b308764
commit
9674bbe71c
|
|
@ -1,6 +1,6 @@
|
||||||
import { TreeSelect } from "antd";
|
import { TreeSelect } from "antd";
|
||||||
import { useEffect } from "react";
|
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) => {
|
const handleChange = (value, label, extra) => {
|
||||||
if (value) {
|
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({
|
const parentNodes = getTreeNodePaths({
|
||||||
data: treeData,
|
data: treeData,
|
||||||
targetId: value,
|
targetId: value,
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ function getService(service, getExtraParams = {}, transform, usePermission) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usePermission)
|
if (usePermission)
|
||||||
params.menuPath = window.location.pathname
|
params.menuPath = window.location.pathname;
|
||||||
|
|
||||||
// 发起请求
|
// 发起请求
|
||||||
const res = await service(params);
|
const res = await service(params);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue