From b811e2fa4cdcb5949047faa78aa9299aec1d2f67 Mon Sep 17 00:00:00 2001
From: zuozhengqing <a13193816592@163.com>
Date: 星期三, 27 三月 2024 15:08:45 +0800
Subject: [PATCH] 确认采购单接口换位post请求,产品列表字段替换

---
 src/views/other/commonDialog/EditDropdownDialog.vue |   74 +++++++++++++++++++++++++++++--------
 1 files changed, 58 insertions(+), 16 deletions(-)

diff --git a/src/views/other/commonDialog/EditDropdownDialog.vue b/src/views/other/commonDialog/EditDropdownDialog.vue
index 4691fa8..e67830f 100644
--- a/src/views/other/commonDialog/EditDropdownDialog.vue
+++ b/src/views/other/commonDialog/EditDropdownDialog.vue
@@ -55,7 +55,7 @@
 </template>
 
 <script>
-import { getSupplierTypeList, updateSupplierType } from "@/api/supplierManage/supplier"
+import { getSupplierTypeList, updateSupplierType, updateIndustry, getIndustryList } from "@/api/supplierManage/supplier"
 export default {
   name: "EditDropdownDialog",
   props: {
@@ -80,7 +80,8 @@
     return {
       dialogWidth: "20%",
       editConfig: this.editDropdownConfig,
-      tableData: []
+      tableData: [],
+      isName: false
     }
   },
   created() {
@@ -90,6 +91,8 @@
     setList() {
       if (this.editConfig.title === "渚涘簲鍟嗙被鍨�") {
         this.getSupplierTypeList()
+      } else if (this.editConfig.title === "鎵�灞炶涓�") {
+        this.getIndustryList()
       }
     },
     // 渚涘簲鍟嗙被鍨�
@@ -98,13 +101,20 @@
         page: 1,
         pageSize: 100
       }).then((res) => {
-        console.log("dsss")
         console.log(res.data)
-        this.tableData = res.data.data.list
+        this.tableData = res.data.list
       })
     },
     // 鎵�灞炶涓�
-    async getIndustryList() {},
+    async getIndustryList() {
+      await getIndustryList({
+        page: 1,
+        pageSize: 100
+      }).then((res) => {
+        console.log(res.data)
+        this.tableData = res.data.list
+      })
+    },
     handleClose() {
       this.editConfig.editVisible = false
     },
@@ -151,22 +161,54 @@
     // 鏂板涓嬫媺妗�
     addDropdown() {
       this.tableData.push({
-        name: "",
-        id: 0
+        ID: 0,
+        name: ""
       })
+    },
+    // 鍒ゆ柇娣诲姞name鏄惁涓虹┖
+    determineNameEmpty(data) {
+      for (let i = 0; i < data.length; i++) {
+        if (data[i].name.length === 0) {
+          this.isName = true
+          break
+        } else {
+          this.isName = false
+        }
+      }
     },
     async saveClick() {
       console.log(this.tableData)
-      if (this.editConfig.title === "渚涘簲鍟嗙被鍨�") {
-        updateSupplierType({
-          supplierTypes: this.tableData
-        }).then((res) => {
-          console.log(res)
-          if (res.code === 200) {
-            this.$message.success("缂栬緫鎴愬姛")
-            this.$parent.getData()
-          }
+      this.determineNameEmpty(this.tableData)
+      if (this.isName) {
+        this.$message.error("鍚嶇О涓嶈兘涓虹┖")
+      } else {
+        this.tableData.map((ite) => {
+          ite.ID = 0
+          return { ...ite }
         })
+        if (this.editConfig.title === "渚涘簲鍟嗙被鍨�") {
+          updateSupplierType({
+            supplierTypes: this.tableData
+          }).then((res) => {
+            console.log(res)
+            if (res.code === 200) {
+              this.$message.success("缂栬緫鎴愬姛")
+              this.$parent.getSupplierTypeList()
+              this.handleClose()
+            }
+          })
+        } else if (this.editConfig.title === "鎵�灞炶涓�") {
+          updateIndustry({
+            industries: this.tableData
+          }).then((res) => {
+            console.log(res)
+            if (res.code === 200) {
+              this.$message.success("缂栬緫鎴愬姛")
+              this.$parent.getIndustryList()
+              this.handleClose()
+            }
+          })
+        }
       }
     }
   }

--
Gitblit v1.8.0