102 lines
3.4 KiB
Vue
102 lines
3.4 KiB
Vue
import { BasicColumn, FormSchema } from '/@/components/Table';
|
|
import { checkSparePartName } from './MesXslSparePart.api';
|
|
|
|
export const columns: BasicColumn[] = [
|
|
{ title: '备品件名称', align: 'center', dataIndex: 'sparePartName', width: 160 },
|
|
{ title: '类别名称', align: 'center', dataIndex: 'sparePartsCategoryName', width: 140 },
|
|
{ title: '规格型号', align: 'center', dataIndex: 'specModel', width: 140, ellipsis: true },
|
|
{ title: '最大库存', align: 'center', dataIndex: 'maxStock', width: 110 },
|
|
{ title: '最小库存', align: 'center', dataIndex: 'minStock', width: 110 },
|
|
{ title: '单位', align: 'center', dataIndex: 'unitName', width: 90 },
|
|
{ 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: 'sparePartName', component: 'Input', colProps: { span: 6 } },
|
|
{ label: '类别名称', field: 'sparePartsCategoryName', component: 'Input', colProps: { span: 6 } },
|
|
{ label: '规格型号', field: 'specModel', component: 'Input', colProps: { span: 6 } },
|
|
];
|
|
|
|
export const formSchema: FormSchema[] = [
|
|
{ label: '', field: 'id', component: 'Input', show: false },
|
|
{
|
|
label: '备品件名称',
|
|
field: 'sparePartName',
|
|
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 checkSparePartName({ sparePartName: 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: 'sparePartsCategoryId',
|
|
component: 'Input',
|
|
show: false,
|
|
dynamicRules: () => [{ required: true, message: '请选择所属备品件类别' }],
|
|
},
|
|
{
|
|
label: '所属类别',
|
|
field: 'sparePartsCategoryName',
|
|
component: 'Input',
|
|
slot: 'sparePartsCategoryPicker',
|
|
},
|
|
{
|
|
label: '规格型号',
|
|
field: 'specModel',
|
|
component: 'Input',
|
|
componentProps: { placeholder: '可选' },
|
|
},
|
|
{
|
|
label: '最大库存',
|
|
field: 'maxStock',
|
|
required: true,
|
|
component: 'InputNumber',
|
|
componentProps: { min: 0, precision: 4, style: { width: '100%' } },
|
|
},
|
|
{
|
|
label: '最小库存',
|
|
field: 'minStock',
|
|
required: true,
|
|
component: 'InputNumber',
|
|
componentProps: { min: 0, precision: 4, style: { width: '100%' } },
|
|
},
|
|
{
|
|
label: '',
|
|
field: 'unitId',
|
|
component: 'Input',
|
|
show: false,
|
|
dynamicRules: () => [{ required: true, message: '请选择单位' }],
|
|
},
|
|
{
|
|
label: '单位',
|
|
field: 'unitName',
|
|
component: 'Input',
|
|
slot: 'unitPicker',
|
|
},
|
|
];
|