feat: add system user view

This commit is contained in:
xingyu4j
2026-05-18 21:45:17 +08:00
parent 5db93a345a
commit aac626da32
9 changed files with 671 additions and 0 deletions

View File

@@ -0,0 +1,135 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { OnActionClickFn, VxeTableGridColumns } from '#/adapter/vxe-table';
import type { SystemUserApi } from '#/api';
import { getDeptList } from '#/api';
import { $t } from '#/locales';
export function useFormSchema(): VbenFormSchema[] {
return [
{
component: 'Input',
fieldName: 'name',
label: $t('system.user.name'),
rules: 'required',
},
{
component: 'ApiTreeSelect',
componentProps: {
allowClear: true,
api: getDeptList,
class: 'w-full',
labelField: 'name',
valueField: 'id',
childrenField: 'children',
},
fieldName: 'deptId',
label: $t('system.user.dept'),
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.user.status'),
},
{
component: 'Textarea',
fieldName: 'remark',
label: $t('system.user.remark'),
},
];
}
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
component: 'Input',
fieldName: 'name',
label: $t('system.user.name'),
},
{ component: 'Input', fieldName: 'id', label: $t('system.user.id') },
{
component: 'Select',
componentProps: {
allowClear: true,
options: [
{ label: $t('common.enabled'), value: 1 },
{ label: $t('common.disabled'), value: 0 },
],
},
fieldName: 'status',
label: $t('system.user.status'),
},
{
component: 'Input',
fieldName: 'remark',
label: $t('system.user.remark'),
},
{
component: 'RangePicker',
fieldName: 'createTime',
label: $t('system.user.createTime'),
},
];
}
export function useColumns<T = SystemUserApi.SystemUser>(
onActionClick: OnActionClickFn<T>,
onStatusChange?: (newStatus: any, row: T) => PromiseLike<boolean | undefined>,
): VxeTableGridColumns {
return [
{
field: 'name',
title: $t('system.user.name'),
width: 200,
},
{
field: 'id',
title: $t('system.user.id'),
width: 200,
},
{
cellRender: {
attrs: { beforeChange: onStatusChange },
name: onStatusChange ? 'CellSwitch' : 'CellTag',
},
field: 'status',
title: $t('system.user.status'),
width: 100,
},
{
field: 'remark',
minWidth: 100,
title: $t('system.user.remark'),
},
{
field: 'createTime',
title: $t('system.user.createTime'),
width: 200,
},
{
align: 'center',
cellRender: {
attrs: {
nameField: 'name',
nameTitle: $t('system.user.name'),
onClick: onActionClick,
},
name: 'CellOperation',
},
field: 'operation',
fixed: 'right',
title: $t('system.user.operation'),
width: 130,
},
];
}