From c5d68d050a5fb84f2e60a34409809fb0b08466c5 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期三, 28 二月 2024 15:22:13 +0800
Subject: [PATCH] 跟进记录模块 如果客户名称有值查询对应的销售机会列表,如果没有查询所有销售机会的逻辑

---
 src/views/service/serviceContract/AddServiceContractDialog.vue |   93 ++++++++++++++++++++++++----------------------
 1 files changed, 49 insertions(+), 44 deletions(-)

diff --git a/src/views/service/serviceContract/AddServiceContractDialog.vue b/src/views/service/serviceContract/AddServiceContractDialog.vue
index 40e96db..4aed079 100644
--- a/src/views/service/serviceContract/AddServiceContractDialog.vue
+++ b/src/views/service/serviceContract/AddServiceContractDialog.vue
@@ -615,46 +615,52 @@
       this.$refs[formName].validate((valid) => {
         if (valid) {
           console.log(this.editConfig.infomation)
-          for (let i = 0; i < this.tableData.length; i++) {
-            if (this.tableData[i].name.length === 0) {
-              this.isNoProduct = true
-              break
-            } else {
-              this.isNoProduct = false
-            }
-          }
-          if (this.isNoProduct) {
-            this.$message.error("浜у搧鍚嶇О涓嶈兘涓虹┖")
+          // for (let i = 0; i < this.tableData.length; i++) {
+          //   if (this.tableData[i].name.length === 0) {
+          //     this.isNoProduct = true
+          //     break
+          //   } else {
+          //     this.isNoProduct = false
+          //   }
+          // }
+          // if (this.isNoProduct) {
+          //   this.$message.error("浜у搧鍚嶇О涓嶈兘涓虹┖")
+          // } else {
+          const params = this.saveParams()
+          if (this.editConfig.title === "鏂板缓") {
+            getAddServiceContract(params).then((res) => {
+              console.log(res)
+              this.editConfig.visible = false
+              if (res.code === 200) {
+                this.$message.success("娣诲姞鎴愬姛")
+                this.$parent.getData()
+              }
+            })
           } else {
-            const params = this.saveParams()
-            if (this.editConfig.title === "鏂板缓") {
-              getAddServiceContract(params).then((res) => {
-                console.log(res)
-                this.editConfig.visible = false
-                if (res.code === 200) {
-                  this.$message.success("娣诲姞鎴愬姛")
-                  this.$parent.getData()
-                }
-              })
-            } else {
-              getUpdateServiceContract(params).then((res) => {
-                console.log(res)
-                this.editConfig.visible = false
-                if (res.code === 200) {
-                  this.$message.success("缂栬緫鎴愬姛")
-                  this.$parent.getData()
-                }
-              })
-            }
+            getUpdateServiceContract(params).then((res) => {
+              console.log(res)
+              this.editConfig.visible = false
+              if (res.code === 200) {
+                this.$message.success("缂栬緫鎴愬姛")
+                this.$parent.getData()
+              }
+            })
           }
-        } else {
-          console.log("error submit")
-          return false
         }
+        // } else {
+        //   console.log("error submit")
+        //   return false
+        // }
       })
     },
     saveParams() {
       let data = this.editConfig.infomation
+      let products = []
+      this.tableData.map((item) => {
+        if (item.number.length > 0) {
+          products.push(item)
+        }
+      })
       let params = {
         id: this.editConfig.title === "鏂板缓" ? 0 : data.id,
         clientId: this.clientId || 0,
@@ -662,7 +668,7 @@
         endTime: data.endTime || "",
         memberId: data.memberId || 0,
         number: data.number || "",
-        products: this.tableData,
+        products: products,
         quotationId: this.quotationId || 0,
         remark: data.remark || "",
         saleChanceId: this.saleChanceId || 0,
@@ -840,19 +846,18 @@
       // this.showSummary.show = true
     },
     // 鏂板鏂瑰紡淇敼
-    getSelectArray(val) {
-      // if (val.length > 0) {
-      //   val.map((item, index) => {
-      //     item.productId = this.tableData.length + index + 1
-      //   })
-      // }
-      console.log(this.tableData, "ddddaaaqqq")
+    getSelectArray(val, index) {
       if (this.tableData.length == 1 && this.tableData[0].number.length == 0) {
-        console.log("ssss")
         this.tableData = []
       }
-      this.tableData = this.tableData.concat(val)
-      console.log(this.tableData, "55555ddddaaaqqq")
+      if (index < this.tableData.length) {
+        this.tableData.splice(index, 1)
+        val.map((item, ind) => {
+          this.tableData.splice(index + ind, 0, item)
+        })
+      } else {
+        this.tableData = this.tableData.concat(val)
+      }
       this.productTableList.tableData = this.tableData
       this.showSummary.show = true
     },

--
Gitblit v1.8.0