From 7cf708376b46741dbee847e59c64a8e11ad088c5 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 15 十月 2025 13:27:58 +0800
Subject: [PATCH] fix: 绞线的钢芯领用取消关联

---
 src/pages/production/twist/receive/steelCore/form.vue |   89 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 84 insertions(+), 5 deletions(-)

diff --git a/src/pages/production/twist/receive/steelCore/form.vue b/src/pages/production/twist/receive/steelCore/form.vue
index d0e4c2c..c4185ec 100644
--- a/src/pages/production/twist/receive/steelCore/form.vue
+++ b/src/pages/production/twist/receive/steelCore/form.vue
@@ -26,10 +26,18 @@
         placeholder="璇疯緭鍏ラ暱搴�"
       />
       <wd-input
-        v-model="model.manufacturers"
+        v-model="model.weight"
+        label="閲嶉噺"
+        label-width="100px"
+        prop="weight"
+        clearable
+        placeholder="璇疯緭鍏ラ噸閲�"
+      />
+      <wd-input
+        v-model="model.supplier"
         label="鍘傚"
         label-width="100px"
-        prop="manufacturers"
+        prop="supplier"
         clearable
         placeholder="璇疯緭鍏ュ巶瀹�"
       />
@@ -44,15 +52,19 @@
 
 const emits = defineEmits(["refresh"]);
 const paramsId = ref();
+const editId = ref(); // 缂栬緫鏃剁殑ID
+const allListData = ref<any[]>([]); // 瀛樺偍瀹屾暣鍒楄〃鏁版嵁
 const toast = useToast();
 const { form: model } = useFormData({
   model: undefined, // 瑙勬牸鍨嬪彿
   monofilamentNumber: undefined, // 鏍峰搧缂栧彿
   amount: undefined, // 鏁伴噺
-  manufacturers: undefined, // 鍘傚
+  weight: undefined, // 閲嶉噺
+  supplier: undefined, // 鍘傚
   type: "閽㈣姱",
 });
 
+// 鏂板鎻愪氦
 const submit = async () => {
   const { code } = await TwistApi.addStrandedWireDish([
     {
@@ -65,6 +77,73 @@
     emits("refresh");
     return true;
   }
+  return false;
+};
+
+// 缂栬緫鎻愪氦锛堜篃璧版柊澧炴帴鍙o紝鎻愪氦鏁翠釜鍒楄〃锛�
+const submitEdit = async () => {
+  if (!editId.value) {
+    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 updatedItem = {
+        ...item, // 鍏堜繚鐣欏師鏈夌殑鎵�鏈夋暟鎹�
+        model: model.model,
+        monofilamentNumber: model.monofilamentNumber,
+        amount: model.amount,
+        weight: model.weight,
+        supplier: model.supplier,
+        type: model.type,
+      };
+      console.log("submitEdit - 鏇存柊鍚庣殑椤�:", updatedItem);
+      return updatedItem;
+    }
+    return item;
+  });
+
+  console.log("submitEdit - 鎻愪氦鐨勫畬鏁村垪琛�:", updatedList);
+
+  // 鎻愪氦鏁翠釜鍒楄〃
+  const { code } = await TwistApi.addStrandedWireDish(updatedList);
+
+  if (code == 200) {
+    toast.success("鏇存柊鎴愬姛");
+    return true;
+  }
+  return false;
+};
+
+// 璁剧疆琛ㄥ崟鏁版嵁锛堢敤浜庣紪杈戞椂鍥炴樉锛�
+const setFormData = (list: any[], currentEditId: number) => {
+  // 瀹夊叏妫�鏌ワ細纭繚list鏄暟缁�
+  if (!Array.isArray(list)) {
+    console.error("setFormData: list 鍙傛暟涓嶆槸鏁扮粍", list);
+    return;
+  }
+
+  // 瀛樺偍瀹屾暣鍒楄〃鏁版嵁
+  allListData.value = list;
+  editId.value = currentEditId;
+
+  // 鎵惧埌褰撳墠缂栬緫椤瑰苟鍥炴樉鍒拌〃鍗�
+  const currentItem = list.find((item) => item.id === currentEditId);
+  if (currentItem) {
+    model.model = currentItem.model;
+    model.monofilamentNumber = currentItem.monofilamentNumber;
+    model.amount = currentItem.amount;
+    model.weight = currentItem.weight;
+    model.supplier = currentItem.supplier;
+    model.type = currentItem.type || "閽㈣姱";
+  }
 };
 
 onLoad((options: any) => {
@@ -73,12 +152,12 @@
 
 defineExpose({
   submit,
+  submitEdit,
+  setFormData,
 });
 </script>
 
 <style lang="scss" scoped>
-.form_box {
-}
 .submit_btn {
   position: absolute;
   bottom: 0;

--
Gitblit v1.9.3