mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 09:49:20 +08:00
refactor: 权限点页改为系统权限,使用系统权限树接口
- 路由标题/菜单名:权限点 -> 系统权限 - 权限点页调用 getSystemPermissionTreeApi 获取系统管理权限树 - 新增 getSystemPermissionTreeApi 接口
This commit is contained in:
@@ -25,22 +25,13 @@ const routes: RouteRecordRaw[] = [
|
|||||||
name: 'SystemPlatformPermission',
|
name: 'SystemPlatformPermission',
|
||||||
path: '/platform-admin/permission',
|
path: '/platform-admin/permission',
|
||||||
component: () => import('#/views/system/permission/index.vue'),
|
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: {
|
meta: {
|
||||||
icon: 'lucide:layoutDashboard',
|
icon: 'lucide:layoutDashboard',
|
||||||
title: '系统权限',
|
title: '系统权限',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'SystemPlatformField',
|
name: 'SystemPlatformField',
|
||||||
path: '/platform-admin/field',
|
path: '/platform-admin/field',
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
deletePermissionApi,
|
deletePermissionApi,
|
||||||
getAllPermissionsApi,
|
getAllPermissionsApi,
|
||||||
getPermissionPageApi,
|
getPermissionPageApi,
|
||||||
getPermissionTreeApi,
|
getSystemPermissionTreeApi,
|
||||||
} from '#/api/system/permission';
|
} from '#/api/system/permission';
|
||||||
|
|
||||||
import PermissionFormModal from './components/PermissionFormModal.vue';
|
import PermissionFormModal from './components/PermissionFormModal.vue';
|
||||||
@@ -33,7 +33,7 @@ const viewMode = ref<'table' | 'tree'>('table');
|
|||||||
// 树数据
|
// 树数据
|
||||||
const permissionTree = ref<PermissionVO.PermissionInfoVO[]>([]);
|
const permissionTree = ref<PermissionVO.PermissionInfoVO[]>([]);
|
||||||
const treeLoading = ref(false);
|
const treeLoading = ref(false);
|
||||||
const expandedKeys = ref<number[]>([]);
|
const expandedKeys = ref<string[]>([]); // 树状视图预展开
|
||||||
|
|
||||||
// 搜索表单
|
// 搜索表单
|
||||||
const searchForm = ref({
|
const searchForm = ref({
|
||||||
@@ -232,10 +232,10 @@ function refreshTable() {
|
|||||||
async function loadPermissionTree() {
|
async function loadPermissionTree() {
|
||||||
treeLoading.value = true;
|
treeLoading.value = true;
|
||||||
try {
|
try {
|
||||||
const result = await getPermissionTreeApi();
|
const result = await getSystemPermissionTreeApi();
|
||||||
permissionTree.value = result || [];
|
permissionTree.value = result || [];
|
||||||
// 默认展开所有节点
|
// 默认展开所有节点
|
||||||
expandedKeys.value = permissionTree.value.map((n) => n.id);
|
expandedKeys.value = permissionTree.value.map((n) => String(n.id));
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
message.error(error?.message || '获取权限树失败');
|
message.error(error?.message || '获取权限树失败');
|
||||||
} finally {
|
} finally {
|
||||||
@@ -313,18 +313,9 @@ const getTypeColor = (type: string) => {
|
|||||||
// Ant Design Tree 格式转换
|
// Ant Design Tree 格式转换
|
||||||
function toAntdTreeData(nodes: PermissionVO.PermissionInfoVO[]): any[] {
|
function toAntdTreeData(nodes: PermissionVO.PermissionInfoVO[]): any[] {
|
||||||
return nodes.map((node) => ({
|
return nodes.map((node) => ({
|
||||||
key: node.id,
|
key: String(node.id),
|
||||||
title: (
|
title: `${node.name} (${node.code})`,
|
||||||
<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>
|
|
||||||
),
|
|
||||||
children: node.children ? toAntdTreeData(node.children) : undefined,
|
children: node.children ? toAntdTreeData(node.children) : undefined,
|
||||||
disabled: node.type === 'module',
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,7 +325,7 @@ onMounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page title="权限管理" auto-content-height>
|
<Page title="系统权限" auto-content-height>
|
||||||
<template #description>
|
<template #description>
|
||||||
<div class="text-foreground/80 mt-2">
|
<div class="text-foreground/80 mt-2">
|
||||||
管理系统权限码,支持权限的增删改查操作
|
管理系统权限码,支持权限的增删改查操作
|
||||||
@@ -399,7 +390,7 @@ onMounted(() => {
|
|||||||
<Tree
|
<Tree
|
||||||
v-if="permissionTree.length > 0"
|
v-if="permissionTree.length > 0"
|
||||||
:tree-data="toAntdTreeData(permissionTree)"
|
:tree-data="toAntdTreeData(permissionTree)"
|
||||||
:expanded-keys="expandedKeys"
|
:default-expanded-keys="expandedKeys"
|
||||||
:selectable="false"
|
:selectable="false"
|
||||||
class="min-h-[400px]"
|
class="min-h-[400px]"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user