feat: System role permission
This commit is contained in:
parent
f13a29a611
commit
06095ad94f
@ -35,7 +35,7 @@ const systemRouter = {
|
|||||||
permission: [
|
permission: [
|
||||||
new ComplexPermission(
|
new ComplexPermission(
|
||||||
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE.getWorkspaceRole],
|
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE.getWorkspaceRole],
|
||||||
[PermissionConst.ROLE_READ],
|
[PermissionConst.ROLE_READ, PermissionConst.WORKSPACE_ROLE_READ],
|
||||||
[EditionConst.IS_EE],
|
[EditionConst.IS_EE],
|
||||||
'OR',
|
'OR',
|
||||||
),
|
),
|
||||||
@ -57,7 +57,7 @@ const systemRouter = {
|
|||||||
new ComplexPermission(
|
new ComplexPermission(
|
||||||
[RoleConst.WORKSPACE_MANAGE, RoleConst.ADMIN],
|
[RoleConst.WORKSPACE_MANAGE, RoleConst.ADMIN],
|
||||||
[
|
[
|
||||||
PermissionConst.WORKSPACE_READ.getWorkspacePermissionWorkspaceManageRole,
|
PermissionConst.WORKSPACE_WORKSPACE_READ,
|
||||||
PermissionConst.WORKSPACE_READ,
|
PermissionConst.WORKSPACE_READ,
|
||||||
],
|
],
|
||||||
[EditionConst.IS_EE],
|
[EditionConst.IS_EE],
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { PermissionConst, EditionConst, RoleConst } from '@/utils/permission/dat
|
|||||||
import { hasPermission } from '@/utils/permission/index'
|
import { hasPermission } from '@/utils/permission/index'
|
||||||
import roleSystemApi from '@/api/system/role'
|
import roleSystemApi from '@/api/system/role'
|
||||||
import roleWorkspaceApi from '@/api/workspace/role'
|
import roleWorkspaceApi from '@/api/workspace/role'
|
||||||
|
import { ComplexPermission } from '../permission/type'
|
||||||
|
|
||||||
// 系统管理员 API
|
// 系统管理员 API
|
||||||
const systemApiMap = {
|
const systemApiMap = {
|
||||||
@ -19,11 +20,19 @@ const workspaceApiMap = {
|
|||||||
|
|
||||||
export function loadPermissionApi(type: string) {
|
export function loadPermissionApi(type: string) {
|
||||||
if (hasPermission(EditionConst.IS_EE, 'OR')) {
|
if (hasPermission(EditionConst.IS_EE, 'OR')) {
|
||||||
if (hasPermission([RoleConst.ADMIN], 'OR')) {
|
if (hasPermission(new ComplexPermission (
|
||||||
// 加载企业版工作空间管理员 API
|
[RoleConst.ADMIN],
|
||||||
return systemApiMap[type]
|
[PermissionConst.ROLE_READ],
|
||||||
} else if (hasPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole], 'OR')) {
|
[],
|
||||||
|
'OR'),'OR')) {
|
||||||
// 加载系统管理员 API
|
// 加载系统管理员 API
|
||||||
|
return systemApiMap[type]
|
||||||
|
} if (hasPermission(new ComplexPermission (
|
||||||
|
[RoleConst.WORKSPACE_MANAGE.getWorkspaceRole],
|
||||||
|
[PermissionConst.WORKSPACE_ROLE_READ.getWorkspacePermissionWorkspaceManageRole],
|
||||||
|
[],
|
||||||
|
'OR'),'OR' )) {
|
||||||
|
// 加载企业版工作空间管理员 API
|
||||||
return workspaceApiMap[type]
|
return workspaceApiMap[type]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,11 +75,11 @@ const PermissionConst = {
|
|||||||
|
|
||||||
|
|
||||||
ROLE_READ: new Permission('ROLE:READ'),
|
ROLE_READ: new Permission('ROLE:READ'),
|
||||||
ROLE_CREATE: new Permission('ROLE:READ'),
|
ROLE_CREATE: new Permission('ROLE:READ+CREATE'),
|
||||||
ROLE_EDIT: new Permission('ROLE:READ'),
|
ROLE_EDIT: new Permission('ROLE:READ+EDIT'),
|
||||||
ROLE_DELETE: new Permission('ROLE:READ'),
|
ROLE_DELETE: new Permission('ROLE:READ+DELETE'),
|
||||||
ROLE_ADD_MEMBER: new Permission('ROLE:READ'),
|
ROLE_ADD_MEMBER: new Permission('ROLE:READ+ADD_MEMBER'),
|
||||||
ROLE_REMOVE_MEMBER: new Permission('ROLE:READ'),
|
ROLE_REMOVE_MEMBER: new Permission('ROLE:READ+REMOVE_MEMBER'),
|
||||||
|
|
||||||
|
|
||||||
KNOWLEDGE_READ: new Permission('KNOWLEDGE:READ'),
|
KNOWLEDGE_READ: new Permission('KNOWLEDGE:READ'),
|
||||||
|
|||||||
@ -6,12 +6,11 @@
|
|||||||
@click="handleAdd"
|
@click="handleAdd"
|
||||||
v-hasPermission="
|
v-hasPermission="
|
||||||
new ComplexPermission(
|
new ComplexPermission(
|
||||||
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE.getWorkspaceRole],
|
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||||
[PermissionConst.ROLE_ADD_MEMBER.getWorkspacePermission],
|
[PermissionConst.WORKSPACE_ROLE_ADD_MEMBER, PermissionConst.ROLE_ADD_MEMBER],
|
||||||
[],
|
[],
|
||||||
'OR',
|
'OR',
|
||||||
)
|
)"
|
||||||
"
|
|
||||||
>
|
>
|
||||||
{{ $t('views.role.member.add') }}
|
{{ $t('views.role.member.add') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
@ -57,8 +56,8 @@
|
|||||||
@click.stop="handleDelete(row)"
|
@click.stop="handleDelete(row)"
|
||||||
v-hasPermission="
|
v-hasPermission="
|
||||||
new ComplexPermission(
|
new ComplexPermission(
|
||||||
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE.getWorkspaceRole],
|
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||||
[PermissionConst.ROLE_REMOVE_MEMBER.getWorkspacePermission],
|
[PermissionConst.ROLE_REMOVE_MEMBER, PermissionConst.WORKSPACE_ROLE_REMOVE_MEMBER],
|
||||||
[],
|
[],
|
||||||
'OR',
|
'OR',
|
||||||
)
|
)
|
||||||
|
|||||||
@ -2,9 +2,9 @@
|
|||||||
<div class="role-manage p-16-24">
|
<div class="role-manage p-16-24">
|
||||||
<h2 class="mb-16">{{ $t('views.role.title') }}</h2>
|
<h2 class="mb-16">{{ $t('views.role.title') }}</h2>
|
||||||
<el-card style="--el-card-padding: 0">
|
<el-card style="--el-card-padding: 0">
|
||||||
<div class="flex main-calc-height">
|
<div class="flex h-full">
|
||||||
<div class="role-left border-r p-16">
|
<div class="role-left border-r">
|
||||||
<div class="p-8 pb-0 mb-12">
|
<div class="p-24 pb-0">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="filterText"
|
v-model="filterText"
|
||||||
:placeholder="$t('common.search')"
|
:placeholder="$t('common.search')"
|
||||||
@ -14,6 +14,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="list-height-left">
|
<div class="list-height-left">
|
||||||
<el-scrollbar v-loading="loading">
|
<el-scrollbar v-loading="loading">
|
||||||
|
<div class="p-16">
|
||||||
<div class="color-secondary lighter ml-8 mb-8">
|
<div class="color-secondary lighter ml-8 mb-8">
|
||||||
<span>{{ $t('views.role.internalRole') }}</span>
|
<span>{{ $t('views.role.internalRole') }}</span>
|
||||||
</div>
|
</div>
|
||||||
@ -36,11 +37,27 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu style="min-width: 80px">
|
<el-dropdown-menu style="min-width: 80px">
|
||||||
<el-dropdown-item @click.stop="createOrUpdateRole(row)" class="p-8">
|
<el-dropdown-item @click.stop="createOrUpdateRole(row)" class="p-8"
|
||||||
|
v-if="hasPermission(
|
||||||
|
new ComplexPermission(
|
||||||
|
[RoleConst.ADMIN],
|
||||||
|
[PermissionConst.ROLE_EDIT],
|
||||||
|
[],'OR'
|
||||||
|
),'OR'
|
||||||
|
)"
|
||||||
|
>
|
||||||
<el-icon><EditPen /></el-icon>
|
<el-icon><EditPen /></el-icon>
|
||||||
{{ $t('common.rename') }}
|
{{ $t('common.rename') }}
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
<el-dropdown-item @click.stop="deleteRole(row)" class="border-t p-8">
|
<el-dropdown-item @click.stop="deleteRole(row)" class="border-t p-8"
|
||||||
|
v-if="hasPermission(
|
||||||
|
new ComplexPermission(
|
||||||
|
[RoleConst.ADMIN],
|
||||||
|
[PermissionConst.ROLE_DELETE],
|
||||||
|
[],'OR'
|
||||||
|
),'OR'
|
||||||
|
)"
|
||||||
|
>
|
||||||
<el-icon><Delete /></el-icon>
|
<el-icon><Delete /></el-icon>
|
||||||
{{ $t('common.delete') }}
|
{{ $t('common.delete') }}
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
@ -68,12 +85,10 @@
|
|||||||
@click="createOrUpdateRole()"
|
@click="createOrUpdateRole()"
|
||||||
v-hasPermission="
|
v-hasPermission="
|
||||||
new ComplexPermission(
|
new ComplexPermission(
|
||||||
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE.getWorkspaceRole],
|
[RoleConst.ADMIN],
|
||||||
[PermissionConst.ROLE_CREATE.getWorkspacePermission],
|
[PermissionConst.ROLE_CREATE],
|
||||||
[],
|
[],
|
||||||
'OR',
|
'OR',)"
|
||||||
)
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<el-icon :size="18"><Plus /></el-icon>
|
<el-icon :size="18"><Plus /></el-icon>
|
||||||
</el-button>
|
</el-button>
|
||||||
@ -103,11 +118,27 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu style="min-width: 80px">
|
<el-dropdown-menu style="min-width: 80px">
|
||||||
<el-dropdown-item @click.stop="createOrUpdateRole(row)" class="p-8">
|
<el-dropdown-item @click.stop="createOrUpdateRole(row)" class="p-8"
|
||||||
|
v-if="hasPermission(
|
||||||
|
new ComplexPermission(
|
||||||
|
[RoleConst.ADMIN],
|
||||||
|
[PermissionConst.ROLE_EDIT],
|
||||||
|
[],'OR'
|
||||||
|
),'OR'
|
||||||
|
)"
|
||||||
|
>
|
||||||
<el-icon><EditPen /></el-icon>
|
<el-icon><EditPen /></el-icon>
|
||||||
{{ $t('common.rename') }}
|
{{ $t('common.rename') }}
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
<el-dropdown-item @click.stop="deleteRole(row)" class="border-t p-8">
|
<el-dropdown-item @click.stop="deleteRole(row)" class="border-t p-8"
|
||||||
|
v-if="hasPermission(
|
||||||
|
new ComplexPermission(
|
||||||
|
[RoleConst.ADMIN],
|
||||||
|
[PermissionConst.ROLE_DELETE],
|
||||||
|
[],'OR'
|
||||||
|
),'OR'
|
||||||
|
)"
|
||||||
|
>
|
||||||
<el-icon><Delete /></el-icon>
|
<el-icon><Delete /></el-icon>
|
||||||
{{ $t('common.delete') }}
|
{{ $t('common.delete') }}
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
@ -121,6 +152,7 @@
|
|||||||
<span></span>
|
<span></span>
|
||||||
</template>
|
</template>
|
||||||
</common-list>
|
</common-list>
|
||||||
|
</div>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -176,6 +208,7 @@ import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
|||||||
import { loadPermissionApi } from '@/utils/dynamics-api/permission-api'
|
import { loadPermissionApi } from '@/utils/dynamics-api/permission-api'
|
||||||
import { PermissionConst, RoleConst } from '@/utils/permission/data'
|
import { PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||||
import { ComplexPermission } from '@/utils/permission/type'
|
import { ComplexPermission } from '@/utils/permission/type'
|
||||||
|
import { hasPermission } from '@/utils/permission/index'
|
||||||
|
|
||||||
const filterText = ref('')
|
const filterText = ref('')
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
@ -240,9 +273,7 @@ function deleteRole(item: RoleItem) {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
loadPermissionApi('role')
|
loadPermissionApi('role').deleteRole(item.id, loading).then(async () => {
|
||||||
.deleteRole(item.id, loading)
|
|
||||||
.then(async () => {
|
|
||||||
MsgSuccess(t('common.deleteSuccess'))
|
MsgSuccess(t('common.deleteSuccess'))
|
||||||
await getRole()
|
await getRole()
|
||||||
currentRole.value =
|
currentRole.value =
|
||||||
@ -289,3 +320,4 @@ function mouseenter(row: any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,12 @@
|
|||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="handleAdd"
|
@click="handleAdd"
|
||||||
v-hasPermission="[RoleConst.ADMIN, PermissionConst.WORKSPACE_ADD_MEMBER]"
|
v-hasPermission="
|
||||||
|
new ComplexPermission(
|
||||||
|
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||||
|
[PermissionConst.WORKSPACE_ADD_MEMBER, PermissionConst.WORKSPACE_WORKSPACE_ADD_MEMBER],
|
||||||
|
[],
|
||||||
|
'OR',)"
|
||||||
>
|
>
|
||||||
{{ $t('views.role.member.add') }}
|
{{ $t('views.role.member.add') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
@ -42,7 +47,12 @@
|
|||||||
type="primary"
|
type="primary"
|
||||||
text
|
text
|
||||||
@click.stop="handleDelete(row)"
|
@click.stop="handleDelete(row)"
|
||||||
v-hasPermission="[RoleConst.ADMIN, PermissionConst.WORKSPACE_REMOVE_MEMBER]"
|
v-hasPermission="
|
||||||
|
new ComplexPermission(
|
||||||
|
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||||
|
[PermissionConst.WORKSPACE_REMOVE_MEMBER, PermissionConst.WORKSPACE_WORKSPACE_REMOVE_MEMBER],
|
||||||
|
[],
|
||||||
|
'OR',)"
|
||||||
>
|
>
|
||||||
<AppIcon iconName="app-delete-users"></AppIcon>
|
<AppIcon iconName="app-delete-users"></AppIcon>
|
||||||
</el-button>
|
</el-button>
|
||||||
@ -65,6 +75,8 @@ import AddMemberDrawer from './AddMemberDrawer.vue'
|
|||||||
import WorkspaceApi from '@/api/workspace/workspace'
|
import WorkspaceApi from '@/api/workspace/workspace'
|
||||||
import type { WorkspaceMemberItem, WorkspaceItem } from '@/api/type/workspace'
|
import type { WorkspaceMemberItem, WorkspaceItem } from '@/api/type/workspace'
|
||||||
import { PermissionConst, RoleConst } from '@/utils/permission/data'
|
import { PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||||
|
import { ComplexPermission } from '@/utils/permission/type'
|
||||||
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
currentWorkspace?: WorkspaceItem
|
currentWorkspace?: WorkspaceItem
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user