mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 10:02:46 +00:00
fix: resource_permission
This commit is contained in:
parent
0f8fe31e52
commit
add71a4bc2
|
|
@ -44,7 +44,12 @@ const putResourceAuthorization: (
|
|||
body: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (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,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<div class="flex align-center" v-if="hasPermission(EditionConst.IS_EE, 'OR')">
|
||||
<!-- 企业版: 选优先级-->
|
||||
<span class="lighter mr-16">{{ $t('views.resourceAuthorization.priority.label') }}</span>
|
||||
<el-radio-group v-model="isRole">
|
||||
<el-radio-group v-model="radioRole">
|
||||
<el-radio :value="true" size="large">{{
|
||||
$t('views.resourceAuthorization.priority.role')
|
||||
}}</el-radio>
|
||||
|
|
@ -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('')
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@
|
|||
:tableHeight="tableHeight"
|
||||
:manage="isManage(currentType)"
|
||||
@refreshData="refreshData"
|
||||
v-model:isRole="item.isRole"
|
||||
></PermissionSetting>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
|
@ -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<any[]>([]) // 全部成员
|
||||
|
|
@ -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<any>, result: Array<any>) => {
|
|||
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%;
|
||||
|
|
|
|||
|
|
@ -160,7 +160,23 @@
|
|||
</CardBox>
|
||||
</el-col>
|
||||
<el-col v-else :xs="24" :sm="12" :md="12" :lg="8" :xl="6" class="mb-16">
|
||||
<CardBox :title="item.name" :description="item.desc" class="cursor">
|
||||
<CardBox
|
||||
:title="item.name"
|
||||
:description="item.desc"
|
||||
class="cursor"
|
||||
@click.stop="openCreateDialog(item)"
|
||||
:disabled="
|
||||
hasPermission(
|
||||
[
|
||||
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
|
||||
RoleConst.USER.getWorkspaceRole,
|
||||
PermissionConst.TOOL_EDIT.getWorkspacePermissionWorkspaceManageRole,
|
||||
PermissionConst.TOOL_EDIT.getWorkspacePermission,
|
||||
],
|
||||
'OR',
|
||||
)
|
||||
"
|
||||
>
|
||||
<template #icon>
|
||||
<el-avatar
|
||||
v-if="isAppIcon(item?.icon)"
|
||||
|
|
@ -370,7 +386,7 @@ function openCreateDialog(data?: any) {
|
|||
}
|
||||
ToolDrawertitle.value = data ? t('views.tool.editTool') : t('views.tool.createTool')
|
||||
if (data) {
|
||||
ToolApi.getToolById(data?.id, changeStateloading).then((res) => {
|
||||
ToolApi.getToolById(data?.id, loading).then((res) => {
|
||||
ToolFormDrawerRef.value.open(res.data)
|
||||
})
|
||||
} else {
|
||||
|
|
@ -411,6 +427,8 @@ async function changeState(row: any) {
|
|||
}
|
||||
ToolApi.putTool(row.id, obj, changeStateloading)
|
||||
.then(() => {
|
||||
const index = toolList.value.findIndex((v) => v.id === row.id)
|
||||
toolList.value[index].is_active = !row.is_active
|
||||
return true
|
||||
})
|
||||
.catch(() => {
|
||||
|
|
@ -434,6 +452,8 @@ async function changeState(row: any) {
|
|||
}
|
||||
ToolApi.putTool(row.id, obj, changeStateloading)
|
||||
.then(() => {
|
||||
const index = toolList.value.findIndex((v) => v.id === row.id)
|
||||
toolList.value[index].is_active = !row.is_active
|
||||
return true
|
||||
})
|
||||
.catch(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue