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

pull/68/head
YunaiV 2025-04-05 09:43:01 +08:00
parent 49f13bf301
commit a617d4b71e
30 changed files with 199 additions and 42 deletions

View File

@ -9,6 +9,9 @@ import { getSimpleUserList } from '#/api/system/user';
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
import { CommonStatusEnum } from '#/utils/constants';
import { handleTree } from '#/utils/tree';
import { useAccess } from '@vben/access';
const { hasAccessByCodes } = useAccess();
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
@ -180,10 +183,15 @@ export function useGridColumns(
{
code: 'append',
text: '新增下级',
show: hasAccessByCodes(['system:dept:create']),
},
'edit', // 默认的编辑按钮
{
code: 'delete', // 默认的删除按钮
code: 'edit',
show: hasAccessByCodes(['system:dept:update']),
},
{
code: 'delete',
show: hasAccessByCodes(['system:dept:delete']),
disabled: (row: SystemDeptApi.SystemDept) => {
return !!(row.children && row.children.length > 0);
},

View File

@ -123,7 +123,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
<FormModal @success="onRefresh" />
<Grid table-title="">
<template #toolbar-tools>
<Button type="primary" @click="onCreate">
<Button type="primary" @click="onCreate" v-access:code="['system:dept:create']">
<Plus class="size-5" />
{{ $t('ui.actionTitle.create', ['部门']) }}
</Button>
@ -133,4 +133,4 @@ const [Grid, gridApi] = useVbenVxeGrid({
</template>
</Grid>
</Page>
</template>
</template>

View File

@ -4,6 +4,9 @@ import type { SystemMailAccountApi } from '#/api/system/mail/account';
import { z } from '#/adapter/form';
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
import { useAccess } from '@vben/access';
const { hasAccessByCodes } = useAccess();
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
@ -187,7 +190,17 @@ export function useGridColumns<T = SystemMailAccountApi.SystemMailAccount>(
nameTitle: '邮箱账号',
onClick: onActionClick,
},
name: 'CellOperation'
name: 'CellOperation',
options: [
{
code: 'edit',
show: hasAccessByCodes(['system:mail-account:update']),
},
{
code: 'delete',
show: hasAccessByCodes(['system:mail-account:delete']),
}
],
},
},
];

View File

@ -103,7 +103,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
<FormModal @success="onRefresh" />
<Grid table-title="">
<template #toolbar-tools>
<Button type="primary" @click="onCreate">
<Button type="primary" @click="onCreate" v-access:code="['system:mail-account:create']">
<Plus class="size-5" />
{{ $t('ui.actionTitle.create', ['邮箱账号']) }}
</Button>

View File

@ -5,6 +5,9 @@ import type { SystemMailLogApi } from '#/api/system/mail/log';
import { getSimpleMailAccountList } from '#/api/system/mail/account';
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
import { getRangePickerDefaultProps } from '#/utils/date';
import { useAccess } from '@vben/access';
const { hasAccessByCodes } = useAccess();
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
@ -138,6 +141,7 @@ export function useGridColumns<T = SystemMailLogApi.SystemMailLog>(
{
code: 'view',
text: '查看',
show: hasAccessByCodes(['system:mail-log:query']),
}
],
},

View File

@ -7,6 +7,9 @@ import { getSimpleMailAccountList } from '#/api/system/mail/account';
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[] {
@ -252,11 +255,18 @@ export function useGridColumns<T = SystemMailTemplateApi.SystemMailTemplate>(
},
name: 'CellOperation',
options: [
'edit', // 默认的编辑按钮
'delete', // 默认的删除按钮
{
code: 'edit',
show: hasAccessByCodes(['system:mail-template:update']),
},
{
code: 'delete',
show: hasAccessByCodes(['system:mail-template:delete']),
},
{
code: 'send',
text: '测试',
show: hasAccessByCodes(['system:mail-template:send-mail']),
},
],
},

View File

@ -119,7 +119,7 @@ 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:mail-template:create']">
<Plus class="size-5" />
{{ $t('ui.actionTitle.create', ['邮件模板']) }}
</Button>

View File

@ -14,6 +14,9 @@ import { DICT_TYPE, getDictOptions } from '#/utils/dict';
import { handleTree } from '#/utils/tree';
import { CommonStatusEnum, SystemMenuTypeEnum } from '#/utils/constants';
import { isHttpUrl } from '@vben/utils';
import { useAccess } from '@vben/access';
const { hasAccessByCodes } = useAccess();
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
@ -323,11 +326,18 @@ export function useGridColumns(
{
code: 'append',
text: '新增下级',
show: hasAccessByCodes(['system:menu:create']),
},
{
code: 'edit',
show: hasAccessByCodes(['system:menu:update']),
},
{
code: 'delete',
show: hasAccessByCodes(['system:menu:delete']),
},
'edit', // 默认的编辑按钮
'delete', // 默认的删除按钮
],
},
},
];
}
}

View File

@ -123,7 +123,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
<FormModal @success="onRefresh" />
<Grid>
<template #toolbar-tools>
<Button type="primary" @click="onCreate">
<Button type="primary" @click="onCreate" v-access:code="['system:menu:create']">
<Plus class="size-5" />
{{ $t('ui.actionTitle.create', ['菜单']) }}
</Button>
@ -151,4 +151,4 @@ const [Grid, gridApi] = useVbenVxeGrid({
</template>
</Grid>
</Page>
</template>
</template>

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>

View File

@ -4,6 +4,9 @@ import type { SystemPostApi } from '#/api/system/post';
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
import { CommonStatusEnum } from '#/utils/constants';
import { useAccess } from '@vben/access';
const { hasAccessByCodes } = useAccess();
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
@ -143,6 +146,16 @@ export function useGridColumns<T = SystemPostApi.SystemPost>(
onClick: onActionClick,
},
name: 'CellOperation',
options: [
{
code: 'edit',
show: hasAccessByCodes(['system:post:update']),
},
{
code: 'delete',
show: hasAccessByCodes(['system:post:delete']),
},
],
},
},
];

View File

@ -110,11 +110,11 @@ const [Grid, gridApi] = useVbenVxeGrid({
<FormModal @success="onRefresh" />
<Grid table-title="">
<template #toolbar-tools>
<Button type="primary" @click="onCreate">
<Button type="primary" @click="onCreate" v-access:code="['system:post: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:post:export']">
<Download class="size-5" />
{{ $t('ui.actionTitle.export') }}
</Button>

View File

@ -6,6 +6,9 @@ import { z } from '#/adapter/form';
import { CommonStatusEnum, SystemDataScopeEnum } 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[] {
@ -250,15 +253,23 @@ export function useGridColumns<T = SystemRoleApi.SystemRole>(
},
name: 'CellOperation',
options: [
'edit', // 默认的编辑按钮
'delete', // 默认的删除按钮
{
code: 'edit',
show: hasAccessByCodes(['system:role:update']),
},
{
code: 'delete',
show: hasAccessByCodes(['system:role:delete']),
},
{
code: 'assign-data-permission',
text: '数据权限',
show: hasAccessByCodes(['system:permission:assign-role-data-scope']),
},
{
code: 'assign-menu',
text: '菜单权限',
show: hasAccessByCodes(['system:permission:assign-role-menu']),
},
],
},

View File

@ -145,11 +145,11 @@ const [Grid, gridApi] = useVbenVxeGrid({
<AssignMenuFormModel @success="onRefresh" />
<Grid table-title="">
<template #toolbar-tools>
<Button type="primary" @click="onCreate">
<Button type="primary" @click="onCreate" v-access:code="['system:role: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:role:export']">
<Download class="size-5" />
{{ $t('ui.actionTitle.export') }}
</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[] {
@ -200,6 +203,16 @@ export function useGridColumns<T = SystemSmsChannelApi.SystemSmsChannel>(
onClick: onActionClick,
},
name: 'CellOperation',
options: [
{
code: 'edit',
show: hasAccessByCodes(['system:sms-channel:update']),
},
{
code: 'delete',
show: hasAccessByCodes(['system:sms-channel:delete']),
}
],
},
},
];

View File

@ -111,11 +111,11 @@ const [Grid, gridApi] = useVbenVxeGrid({
<FormModal @success="onRefresh" />
<Grid table-title="">
<template #toolbar-tools>
<Button type="primary" @click="onCreate">
<Button type="primary" @click="onCreate" v-access:code="['system:sms-channel: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:sms-channel:export']">
<Download class="size-5" />
{{ $t('ui.actionTitle.export') }}
</Button>

View File

@ -5,6 +5,9 @@ import type { SystemSmsLogApi } from '#/api/system/sms/log';
import { getSimpleSmsChannelList } from '#/api/system/sms/channel';
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
import { getRangePickerDefaultProps } from '#/utils/date';
import { useAccess } from '@vben/access';
const { hasAccessByCodes } = useAccess();
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
@ -176,6 +179,7 @@ export function useGridColumns<T = SystemSmsLogApi.SystemSmsLog>(
{
code: 'view',
text: '查看',
show: hasAccessByCodes(['system:sms-log:query']),
},
],
},

View File

@ -83,7 +83,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
<DetailModal @success="onRefresh" />
<Grid table-title="">
<template #toolbar-tools>
<Button type="primary" class="ml-2" @click="onExport">
<Button type="primary" class="ml-2" @click="onExport" v-access:code="['system:sms-log:export']">
<Download class="size-5" />
{{ $t('ui.actionTitle.export') }}
</Button>

View File

@ -7,6 +7,9 @@ import { getSimpleSmsChannelList } from '#/api/system/sms/channel';
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[] {
@ -280,11 +283,18 @@ export function useGridColumns<T = SystemSmsTemplateApi.SystemSmsTemplate>(
},
name: 'CellOperation',
options: [
'edit', // 默认的编辑按钮
'delete', // 默认的删除按钮
{
code: 'edit',
show: hasAccessByCodes(['system:sms-template:update']),
},
{
code: 'delete',
show: hasAccessByCodes(['system:sms-template:delete']),
},
{
code: 'sms-send',
text: '发送短信',
show: hasAccessByCodes(['system:sms-template:send-sms']),
},
],
},

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:sms-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:sms-template:export']">
<Download class="size-5" />
{{ $t('ui.actionTitle.export') }}
</Button>

View File

@ -7,6 +7,9 @@ import { getTenantPackageList } from '#/api/system/tenant-package';
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[] {
@ -254,6 +257,16 @@ export function useGridColumns<T = SystemTenantApi.SystemTenant>(onActionClick:
onClick: onActionClick,
},
name: 'CellOperation',
options: [
{
code: 'edit',
show: hasAccessByCodes(['system:tenant:update']),
},
{
code: 'delete',
show: hasAccessByCodes(['system:tenant:delete']),
},
],
},
},
];

View File

@ -111,11 +111,11 @@ const [Grid, gridApi] = useVbenVxeGrid({
<FormModal @success="onRefresh" />
<Grid table-title="">
<template #toolbar-tools>
<Button type="primary" @click="onCreate">
<Button type="primary" @click="onCreate" v-access:code="['system:tenant: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:tenant:export']">
<Download class="size-5" />
{{ $t('ui.actionTitle.export') }}
</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[] {
@ -135,6 +138,16 @@ export function useGridColumns<T = SystemTenantPackageApi.SystemTenantPackage>(o
onClick: onActionClick,
},
name: 'CellOperation',
options: [
{
code: 'edit',
show: hasAccessByCodes(['system:tenant-package:update']),
},
{
code: 'delete',
show: hasAccessByCodes(['system:tenant-package:delete']),
},
],
},
},
];

View File

@ -101,7 +101,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
<FormModal @success="onRefresh" />
<Grid table-title="">
<template #toolbar-tools>
<Button type="primary" @click="onCreate">
<Button type="primary" @click="onCreate" v-access:code="['system:tenant-package:create']">
<Plus class="size-5" />
{{ $t('ui.actionTitle.create', ['套餐']) }}
</Button>

View File

@ -10,6 +10,9 @@ import { getSimplePostList } from '#/api/system/post';
import { getSimpleRoleList } from '#/api/system/role';
import { handleTree } from '#/utils/tree';
import { getRangePickerDefaultProps } from '#/utils/date';
import { useAccess } from '@vben/access';
const { hasAccessByCodes } = useAccess();
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
@ -344,15 +347,24 @@ export function useGridColumns<T = SystemUserApi.SystemUser>(
name: 'CellOperation',
// TODO @芋艿:后续把 delete、assign-role、reset-password 搞成"更多"
options: [
'edit', // 默认的编辑按钮
'delete', // 默认的删除按钮
{
code: 'edit',
show: hasAccessByCodes(['system:user:update']),
},
{
code: 'delete',
show: hasAccessByCodes(['system:user:delete']),
},
{
code: 'assign-role',
text: '分配角色',
show: hasAccessByCodes(['system:permission:assign-user-role']),
'v-access:code': 'system:user:assign-role1',
},
{
code: 'reset-password',
text: '重置密码',
show: hasAccessByCodes(['system:user:update-password']),
},
],
},

View File

@ -202,15 +202,15 @@ const [Grid, gridApi] = useVbenVxeGrid({
<div class="w-18/24">
<Grid table-title="">
<template #toolbar-tools>
<Button type="primary" @click="onCreate">
<Button type="primary" @click="onCreate" v-access:code="['system:user: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:user:export']">
<Download class="size-5" />
{{ $t('ui.actionTitle.export') }}
</Button>
<Button type="primary" class="ml-2" @click="onImport">
<Button type="primary" class="ml-2" @click="onImport" v-access:code="['system:user:import']">
<Upload class="size-5" />
{{ $t('ui.actionTitle.import', ['用户']) }}
</Button>