From 03cfba0f636b42417070fc8caef44bcdd792a085 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期二, 07 五月 2024 17:34:37 +0800
Subject: [PATCH] 概述 出库模块 编辑的时候循环处理对应产品调用接口获取在库数量的逻辑处理

---
 src/views/productManage/product/components/bomDialog.vue |   59 +++++++++++++++++++++++++++--------------------------------
 1 files changed, 27 insertions(+), 32 deletions(-)

diff --git a/src/views/productManage/product/components/bomDialog.vue b/src/views/productManage/product/components/bomDialog.vue
index 3e75b28..9d34367 100644
--- a/src/views/productManage/product/components/bomDialog.vue
+++ b/src/views/productManage/product/components/bomDialog.vue
@@ -6,7 +6,7 @@
       缂栬緫涓嬫媺妗�>鍗曚綅
     </div>
     <div class="drawerContent">
-      <el-table v-if="isTableShow" :header-cell-style="{ background: '#f1f3f8', color: '#000009' }" ref="multipleTable"
+      <el-table v-if="isTableShow" :header-cell-style="{ background: '#f1f3f8', color: '#000009' }" ref="unitTable"
         :data="thatEditRow.BomTableData" tooltip-effect="dark" height="440">
         <el-table-column prop="unit" label="鍗曚綅">
           <template slot-scope="scope">
@@ -20,7 +20,7 @@
         </el-table-column>
         <el-table-column label="鎿嶄綔" width="100">
           <template slot-scope="scope">
-            <i class="el-icon-delete" id="iconStyle" @click="handleDelete(scope.row.id)"></i>
+            <i class="el-icon-delete cursor_pointer" id="iconStyle" @click="handleDelete(scope.row.id,scope)"></i>
           </template>
         </el-table-column>
       </el-table>
@@ -32,7 +32,8 @@
         style="margin-left: 16px; color: #fff; background-color: #ee790c"
         >鏂板</el-button
       > -->
-      <el-button @click="shutdown">鍙栨秷</el-button><el-button type="primary" @click="handleConfirmSave()"
+      <el-button @click="shutdown">鍙栨秷</el-button>
+      <el-button type="primary" @click="handleConfirmSave()"
         style="margin-left: 16px; color: #fff; background-color: #2a78fb">纭畾</el-button>
     </div>
   </el-dialog>
@@ -52,6 +53,7 @@
       default: () => {
         return {
           editDialogVisible: false,
+          BomTableData:[]
         };
       },
     },
@@ -64,7 +66,9 @@
       thatEditRow:this.editRow,
       isTableShow: true,
       form: {},
-      // BomTableData: JSON.parse(this.thatEditRow.BomTableData),
+      BomTableData:[],
+      // BomTableData: this.editRow.BomTableData,
+      // BomTableData: JSON.parse(this.editRow.BomTableData),
       // BomTableData: [{ id: 303, createdAt: "2024-02-05 18:02:47", updatedAt: "2024-02-05 18:02:47",name: "kg", isDefault: false }],
       work: 1,
       flag: "add",
@@ -101,29 +105,28 @@
     };
   },
   watch: {
-    // editDialogVisible(newVal) {
-    //   console.log(newVal,"鐪嬬湅val")
-    //   if (newVal) {
-    //     this.BomTableData = this.workList;
-    //   }
-    // },
-    // workList(newVal) {
-    //   console.log(newVal)
-    //   this.BomTableData = this.workList;
-    // },
   },
   created() {
-    console.log(this.thatEditRow,"thatEditRow")
   },
-  mounted() { },
+  mounted() { 
+  },
   methods: {
     handleAdd() {
+      this.BomTableData=this.thatEditRow.BomTableData
       this.BomTableData.push({ name: "", isDefault: false });
+      this.$nextTick(()=>{
+        setTimeout(() => {
+          this.$refs.unitTable.bodyWrapper.scrollTop=this.$refs.unitTable.bodyWrapper.scrollHeight
+          }, 500);
+      })
     },
-    handleDelete(id) {
-      this.BomTableData = this.BomTableData.filter((i) => {
-        return i.id != id;
-      });
+    handleDelete(id,scope) {
+      if (this.thatEditRow.BomTableData.length === 1) {
+        this.$message.warning("鑷冲皯淇濈暀涓�鏉℃暟鎹�");
+        return;
+      }
+      this.thatEditRow.BomTableData.splice(scope.$index,1)
+      this.BomTableData=this.thatEditRow.BomTableData
     },
     async getCodeStandardList() {
       const res = await getCodeStandardList(this.obj);
@@ -148,19 +151,11 @@
       console.log(this.codenumberList.replace(/,/g, ""));
     },
     switchChange(scope, val) {
-      let arr = [];
+      this.BomTableData=this.thatEditRow.BomTableData
       for (let i in this.BomTableData) {
-        if (this.BomTableData[i].isDefault) {
-          arr.push(i);
-        }
+        this.thatEditRow.BomTableData[i].isDefault=false
       }
-      if (arr.length > 1) {
-        this.$message({
-          message: "鍙兘璁句竴涓负榛樿",
-          type: "warning",
-        });
-        scope.row.isDefault = !val;
-      }
+      scope.row.isDefault = val;
     },
     handleConfirmSave() {
       let arr = [];
@@ -186,7 +181,7 @@
         let fn = this.flag == "set" ? updateMaterial : addMaterial;
         const res = await fn(this.form);
         this.shutdown();
-        this.$sucessSet("sucessSet");
+        // this.$sucessSet("sucessSet");
         if (res.code == 200) {
           this.$message({
             message: this.flag == "set" ? "淇敼鎴愬姛锛�" : "娣诲姞鎴愬姛锛�",

--
Gitblit v1.8.0