98 lines
1.9 KiB
TypeScript
98 lines
1.9 KiB
TypeScript
import type { VbenFormSchema } from '#/adapter/form';
|
|
|
|
import { getAdminOptions, getMenuTree } from '#/api';
|
|
|
|
export function useSubmitFormSchema(): VbenFormSchema[] {
|
|
return [
|
|
{
|
|
component: 'Input',
|
|
fieldName: 'roleName',
|
|
label: '角色名称',
|
|
rules: 'required',
|
|
},
|
|
{
|
|
component: 'Input',
|
|
fieldName: 'roleCode',
|
|
label: '角色编码',
|
|
rules: 'required',
|
|
},
|
|
{
|
|
component: 'ApiSelect',
|
|
fieldName: 'adminIds',
|
|
label: '用户',
|
|
componentProps: {
|
|
api: getAdminOptions,
|
|
resultField: '',
|
|
multiple: true,
|
|
clearable: true,
|
|
labelField: 'displayName',
|
|
valueField: 'id',
|
|
optionsPropName: 'options',
|
|
},
|
|
},
|
|
{
|
|
component: 'ApiTree',
|
|
// 对应组件的参数
|
|
componentProps: {
|
|
// 菜单接口
|
|
api: getMenuTree,
|
|
resultField: 'items',
|
|
keys: { label: 'menuName', value: 'id'},
|
|
checkStrictly: true,
|
|
checkable: true,
|
|
expandAll: true,
|
|
clearable: true,
|
|
multiple: true,
|
|
},
|
|
fieldName: 'menuIds',
|
|
label: '权限',
|
|
},
|
|
{
|
|
component: 'Input',
|
|
fieldName: 'remark',
|
|
label: '备注',
|
|
componentProps: {
|
|
type: 'textarea',
|
|
},
|
|
},
|
|
];
|
|
}
|
|
|
|
export function useGridSchema() {
|
|
return [
|
|
{
|
|
field: 'status',
|
|
title: '状态',
|
|
slots: { default: 'status' },
|
|
width: 120,
|
|
fixed: 'left',
|
|
},
|
|
{
|
|
field: 'roleName',
|
|
title: '角色名称',
|
|
width: 150,
|
|
},
|
|
{
|
|
field: 'roleCode',
|
|
title: '角色编码',
|
|
width: 150,
|
|
},
|
|
{
|
|
field: 'adminIds',
|
|
title: '用户',
|
|
slots: { default: 'adminIds' },
|
|
},
|
|
{
|
|
field: 'remark',
|
|
title: '备注',
|
|
},
|
|
{
|
|
field: 'actions',
|
|
title: '操作',
|
|
fixed: 'right',
|
|
width: 150,
|
|
slots: { default: 'actions' },
|
|
},
|
|
];
|
|
}
|