基础资料限制修改
This commit is contained in:
@@ -4,7 +4,7 @@ import { checkEquipmentCode, checkEquipmentName } from './MesXslEquipmentLedger.
|
||||
const colHalf = { span: 12 };
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: '系统编号', align: 'center', dataIndex: 'ledgerNo', width: 100 },
|
||||
{ title: '系统编号', align: 'center', dataIndex: 'ledgerNo', width: 100, defaultHidden: true },
|
||||
{ title: '设备编号', align: 'center', dataIndex: 'equipmentCode', width: 130 },
|
||||
{ title: '设备名称', align: 'center', dataIndex: 'equipmentName', width: 160 },
|
||||
{ title: '工序', align: 'center', dataIndex: 'processOperationName', width: 120 },
|
||||
@@ -12,6 +12,8 @@ export const columns: BasicColumn[] = [
|
||||
{ title: '设备类型', align: 'center', dataIndex: 'equipmentTypeName', width: 110 },
|
||||
{ title: '设备厂家', align: 'center', dataIndex: 'manufacturerName', width: 120 },
|
||||
{ title: '所属工厂', align: 'center', dataIndex: 'factoryName', width: 120 },
|
||||
{ title: '设备描述', align: 'left', dataIndex: 'equipmentDesc', width: 200, ellipsis: true },
|
||||
{ title: '受控PDA', align: 'center', dataIndex: 'controlledPda', width: 120 },
|
||||
{ title: '设备状态', align: 'center', dataIndex: 'equipmentStatus_dictText', width: 90 },
|
||||
{ title: '是否启用', align: 'center', dataIndex: 'enabledFlag_dictText', width: 90 },
|
||||
{ title: '设备型号', align: 'center', dataIndex: 'equipmentModel', width: 110, defaultHidden: true },
|
||||
@@ -85,14 +87,6 @@ export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'equipmentCategoryId', component: 'Input', show: false, dynamicRules: () => [{ required: true, message: '请选择设备类别' }] },
|
||||
{ label: '', field: 'equipmentTypeId', component: 'Input', show: false, dynamicRules: () => [{ required: true, message: '请选择设备类型' }] },
|
||||
{ label: '', field: 'factoryId', component: 'Input', show: false },
|
||||
{
|
||||
label: '所属工序',
|
||||
field: 'processOperationName',
|
||||
component: 'Input',
|
||||
slot: 'processOperationPicker',
|
||||
colProps: colHalf,
|
||||
dynamicRules: () => [{ required: true, message: '请选择所属工序' }],
|
||||
},
|
||||
{
|
||||
label: '系统编号',
|
||||
field: 'ledgerNo',
|
||||
@@ -100,6 +94,30 @@ export const formSchema: FormSchema[] = [
|
||||
colProps: colHalf,
|
||||
componentProps: { readonly: true, placeholder: '保存时从001起自动生成' },
|
||||
},
|
||||
{
|
||||
label: '设备类型',
|
||||
field: 'equipmentTypeName',
|
||||
component: 'Input',
|
||||
slot: 'equipmentTypePicker',
|
||||
colProps: colHalf,
|
||||
dynamicRules: () => [{ required: true, message: '请选择设备类型' }],
|
||||
},
|
||||
{
|
||||
label: '所属工序',
|
||||
field: 'processOperationName',
|
||||
component: 'Input',
|
||||
colProps: colHalf,
|
||||
componentProps: { readonly: true, placeholder: '选择设备类型后自动带出' },
|
||||
dynamicRules: () => [{ required: true, message: '请先选择设备类型' }],
|
||||
},
|
||||
{
|
||||
label: '设备类别',
|
||||
field: 'equipmentCategoryName',
|
||||
component: 'Input',
|
||||
colProps: colHalf,
|
||||
componentProps: { readonly: true, placeholder: '选择设备类型后自动带出' },
|
||||
dynamicRules: () => [{ required: true, message: '请先选择设备类型' }],
|
||||
},
|
||||
{
|
||||
label: '设备编号',
|
||||
field: 'equipmentCode',
|
||||
@@ -153,22 +171,6 @@ export const formSchema: FormSchema[] = [
|
||||
slot: 'manufacturerPicker',
|
||||
colProps: colHalf,
|
||||
},
|
||||
{
|
||||
label: '设备类别',
|
||||
field: 'equipmentCategoryName',
|
||||
component: 'Input',
|
||||
slot: 'equipmentCategoryPicker',
|
||||
colProps: colHalf,
|
||||
dynamicRules: () => [{ required: true, message: '请选择设备类别' }],
|
||||
},
|
||||
{
|
||||
label: '设备类型',
|
||||
field: 'equipmentTypeName',
|
||||
component: 'Input',
|
||||
slot: 'equipmentTypePicker',
|
||||
colProps: colHalf,
|
||||
dynamicRules: () => [{ required: true, message: '请选择设备类型' }],
|
||||
},
|
||||
{
|
||||
label: '所属工厂',
|
||||
field: 'factoryName',
|
||||
|
||||
@@ -10,13 +10,6 @@
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<BasicForm @register="registerForm">
|
||||
<template #processOperationPicker="{ model, field }">
|
||||
<a-input-group compact style="display: flex; width: 100%">
|
||||
<a-input v-model:value="model[field]" read-only placeholder="请选择工序" style="flex: 1" />
|
||||
<a-button type="primary" :disabled="isDetail" @click="openProcessSelect">选择</a-button>
|
||||
<a-button v-if="model.processOperationId && !isDetail" @click="clearProcess(model)">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
<template #manufacturerPicker="{ model, field }">
|
||||
<a-input-group compact style="display: flex; width: 100%">
|
||||
<a-input v-model:value="model[field]" read-only placeholder="请选择设备厂家" style="flex: 1" />
|
||||
@@ -24,13 +17,6 @@
|
||||
<a-button v-if="model.manufacturerId && !isDetail" @click="clearManufacturer(model)">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
<template #equipmentCategoryPicker="{ model, field }">
|
||||
<a-input-group compact style="display: flex; width: 100%">
|
||||
<a-input v-model:value="model[field]" read-only placeholder="请选择设备类别" style="flex: 1" />
|
||||
<a-button type="primary" :disabled="isDetail" @click="openCategorySelect">选择</a-button>
|
||||
<a-button v-if="model.equipmentCategoryId && !isDetail" @click="clearCategory(model)">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
<template #equipmentTypePicker="{ model, field }">
|
||||
<a-input-group compact style="display: flex; width: 100%">
|
||||
<a-input v-model:value="model[field]" read-only placeholder="请选择设备类型" style="flex: 1" />
|
||||
@@ -46,13 +32,11 @@
|
||||
</a-input-group>
|
||||
</template>
|
||||
</BasicForm>
|
||||
<MesXslProcessOperationSelectModal @register="registerProcessModal" @select="onProcessSelect" />
|
||||
<MesXslManufacturerSelectModal
|
||||
@register="registerManufacturerModal"
|
||||
:modal-title="manufacturerModalTitle"
|
||||
@select="onManufacturerSelect"
|
||||
/>
|
||||
<MesXslEquipmentCategorySelectModal @register="registerCategoryModal" @select="onCategorySelect" />
|
||||
<MesXslEquipmentTypeSelectModal @register="registerTypeModal" @select="onTypeSelect" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
@@ -61,14 +45,14 @@
|
||||
import { computed, ref, unref, onMounted } from 'vue';
|
||||
import { BasicModal, useModalInner, useModal } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { formSchema } from '../MesXslEquipmentLedger.data';
|
||||
import { fetchNextLedgerNo, saveOrUpdate } from '../MesXslEquipmentLedger.api';
|
||||
import MesXslProcessOperationSelectModal from '/@/views/xslmes/mesXslEquipmentCategory/components/MesXslProcessOperationSelectModal.vue';
|
||||
import MesXslManufacturerSelectModal from './MesXslManufacturerSelectModal.vue';
|
||||
import MesXslEquipmentCategorySelectModal from '/@/views/xslmes/mesXslEquipmentType/components/MesXslEquipmentCategorySelectModal.vue';
|
||||
import MesXslEquipmentTypeSelectModal from './MesXslEquipmentTypeSelectModal.vue';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const { createMessage } = useMessage();
|
||||
const isUpdate = ref(true);
|
||||
const isDetail = ref(false);
|
||||
|
||||
@@ -89,9 +73,7 @@
|
||||
manufacturerPickTarget.value === 'factory' ? '选择所属工厂' : '选择设备厂家',
|
||||
);
|
||||
|
||||
const [registerProcessModal, { openModal: openProcessModal }] = useModal();
|
||||
const [registerManufacturerModal, { openModal: openManufacturerModal }] = useModal();
|
||||
const [registerCategoryModal, { openModal: openCategoryModal }] = useModal();
|
||||
const [registerTypeModal, { openModal: openTypeModal }] = useModal();
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
|
||||
@@ -127,11 +109,6 @@
|
||||
!unref(isUpdate) ? '新增设备台账' : unref(isDetail) ? '设备台账详情' : '编辑设备台账',
|
||||
);
|
||||
|
||||
function openProcessSelect() {
|
||||
const v = getFieldsValue();
|
||||
openProcessModal(true, { processOperationId: v?.processOperationId });
|
||||
}
|
||||
|
||||
function openManufacturerSelect(target: 'manufacturer' | 'factory') {
|
||||
manufacturerPickTarget.value = target;
|
||||
const v = getFieldsValue();
|
||||
@@ -140,23 +117,11 @@
|
||||
});
|
||||
}
|
||||
|
||||
function openCategorySelect() {
|
||||
const v = getFieldsValue();
|
||||
openCategoryModal(true, { equipmentCategoryId: v?.equipmentCategoryId });
|
||||
}
|
||||
|
||||
function openTypeSelect() {
|
||||
const v = getFieldsValue();
|
||||
openTypeModal(true, { equipmentTypeId: v?.equipmentTypeId });
|
||||
}
|
||||
|
||||
function onProcessSelect(payload: Recordable) {
|
||||
setFieldsValue({
|
||||
processOperationId: payload.processOperationId,
|
||||
processOperationName: payload.processOperationName,
|
||||
});
|
||||
}
|
||||
|
||||
function onManufacturerSelect(payload: Recordable) {
|
||||
if (manufacturerPickTarget.value === 'factory') {
|
||||
setFieldsValue({
|
||||
@@ -171,27 +136,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
function onCategorySelect(payload: Recordable) {
|
||||
setFieldsValue({
|
||||
equipmentCategoryId: payload.equipmentCategoryId,
|
||||
equipmentCategoryName: payload.equipmentCategoryName,
|
||||
});
|
||||
}
|
||||
|
||||
function onTypeSelect(payload: Recordable) {
|
||||
setFieldsValue({
|
||||
equipmentTypeId: payload.equipmentTypeId,
|
||||
equipmentTypeName: payload.equipmentTypeName,
|
||||
equipmentCategoryId: payload.equipmentCategoryId || getFieldsValue()?.equipmentCategoryId,
|
||||
equipmentCategoryName: payload.equipmentCategoryName || getFieldsValue()?.equipmentCategoryName,
|
||||
equipmentTypeId: payload.equipmentTypeId || '',
|
||||
equipmentTypeName: payload.equipmentTypeName || '',
|
||||
equipmentCategoryId: payload.equipmentCategoryId || '',
|
||||
equipmentCategoryName: payload.equipmentCategoryName || '',
|
||||
processOperationId: payload.processOperationId || '',
|
||||
processOperationName: payload.processOperationName || '',
|
||||
});
|
||||
}
|
||||
|
||||
function clearProcess(model: Recordable) {
|
||||
model.processOperationId = '';
|
||||
model.processOperationName = '';
|
||||
}
|
||||
|
||||
function clearManufacturer(model: Recordable) {
|
||||
model.manufacturerId = '';
|
||||
model.manufacturerName = '';
|
||||
@@ -202,26 +157,38 @@
|
||||
model.factoryName = '';
|
||||
}
|
||||
|
||||
function clearCategory(model: Recordable) {
|
||||
model.equipmentCategoryId = '';
|
||||
model.equipmentCategoryName = '';
|
||||
}
|
||||
|
||||
function clearType(model: Recordable) {
|
||||
model.equipmentTypeId = '';
|
||||
model.equipmentTypeName = '';
|
||||
model.equipmentCategoryId = '';
|
||||
model.equipmentCategoryName = '';
|
||||
model.processOperationId = '';
|
||||
model.processOperationName = '';
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
// validate 结果可能不含隐藏字段最新值,与 getFieldsValue 合并
|
||||
const values = { ...(getFieldsValue() || {}), ...(await validate()) };
|
||||
if (!values.equipmentTypeId) {
|
||||
createMessage.warning('请选择设备类型');
|
||||
return;
|
||||
}
|
||||
if (!values.processOperationId) {
|
||||
createMessage.warning('所选设备类型未绑定工序,请先维护设备类型');
|
||||
return;
|
||||
}
|
||||
if (!values.equipmentCategoryId) {
|
||||
createMessage.warning('所选设备类型未绑定设备类别,请先维护设备类型');
|
||||
return;
|
||||
}
|
||||
setModalProps({ confirmLoading: true });
|
||||
await saveOrUpdate(values, isUpdate.value);
|
||||
closeModal();
|
||||
emit('success');
|
||||
} catch (e) {
|
||||
// 表单校验失败时 ant-design 会标红;此处避免未捕获异常导致“点保存无反应”
|
||||
console.warn('[设备台账] 保存校验未通过', e);
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
|
||||
@@ -79,6 +79,8 @@
|
||||
equipmentTypeName: '',
|
||||
equipmentCategoryId: '',
|
||||
equipmentCategoryName: '',
|
||||
processOperationId: '',
|
||||
processOperationName: '',
|
||||
});
|
||||
closeModal();
|
||||
return;
|
||||
@@ -88,6 +90,8 @@
|
||||
equipmentTypeName: row.typeName || '',
|
||||
equipmentCategoryId: row.equipmentCategoryId || '',
|
||||
equipmentCategoryName: row.equipmentCategoryName || '',
|
||||
processOperationId: row.processOperationId || '',
|
||||
processOperationName: row.processOperationName || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ enum Api {
|
||||
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
|
||||
export const checkConditionName = (params: { conditionName: string; dataId?: string }) =>
|
||||
export const checkConditionName = (params: { conditionName: string; equipmentId?: string; dataId?: string }) =>
|
||||
defHttp.get({ url: Api.checkConditionName, params }, { successMessageMode: 'none', errorMessageMode: 'none' });
|
||||
|
||||
export const checkConditionCode = (params: { conditionCode: string; dataId?: string }) =>
|
||||
export const checkConditionCode = (params: { conditionCode: string; equipmentId?: string; dataId?: string }) =>
|
||||
defHttp.get({ url: Api.checkConditionCode, params }, { successMessageMode: 'none', errorMessageMode: 'none' });
|
||||
|
||||
export const deleteOne = (params, handleSuccess) =>
|
||||
|
||||
@@ -42,11 +42,13 @@ export const formSchema: FormSchema[] = [
|
||||
validator: async (_rule, value) => {
|
||||
const v = value == null ? '' : String(value).trim();
|
||||
if (!v) return Promise.resolve();
|
||||
// 未选设备时不做跨设备校验,保存时仍会强制校验
|
||||
if (!model?.equipmentId) return Promise.resolve();
|
||||
try {
|
||||
await checkConditionName({ conditionName: v, dataId: model?.id });
|
||||
await checkConditionName({ conditionName: v, equipmentId: model.equipmentId, dataId: model?.id });
|
||||
return Promise.resolve();
|
||||
} catch (e: any) {
|
||||
return Promise.reject(e?.response?.data?.message || e?.message || '条件名称不能重复');
|
||||
return Promise.reject(e?.response?.data?.message || e?.message || '同一设备下条件名称不能重复');
|
||||
}
|
||||
},
|
||||
trigger: 'blur',
|
||||
@@ -64,11 +66,12 @@ export const formSchema: FormSchema[] = [
|
||||
validator: async (_rule, value) => {
|
||||
const v = value == null ? '' : String(value).trim();
|
||||
if (!v) return Promise.resolve();
|
||||
if (!model?.equipmentId) return Promise.resolve();
|
||||
try {
|
||||
await checkConditionCode({ conditionCode: v, dataId: model?.id });
|
||||
await checkConditionCode({ conditionCode: v, equipmentId: model.equipmentId, dataId: model?.id });
|
||||
return Promise.resolve();
|
||||
} catch (e: any) {
|
||||
return Promise.reject(e?.response?.data?.message || e?.message || '条件代码不能重复');
|
||||
return Promise.reject(e?.response?.data?.message || e?.message || '同一设备下条件代码不能重复');
|
||||
}
|
||||
},
|
||||
trigger: 'blur',
|
||||
|
||||
Reference in New Issue
Block a user