From ddc18e948679e7936e83b4cca5e444abc436a356 Mon Sep 17 00:00:00 2001 From: dataeaseShu Date: Wed, 25 Nov 2026 16:31:26 +0800 Subject: [PATCH] fix(permission): key user selection by id instead of name The restricted-user search can now be narrowed by account, so two users sharing a display name can appear one at a time. The merge, restore and select-all paths still matched users by name, so selecting all on a filtered view dropped an already-selected same-name user, and the select-all checkbox could read as checked while only a hidden same-name user was selected. Match, merge and render by user id instead. Co-Authored-By: Claude Sonnet 5 --- .../system/permission/SelectPermission.vue | 58 +++++++------------ 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/frontend/src/views/system/permission/SelectPermission.vue b/frontend/src/views/system/permission/SelectPermission.vue index 8a854061d..624972bb8 100644 --- a/frontend/src/views/system/permission/SelectPermission.vue +++ b/frontend/src/views/system/permission/SelectPermission.vue @@ -69,7 +69,7 @@
@@ -123,46 +123,32 @@ const workspaceWithKeywords = computed(() => { ) }) +const visibleIds = computed(() => new Set(workspaceWithKeywords.value.map((ele: any) => ele.id))) +const isVisibleUser = (ele: any) => visibleIds.value.has(ele.id) + +const syncCheckedState = () => { + const total = workspaceWithKeywords.value.length + const checked = checkedWorkspace.value.length + checkAll.value = total > 0 && checked === total + isIndeterminate.value = checked > 0 && checked < total +} + watch(search, () => { - const tableNameArr = workspaceWithKeywords.value.map((ele: any) => ele.name) - checkedWorkspace.value = checkTableList.value.filter((ele: any) => - tableNameArr.includes(ele.name) - ) - const checkedCount = checkedWorkspace.value.length - checkAll.value = checkedCount === workspaceWithKeywords.value.length - isIndeterminate.value = checkedCount > 0 && checkedCount < workspaceWithKeywords.value.length + checkedWorkspace.value = checkTableList.value.filter(isVisibleUser) + syncCheckedState() }) const handleCheckAllChange = (val: CheckboxValueType) => { - const tableNameArr = workspaceWithKeywords.value.map((ele: any) => ele.name) - checkedWorkspace.value = val - ? [ - ...new Set([ - ...workspaceWithKeywords.value, - ...checkedWorkspace.value.filter((ele: any) => !tableNameArr.includes(ele.name)), - ]), - ] - : [] - isIndeterminate.value = false - checkTableList.value = val - ? [ - ...new Set([ - ...workspaceWithKeywords.value, - ...checkTableList.value.filter((ele: any) => !tableNameArr.includes(ele.name)), - ]), - ] - : checkTableList.value.filter((ele: any) => !tableNameArr.includes(ele.name)) + const rest = checkTableList.value.filter((ele: any) => !isVisibleUser(ele)) + checkTableList.value = val ? [...rest, ...workspaceWithKeywords.value] : rest + checkedWorkspace.value = val ? [...workspaceWithKeywords.value] : [] + syncCheckedState() } const handleCheckedWorkspaceChange = (value: CheckboxValueType[]) => { - const checkedCount = value.length - checkAll.value = checkedCount === workspaceWithKeywords.value.length - isIndeterminate.value = checkedCount > 0 && checkedCount < workspaceWithKeywords.value.length - const tableNameArr = workspaceWithKeywords.value.map((ele: any) => ele.name) - checkTableList.value = [ - ...new Set([ - ...checkTableList.value.filter((ele: any) => !tableNameArr.includes(ele.name)), - ...value, - ]), - ] + const rest = checkTableList.value.filter((ele: any) => !isVisibleUser(ele)) + const picked = (value as any[]).filter(isVisibleUser) + checkTableList.value = [...rest, ...picked] + checkedWorkspace.value = [...picked] + syncCheckedState() } const USER_PAGE_SIZE = 500