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( onActionClick: OnActionClickFn, onStatusChange?: (newStatus: any, row: T) => PromiseLike, ): 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', }, ]; }