mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 18:29:19 +08:00
remove: 移除废弃文件
This commit is contained in:
@@ -1,198 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { PermissionVO } from '#/api/sys/permission/types';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { Spin, Tag, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getSystemPermissionTreeApi } from '#/api/sys/permission';
|
||||
|
||||
defineOptions({ name: 'SystemPermissionPage' });
|
||||
|
||||
const loading = ref(false);
|
||||
const permissionData = ref<PermissionVO.PermissionInfoVO[]>([]);
|
||||
|
||||
// 获取系统权限树
|
||||
async function loadSystemPermissions() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const result = await getSystemPermissionTreeApi();
|
||||
permissionData.value = result || [];
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '获取系统权限树失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 扁平化树数据(用于多级表格展示)
|
||||
interface FlatNode {
|
||||
id: number;
|
||||
name: string;
|
||||
code: string;
|
||||
type: string;
|
||||
status: number;
|
||||
sortOrder: number;
|
||||
parentId: number | null;
|
||||
level: number;
|
||||
children?: FlatNode[];
|
||||
hasChildren: boolean;
|
||||
}
|
||||
|
||||
function flattenTree(nodes: PermissionVO.PermissionInfoVO[], level = 0, result: FlatNode[] = []): FlatNode[] {
|
||||
for (const node of nodes) {
|
||||
const flat: FlatNode = {
|
||||
id: node.id!,
|
||||
name: node.name!,
|
||||
code: node.code!,
|
||||
type: node.type!,
|
||||
status: node.status!,
|
||||
sortOrder: node.sortOrder || 0,
|
||||
parentId: node.parentId ?? null,
|
||||
level,
|
||||
hasChildren: !!(node.children && node.children.length > 0),
|
||||
children: node.children ? flattenTree(node.children, level + 1, []) : undefined,
|
||||
};
|
||||
result.push(flat);
|
||||
if (node.children && node.children.length > 0) {
|
||||
flattenTree(node.children, level + 1, result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// 表格配置
|
||||
const gridOptions: VxeGridProps<FlatNode> = {
|
||||
border: true,
|
||||
stripe: true,
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
columnConfig: {
|
||||
resizable: true,
|
||||
},
|
||||
rowConfig: {
|
||||
isHover: true,
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
type: 'seq',
|
||||
width: 60,
|
||||
title: '序号',
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '权限名称',
|
||||
minWidth: 200,
|
||||
slots: { default: 'name' },
|
||||
},
|
||||
{
|
||||
field: 'code',
|
||||
title: '权限码',
|
||||
minWidth: 200,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'type',
|
||||
title: '类型',
|
||||
width: 120,
|
||||
slots: { default: 'type' },
|
||||
},
|
||||
{
|
||||
field: 'sortOrder',
|
||||
title: '排序',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
width: 100,
|
||||
slots: { default: 'status' },
|
||||
},
|
||||
],
|
||||
data: [],
|
||||
};
|
||||
|
||||
const [Grid] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
});
|
||||
|
||||
function getTypeText(type: string) {
|
||||
const map: Record<string, string> = {
|
||||
api: '接口权限',
|
||||
button: '按钮权限',
|
||||
data: '数据权限',
|
||||
module: '模块分组',
|
||||
};
|
||||
return map[type] || type;
|
||||
}
|
||||
|
||||
function getTypeTagColor(type: string) {
|
||||
const map: Record<string, string> = {
|
||||
api: 'processing',
|
||||
button: 'success',
|
||||
data: 'warning',
|
||||
module: 'purple',
|
||||
};
|
||||
return map[type] || 'default';
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadSystemPermissions().then(() => {
|
||||
const flatData = flattenTree(permissionData.value);
|
||||
const grid = (Grid as any).grid;
|
||||
if (grid) {
|
||||
grid.loadData(flatData);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="系统权限" auto-content-height>
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
系统管理模块下的完整权限树,用于查看系统权限结构(平台超管专用)
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<Spin :spinning="loading">
|
||||
<Grid>
|
||||
<template #name="{ row }">
|
||||
<span
|
||||
class="font-medium"
|
||||
:class="row.type === 'module' ? 'text-[var(--text-primary)]' : 'text-[var(--text-secondary)]'"
|
||||
:style="{ paddingLeft: (row.level * 20) + 'px' }"
|
||||
>
|
||||
<span v-if="row.hasChildren" class="mr-1">📁</span>
|
||||
<span v-else class="mr-1">📄</span>
|
||||
{{ row.name }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #code="{ row }">
|
||||
<code class="text-xs text-gray-500">{{ row.code }}</code>
|
||||
</template>
|
||||
|
||||
<template #type="{ row }">
|
||||
<Tag :color="getTypeTagColor(row.type)">
|
||||
{{ getTypeText(row.type) }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
<template #status="{ row }">
|
||||
<Tag :color="row.status === 1 ? 'green' : 'red'">
|
||||
{{ row.status === 1 ? '启用' : '禁用' }}
|
||||
</Tag>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<div v-if="!loading && permissionData.length === 0" class="py-12 text-center text-gray-400">
|
||||
暂无系统权限数据
|
||||
</div>
|
||||
</Spin>
|
||||
</Page>
|
||||
</template>
|
||||
Reference in New Issue
Block a user