import { BasicColumn, FormSchema } from '/@/components/Table'; import { loadTreeData } from '/@/api/common/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_MATERIAL' }, resultField: '', labelField: 'title', valueField: 'key', placeholder: '请选择胶料类别', }; 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 }, { label: '胶料名称', field: 'materialName', component: 'Input', required: true }, { 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 }, }, ];