优化混炼示方新增时选择机台逻辑
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
:defaultFullscreen="true"
|
||||
wrapClassName="mixing-spec-modal-wrap"
|
||||
@register="registerModal"
|
||||
@cancel="closeNestedPickers"
|
||||
@cancel="handleMainModalClose"
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<template #title>{{ title }}</template>
|
||||
@@ -53,7 +53,7 @@
|
||||
<a-input
|
||||
:value="sheetForm.machineName"
|
||||
readonly
|
||||
placeholder="请点击选择设备台账"
|
||||
:placeholder="machinePickerPlaceholder"
|
||||
:disabled="!showFooter"
|
||||
:bordered="false"
|
||||
:class="['form-input', 'mixing-picker-input', { 'is-filled': !!sheetForm.machineName }]"
|
||||
@@ -467,15 +467,15 @@
|
||||
<BasicForm v-show="false" @register="registerForm" />
|
||||
</div>
|
||||
</BasicModal>
|
||||
<MesXslEquipmentLedgerSelectModal @register="registerMachineModal" @select="onMachineSelect" />
|
||||
<MesXslMixerPsCompileSelectModal @register="registerIssueNumberModal" @select="onIssueNumberSelect" />
|
||||
<MesXslMixingMaterialSelectModal @register="registerMixingMaterialModal" @select="onMixingMaterialSelect" />
|
||||
<MesXslMixingSpecStepHistorySelectModal @register="registerHistoryStepModal" @select="onHistoryStepSelect" />
|
||||
<MesXslMixingSpecSelectModal @register="registerSpecPickerModal" @edit="onSpecPickerEdit" @referenceAdd="onSpecPickerReferenceAdd" />
|
||||
<MesXslEquipmentLedgerSelectModal :key="nestedPickerKey" @register="registerMachineModal" @select="onMachineSelect" />
|
||||
<MesXslMixerPsCompileSelectModal :key="nestedPickerKey" @register="registerIssueNumberModal" @select="onIssueNumberSelect" />
|
||||
<MesXslMixingMaterialSelectModal :key="nestedPickerKey" @register="registerMixingMaterialModal" @select="onMixingMaterialSelect" />
|
||||
<MesXslMixingSpecStepHistorySelectModal :key="nestedPickerKey" @register="registerHistoryStepModal" @select="onHistoryStepSelect" />
|
||||
<MesXslMixingSpecSelectModal :key="nestedPickerKey" @register="registerSpecPickerModal" @edit="onSpecPickerEdit" @referenceAdd="onSpecPickerReferenceAdd" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref, unref } from 'vue';
|
||||
import { computed, nextTick, reactive, ref, unref } from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { BasicModal, useModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
@@ -560,6 +560,9 @@ const showFooter = ref(true);
|
||||
const isHistoryView = ref(false);
|
||||
const historyVersion = ref('');
|
||||
const mixerPsCompilePickerId = ref('');
|
||||
//update-begin---author:cursor ---date:20260615 for:【XSLMES-20260615-A04】主弹窗关闭后重建嵌套选择弹窗,避免 useModal 状态残留-----------
|
||||
const nestedPickerKey = ref(0);
|
||||
//update-end---author:cursor ---date:20260615 for:【XSLMES-20260615-A04】主弹窗关闭后重建嵌套选择弹窗,避免 useModal 状态残留-----------
|
||||
//update-begin---author:cursor ---date:20260522 for:【XSLMES-20260522-A34】混合步骤动作/组合下拉选项-----------
|
||||
const mixerActionOptions = ref<{ title: string; value: string }[]>([]);
|
||||
const mixerConditionOptions = ref<{ title: string; value: string }[]>([]);
|
||||
@@ -985,7 +988,7 @@ const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useF
|
||||
});
|
||||
|
||||
//update-begin---author:cursor ---date:20260522 for:【XSLMES-20260522-A33】混炼示方主表选择弹窗-----------
|
||||
const [registerMachineModal, { openModal: openMachineModalInner, closeModal: closeMachineModal }] = useModal();
|
||||
const [registerMachineModal, { openModal: openMachineModalInner, closeModal: closeMachineModal, setModalProps: setMachineModalProps }] = useModal();
|
||||
const [registerIssueNumberModal, { openModal: openIssueNumberModalInner, closeModal: closeIssueNumberModal }] = useModal();
|
||||
const [registerMixingMaterialModal, { openModal: openMixingMaterialModalInner, closeModal: closeMixingMaterialModal, setModalProps: setMixingMaterialModalProps }] = useModal();
|
||||
//update-begin---author:cursor ---date:20260526 for:【XSLMES-20260526-A58】参照历史混合步骤选择弹窗-----------
|
||||
@@ -1004,14 +1007,42 @@ function closeNestedPickers() {
|
||||
closeSpecPickerModal();
|
||||
materialPickerRow.value = null;
|
||||
}
|
||||
|
||||
//update-begin---author:cursor ---date:20260615 for:【XSLMES-20260615-A03】主弹窗关闭时重置表单并清理嵌套弹窗状态-----------
|
||||
function handleMainModalClose() {
|
||||
closeNestedPickers();
|
||||
resetSheetForm();
|
||||
isUpdate.value = false;
|
||||
isHistoryView.value = false;
|
||||
historyVersion.value = '';
|
||||
showFooter.value = true;
|
||||
mixerActionOptions.value = [];
|
||||
mixerConditionOptions.value = [];
|
||||
nestedPickerKey.value += 1;
|
||||
}
|
||||
|
||||
//update-end---author:cursor ---date:20260615 for:【XSLMES-20260615-A03】主弹窗关闭时重置表单并清理嵌套弹窗状态-----------
|
||||
//update-end---author:cursor ---date:20260525 for:【XSLMES-20260525-A52】关闭混炼示方弹窗时同步关闭嵌套选料弹窗-----------
|
||||
|
||||
function openMachinePicker() {
|
||||
//update-begin---author:cursor ---date:20260615 for:【XSLMES-20260615-A01】规格有数据时机台点击走示方选择弹窗-----------
|
||||
const machinePickerPlaceholder = computed(() =>
|
||||
sheetForm.specName ? '请点击选择混炼示方' : '请点击选择设备台账',
|
||||
);
|
||||
|
||||
async function openMachinePicker() {
|
||||
if (!showFooter.value) {
|
||||
return;
|
||||
}
|
||||
openMachineModalInner(true, { equipmentLedgerId: sheetForm.machineId || '' });
|
||||
if (sheetForm.specName) {
|
||||
openSpecPicker();
|
||||
return;
|
||||
}
|
||||
setMachineModalProps({ zIndex: 1500 });
|
||||
openMachineModalInner(true, { equipmentLedgerId: sheetForm.machineId || '', ts: Date.now() });
|
||||
await nextTick();
|
||||
setMachineModalProps({ zIndex: 1500, open: true });
|
||||
}
|
||||
//update-end---author:cursor ---date:20260615 for:【XSLMES-20260615-A01】规格有数据时机台点击走示方选择弹窗-----------
|
||||
|
||||
async function onMachineSelect(payload: Recordable | null) {
|
||||
sheetForm.machineId = payload?.equipmentLedgerId || '';
|
||||
@@ -1037,7 +1068,11 @@ function openSpecPicker() {
|
||||
return;
|
||||
}
|
||||
setSpecPickerModalProps({ zIndex: 1500 });
|
||||
openSpecPickerModalInner(true, { machineId: sheetForm.machineId || '' });
|
||||
openSpecPickerModalInner(true, {
|
||||
machineId: sheetForm.machineId || '',
|
||||
machineName: sheetForm.machineName || '',
|
||||
ts: Date.now(),
|
||||
});
|
||||
}
|
||||
|
||||
async function applyMixingSpecPageData(row: Recordable, mode: 'edit' | 'referenceAdd') {
|
||||
@@ -1141,6 +1176,7 @@ function openHistoryStepPicker() {
|
||||
setHistoryStepModalProps({ zIndex: 1500 });
|
||||
openHistoryStepModalInner(true, {
|
||||
machineId: sheetForm.machineId || '',
|
||||
machineName: sheetForm.machineName || '',
|
||||
excludeSpecId: sheetForm.id || '',
|
||||
});
|
||||
}
|
||||
@@ -1238,6 +1274,15 @@ function addDownStepRow() {
|
||||
}
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
//update-begin---author:cursor ---date:20260615 for:【XSLMES-20260615-A03】打开主弹窗时先同步清理嵌套弹窗与表单残留-----------
|
||||
isHistoryView.value = !!data?.isHistoryView;
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
showFooter.value = !!data?.showFooter && !isHistoryView.value;
|
||||
closeNestedPickers();
|
||||
resetSheetForm();
|
||||
historyVersion.value = '';
|
||||
await nextTick();
|
||||
//update-end---author:cursor ---date:20260615 for:【XSLMES-20260615-A03】打开主弹窗时先同步清理嵌套弹窗与表单残留-----------
|
||||
await resetFields();
|
||||
resetSheetForm();
|
||||
materialData.value = [];
|
||||
@@ -1248,10 +1293,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
|
||||
downStepData.value = [];
|
||||
tcuData.value = ensureTcuDefaultRows([]);
|
||||
await loadMixerStepOptions('');
|
||||
isHistoryView.value = !!data?.isHistoryView;
|
||||
historyVersion.value = data?.historyVersion || '';
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
showFooter.value = !!data?.showFooter && !isHistoryView.value;
|
||||
await setProps({ disabled: !showFooter.value });
|
||||
setModalProps({ showOkBtn: showFooter.value, showCancelBtn: showFooter.value, confirmLoading: false });
|
||||
if (isHistoryView.value && data?.historyId) {
|
||||
@@ -1346,6 +1388,7 @@ async function handleSubmit() {
|
||||
try {
|
||||
await saveOrUpdate(payload, unref(isUpdate));
|
||||
createMessage.success(unref(isUpdate) ? '编辑成功' : '新增成功');
|
||||
handleMainModalClose();
|
||||
closeModal();
|
||||
emit('success');
|
||||
} finally {
|
||||
|
||||
@@ -94,10 +94,24 @@
|
||||
clickToRowSelect: true,
|
||||
});
|
||||
|
||||
async function loadMachineOptions() {
|
||||
async function loadMachineOptions(preset?: { machineId?: string; machineName?: string }) {
|
||||
machineLoading.value = true;
|
||||
try {
|
||||
const optionMap = new Map<string, { label: string; value: string }>();
|
||||
//update-begin---author:cursor ---date:20260615 for:【XSLMES-20260615-A02】机台下拉合并设备台账并补全预选机台名称-----------
|
||||
const eqRaw = await equipmentList({ pageNo: 1, pageSize: 500 });
|
||||
const eqPage = (eqRaw as Recordable)?.records != null ? eqRaw : (eqRaw as Recordable)?.result;
|
||||
const eqRecords = ((eqPage?.records || eqPage || []) as Recordable[]).filter(Boolean);
|
||||
eqRecords.forEach((row) => {
|
||||
if (!row?.id) {
|
||||
return;
|
||||
}
|
||||
const value = String(row.id);
|
||||
optionMap.set(value, {
|
||||
value,
|
||||
label: row.equipmentName || row.equipmentCode || value,
|
||||
});
|
||||
});
|
||||
const raw = await mixingSpecList({ pageNo: 1, pageSize: 500 });
|
||||
const page = (raw as Recordable)?.records != null ? raw : (raw as Recordable)?.result;
|
||||
const specRecords = ((page?.records || page || []) as Recordable[]).filter(Boolean);
|
||||
@@ -108,24 +122,15 @@
|
||||
const value = String(row.machineId);
|
||||
optionMap.set(value, {
|
||||
value,
|
||||
label: row.machineName || value,
|
||||
label: row.machineName || optionMap.get(value)?.label || value,
|
||||
});
|
||||
});
|
||||
if (!optionMap.size) {
|
||||
const eqRaw = await equipmentList({ pageNo: 1, pageSize: 500 });
|
||||
const eqPage = (eqRaw as Recordable)?.records != null ? eqRaw : (eqRaw as Recordable)?.result;
|
||||
const eqRecords = ((eqPage?.records || eqPage || []) as Recordable[]).filter(Boolean);
|
||||
eqRecords.forEach((row) => {
|
||||
if (!row?.id) {
|
||||
return;
|
||||
}
|
||||
const value = String(row.id);
|
||||
optionMap.set(value, {
|
||||
value,
|
||||
label: row.equipmentName || row.equipmentCode || value,
|
||||
});
|
||||
});
|
||||
const presetId = preset?.machineId ? String(preset.machineId) : '';
|
||||
if (presetId) {
|
||||
const presetLabel = preset?.machineName || optionMap.get(presetId)?.label || presetId;
|
||||
optionMap.set(presetId, { value: presetId, label: presetLabel });
|
||||
}
|
||||
//update-end---author:cursor ---date:20260615 for:【XSLMES-20260615-A02】机台下拉合并设备台账并补全预选机台名称-----------
|
||||
machineOptions.value = Array.from(optionMap.values()).sort((a, b) =>
|
||||
a.label.localeCompare(b.label, 'zh-CN'),
|
||||
);
|
||||
@@ -202,7 +207,10 @@
|
||||
referenceLoading.value = false;
|
||||
clearSelectedRowKeys?.();
|
||||
setModalProps({ confirmLoading: false });
|
||||
await loadMachineOptions();
|
||||
await loadMachineOptions({
|
||||
machineId: data?.machineId || undefined,
|
||||
machineName: data?.machineName || undefined,
|
||||
});
|
||||
reload();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -93,10 +93,24 @@
|
||||
clickToRowSelect: true,
|
||||
});
|
||||
|
||||
async function loadMachineOptions() {
|
||||
async function loadMachineOptions(preset?: { machineId?: string; machineName?: string }) {
|
||||
machineLoading.value = true;
|
||||
try {
|
||||
const optionMap = new Map<string, { label: string; value: string }>();
|
||||
//update-begin---author:cursor ---date:20260615 for:【XSLMES-20260615-A02】机台下拉合并设备台账并补全预选机台名称-----------
|
||||
const eqRaw = await equipmentList({ pageNo: 1, pageSize: 500 });
|
||||
const eqPage = (eqRaw as Recordable)?.records != null ? eqRaw : (eqRaw as Recordable)?.result;
|
||||
const eqRecords = ((eqPage?.records || eqPage || []) as Recordable[]).filter(Boolean);
|
||||
eqRecords.forEach((row) => {
|
||||
if (!row?.id) {
|
||||
return;
|
||||
}
|
||||
const value = String(row.id);
|
||||
optionMap.set(value, {
|
||||
value,
|
||||
label: row.equipmentName || row.equipmentCode || value,
|
||||
});
|
||||
});
|
||||
const raw = await mixingSpecList({ pageNo: 1, pageSize: 500 });
|
||||
const page = (raw as Recordable)?.records != null ? raw : (raw as Recordable)?.result;
|
||||
const specRecords = ((page?.records || page || []) as Recordable[]).filter(Boolean);
|
||||
@@ -107,24 +121,15 @@
|
||||
const value = String(row.machineId);
|
||||
optionMap.set(value, {
|
||||
value,
|
||||
label: row.machineName || value,
|
||||
label: row.machineName || optionMap.get(value)?.label || value,
|
||||
});
|
||||
});
|
||||
if (!optionMap.size) {
|
||||
const eqRaw = await equipmentList({ pageNo: 1, pageSize: 500 });
|
||||
const eqPage = (eqRaw as Recordable)?.records != null ? eqRaw : (eqRaw as Recordable)?.result;
|
||||
const eqRecords = ((eqPage?.records || eqPage || []) as Recordable[]).filter(Boolean);
|
||||
eqRecords.forEach((row) => {
|
||||
if (!row?.id) {
|
||||
return;
|
||||
}
|
||||
const value = String(row.id);
|
||||
optionMap.set(value, {
|
||||
value,
|
||||
label: row.equipmentName || row.equipmentCode || value,
|
||||
});
|
||||
});
|
||||
const presetId = preset?.machineId ? String(preset.machineId) : '';
|
||||
if (presetId) {
|
||||
const presetLabel = preset?.machineName || optionMap.get(presetId)?.label || presetId;
|
||||
optionMap.set(presetId, { value: presetId, label: presetLabel });
|
||||
}
|
||||
//update-end---author:cursor ---date:20260615 for:【XSLMES-20260615-A02】机台下拉合并设备台账并补全预选机台名称-----------
|
||||
machineOptions.value = Array.from(optionMap.values()).sort((a, b) =>
|
||||
a.label.localeCompare(b.label, 'zh-CN'),
|
||||
);
|
||||
@@ -196,7 +201,10 @@
|
||||
selectedRow.value = null;
|
||||
clearSelectedRowKeys?.();
|
||||
setModalProps({ confirmLoading: false });
|
||||
await loadMachineOptions();
|
||||
await loadMachineOptions({
|
||||
machineId: data?.machineId || undefined,
|
||||
machineName: data?.machineName || undefined,
|
||||
});
|
||||
reload();
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user