| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- import type { VbenFormSchema } from '#/adapter/form';
- import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
- import type { SystemModel } from '#/api';
- import { $t } from '#/locales';
- export function useRoleSearchFormSchema(): VbenFormSchema[] {
- return [
- { component: 'Input', fieldName: 'name', label: $t('system.role.name') },
- {
- component: 'Select',
- componentProps: {
- allowClear: true,
- options: [
- { label: $t('common.enabled'), value: 1 },
- { label: $t('common.disabled'), value: 0 },
- ],
- },
- fieldName: 'status',
- label: $t('system.role.status'),
- },
- ];
- }
- export function useRoleTableColumns<T = SystemModel.Role>(
- onActionClick: OnActionClickFn<T>,
- onStatusChange?: (newStatus: any, row: T) => PromiseLike<boolean | undefined>,
- ): VxeTableGridOptions['columns'] {
- return [
- {
- field: 'name',
- title: $t('system.role.name'),
- width: 200,
- },
- {
- field: 'code',
- title: $t('system.role.code'),
- width: 200,
- },
- {
- cellRender: {
- attrs: { beforeChange: onStatusChange },
- // props: { accessRole: '超级管理员' },
- name: onStatusChange ? 'CellSwitch' : 'CellTag',
- },
- field: 'status',
- title: $t('system.role.status'),
- width: 100,
- },
- {
- field: 'remark',
- minWidth: 100,
- title: $t('system.role.remark'),
- },
- {
- field: 'lastTime',
- title: $t('table.column.lastTime'),
- },
- {
- field: 'lastUser',
- title: $t('table.column.lastUser'),
- },
- {
- field: 'createUser',
- title: $t('table.column.createUser'),
- },
- {
- field: 'createTime',
- title: $t('table.column.createTime'),
- },
- {
- align: 'center',
- cellRender: {
- attrs: {
- nameField: 'name',
- nameTitle: $t('system.role.name'),
- onClick: onActionClick,
- },
- name: 'CellOperation',
- },
- field: 'operation',
- fixed: 'right',
- title: $t('table.column.operation'),
- width: 130,
- },
- ];
- }
- export function useRoleFormSchema(): VbenFormSchema[] {
- return [
- {
- component: 'Input',
- fieldName: 'name',
- label: $t('system.role.name'),
- rules: 'required',
- },
- {
- component: 'RadioGroup',
- componentProps: {
- buttonStyle: 'solid',
- options: [
- { label: $t('common.enabled'), value: 1 },
- { label: $t('common.disabled'), value: 0 },
- ],
- optionType: 'button',
- },
- defaultValue: 1,
- fieldName: 'status',
- label: $t('system.role.status'),
- },
- {
- component: 'Textarea',
- fieldName: 'remark',
- label: $t('system.role.remark'),
- },
- {
- component: 'Input',
- fieldName: 'permissions',
- formItemClass: 'items-start',
- label: $t('system.role.setPermissions'),
- modelPropName: 'modelValue',
- },
- ];
- }
|