reactor:【system 系统管理】role 进一步统一代码风格

This commit is contained in:
YunaiV
2025-09-06 20:17:38 +08:00
parent 6d47871f02
commit 8d5a6d8aa0
8 changed files with 224 additions and 206 deletions

View File

@@ -1,8 +1,6 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemRoleApi } from '#/api/system/role';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { useAccess } from '@vben/access';
import {
CommonStatusEnum,
DICT_TYPE,
@@ -13,8 +11,6 @@ import { getDictOptions } from '@vben/hooks';
import { z } from '#/adapter/form';
import { getRangePickerDefaultProps } from '#/utils';
const { hasAccessByCodes } = useAccess();
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
return [
@@ -161,19 +157,28 @@ export function useGridFormSchema(): VbenFormSchema[] {
fieldName: 'name',
label: '角色名称',
component: 'Input',
componentProps: {
placeholder: '请输入角色名称',
clearable: true,
},
},
{
fieldName: 'code',
label: '角色标识',
component: 'Input',
componentProps: {
placeholder: '请输入角色标识',
clearable: true,
},
},
{
fieldName: 'status',
label: '角色状态',
component: 'Select',
componentProps: {
clearable: true,
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
placeholder: '请选择角色状态',
clearable: true,
},
},
{
@@ -189,18 +194,13 @@ export function useGridFormSchema(): VbenFormSchema[] {
}
/** 列表的字段 */
export function useGridColumns<T = SystemRoleApi.Role>(
onActionClick: OnActionClickFn<T>,
): VxeTableGridOptions['columns'] {
export function useGridColumns(): VxeTableGridOptions['columns'] {
return [
{
type: 'checkbox',
width: 40,
},
{ type: 'checkbox', width: 40 },
{
field: 'id',
title: '角色编号',
minWidth: 200,
minWidth: 100,
},
{
field: 'name',
@@ -247,41 +247,10 @@ export function useGridColumns<T = SystemRoleApi.Role>(
formatter: 'formatDateTime',
},
{
field: 'operation',
title: '操作',
width: 240,
fixed: 'right',
align: 'center',
cellRender: {
attrs: {
nameField: 'name',
nameTitle: '角色',
onClick: onActionClick,
},
name: 'CellOperation',
options: [
{
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']),
},
],
},
slots: { default: 'actions' },
},
];
}