优化混炼示方新增时选择机台逻辑
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user