完善权限的管理和校验
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<a-tabs v-model:activeKey="activeTab">
|
||||
<a-tab-pane key="permissions" tab="权限列表">
|
||||
<template #extra>
|
||||
<a-button v-if="hasPermission('permission:create')" type="primary" @click="showAddPermissionModal">
|
||||
<a-button v-if="currentLoginUser?.type === 4 || hasPermission('permission:create')" type="primary" @click="showAddPermissionModal">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
@@ -28,11 +28,11 @@
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<a-space>
|
||||
<a-button v-if="hasPermission('permission:edit')" type="link" size="small" @click="showEditPermissionModal(record)">
|
||||
<a-button v-if="currentLoginUser?.type === 4 || hasPermission('permission:edit')" type="link" size="small" @click="showEditPermissionModal(record)">
|
||||
编辑
|
||||
</a-button>
|
||||
<a-popconfirm
|
||||
v-if="hasPermission('permission:delete')"
|
||||
v-if="currentLoginUser?.type === 4 || hasPermission('permission:delete')"
|
||||
title="确定要删除这个权限吗?"
|
||||
@confirm="handleDeletePermission(record)"
|
||||
>
|
||||
@@ -86,7 +86,7 @@
|
||||
:bordered="false"
|
||||
>
|
||||
<template #extra>
|
||||
<a-button v-if="selectedUser && hasPermission('permission:assign')" type="primary" @click="handleSaveUserPermissions">
|
||||
<a-button v-if="selectedUser && (currentLoginUser?.type === 4 || hasPermission('permission:assign'))" type="primary" @click="handleSaveUserPermissions">
|
||||
保存权限
|
||||
</a-button>
|
||||
</template>
|
||||
@@ -181,7 +181,7 @@ import { DEFAULT_AVATAR } from '@/constants'
|
||||
import { permissionApi, type PermissionVO, userApi, type UserVO } from '@/api/admin'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
|
||||
const { hasPermission } = usePermission()
|
||||
const { hasPermission, loadUserPermissions } = usePermission()
|
||||
|
||||
const activeTab = ref('permissions')
|
||||
const loading = ref(false)
|
||||
@@ -326,6 +326,8 @@ const handleSaveUserPermissions = async () => {
|
||||
try {
|
||||
await permissionApi.assignUserPermissions(selectedUser.value.id, selectedPermissions.value)
|
||||
message.success('权限保存成功')
|
||||
// 重新加载当前用户的权限
|
||||
await loadUserPermissions()
|
||||
} catch (error) {
|
||||
message.error('权限保存失败')
|
||||
}
|
||||
@@ -393,6 +395,7 @@ const handleDeletePermission = async (record: PermissionVO) => {
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchCurrentUser()
|
||||
await loadUserPermissions()
|
||||
fetchPermissionList()
|
||||
fetchUserList()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user