admin-vben5/apps/web-antd/src/views/sis/personLibImg/data.tsx
zcxlsm 3fe2ff30f8
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
feat(sis): 1
2025-07-14 18:10:37 +08:00

176 lines
3.9 KiB
TypeScript

import { type FormSchemaGetter, type VbenFormSchema } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { DictEnum } from '@vben/constants';
import { getPopupContainer } from '@vben/utils';
import { getDictOptions } from '#/utils/dict';
import { personLibList } from '#/api/sis/personLib';
import type { PersonLibQuery, PersonLibVO } from '#/api/sis/personLib/model';
let libArr: PersonLibVO[] = [];
export const querySchema: FormSchemaGetter = () => [
{
label: '图片库',
fieldName: 'libId',
component: 'ApiSelect',
componentProps: {
resultField: 'list', // 根据API返回结构调整
labelField: 'libName',
valueField: 'id',
// immediate: true,
api: async () => {
if (!libArr || libArr.length == 0) {
const params: PersonLibQuery = {
pageNum: 1,
pageSize: 500,
};
const res = await personLibList(params);
libArr = res.rows;
}
return libArr;
},
},
},
{
component: 'Input',
fieldName: 'imgName',
label: '人像名称',
},
{
component: 'Select',
componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.SYS_USER_SEX),
},
fieldName: 'sex',
label: '性别',
},
];
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
/* {
title: '人员库编码',
field: 'libCode',
},*/
{
title: '人像名称',
field: 'imgName',
},
{
title: '性别',
field: 'sex',
},
{
title: '邮箱',
field: 'email',
},
{
title: '联系方式',
field: 'tel',
},
{
title: '证件类型',
field: 'certificateType',
},
{
title: '证件号码',
field: 'certificateNo',
},
{
title: '出生日期',
field: 'birthDate',
},
{
field: 'action',
fixed: 'right',
slots: { default: 'action' },
title: '操作',
width: 180,
},
];
export const modalSchema: FormSchemaGetter = () => [
{
label: '图片库',
fieldName: 'libIds',
component: 'ApiSelect',
rules: 'required',
componentProps: {
resultField: 'list', // 根据API返回结构调整
labelField: 'libName',
valueField: 'id',
mode: 'multiple',
// immediate: true,
api: async () => {
if (!libArr || libArr.length == 0) {
const params: PersonLibQuery = {
pageNum: 1,
pageSize: 500,
};
const res = await personLibList(params);
libArr = res.rows;
}
return libArr;
},
},
},
{
label: '人像名称',
fieldName: 'imgName',
component: 'Input',
rules: 'required',
},
{
label: '性别',
fieldName: 'sex',
component: 'Select',
componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.SYS_USER_SEX),
},
},
{
label: '邮箱',
fieldName: 'email',
component: 'Input',
},
{
label: '联系方式',
fieldName: 'tel',
component: 'Input',
},
{
label: '证件类型',
fieldName: 'certificateType',
component: 'Select',
componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.SYS_CERTIFICATE_TYPE),
},
},
{
label: '证件号码',
fieldName: 'certificateNo',
component: 'Input',
},
{
label: '出生日期',
fieldName: 'birthDate',
component: 'Input',
},
{
label: '人像图片',
fieldName: 'imgOssId',
component: 'ImageUpload',
componentProps: {
// accept: 'image/*', // 可选拓展名或者mime类型 ,拼接
maxCount: 1, // 最大上传文件数 默认为1 为1会绑定为string而非string[]类型
},
formItemClass: 'col-span-2',
},
];