From 504e00da9a9898ac419e97f93fc66cc7c7c6f620 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期三, 28 二月 2024 14:30:25 +0800
Subject: [PATCH] 服务合同-去掉产品为空的判断增加保存时去掉未选择产品的对象

---
 src/views/service/serviceContract/AddServiceContractDialog.vue |   74 ++++++++++++++++++++-----------------
 1 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/src/views/service/serviceContract/AddServiceContractDialog.vue b/src/views/service/serviceContract/AddServiceContractDialog.vue
index 7bc8e08..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,

--
Gitblit v1.8.0