import { BasicColumn, FormSchema } from '/@/components/Table'; import { checkSubPartCode } from './MesXslEquipmentSubPart.api'; export const columns: BasicColumn[] = [ { title: '小部位代码', align: 'center', dataIndex: 'subPartCode', width: 120 }, { title: '类别名称', align: 'center', dataIndex: 'equipmentCategoryName', width: 140 }, { title: '大部位名称', align: 'center', dataIndex: 'equipmentPartName', width: 140 }, { title: '小部位名称', align: 'center', dataIndex: 'subPartName', width: 140 }, { title: '部位描述', align: 'center', dataIndex: 'subPartDescription', width: 200, ellipsis: true }, { title: '是否启用', align: 'center', dataIndex: 'enableStatus_dictText', width: 100 }, { 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), }, { title: '租户ID', align: 'center', dataIndex: 'tenantId', width: 90, defaultHidden: true }, ]; export const searchFormSchema: FormSchema[] = [ { label: '小部位代码', field: 'subPartCode', component: 'Input', colProps: { span: 6 } }, { label: '类别名称', field: 'equipmentCategoryName', component: 'Input', colProps: { span: 6 } }, { label: '大部位名称', field: 'equipmentPartName', component: 'Input', colProps: { span: 6 } }, { label: '小部位名称', field: 'subPartName', component: 'Input', colProps: { span: 6 } }, { label: '是否启用', field: 'enableStatus', component: 'JDictSelectTag', componentProps: { dictCode: 'xslmes_unit_status' }, colProps: { span: 6 }, }, ]; export const formSchema: FormSchema[] = [ { label: '', field: 'id', component: 'Input', show: false }, { label: '小部位代码', field: 'subPartCode', 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 checkSubPartCode({ subPartCode: 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, dynamicRules: () => [{ required: true, message: '请选择所属设备类别' }], }, { label: '所属类别', field: 'equipmentCategoryName', component: 'Input', slot: 'equipmentCategoryPicker', }, { label: '', field: 'equipmentPartId', component: 'Input', show: false, dynamicRules: () => [{ required: true, message: '请选择所属设备大部位' }], }, { label: '所属大部位', field: 'equipmentPartName', component: 'Input', slot: 'equipmentPartPicker', }, { label: '小部位名称', field: 'subPartName', required: true, component: 'Input', componentProps: { placeholder: '请输入小部位名称' }, }, { label: '部位描述', field: 'subPartDescription', component: 'InputTextArea', componentProps: { rows: 3 }, }, { label: '是否启用', field: 'enableStatus', required: true, component: 'JDictSelectTag', componentProps: { dictCode: 'xslmes_unit_status', placeholder: '请选择' }, defaultValue: '0', }, ];