补充权限控制

This commit is contained in:
xie7654
2025-07-03 17:08:10 +08:00
parent 18f9afb924
commit 6dfc242166
12 changed files with 52 additions and 32 deletions

View File

@@ -128,7 +128,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
function refreshGrid() { function refreshGrid() {
gridApi.query(); gridApi.query();
} }
</script> </script>
<template> <template>
<Page auto-content-height> <Page auto-content-height>

View File

@@ -7,7 +7,8 @@ import type { SystemDictDataApi } from '#/api/system/dict_data';
import { z } from '#/adapter/form'; import { z } from '#/adapter/form';
import { getDictTypeList } from '#/api/system/dict_type'; import { getDictTypeList } from '#/api/system/dict_type';
import { $t } from '#/locales'; import { $t } from '#/locales';
import {format_datetime} from "#/utils/date"; import { format_datetime } from '#/utils/date';
import { op } from '#/utils/permission';
/** /**
* 获取编辑表单的字段配置。如果没有使用多语言可以直接export一个数组常量 * 获取编辑表单的字段配置。如果没有使用多语言可以直接export一个数组常量
@@ -88,7 +89,7 @@ export function useSchema(): VbenFormSchema[] {
label: '危险', label: '危险',
}, },
], ],
} },
}, },
{ {
component: 'Input', component: 'Input',
@@ -191,13 +192,8 @@ export function useColumns(
}, },
name: 'CellOperation', name: 'CellOperation',
options: [ options: [
'edit', // 默认的编辑按钮 op('system:dict_data:edit', 'edit'),
{ op('system:dict_data:delete', 'delete'),
code: 'delete', // 默认的删除按钮
disabled: (row: SystemDictDataApi.SystemDictData) => {
return !!(row.children && row.children.length > 0);
},
},
], ],
}, },
field: 'operation', field: 'operation',

View File

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

View File

@@ -7,6 +7,7 @@ import type { SystemDictTypeApi } from '#/api/system/dict_type';
import { z } from '#/adapter/form'; import { z } from '#/adapter/form';
import { $t } from '#/locales'; import { $t } from '#/locales';
import { format_datetime } from '#/utils/date'; import { format_datetime } from '#/utils/date';
import {op} from "#/utils/permission";
/** /**
* 获取编辑表单的字段配置。如果没有使用多语言可以直接export一个数组常量 * 获取编辑表单的字段配置。如果没有使用多语言可以直接export一个数组常量
@@ -123,17 +124,12 @@ export function useColumns(
}, },
name: 'CellOperation', name: 'CellOperation',
options: [ options: [
'edit', // 默认的编辑按钮 op('system:dict_type:edit', 'edit'),
{ {
code: 'view', // 新增查看详情按钮可自定义code code: 'view', // 新增查看详情按钮可自定义code
text: '数据', // 按钮文本(国际化) text: '数据', // 按钮文本(国际化)
}, },
{ op('system:dict_type:delete', 'delete'),
code: 'delete', // 默认的删除按钮
disabled: (row: SystemDictTypeApi.SystemDictType) => {
return !!(row.children && row.children.length > 0);
},
},
], ],
}, },
field: 'operation', field: 'operation',

View File

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

View File

@@ -2,6 +2,7 @@ import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemMenuApi } from '#/api/system/menu'; import type { SystemMenuApi } from '#/api/system/menu';
import { $t } from '#/locales'; import { $t } from '#/locales';
import {op} from "#/utils/permission";
export function getMenuTypeOptions() { export function getMenuTypeOptions() {
return [ return [
@@ -95,12 +96,12 @@ export function useColumns(
}, },
name: 'CellOperation', name: 'CellOperation',
options: [ options: [
{ op('system:menu:create', {
code: 'append', code: 'append',
text: '新增下级', text: '新增下级',
}, }),
'edit', // 默认的编辑按钮 op('system:menu:edit', 'edit'),
'delete', // 默认的删除按钮 op('system:menu:delete', 'delete'),
], ],
}, },
field: 'operation', field: 'operation',

View File

@@ -115,7 +115,11 @@ function onDelete(row: SystemMenuApi.SystemMenu) {
<FormDrawer @success="onRefresh" /> <FormDrawer @success="onRefresh" />
<Grid> <Grid>
<template #toolbar-tools> <template #toolbar-tools>
<Button type="primary" @click="onCreate"> <Button
type="primary"
@click="onCreate"
v-permission="'system:menu:create'"
>
<Plus class="size-5" /> <Plus class="size-5" />
{{ $t('ui.actionTitle.create', [$t('system.menu.name')]) }} {{ $t('ui.actionTitle.create', [$t('system.menu.name')]) }}
</Button> </Button>

View File

@@ -7,6 +7,7 @@ import type { SystemPostApi } from '#/models/system/post';
import { z } from '#/adapter/form'; import { z } from '#/adapter/form';
import { $t } from '#/locales'; import { $t } from '#/locales';
import { format_datetime } from '#/utils/date'; import { format_datetime } from '#/utils/date';
import {op} from "#/utils/permission";
/** /**
* 获取编辑表单的字段配置 * 获取编辑表单的字段配置
@@ -107,10 +108,8 @@ export function useColumns(
}, },
name: 'CellOperation', name: 'CellOperation',
options: [ options: [
'edit', // 默认的编辑按钮 op('system:post:edit', 'edit'),
{ op('system:post:delete', 'delete'),
code: 'delete', // 默认的删除按钮
},
], ],
}, },
field: 'operation', field: 'operation',

View File

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

View File

@@ -4,6 +4,7 @@ import type { SystemRoleApi } from '#/api/system/role';
import { $t } from '#/locales'; import { $t } from '#/locales';
import { format_datetime } from '#/utils/date'; import { format_datetime } from '#/utils/date';
import {op} from "#/utils/permission";
export function useFormSchema(): VbenFormSchema[] { export function useFormSchema(): VbenFormSchema[] {
return [ return [
@@ -127,6 +128,10 @@ export function useColumns<T = SystemRoleApi.SystemRole>(
onClick: onActionClick, onClick: onActionClick,
}, },
name: 'CellOperation', name: 'CellOperation',
options: [
op('system:role:edit', 'edit'),
op('system:role:delete', 'delete'),
],
}, },
field: 'operation', field: 'operation',
fixed: 'right', fixed: 'right',

View File

@@ -153,10 +153,14 @@ function onCreate() {
</script> </script>
<template> <template>
<Page auto-content-height> <Page auto-content-height>
<FormDrawer @success="onRefresh"/> <FormDrawer @success="onRefresh" />
<Grid :table-title="$t('system.role.list')"> <Grid :table-title="$t('system.role.list')">
<template #toolbar-tools> <template #toolbar-tools>
<Button type="primary" @click="onCreate"> <Button
type="primary"
@click="onCreate"
v-permission="'system:role:create'"
>
<Plus class="size-5" /> <Plus class="size-5" />
{{ $t('ui.actionTitle.create', [$t('system.role.name')]) }} {{ $t('ui.actionTitle.create', [$t('system.role.name')]) }}
</Button> </Button>

View File

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