From ad58a86f8e1713ce1a05c4770e33542e31544680 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Mon, 7 Jul 2025 17:43:16 +0800 Subject: [PATCH] feat: enhance data filtering in PermissionSetting component with recursive support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1057808 --user=刘瑞斌 【资源授权】资源授权界面成员、资源搜索功能无效 https://www.tapd.cn/62980211/s/1724794 --bug=1057547 --user=刘瑞斌 【资源授权】社区&专业&企业版-资源授权-知识库/应用搜索框功能未生效 https://www.tapd.cn/62980211/s/1724805 --- .../component/PermissionSetting.vue | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/ui/src/views/system/resource-authorization/component/PermissionSetting.vue b/ui/src/views/system/resource-authorization/component/PermissionSetting.vue index 1cc9192c2..bff8ad9d9 100644 --- a/ui/src/views/system/resource-authorization/component/PermissionSetting.vue +++ b/ui/src/views/system/resource-authorization/component/PermissionSetting.vue @@ -227,9 +227,27 @@ const dfsPermission = (arr: any = [], Name: string | number, e: boolean, idArr: const filterText = ref('') -const filterData = computed(() => - props.data.filter((v: any) => v.name.toLowerCase().includes(filterText.value.toLowerCase())), -) +const filterData = computed(() => { + function filterTree(data: any[]): any[] { + return data + .map(item => { + // 递归过滤 children + const children = item.children ? filterTree(item.children) : [] + // 判断当前节点或其子节点是否匹配 + const isMatch = item.name.toLowerCase().includes(filterText.value.toLowerCase()) + if (isMatch || children.length) { + return { + ...item, + children: children.length ? children : undefined, + } + } + return null + }) + .filter(Boolean) + } + + return filterTree(props.data) +}) function checkedOperateChange(Name: string | number, row: any, e: boolean) { dfsPermission(props.data, Name, e, [row.id])