添加动态权限控制

This commit is contained in:
xie7654
2025-07-02 21:54:13 +08:00
parent eace8a524d
commit 78b9f9e832
12 changed files with 186 additions and 24 deletions

View File

@@ -8,6 +8,8 @@ import { z } from '#/adapter/form';
import { getDeptList } from '#/api/system/dept';
import { $t } from '#/locales';
import { format_datetime } from '#/utils/date';
import { op } from '#/utils/permission';
/**
* 获取编辑表单的字段配置。如果没有使用多语言可以直接export一个数组常量
*/
@@ -137,18 +139,15 @@ export function useColumns(
},
name: 'CellOperation',
options: [
{
code: 'append',
text: '新增下级',
},
'edit', // 默认的编辑按钮
{
code: 'delete', // 默认的删除按钮
op('system:dept:create', { code: 'append', text: '新增下级' }),
op('system:dept:edit', 'edit'),
op('system:dept:delete', {
code: 'delete',
disabled: (row: SystemDeptApi.SystemDept) => {
return !!(row.children && row.children.length > 0);
},
},
],
}),
].filter(Boolean),
},
field: 'operation',
fixed: 'right',

View File

@@ -133,7 +133,11 @@ function refreshGrid() {
<FormModal @success="refreshGrid" />
<Grid table-title="部门列表">
<template #toolbar-tools>
<Button type="primary" @click="onCreate">
<Button
type="primary"
@click="onCreate"
v-permission="'system:dept:create'"
>
<Plus class="size-5" />
{{ $t('ui.actionTitle.create', [$t('system.dept.name')]) }}
</Button>