Files
qhmes/jeecgboot-vue3/src/views/xslmes/mesXslEquipmentPart/MesXslEquipmentPart.data.ts

92 lines
3.3 KiB
Vue

import { BasicColumn, FormSchema } from '/@/components/Table';
import { checkPartCode } from './MesXslEquipmentPart.api';
export const columns: BasicColumn[] = [
{ title: '部位代码', align: 'center', dataIndex: 'partCode', width: 120 },
{ title: '类别名称', align: 'center', dataIndex: 'equipmentCategoryName', width: 160 },
{ title: '部位名称', align: 'center', dataIndex: 'partName', width: 140 },
{ title: '部位描述', align: 'center', dataIndex: 'partDescription', 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: 'partCode', component: 'Input', colProps: { span: 6 } },
{ label: '', field: 'equipmentCategoryId', component: 'Input', show: false },
{
label: '所属类别',
field: 'equipmentCategoryName',
component: 'Input',
slot: 'equipmentCategoryPicker',
colProps: { span: 6 },
},
{ label: '部位名称', field: 'partName', 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: 'partCode',
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 checkPartCode({ partCode: 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: 'partName',
required: true,
component: 'Input',
componentProps: { placeholder: '请输入部位名称' },
},
{ label: '部位描述', field: 'partDescription', component: 'InputTextArea', componentProps: { rows: 3 } },
{
label: '是否启用',
field: 'enableStatus',
required: true,
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_unit_status', placeholder: '请选择' },
defaultValue: '0',
},
];