From 2ecdb66307bedeba6f878b33362ffe99ae67dc14 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Fri, 24 Oct 2025 16:25:54 +0800 Subject: [PATCH] fix: Resource authorization selection directory checkbox Cancel optimization (#4253) --- ui/src/components/app-table/index.vue | 10 +++++- .../component/PermissionTable.vue | 31 ++++++++++++++++--- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/ui/src/components/app-table/index.vue b/ui/src/components/app-table/index.vue index 003b82394..72c8748ae 100644 --- a/ui/src/components/app-table/index.vue +++ b/ui/src/components/app-table/index.vue @@ -36,7 +36,7 @@ { diff --git a/ui/src/views/system/resource-authorization/component/PermissionTable.vue b/ui/src/views/system/resource-authorization/component/PermissionTable.vue index f6ed45fef..a17198040 100644 --- a/ui/src/views/system/resource-authorization/component/PermissionTable.vue +++ b/ui/src/views/system/resource-authorization/component/PermissionTable.vue @@ -55,7 +55,7 @@ ref="multipleTableRef" class="mt-16" :data="filteredData" - @selection-change="handleSelectionChange" + @select="select" :maxTableHeight="260" :row-key="(row: any) => row.id" style="min-width: 600px" @@ -147,6 +147,7 @@ import { hasPermission } from '@/utils/permission/index' import { ComplexPermission } from '@/utils/permission/type' import { getPermissionOptions } from '@/views/system/resource-authorization/constant' import useStore from '@/stores' +import { TreeToFlatten } from '@/utils/array' const { model, user } = useStore() const route = useRoute() @@ -310,11 +311,33 @@ const filteredData = computed(() => { }) const multipleSelection = ref([]) +const selectObj: any = {} +const select = (val: any[], active: any) => { + if (active.resource_type === 'folder') { + if (!val.some((item) => item.id == active.id)) { + if (selectObj[active.id] === undefined) { + selectObj[active.id] = 0 + } + if (selectObj[active.id] % 2 == 0) { + console.log(TreeToFlatten([active])) + TreeToFlatten([active]) + .filter((item: any) => item.id != active.id) + .forEach((item: any) => { + multipleTableRef.value?.toggleRowSelection(item, true) + }) -const handleSelectionChange = (val: any[]) => { - multipleSelection.value = val + multipleSelection.value = multipleTableRef.value.getSelectionRows() + } else { + multipleSelection.value = val + } + selectObj[active.id] = selectObj[active.id] + 1 + } else { + multipleSelection.value = val + } + } else { + multipleSelection.value = val + } } - const dialogVisible = ref(false) const radioPermission = ref('') function openMulConfigureDialog() {