Skip to content

Commit add71a4

Browse files
fix: resource_permission
1 parent 0f8fe31 commit add71a4

File tree

4 files changed

+56
-24
lines changed

4 files changed

+56
-24
lines changed

ui/src/api/system/resource-authorization.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ const putResourceAuthorization: (
4444
body: any,
4545
loading?: Ref<boolean>,
4646
) => Promise<Result<any>> = (workspace_id, user_id, body, loading) => {
47-
return put(`${prefix}/${workspace_id}/user_resource_permission/user/${user_id}`, body, loading)
47+
return put(
48+
`${prefix}/${workspace_id}/user_resource_permission/user/${user_id}`,
49+
body,
50+
{},
51+
loading,
52+
)
4853
}
4954

5055
/**

ui/src/views/system/resource-authorization/component/PermissionSetting.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="flex align-center" v-if="hasPermission(EditionConst.IS_EE, 'OR')">
55
<!-- 企业版: 选优先级-->
66
<span class="lighter mr-16">{{ $t('views.resourceAuthorization.priority.label') }}</span>
7-
<el-radio-group v-model="isRole">
7+
<el-radio-group v-model="radioRole">
88
<el-radio :value="true" size="large">{{
99
$t('views.resourceAuthorization.priority.role')
1010
}}</el-radio>
@@ -179,10 +179,16 @@ const props = defineProps({
179179
type: String,
180180
tableHeight: Number,
181181
manage: Boolean,
182+
isRole: Boolean,
182183
})
184+
const emit = defineEmits(['update:data', 'refreshData','update:isRole'])
185+
const radioRole = computed({
186+
get: () => props.isRole,
187+
set: (v:boolean) => {
188+
emit('update:isRole', v)
183189
184-
const isRole = ref(false)
185-
190+
}
191+
})
186192
const isKnowledge = computed(() => props.type === AuthorizationEnum.KNOWLEDGE)
187193
const isApplication = computed(() => props.type === AuthorizationEnum.APPLICATION)
188194
@@ -208,7 +214,7 @@ const dfsPermission = (arr: any = [], Name: string | number, e: boolean, idArr:
208214
})
209215
}
210216
211-
const emit = defineEmits(['update:data', 'refreshData'])
217+
212218
213219
const filterText = ref('')
214220

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
:tableHeight="tableHeight"
7171
:manage="isManage(currentType)"
7272
@refreshData="refreshData"
73+
v-model:isRole="item.isRole"
7374
></PermissionSetting>
7475
</el-tab-pane>
7576
</el-tabs>
@@ -98,6 +99,7 @@ import { hasPermission } from '@/utils/permission/index'
9899
import WorkspaceApi from '@/api/workspace/workspace.ts'
99100
import type { WorkspaceItem } from '@/api/type/workspace'
100101
102+
const PermissionSettingRef = ref()
101103
const loading = ref(false)
102104
const rLoading = ref(false)
103105
const memberList = ref<any[]>([]) // 全部成员
@@ -115,11 +117,13 @@ const settingTags = reactive([
115117
label: t('views.knowledge.title'),
116118
value: AuthorizationEnum.KNOWLEDGE,
117119
data: [] as any,
120+
isRole: false,
118121
},
119122
{
120123
label: t('views.application.title'),
121124
value: AuthorizationEnum.APPLICATION,
122125
data: [] as any,
126+
isRole: false,
123127
},
124128
])
125129
@@ -147,22 +151,19 @@ const flotTree = (tree: Array<any>, result: Array<any>) => {
147151
return result
148152
}
149153
function submitPermissions() {
150-
const user_resource_permission_list = settingTags
151-
.map((item: any) => {
152-
return flotTree(item.data, [])
153-
.filter((v: any) => !v.isFolder)
154-
.map((v: any) => {
155-
return {
156-
target_id: v.id,
157-
auth_target_type: item.value,
158-
permission: v.permission,
159-
auth_type: 'RESOURCE_PERMISSION_GROUP',
160-
}
161-
})
162-
})
163-
.reduce((pre, next) => {
164-
return [...pre, ...next]
165-
}, [])
154+
const user_resource_permission_list = settingTags.map((item: any, index: number) => {
155+
return flotTree(item.data, [])
156+
.filter((v: any) => !v.isFolder)
157+
.map((v: any) => {
158+
return {
159+
target_id: v.id,
160+
auth_target_type: item.value,
161+
permission: v.permission,
162+
auth_type: item.isRole ? 'ROLE' : 'RESOURCE_PERMISSION_GROUP',
163+
}
164+
})
165+
})
166+
166167
AuthorizationApi.putResourceAuthorization(
167168
currentWorkspaceId.value || 'default',
168169
currentUser.value,
@@ -392,7 +393,7 @@ onMounted(() => {
392393
}
393394
394395
.permission-setting {
395-
flex:1;
396+
flex: 1;
396397
overflow: hidden;
397398
box-sizing: border-box;
398399
width: 100%;

ui/src/views/tool/index.vue

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,23 @@
160160
</CardBox>
161161
</el-col>
162162
<el-col v-else :xs="24" :sm="12" :md="12" :lg="8" :xl="6" class="mb-16">
163-
<CardBox :title="item.name" :description="item.desc" class="cursor">
163+
<CardBox
164+
:title="item.name"
165+
:description="item.desc"
166+
class="cursor"
167+
@click.stop="openCreateDialog(item)"
168+
:disabled="
169+
hasPermission(
170+
[
171+
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
172+
RoleConst.USER.getWorkspaceRole,
173+
PermissionConst.TOOL_EDIT.getWorkspacePermissionWorkspaceManageRole,
174+
PermissionConst.TOOL_EDIT.getWorkspacePermission,
175+
],
176+
'OR',
177+
)
178+
"
179+
>
164180
<template #icon>
165181
<el-avatar
166182
v-if="isAppIcon(item?.icon)"
@@ -370,7 +386,7 @@ function openCreateDialog(data?: any) {
370386
}
371387
ToolDrawertitle.value = data ? t('views.tool.editTool') : t('views.tool.createTool')
372388
if (data) {
373-
ToolApi.getToolById(data?.id, changeStateloading).then((res) => {
389+
ToolApi.getToolById(data?.id, loading).then((res) => {
374390
ToolFormDrawerRef.value.open(res.data)
375391
})
376392
} else {
@@ -411,6 +427,8 @@ async function changeState(row: any) {
411427
}
412428
ToolApi.putTool(row.id, obj, changeStateloading)
413429
.then(() => {
430+
const index = toolList.value.findIndex((v) => v.id === row.id)
431+
toolList.value[index].is_active = !row.is_active
414432
return true
415433
})
416434
.catch(() => {
@@ -434,6 +452,8 @@ async function changeState(row: any) {
434452
}
435453
ToolApi.putTool(row.id, obj, changeStateloading)
436454
.then(() => {
455+
const index = toolList.value.findIndex((v) => v.id === row.id)
456+
toolList.value[index].is_active = !row.is_active
437457
return true
438458
})
439459
.catch(() => {

0 commit comments

Comments
 (0)