import type {FormSchemaGetter} from '#/adapter/form'; import type {VxeGridProps} from '#/adapter/vxe-table'; import {getDictOptions} from "#/utils/dict"; import {renderDict} from "#/utils/render"; import {z} from "#/adapter/form"; export const querySchema: FormSchemaGetter = () => [ { component: 'Input', fieldName: 'name', label: '单位名称', }, { component: 'Input', fieldName: 'contactPerson', label: '联系人', }, { component: 'Select', componentProps: { options: getDictOptions('wy_state'), }, fieldName: 'state', label: '状态', }, ]; export const columns: VxeGridProps['columns'] = [ {type: 'checkbox', width: 60}, // { // title: '序号', // field: 'id', // slots: { // default: ({ rowIndex }) => { // return (rowIndex + 1).toString(); // }, // }, // width: 60 // }, { title: '单位编号', field: 'unitNumber', slots:{ default: ({ row }) => { return row.id; }}, width: 100 }, { title: '单位名称', field: 'name', width: 100 }, { title: '单位类型', field: 'type', slots: { default: ({ row }) => { return renderDict(row.type, 'wy_qylx'); }, }, width: 100 }, { title: '联系人', field: 'contactPerson', width: 100 }, { title: '联系电话', field: 'phone', width: 100 }, // { // title: '入驻位置', // field: 'location', // width: 100, // }, { title: '入驻时间', field: 'time', width: 100, }, { title: '状态', field: 'state', slots: {default: 'state'}, width: 100, }, // { // title: '员工数量', // field: 'number', // width: 100, // }, { title: '备注', field: 'remark', width: 100, }, { title: '创建时间', field: 'createTime', width: 100, }, { field: 'action', fixed: 'right', slots: {default: 'action'}, title: '操作', minWidth: 180, }, ]; export const modalSchema: FormSchemaGetter = () => [ { label: 'id', fieldName: 'id', component: 'Input', dependencies: { show: () => false, triggerFields: [''], }, }, { label: '单位名称', fieldName: 'name', component: 'Input', rules: 'required', }, { label: '单位类型', fieldName: 'type', component: 'Select', componentProps: { options: getDictOptions('wy_qylx'), }, rules: 'required', }, { label: '联系人', fieldName: 'contactPerson', component: 'Input', rules: 'required', }, { label: '联系电话', fieldName: 'phone', component: 'Input', rules:z.union([ z.string().regex(/^1[3-9]\d{9}$/, { message: '手机号格式错误' }), z.number().int().min(1000000000).max(19999999999, { message: '手机号格式错误' }) ]).transform(val => val.toString()), }, { label: '入驻位置', fieldName: 'location', component: 'TreeSelect', rules: 'selectRequired', formItemClass: 'col-span-2' }, { label: '入驻时间', fieldName: 'time', component: 'DatePicker', componentProps: { showTime: true, format: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'YYYY-MM-DD HH:mm:ss', }, rules: 'required', }, { label: '备注', fieldName: 'remark', component: 'Textarea', formItemClass: 'col-span-2' }, ];