From 27c416bf9742574411401fb67203ee9669e57c8a Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 26 十一月 2025 14:20:02 +0800
Subject: [PATCH] fix: 绞线报工的盘具领用和芯线领用的厂家字段使用字典维护做下拉框

---
 src/pages/production/twist/receive/plate/form.vue |   77 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/src/pages/production/twist/receive/plate/form.vue b/src/pages/production/twist/receive/plate/form.vue
index 032e5b0..1d4c19e 100644
--- a/src/pages/production/twist/receive/plate/form.vue
+++ b/src/pages/production/twist/receive/plate/form.vue
@@ -27,13 +27,25 @@
         clearable
         placeholder="璇疯緭鍏ユ暟閲�"
       />
-      <wd-input
+      <wd-picker
+        v-model="model.unit"
+        :columns="unitOptions"
+        label="鍗曚綅"
+        label-width="100px"
+        prop="unit"
+        placeholder="璇烽�夋嫨鍗曚綅"
+        clearable
+        @confirm="handleUnitChange"
+      />
+      <wd-picker
         v-model="model.supplier"
+        :columns="supplierOptions"
         label="鍘傚"
         label-width="100px"
         prop="supplier"
+        placeholder="璇烽�夋嫨鍘傚"
         clearable
-        placeholder="璇疯緭鍏ュ巶瀹�"
+        @confirm="handleSupplierChange"
       />
     </wd-cell-group>
     <wd-toast />
@@ -41,6 +53,7 @@
 </template>
 
 <script setup lang="ts">
+import { onMounted, watch } from "vue";
 import useFormData from "@/hooks/useFormData";
 import TwistApi from "@/api/product/twist";
 import ManageApi from "@/api/product/manage";
@@ -64,6 +77,7 @@
   diskMaterial: undefined, // 鐩樺叿绫诲瀷
   model: undefined, // 灏哄
   amount: undefined, // 鏁伴噺
+  unit: "鍙�", // 鍗曚綅锛岄粯璁ゅ�间负"鍙�"
   supplier: undefined,
   type: "鐩樺叿",
 });
@@ -75,6 +89,12 @@
 // 鐩樺叿绫诲瀷瀛楀吀鏁版嵁
 const diskMaterialOptions = ref<Array<{ label: string; value: string }>>([]);
 const diskMaterialValue = ref("");
+
+// 鍗曚綅瀛楀吀鏁版嵁
+const unitOptions = ref<Array<{ label: string; value: string }>>([]);
+
+// 鍘傚瀛楀吀鏁版嵁
+const supplierOptions = ref<Array<{ label: string; value: string }>>([]);
 
 // 鍔犺浇鐩樺叿绫诲瀷瀛楀吀鏁版嵁
 const loadDiskMaterialDict = async () => {
@@ -91,9 +111,56 @@
   }
 };
 
+// 鍔犺浇鍗曚綅瀛楀吀鏁版嵁
+const loadUnitDict = async () => {
+  try {
+    const res = await ManageApi.dictAPI("technical_weight_unit");
+    if (res.data && Array.isArray(res.data)) {
+      unitOptions.value = res.data.map((item: any) => ({
+        label: item.dictLabel || "",
+        value: item.dictValue || "",
+      }));
+      // 璁剧疆榛樿鍊间负"鍙�"锛屽鏋滃瓧鍏镐腑鏈�"鍙�"閫夐」
+      const defaultOption = unitOptions.value.find(
+        (item) => item.label === "鍙�" || item.value === "鍙�"
+      );
+      if (defaultOption && !model.unit) {
+        model.unit = defaultOption.value;
+      }
+    }
+  } catch (error) {
+    // 鍔犺浇瀛楀吀澶辫触锛岄潤榛樺鐞�
+  }
+};
+
+// 鍔犺浇鍘傚瀛楀吀鏁版嵁
+const loadSupplierDict = async () => {
+  try {
+    const res = await ManageApi.dictAPI("factory");
+    if (res.data && Array.isArray(res.data)) {
+      supplierOptions.value = res.data.map((item: any) => ({
+        label: item.dictLabel || "",
+        value: item.dictValue || "",
+      }));
+    }
+  } catch (error) {
+    // 鍔犺浇瀛楀吀澶辫触锛岄潤榛樺鐞�
+  }
+};
+
 // 澶勭悊鐩樺叿绫诲瀷閫夋嫨
 const handleDiskMaterialChange = (val: any) => {
   model.diskMaterial = val.value;
+};
+
+// 澶勭悊鍗曚綅閫夋嫨
+const handleUnitChange = (val: any) => {
+  model.unit = val.value;
+};
+
+// 澶勭悊鍘傚閫夋嫨
+const handleSupplierChange = (val: any) => {
+  model.supplier = val.value;
 };
 
 // 鐩戝惉 model.diskMaterial 鍙樺寲锛屽悓姝ラ�夋嫨鍣ㄦ樉绀�
@@ -139,6 +206,7 @@
         diskMaterial: model.diskMaterial,
         model: model.model,
         amount: model.amount,
+        unit: model.unit,
         supplier: model.supplier,
         type: model.type,
       };
@@ -175,6 +243,7 @@
     model.diskMaterial = currentItem.diskMaterial;
     model.model = currentItem.model;
     model.amount = currentItem.amount;
+    model.unit = currentItem.unit || "鍙�";
     model.supplier = currentItem.supplier;
     model.type = currentItem.type || "鐩樺叿";
     // 璁剧疆鐩樺叿绫诲瀷鐨勫洖鏄惧��
@@ -188,6 +257,8 @@
 
 onMounted(async () => {
   await loadDiskMaterialDict();
+  await loadUnitDict();
+  await loadSupplierDict();
 });
 
 // 鐩戝惉缂栬緫鏁版嵁鍙樺寲锛岃嚜鍔ㄥ洖鏄�
@@ -198,6 +269,7 @@
       model.diskMaterial = newData.diskMaterial || "";
       model.model = newData.model || "";
       model.amount = newData.amount || "";
+      model.unit = newData.unit || "鍙�";
       model.supplier = newData.supplier || "";
       model.type = newData.type || "鐩樺叿";
       diskMaterialValue.value = newData.diskMaterial || "";
@@ -211,6 +283,7 @@
   model.diskMaterial = undefined;
   model.model = undefined;
   model.amount = undefined;
+  model.unit = "鍙�";
   model.supplier = undefined;
   model.type = "鐩樺叿";
   diskMaterialValue.value = "";

--
Gitblit v1.9.3