From 9674bbe71c85fa895eff04a03c74e76c3d906f35 Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Mon, 8 Dec 2025 10:49:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96BasicSelectTree?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/SelectTree/Basic/index.js | 18 +++++++++++++++++- hooks/useTable/index.js | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/components/SelectTree/Basic/index.js b/components/SelectTree/Basic/index.js index b341df5..85cf71a 100644 --- a/components/SelectTree/Basic/index.js +++ b/components/SelectTree/Basic/index.js @@ -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, diff --git a/hooks/useTable/index.js b/hooks/useTable/index.js index e51d689..b8b148d 100644 --- a/hooks/useTable/index.js +++ b/hooks/useTable/index.js @@ -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);