import { BasicColumn, FormSchema } from '/@/components/Table'; import { checkItemCode, checkItemName } from './MesXslInspectMaintainItem.api'; export const columns: BasicColumn[] = [ { title: '项目名称', align: 'center', dataIndex: 'itemName', width: 140 }, { title: '项目编号', align: 'center', dataIndex: 'itemCode', width: 120 }, { title: '设备类别', align: 'center', dataIndex: 'equipmentCategoryName', width: 120 }, { title: '设备类型', align: 'center', dataIndex: 'equipmentTypeName', width: 120 }, { title: '设备部位', align: 'center', dataIndex: 'equipmentPartName', width: 120 }, { title: '设备小部位', align: 'center', dataIndex: 'equipmentSubPartName', width: 120 }, { title: '项目类别', align: 'center', dataIndex: 'itemCategory_dictText', width: 90 }, { title: '项目类型', align: 'center', dataIndex: 'itemType_dictText', width: 90 }, { title: '点检方式', align: 'center', dataIndex: 'inspectMethod_dictText', width: 90 }, { title: '判断基准', align: 'center', dataIndex: 'judgmentCriteria', width: 160, ellipsis: true }, { title: '保养周期(天)', align: 'center', dataIndex: 'maintainCycleDays', width: 110 }, { title: '创建人', align: 'center', dataIndex: 'createBy', width: 100 }, { title: '创建时间', align: 'center', dataIndex: 'createTime', width: 165, customRender: ({ text }) => (!text ? '' : String(text).length > 19 ? String(text).substring(0, 19) : text), }, ]; export const searchFormSchema: FormSchema[] = [ { label: '项目名称', field: 'itemName', component: 'Input', colProps: { span: 6 } }, { label: '项目编号', field: 'itemCode', component: 'Input', colProps: { span: 6 } }, { label: '设备类别', field: 'equipmentCategoryName', component: 'Input', colProps: { span: 6 } }, { label: '项目类别', field: 'itemCategory', component: 'JDictSelectTag', componentProps: { dictCode: 'xslmes_im_item_category' }, colProps: { span: 6 }, }, ]; export const formSchema: FormSchema[] = [ { label: '', field: 'id', component: 'Input', show: false }, { label: '项目名称', field: 'itemName', component: 'Input', componentProps: { placeholder: '同租户内未删除数据中不可重复' }, dynamicRules: ({ model }) => [ { required: true, message: '请输入项目名称' }, { validator: async (_rule, value) => { const v = value == null ? '' : String(value).trim(); if (!v) { return Promise.resolve(); } try { await checkItemName({ itemName: v, dataId: model?.id }); return Promise.resolve(); } catch (e: any) { const msg = e?.response?.data?.message || e?.message || '项目名称不能重复'; return Promise.reject(msg); } }, trigger: 'blur', }, ], }, { label: '项目编号', field: 'itemCode', component: 'Input', componentProps: { placeholder: '同租户内未删除数据中不可重复' }, dynamicRules: ({ model }) => [ { required: true, message: '请输入项目编号' }, { validator: async (_rule, value) => { const v = value == null ? '' : String(value).trim(); if (!v) { return Promise.resolve(); } try { await checkItemCode({ itemCode: v, dataId: model?.id }); return Promise.resolve(); } catch (e: any) { const msg = e?.response?.data?.message || e?.message || '项目编号不能重复'; return Promise.reject(msg); } }, trigger: 'blur', }, ], }, { label: '', field: 'equipmentCategoryId', component: 'Input', show: false }, { label: '设备类别', field: 'equipmentCategoryName', component: 'Input', slot: 'equipmentCategoryPicker', }, { label: '', field: 'equipmentTypeId', component: 'Input', show: false }, { label: '设备类型', field: 'equipmentTypeName', component: 'Input', slot: 'equipmentTypePicker', }, { label: '', field: 'equipmentPartId', component: 'Input', show: false }, { label: '设备部位', field: 'equipmentPartName', component: 'Input', slot: 'equipmentPartPicker', }, { label: '', field: 'equipmentSubPartId', component: 'Input', show: false }, { label: '设备小部位', field: 'equipmentSubPartName', component: 'Input', slot: 'equipmentSubPartPicker', }, { label: '项目类别', field: 'itemCategory', component: 'JDictSelectTag', required: true, componentProps: { dictCode: 'xslmes_im_item_category', placeholder: '点检/保养' }, }, { label: '项目类型', field: 'itemType', component: 'JDictSelectTag', required: true, componentProps: { dictCode: 'xslmes_im_item_type', placeholder: '机械类/电气类' }, }, { label: '点检方式', field: 'inspectMethod', component: 'JDictSelectTag', required: true, componentProps: { dictCode: 'xslmes_im_inspect_method', placeholder: '视觉/目测/听觉' }, }, { label: '判断基准', field: 'judgmentCriteria', component: 'InputTextArea', required: true, componentProps: { rows: 3, maxlength: 500, showCount: true }, }, { label: '保养周期(天)', field: 'maintainCycleDays', component: 'InputNumber', componentProps: { min: 0, precision: 0, style: { width: '100%' } }, }, ];