From 78c565e37520fad100693c4e298e30e7c916d1bb Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期二, 28 十月 2025 16:21:40 +0800
Subject: [PATCH] fix: 领用二维码异常提示,原材料自检重构

---
 src/pages/production/twist/receive/steelCore/form.vue |   56 +++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/src/pages/production/twist/receive/steelCore/form.vue b/src/pages/production/twist/receive/steelCore/form.vue
index c4185ec..616e48f 100644
--- a/src/pages/production/twist/receive/steelCore/form.vue
+++ b/src/pages/production/twist/receive/steelCore/form.vue
@@ -50,6 +50,17 @@
 import TwistApi from "@/api/product/twist";
 import { useToast } from "wot-design-uni";
 
+const props = defineProps({
+  mode: {
+    type: String,
+    default: "add",
+  },
+  editData: {
+    type: Object,
+    default: null,
+  },
+});
+
 const emits = defineEmits(["refresh"]);
 const paramsId = ref();
 const editId = ref(); // 缂栬緫鏃剁殑ID
@@ -81,19 +92,18 @@
 };
 
 // 缂栬緫鎻愪氦锛堜篃璧版柊澧炴帴鍙o紝鎻愪氦鏁翠釜鍒楄〃锛�
-const submitEdit = async () => {
-  if (!editId.value) {
+const submitEdit = async (list?: any[], id?: number) => {
+  const currentList = list || allListData.value;
+  const currentId = id || editId.value;
+
+  if (!currentId) {
     toast.error("缂哄皯璁板綍ID");
     return false;
   }
 
-  console.log("submitEdit - 缂栬緫鍓嶇殑鍒楄〃:", allListData.value);
-  console.log("submitEdit - 褰撳墠琛ㄥ崟鏁版嵁:", model);
-  console.log("submitEdit - 缂栬緫鐨処D:", editId.value);
-
   // 鏇存柊鍒楄〃涓搴旂殑鏁版嵁椤�
-  const updatedList = allListData.value.map((item) => {
-    if (item.id === editId.value) {
+  const updatedList = currentList.map((item) => {
+    if (item.id === currentId) {
       // 淇濈暀鍘熸湁鏁版嵁锛岀劧鍚庢洿鏂颁慨鏀圭殑瀛楁
       const updatedItem = {
         ...item, // 鍏堜繚鐣欏師鏈夌殑鎵�鏈夋暟鎹�
@@ -104,13 +114,10 @@
         supplier: model.supplier,
         type: model.type,
       };
-      console.log("submitEdit - 鏇存柊鍚庣殑椤�:", updatedItem);
       return updatedItem;
     }
     return item;
   });
-
-  console.log("submitEdit - 鎻愪氦鐨勫畬鏁村垪琛�:", updatedList);
 
   // 鎻愪氦鏁翠釜鍒楄〃
   const { code } = await TwistApi.addStrandedWireDish(updatedList);
@@ -146,6 +153,32 @@
   }
 };
 
+// 鐩戝惉缂栬緫鏁版嵁鍙樺寲锛岃嚜鍔ㄥ洖鏄�
+watch(
+  () => props.editData,
+  (newData) => {
+    if (newData && props.mode === "edit") {
+      model.model = newData.model || "";
+      model.monofilamentNumber = newData.monofilamentNumber || "";
+      model.amount = newData.amount || "";
+      model.weight = newData.weight || "";
+      model.supplier = newData.supplier || "";
+      model.type = newData.type || "閽㈣姱";
+    }
+  },
+  { immediate: true, deep: true }
+);
+
+// 閲嶇疆琛ㄥ崟鏁版嵁
+const resetFormData = () => {
+  model.model = undefined;
+  model.monofilamentNumber = undefined;
+  model.amount = undefined;
+  model.weight = undefined;
+  model.supplier = undefined;
+  model.type = "閽㈣姱";
+};
+
 onLoad((options: any) => {
   paramsId.value = options.id;
 });
@@ -154,6 +187,7 @@
   submit,
   submitEdit,
   setFormData,
+  resetFormData,
 });
 </script>
 

--
Gitblit v1.9.3