优化混炼示方新增时选择机台逻辑

This commit is contained in:
geht
2026-06-15 15:19:47 +08:00
parent ece8e590e4
commit 33b969fc70
3 changed files with 108 additions and 49 deletions

View File

@@ -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>