Skip to content

Commit 691d7ce

Browse files
committed
fix: correct tag rendering and permission check logic in index.vue
--bug=1057921 --user=刘瑞斌 【资源授权】专业版和社区版、企业版授权工具勾选了文件夹,保存后,文件夹自动取消勾选,只勾选了工具 https://www.tapd.cn/62980211/s/1728387
1 parent a2726a9 commit 691d7ce

File tree

1 file changed

+18
-5
lines changed
  • ui/src/views/system/resource-authorization

1 file changed

+18
-5
lines changed

ui/src/views/system/resource-authorization/index.vue

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<div class="flex-between">
4747
<div class="flex">
4848
<span class="mr-8">{{ row.nick_name }}</span>
49-
<TagGroup :tags="row.roles"
49+
<TagGroup :tags="row.roles"
5050
v-if="hasPermission([EditionConst.IS_EE,EditionConst.IS_PE],'OR')"
5151
/>
5252
</div>
@@ -314,13 +314,26 @@ const dfsPermissionIndeterminate = (
314314
}
315315
316316
if (item.isFolder) {
317-
item.permissionHalf[type] = permissionHalfMap[item.id][type].length
318-
? new Set(permissionHalfMap[item.id][type]).size > 1
319-
: false
317+
// 判断是否存在子项且全部选中或全部未选中
318+
const hasPermissions = permissionHalfMap[item.id][type];
319+
const allTrue = hasPermissions.length && hasPermissions.every((p: boolean) => p);
320+
const allFalse = hasPermissions.length && hasPermissions.every((p: boolean) => !p);
321+
322+
// 只有在既有选中又有未选中的情况下才设置为半选状态
323+
item.permissionHalf[type] = hasPermissions.length && !allTrue && !allFalse;
324+
325+
// 检查子文件夹是否有半选状态
320326
if (item.children.some((ele: any) => ele.isFolder && ele.permissionHalf[type])) {
321-
item.permissionHalf[type] = true
327+
item.permissionHalf[type] = true;
328+
}
329+
330+
// 如果所有子项都已选中,确保当前项也被选中而不是半选
331+
if (allTrue) {
332+
item.permission[type] = true;
333+
item.permissionHalf[type] = false
322334
}
323335
336+
// 如果子项中有选中的也有未选中的,则设置为半选状态
324337
if (
325338
item.children.some((ele: any) => ele.permission[type]) &&
326339
item.children.some((ele: any) => !ele.permission[type])

0 commit comments

Comments
 (0)