feat:所有模块,接入 access 权限控制

This commit is contained in:
YunaiV
2025-04-05 09:43:01 +08:00
parent 49f13bf301
commit a617d4b71e
30 changed files with 199 additions and 42 deletions

View File

@@ -4,6 +4,9 @@ import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
import { getRangePickerDefaultProps } from '#/utils/date';
import { useAccess } from '@vben/access';
const { hasAccessByCodes } = useAccess();
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
@@ -153,6 +156,7 @@ export function useGridColumns<T = SystemNotifyMessageApi.SystemNotifyMessage>(
{
code: 'view',
text: '查看',
show: hasAccessByCodes(['system:notify-message:query']),
},
],
},

View File

@@ -2,7 +2,11 @@ import type { VbenFormSchema } from '#/adapter/form';
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
import { getRangePickerDefaultProps } from '#/utils/date';
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
import { useAccess } from '@vben/access';
const { hasAccessByCodes } = useAccess();
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
@@ -23,6 +27,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'RangePicker',
componentProps: {
allowClear: true,
...getRangePickerDefaultProps(),
},
},
];
@@ -90,6 +95,7 @@ export function useGridColumns<T = SystemNotifyMessageApi.SystemNotifyMessage>(
{
code: 'view',
text: '查看',
show: hasAccessByCodes(['system:notify-message:query']),
},
],
},

View File

@@ -150,11 +150,11 @@ const [Grid, gridApi] = useVbenVxeGrid({
<DetailModal @success="onRefresh" />
<Grid table-title="我的站内信">
<template #toolbar-tools>
<Button type="primary" @click="onMarkRead">
<Button type="primary" @click="onMarkRead" v-access:code="['system:notify-message:update-read']">
<MdiCheckboxMarkedCircleOutline />
标记已读
</Button>
<Button type="primary" class="ml-2" @click="onMarkAllRead">
<Button type="primary" class="ml-2" @click="onMarkAllRead" v-access:code="['system:notify-message:update-all-read']">
<MdiCheckboxMarkedCircleOutline />
全部已读
</Button>

View File

@@ -6,6 +6,9 @@ import { z } from '#/adapter/form';
import { CommonStatusEnum } from '#/utils/constants';
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
import { getRangePickerDefaultProps } from '#/utils/date';
import { useAccess } from '@vben/access';
const { hasAccessByCodes } = useAccess();
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
@@ -260,9 +263,19 @@ export function useGridColumns<T = SystemNotifyTemplateApi.SystemNotifyTemplate>
},
name: 'CellOperation',
options: [
'edit', // 默认的编辑按钮
{ code: 'send', text: '测试' },
'delete', // 默认的删除按钮
{
code: 'edit',
show: hasAccessByCodes(['system:notify-template:update']),
},
{
code: 'send',
text: '测试',
show: hasAccessByCodes(['system:notify-template:send-notify']),
},
{
code: 'delete',
show: hasAccessByCodes(['system:notify-template:delete']),
},
],
},
},

View File

@@ -127,11 +127,11 @@ const [Grid, gridApi] = useVbenVxeGrid({
<SendModal />
<Grid table-title="站内信模板列表">
<template #toolbar-tools>
<Button type="primary" @click="onCreate">
<Button type="primary" @click="onCreate" v-access:code="['system:notify-template:create']">
<Plus class="size-5" />
{{ $t('ui.actionTitle.create', ['站内信模板']) }}
</Button>
<Button type="primary" class="ml-2" @click="onExport">
<Button type="primary" class="ml-2" @click="onExport" v-access:code="['system:notify-template:export']">
<Download class="size-5" />
{{ $t('ui.actionTitle.export') }}
</Button>