From bef75ecaea0505064e0ae2e987d930a8ffef17f9 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Tue, 3 Mar 2026 17:31:48 +0800 Subject: [PATCH] feat: When resource authorization is set to unauthorized, sub resource cascading is set --- .../component/PermissionTable.vue | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/ui/src/views/system/resource-authorization/component/PermissionTable.vue b/ui/src/views/system/resource-authorization/component/PermissionTable.vue index 0ac792967f8..234d812d8b9 100644 --- a/ui/src/views/system/resource-authorization/component/PermissionTable.vue +++ b/ui/src/views/system/resource-authorization/component/PermissionTable.vue @@ -383,7 +383,39 @@ function closeDialog() { multipleSelection.value = [] multipleTableRef.value?.clearSelection() } +function getResourcesByFolderId(treeData: any[], folderId: string): any[] { + const result: any[] = [] + let target: any = null + function dfs(nodes: any[]) { + for (const node of nodes) { + if (node.id === folderId) { + target = node + return + } + if (node.children?.length) { + dfs(node.children) + if (target) return + } + } + } + + function collect(node: any) { + if (!node?.children) return + for (const child of node.children) { + result.push(child) + collect(child) + } + } + + dfs(treeData) + + if (target) { + collect(target) + } + + return result +} function submitPermissions(value: string, row: any) { const obj = [ { @@ -409,9 +441,15 @@ function submitPermissions(value: string, row: any) { } return result } + if (['VIEW', 'MANAGE', 'ROLE'].includes(value)) { emitSubmitPermissions(props.data, [row.folder_id], obj) } + if (['NOT_AUTH'].includes(value) && 'folder' == row.resource_type) { + getResourcesByFolderId(props.data, row.id).forEach((n) => { + obj.push({ target_id: n.id, permission: 'NOT_AUTH' }) + }) + } emit('submitPermissions', obj) } const provider_list = ref>([])