import type { FormSchemaGetter } from '#/adapter/form'; import type { VxeGridProps } from '#/adapter/vxe-table'; import {getDictOptions} from "#/utils/dict"; import {renderDict} from "#/utils/render"; import {resident_unitList} from "#/api/property/resident/unit"; export const querySchema: FormSchemaGetter = () => [ { component: 'Input', fieldName: 'unitId', label: '所属单位', }, { component: 'ApiSelect', fieldName: 'unitId', label: '所属单位', componentProps: { api: getUnitList, resultField: 'data', labelField: 'label', valueField: 'value', immediate: true, debounceTime: 500, allowClear: true, placeholder: '请选择所属单位', }, rules: 'required', }, { component: 'Input', fieldName: 'userName', label: '员工名称', }, { component: 'Select', componentProps: { options: getDictOptions('wy_rzryzt'), }, fieldName: 'state', label: '状态', }, ]; export const columns: VxeGridProps['columns'] = [ { type: 'checkbox', width: 60 }, { title: '序号', field: 'id', slots: { default: ({ rowIndex }) => { return (rowIndex + 1).toString(); }, }, }, { title: '员工编号', field: 'userId', }, { title: '员工名称', field: 'userName', }, { title: '联系电话', field: 'phone', }, { title: '性别', field: 'gender', slots:{ default: ({row})=>{ return renderDict(row.gender,'wy_rzryzt') } } }, { field: 'img', title: '人脸图片', slots: { default: 'img' }, minWidth: 80, }, { title: '所属单位', field: 'unitName', }, { title: '入驻位置', field: 'locathon', }, { title: '入驻时间', field: 'time', }, { title: '车牌号码', field: 'carNumber', }, { title: '状态', field: 'state', slots:{ default: ({row})=>{ return renderDict(row.state,'wy_rzryzt') } } }, { title: '备注', field: 'remark', }, { field: 'action', fixed: 'right', slots: { default: 'action' }, title: '操作', width: 180, }, ]; export const modalSchema: FormSchemaGetter = () => [ { label: '主键id', fieldName: 'id', component: 'Input', dependencies: { show: () => false, triggerFields: [''], }, }, { label: '入住员工', fieldName: 'userId', component: "Select", rules: 'selectRequired', formItemClass: 'col-span-2' }, { label: '所属单位', fieldName: 'unitId', component: 'Select', formItemClass: 'col-span-2', rules:'selectRequired', }, // { // label: '入驻位置', // fieldName: 'locathon', // component: 'Input', // rules:'required', // formItemClass: 'col-span-2', // }, { label: '人脸图片', fieldName: 'img', component: 'ImageUpload', componentProps: { // accept: 'image/*', // 可选拓展名或者mime类型 ,拼接 maxCount: 1, // 最大上传文件数 默认为1 为1会绑定为string而非string[]类型 }, 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', }, }, { label: '车牌号码', fieldName: 'carNumber', component: 'Input', }, { label: '人员状态', fieldName: 'state', component: 'Select', componentProps: { options: getDictOptions('wy_rzryzt'), }, }, { label: '备注', fieldName: 'remark', component: 'Textarea', formItemClass: 'col-span-2', }, ]; //门禁记录 export const accessControlColumns: VxeGridProps['columns'] = [ { title: '序号', field: 'id', }, { title: '通过时间', field: 'userId', }, { title: '进出类型', field: 'userName', }, { title: '位置', field: 'phone', }, { title: '设备名称', field: 'gender', }, { title: '门禁类型', field: 'img', }, { title: '识别类型', field: 'unitName', }, { title: '状态', field: 'locathon', }, ]; //车辆记录 export const carColumns: VxeGridProps['columns'] = [ { title: '序号', field: 'id', }, { title: '通过时间', field: 'userId', }, { title: '进出类型', field: 'userName', }, { title: '位置', field: 'phone', }, { title: '设备名称', field: 'gender', }, { title: '进出方式', field: 'img', }, { title: '停车类型', field: 'unitName', }, { title: '费用(元)', field: 'locathon', }, { title: '状态', field: 'state', }, { title: '备注', field: 'remark', }, ]; export async function getUnitList(): Promise<{ value: number; label: string }[]> { const queryParam = { pageNum: 1000, pageSize: 1, }; const res = await resident_unitList(queryParam); const data: { value: number; label: string }[] = []; res.rows.forEach((r: any) => { data.push({ value: r.name, label: r.id, }); }); return data; }