import { BasicColumn, FormSchema } from '/@/components/Table'; import { loadTreeData } from '/@/api/common/api'; import { checkMaterialName } from './MesMaterial.api'; function useStatusText(v: unknown) { if (v === 1) return '使用中'; if (v === 0) return '停用'; return '-'; } function specialRubberText(v: unknown) { if (v === 1) return '是'; if (v === 0) return '否'; return '-'; } const useStatusOptions = [ { label: '使用中', value: 1 }, { label: '停用', value: 0 }, ]; const specialRubberOptions = [ { label: '是', value: 1 }, { label: '否', value: 0 }, ]; const glueCategoryProps = { api: loadTreeData, params: { pcode: 'XSLMES_RUBBER' }, resultField: '', labelField: 'title', valueField: 'key', placeholder: '请选择胶料类别', }; //update-begin---author:jiangxh ---date:20260729 for:【胶料】列表/表单去掉胶料编码展示----------- export const columns: BasicColumn[] = [ { title: '胶料名称', align: 'center', width: 160, dataIndex: 'materialName' }, { title: '胶料类别', align: 'center', width: 140, dataIndex: 'categoryId_dictText' }, { title: '胶料别名', align: 'center', width: 140, dataIndex: 'aliasName' }, { title: '胶料客户', align: 'center', width: 140, dataIndex: 'customerId_dictText' }, { title: 'ERP编号', align: 'center', width: 140, dataIndex: 'erpCode' }, { title: '终炼胶保质期(天)', align: 'center', width: 150, dataIndex: 'finalShelfLifeDays' }, { title: '母炼胶保质期(天)', align: 'center', width: 150, dataIndex: 'masterShelfLifeDays' }, { title: '最小停放时间(时)', align: 'center', width: 150, dataIndex: 'minStandingHours' }, { title: '使用状态', align: 'center', width: 110, dataIndex: 'enableFlag', customRender: ({ text }) => useStatusText(text), }, { title: '是否为特种胶', align: 'center', width: 120, dataIndex: 'isSpecialRubber', customRender: ({ text }) => specialRubberText(text), }, ]; export const searchFormSchema: FormSchema[] = [ { label: '胶料名称', field: 'materialName', component: 'Input', colProps: { span: 6 } }, { label: '胶料类别', field: 'categoryId', component: 'ApiSelect', componentProps: glueCategoryProps, colProps: { span: 6 }, }, { label: '胶料客户', field: 'customerId', component: 'JDictSelectTag', componentProps: { dictCode: 'mes_xsl_customer,customer_name,id' }, colProps: { span: 6 }, }, { label: 'ERP编号', field: 'erpCode', component: 'Input', colProps: { span: 6 } }, { label: '使用状态', field: 'enableFlag', component: 'Select', componentProps: { options: useStatusOptions }, colProps: { span: 6 }, }, { label: '是否为特种胶', field: 'isSpecialRubber', component: 'Select', componentProps: { options: specialRubberOptions }, colProps: { span: 6 }, }, ]; export const formSchema: FormSchema[] = [ { label: '', field: 'id', component: 'Input', show: false }, //update-begin---author:jiangxh ---date:20260730 for:【胶料】编号隐藏,保存由后端按名称回填----------- // 列表/表单均不展示;新增编辑保存后后端将 materialCode = materialName { label: '', field: 'materialCode', component: 'Input', show: false }, //update-end---author:jiangxh ---date:20260730 for:【胶料】编号隐藏,保存由后端按名称回填----------- { label: '胶料名称', field: 'materialName', component: 'Input', required: true, dynamicRules: ({ model }) => [ { required: true, message: '请输入胶料名称' }, { validator: async (_rule, value) => { const v = value == null ? '' : String(value).trim(); if (!v) return Promise.resolve(); try { await checkMaterialName({ materialName: v, dataId: model?.id }); return Promise.resolve(); } catch (e: any) { return Promise.reject(e?.response?.data?.message || e?.message || '胶料名称不能重复'); } }, trigger: 'blur', }, ], }, { label: '胶料类别', field: 'categoryId', component: 'ApiSelect', required: true, componentProps: glueCategoryProps, }, { label: '胶料别名', field: 'aliasName', component: 'Input' }, { label: '胶料客户', field: 'customerId', component: 'JDictSelectTag', componentProps: { dictCode: 'mes_xsl_customer,customer_name,id', placeholder: '请选择胶料客户' }, }, { label: 'ERP编号', field: 'erpCode', component: 'Input' }, { label: '终炼胶保质期(天)', field: 'finalShelfLifeDays', component: 'InputNumber', componentProps: { min: 0, precision: 0 }, }, { label: '母炼胶保质期(天)', field: 'masterShelfLifeDays', component: 'InputNumber', componentProps: { min: 0, precision: 0 }, }, { label: '最小停放时间(时)', field: 'minStandingHours', component: 'InputNumber', componentProps: { min: 0, precision: 0 }, }, { label: '使用状态', field: 'enableFlag', component: 'Select', defaultValue: 1, componentProps: { options: useStatusOptions }, }, { label: '是否为特种胶', field: 'isSpecialRubber', component: 'Select', defaultValue: 0, componentProps: { options: specialRubberOptions }, }, ]; //update-end---author:jiangxh ---date:20260729 for:【胶料】列表/表单去掉胶料编码展示-----------