From dc128ec95cab469003693b74d95c86447c4d7b6f Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期一, 27 四月 2026 15:01:59 +0800
Subject: [PATCH] 编辑回显同步产品规格
---
src/views/productionManagement/productionProcess/Edit.vue | 33 +++++++++++++++++++++++++++++++--
1 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/src/views/productionManagement/productionProcess/Edit.vue b/src/views/productionManagement/productionProcess/Edit.vue
index f12e5a5..b3ccddc 100644
--- a/src/views/productionManagement/productionProcess/Edit.vue
+++ b/src/views/productionManagement/productionProcess/Edit.vue
@@ -186,7 +186,7 @@
id: newRecord.id,
name: newRecord.name || '',
productId: newRecord.productId,
- productModelId: newRecord.productModelId,
+ productModelId: getRecordProductModelId(newRecord),
no: newRecord.no || '',
type: newRecord.type,
remark: newRecord.remark || '',
@@ -205,7 +205,7 @@
id: props.record.id,
name: props.record.name || '',
productId: props.record.productId,
- productModelId: props.record.productModelId,
+ productModelId: getRecordProductModelId(props.record),
no: props.record.no || '',
type: props.record.type,
remark: props.record.remark || '',
@@ -214,6 +214,7 @@
plannerName: props.record.plannerName || '',
isQuality: props.record.isQuality,
};
+ getModelOptions(formState.value.productId);
}
});
@@ -271,6 +272,32 @@
return undefined;
};
+function findModelIdByName(models, modelName) {
+ if (!modelName) {
+ return undefined;
+ }
+ const matched = (models || []).find(item => String(item.model) === String(modelName));
+ return matched?.id;
+}
+
+function getRecordProductModelId(record) {
+ if (!record) {
+ return undefined;
+ }
+ return record.productModelId ?? record.modelId ?? record.specificationModelId ?? undefined;
+}
+
+function syncProductModelIdFromModelName() {
+ if (formState.value.productModelId || modelOptions.value.length === 0) {
+ return;
+ }
+ const modelName = props.record?.productModel || props.record?.model || props.record?.specificationModel || "";
+ const matchedId = findModelIdByName(modelOptions.value, modelName);
+ if (matchedId !== undefined) {
+ formState.value.productModelId = matchedId;
+ }
+}
+
const getProductCategoryOptions = async () => {
try {
const res = await productTreeList();
@@ -280,6 +307,7 @@
formState.value.productId = findNodeIdByLabel(productCategoryOptions.value, formState.value.name);
}
await getModelOptions(formState.value.productId);
+ syncProductModelIdFromModelName();
} catch (e) {
productCategoryOptions.value = [];
}
@@ -298,6 +326,7 @@
});
const records = res?.records || res?.data?.records || [];
modelOptions.value = records;
+ syncProductModelIdFromModelName();
} catch (e) {
modelOptions.value = [];
}
--
Gitblit v1.9.3