refactor: 权限点页改为系统权限,使用系统权限树接口

- 路由标题/菜单名:权限点 -> 系统权限
- 权限点页调用 getSystemPermissionTreeApi 获取系统管理权限树
- 新增 getSystemPermissionTreeApi 接口
This commit is contained in:
小蟑螂
2026-04-10 23:03:37 +08:00
parent f531121578
commit fb9472bc8c
2 changed files with 9 additions and 27 deletions
@@ -25,22 +25,13 @@ const routes: RouteRecordRaw[] = [
name: 'SystemPlatformPermission',
path: '/platform-admin/permission',
component: () => import('#/views/system/permission/index.vue'),
meta: {
icon: 'lucide:shield-check',
title: '权限点',
requiresAuth: true,
},
},
{
name: 'SystemPlatformSystemPermission',
path: '/platform-admin/system-permission',
component: () => import('#/views/system/system-permission/index.vue'),
meta: {
icon: 'lucide:layoutDashboard',
title: '系统权限',
requiresAuth: true,
},
},
{
name: 'SystemPlatformField',
path: '/platform-admin/field',
@@ -15,7 +15,7 @@ import {
deletePermissionApi,
getAllPermissionsApi,
getPermissionPageApi,
getPermissionTreeApi,
getSystemPermissionTreeApi,
} from '#/api/system/permission';
import PermissionFormModal from './components/PermissionFormModal.vue';
@@ -33,7 +33,7 @@ const viewMode = ref<'table' | 'tree'>('table');
// 树数据
const permissionTree = ref<PermissionVO.PermissionInfoVO[]>([]);
const treeLoading = ref(false);
const expandedKeys = ref<number[]>([]);
const expandedKeys = ref<string[]>([]); // 树状视图预展开
// 搜索表单
const searchForm = ref({
@@ -232,10 +232,10 @@ function refreshTable() {
async function loadPermissionTree() {
treeLoading.value = true;
try {
const result = await getPermissionTreeApi();
const result = await getSystemPermissionTreeApi();
permissionTree.value = result || [];
// 默认展开所有节点
expandedKeys.value = permissionTree.value.map((n) => n.id);
expandedKeys.value = permissionTree.value.map((n) => String(n.id));
} catch (error: any) {
message.error(error?.message || '获取权限树失败');
} finally {
@@ -313,18 +313,9 @@ const getTypeColor = (type: string) => {
// Ant Design Tree 格式转换
function toAntdTreeData(nodes: PermissionVO.PermissionInfoVO[]): any[] {
return nodes.map((node) => ({
key: node.id,
title: (
<span class="flex items-center gap-2">
<span class="font-medium">{node.name}</span>
<span class="text-xs text-gray-400">({node.code})</span>
<Tag color={node.status === 1 ? 'green' : 'red'} class="text-xs">
{node.status === 1 ? '启用' : '禁用'}
</Tag>
</span>
),
key: String(node.id),
title: `${node.name} (${node.code})`,
children: node.children ? toAntdTreeData(node.children) : undefined,
disabled: node.type === 'module',
}));
}
@@ -334,7 +325,7 @@ onMounted(() => {
</script>
<template>
<Page title="权限管理" auto-content-height>
<Page title="系统权限" auto-content-height>
<template #description>
<div class="text-foreground/80 mt-2">
管理系统权限码,支持权限的增删改查操作
@@ -399,7 +390,7 @@ onMounted(() => {
<Tree
v-if="permissionTree.length > 0"
:tree-data="toAntdTreeData(permissionTree)"
:expanded-keys="expandedKeys"
:default-expanded-keys="expandedKeys"
:selectable="false"
class="min-h-[400px]"
>