From add71a4bc291d3eda27a812b95d6af18304b693d Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Mon, 23 Jun 2025 17:49:43 +0800 Subject: [PATCH] fix: resource_permission --- ui/src/api/system/resource-authorization.ts | 7 +++- .../component/PermissionSetting.vue | 14 +++++--- .../system/resource-authorization/index.vue | 35 ++++++++++--------- ui/src/views/tool/index.vue | 24 +++++++++++-- 4 files changed, 56 insertions(+), 24 deletions(-) diff --git a/ui/src/api/system/resource-authorization.ts b/ui/src/api/system/resource-authorization.ts index dae9e79c4..2d3f74af3 100644 --- a/ui/src/api/system/resource-authorization.ts +++ b/ui/src/api/system/resource-authorization.ts @@ -44,7 +44,12 @@ const putResourceAuthorization: ( body: any, loading?: Ref, ) => Promise> = (workspace_id, user_id, body, loading) => { - return put(`${prefix}/${workspace_id}/user_resource_permission/user/${user_id}`, body, loading) + return put( + `${prefix}/${workspace_id}/user_resource_permission/user/${user_id}`, + body, + {}, + loading, + ) } /** diff --git a/ui/src/views/system/resource-authorization/component/PermissionSetting.vue b/ui/src/views/system/resource-authorization/component/PermissionSetting.vue index 944e4508f..39778cbd0 100644 --- a/ui/src/views/system/resource-authorization/component/PermissionSetting.vue +++ b/ui/src/views/system/resource-authorization/component/PermissionSetting.vue @@ -4,7 +4,7 @@
{{ $t('views.resourceAuthorization.priority.label') }} - + {{ $t('views.resourceAuthorization.priority.role') }} @@ -179,10 +179,16 @@ const props = defineProps({ type: String, tableHeight: Number, manage: Boolean, + isRole: Boolean, }) +const emit = defineEmits(['update:data', 'refreshData','update:isRole']) +const radioRole = computed({ + get: () => props.isRole, + set: (v:boolean) => { + emit('update:isRole', v) -const isRole = ref(false) - + } +}) const isKnowledge = computed(() => props.type === AuthorizationEnum.KNOWLEDGE) const isApplication = computed(() => props.type === AuthorizationEnum.APPLICATION) @@ -208,7 +214,7 @@ const dfsPermission = (arr: any = [], Name: string | number, e: boolean, idArr: }) } -const emit = defineEmits(['update:data', 'refreshData']) + const filterText = ref('') diff --git a/ui/src/views/system/resource-authorization/index.vue b/ui/src/views/system/resource-authorization/index.vue index 94f9e042f..6acdcabe1 100644 --- a/ui/src/views/system/resource-authorization/index.vue +++ b/ui/src/views/system/resource-authorization/index.vue @@ -70,6 +70,7 @@ :tableHeight="tableHeight" :manage="isManage(currentType)" @refreshData="refreshData" + v-model:isRole="item.isRole" > @@ -98,6 +99,7 @@ import { hasPermission } from '@/utils/permission/index' import WorkspaceApi from '@/api/workspace/workspace.ts' import type { WorkspaceItem } from '@/api/type/workspace' +const PermissionSettingRef = ref() const loading = ref(false) const rLoading = ref(false) const memberList = ref([]) // 全部成员 @@ -115,11 +117,13 @@ const settingTags = reactive([ label: t('views.knowledge.title'), value: AuthorizationEnum.KNOWLEDGE, data: [] as any, + isRole: false, }, { label: t('views.application.title'), value: AuthorizationEnum.APPLICATION, data: [] as any, + isRole: false, }, ]) @@ -147,22 +151,19 @@ const flotTree = (tree: Array, result: Array) => { return result } function submitPermissions() { - const user_resource_permission_list = settingTags - .map((item: any) => { - return flotTree(item.data, []) - .filter((v: any) => !v.isFolder) - .map((v: any) => { - return { - target_id: v.id, - auth_target_type: item.value, - permission: v.permission, - auth_type: 'RESOURCE_PERMISSION_GROUP', - } - }) - }) - .reduce((pre, next) => { - return [...pre, ...next] - }, []) + const user_resource_permission_list = settingTags.map((item: any, index: number) => { + return flotTree(item.data, []) + .filter((v: any) => !v.isFolder) + .map((v: any) => { + return { + target_id: v.id, + auth_target_type: item.value, + permission: v.permission, + auth_type: item.isRole ? 'ROLE' : 'RESOURCE_PERMISSION_GROUP', + } + }) + }) + AuthorizationApi.putResourceAuthorization( currentWorkspaceId.value || 'default', currentUser.value, @@ -392,7 +393,7 @@ onMounted(() => { } .permission-setting { - flex:1; + flex: 1; overflow: hidden; box-sizing: border-box; width: 100%; diff --git a/ui/src/views/tool/index.vue b/ui/src/views/tool/index.vue index 4992d54f8..13c3e3633 100644 --- a/ui/src/views/tool/index.vue +++ b/ui/src/views/tool/index.vue @@ -160,7 +160,23 @@ - +