From a08c9f3200771297065583e2bc53bbc721e853d7 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期一, 13 四月 2026 15:29:07 +0800
Subject: [PATCH] 优化车间选择逻辑,改为根据产品类型固定传值设置车间,并增加缺失编码提示
---
pages/wareHouse/nuclearScale/createwriteoffform.vue | 64 +++++++++++---------------------
1 files changed, 22 insertions(+), 42 deletions(-)
diff --git a/pages/wareHouse/nuclearScale/createwriteoffform.vue b/pages/wareHouse/nuclearScale/createwriteoffform.vue
index 9bdfdfd..8611bad 100644
--- a/pages/wareHouse/nuclearScale/createwriteoffform.vue
+++ b/pages/wareHouse/nuclearScale/createwriteoffform.vue
@@ -713,68 +713,48 @@
}
},
/**
- * 鎸変骇鍝佺被鍨嬭嚜鍔ㄨ缃敓浜ц溅闂达紙鍗曢��/澶氶�夊潎鐢辩被鍨嬪喅瀹氾紝鐢ㄦ埛涓嶅彲鏀癸級
+ * 鎸変骇鍝佺被鍨嬭嚜鍔ㄨ缃敓浜ц溅闂达紙鍥哄畾浼犲�硷紝鐢ㄦ埛涓嶅彲鏀癸級
*/
syncWorkshopFromProductType() {
const pt = this.form.productType;
- const list = this.workshopList;
if (!pt) {
this.form.workshop = "";
return;
}
- if (!list.length) {
- this.form.workshop = "";
- return;
- }
if (pt === "TG01") {
- const w =
- list.find((x) => x.label === "閾滄潌") ||
- list.find((x) => x.label.includes("閾滄潌"));
- if (w) {
- this.form.workshop = w.value;
- } else {
- this.form.workshop = "";
- uni.showToast({ title: "瀛楀吀涓湭鎵惧埌閾滄潌杞﹂棿", icon: "none" });
- }
+ this.setWorkshopByValues(["CT01", "ZF01"]);
return;
}
if (pt === "DT01") {
- this.setWorkshopByLabels(["瀵间綋杞﹂棿", "瀵间綋杞﹂棿2"]);
+ this.setWorkshopByValues(["CD01", "CY01", "ZF01"]);
return;
}
if (pt === "DT02") {
- this.setWorkshopByLabels(["瀵间綋杞﹂棿", "瀵间綋杞﹂棿2", "鐩村彂"]);
+ this.setWorkshopByValues(["CD01", "CY01", "ZF01"]);
}
},
- setWorkshopByLabels(requiredLabels) {
- const list = this.workshopList;
- const picked = [];
- const missing = [];
- requiredLabels.forEach((lbl) => {
- let w = list.find((x) => x.label === lbl);
- if (!w && lbl === "鐩村彂") {
- w = list.find((x) => x.label.includes("鐩村彂"));
- }
- if (w) picked.push(w);
- else missing.push(lbl);
- });
- if (missing.length) {
- this.form.workshop = "";
- uni.showToast({
- title: `杞﹂棿瀛楀吀缂哄皯锛�${missing.join("銆�")}`,
- icon: "none",
- });
- return;
- }
+ setWorkshopByValues(requiredValues) {
const uniq = [];
const seen = new Set();
- picked.forEach((w) => {
- if (!seen.has(w.value)) {
- seen.add(w.value);
- uniq.push(w);
+ requiredValues.forEach((value) => {
+ if (!seen.has(value)) {
+ seen.add(value);
+ uniq.push(value);
}
});
- this.form.workshop = uniq.map((x) => x.value).join(",");
+ this.form.workshop = uniq.join(",");
+
+ // 鑻ュ瓧鍏稿凡鍔犺浇鍒欏仛涓�娆″瓨鍦ㄦ�ф彁绀猴紝閬垮厤閰嶇疆涓嶄竴鑷存椂鏃犳劅鐭�
+ if (this.workshopList.length) {
+ const dictValues = new Set(this.workshopList.map((x) => String(x.value)));
+ const missing = uniq.filter((v) => !dictValues.has(String(v)));
+ if (missing.length) {
+ uni.showToast({
+ title: `杞﹂棿瀛楀吀缂哄皯缂栫爜锛�${missing.join("銆�")}`,
+ icon: "none",
+ });
+ }
+ }
},
// 鍙哥鍛�
weighmanChange(e, storage) {
--
Gitblit v1.9.3