后台管理页面权限管理优化,权限管理细化

This commit is contained in:
xiaowang
2026-02-25 16:50:32 +08:00
parent f5b5b01a39
commit f468e5544c
20 changed files with 176 additions and 60 deletions
+19 -3
View File
@@ -56,7 +56,7 @@
@search="handleUserSearch"
/>
<a-list
:data-source="userList"
:data-source="filteredUserList"
:loading="userLoading"
item-layout="horizontal"
size="small"
@@ -72,7 +72,7 @@
<a-avatar :src="item.avatar || DEFAULT_AVATAR" />
</template>
<template #title>{{ item.nickname }}</template>
<template #description>{{ item.account }}</template>
<template #description>{{ item.account }} - {{ getUserTypeText(item.type) }}</template>
</a-list-item-meta>
</a-list-item>
</template>
@@ -228,6 +228,7 @@ const selectedUser = ref<UserVO | null>(null)
const assignLoading = ref(false)
const selectedPermissions = ref<number[]>([])
const activeCollapseKeys = ref<string[]>(['商品管理', '店铺管理', '用户管理', '权限管理'])
const currentLoginUser = ref<UserVO | null>(null)
const groupedPermissions = computed(() => {
const groups: Record<string, PermissionVO[]> = {}
@@ -250,6 +251,20 @@ const getUserTypeText = (type: number) => {
return map[type] || '未知'
}
const filteredUserList = computed(() => {
if (!currentLoginUser.value) return []
return userList.value.filter(user => user.type < currentLoginUser.value!.type)
})
const fetchCurrentUser = async () => {
try {
const res = await userApi.getUserInfo()
currentLoginUser.value = res as unknown as UserVO
} catch (error) {
console.error('获取当前用户信息失败:', error)
}
}
const fetchPermissionList = async () => {
loading.value = true
try {
@@ -373,7 +388,8 @@ const handleDeletePermission = async (record: PermissionVO) => {
}
}
onMounted(() => {
onMounted(async () => {
await fetchCurrentUser()
fetchPermissionList()
fetchUserList()
})