From 46ed69e3b72658140a40127f4bae16bef9a02d56 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期一, 21 八月 2023 11:23:34 +0800
Subject: [PATCH] bug修复

---
 src/views/client/client/AddClientManageDialog.vue |   84 ++++++++++++++++++++++--------------------
 1 files changed, 44 insertions(+), 40 deletions(-)

diff --git a/src/views/client/client/AddClientManageDialog.vue b/src/views/client/client/AddClientManageDialog.vue
index 628f4c3..5c15e02 100644
--- a/src/views/client/client/AddClientManageDialog.vue
+++ b/src/views/client/client/AddClientManageDialog.vue
@@ -28,7 +28,7 @@
                   <div class="custom-name">
                     <el-input v-model="editConfig.infomation.name"></el-input>
                     <!-- <div class="common-select-btn"><i class="el-icon-house" title="宸ュ晢鏌ヨ"></i></div> -->
-                    <div class="common-select-btn"><i class="el-icon-search" title="鏌ラ噸"></i></div>
+                    <!-- <div class="common-select-btn"><i class="el-icon-search" title="鏌ラ噸"></i></div> -->
                   </div>
                 </el-form-item>
               </el-col>
@@ -490,7 +490,7 @@
 </template>
 
 <script>
-import { getAllData, getAddClient, getUpdateClient } from "@/api/client/client"
+import { getAllData, getAddClient, getUpdateClient, checkNameClient } from "@/api/client/client"
 import { getCityList } from "@/api/common/address"
 export default {
   name: "AddClientManageDialog",
@@ -518,7 +518,13 @@
       dialogWidth: "80%",
       editConfig: this.editClientManageConfig,
       rules: {
-        name: [{ required: true, message: "璇疯緭鍏ュ鎴峰悕绉�", trigger: "blur" }],
+        name: [
+          { required: true, message: "璇疯緭鍏ュ鎴峰悕绉�", trigger: "blur" },
+          {
+            validator: this.checkNameClient,
+            trigger: "blur"
+          }
+        ],
         client_status_id: [{ required: true, message: "璇烽�夋嫨瀹㈡埛鐘舵��", trigger: "change" }],
         member_id: [{ required: true, message: "璇烽�夋嫨閿�鍞礋璐d汉", trigger: "change" }],
         approvalOpinion: [{ required: true, message: "璇疯緭鍏ュ鎵规剰瑙�", trigger: "blur" }],
@@ -554,7 +560,8 @@
       provinceOptions: [], // 鐪佷唤
       cityOptions: [], // 鍩庡競
       regionOptions: [], // 鍖哄煙
-      approvalWorkflowOptions: [] // 瀹℃壒娴佺▼
+      approvalWorkflowOptions: [], // 瀹℃壒娴佺▼
+      clientName: this.editClientManageConfig.infomation.name
     }
   },
   created() {
@@ -603,43 +610,29 @@
           const params = this.saveParams()
           console.log(params)
           if (this.editConfig.title === "鏂板缓") {
-            getAddClient(params)
-              .then((res) => {
-                console.log(res)
-                this.editConfig.visible = false
-                if (res.code === 200) {
-                  this.$message({
-                    message: "娣诲姞鎴愬姛",
-                    type: "success"
-                  })
-                  if (this.editConfig.isSalesOpportunity) {
-                    this.$emit("salesOpportunityClick", this.editConfig.infomation)
-                  } else if (this.editConfig.title === "鏂板缓" && this.editConfig.infomation.sales_leads_id) {
-                    this.$parent.handleClose()
-                  } else {
-                    this.$parent.getData()
-                  }
-                }
-              })
-              .catch((err) => {
-                console.log(err)
-              })
-          } else {
-            getUpdateClient(params)
-              .then((res) => {
-                console.log(res)
-                this.editConfig.visible = false
-                if (res.code === 200) {
-                  this.$message({
-                    message: "缂栬緫鎴愬姛",
-                    type: "success"
-                  })
+            getAddClient(params).then((res) => {
+              console.log(res)
+              this.editConfig.visible = false
+              if (res.code === 200) {
+                this.$message.success("娣诲姞鎴愬姛")
+                if (this.editConfig.isSalesOpportunity) {
+                  this.$emit("salesOpportunityClick", this.editConfig.infomation)
+                } else if (this.editConfig.title === "鏂板缓" && this.editConfig.infomation.sales_leads_id) {
+                  this.$parent.handleClose()
+                } else {
                   this.$parent.getData()
                 }
-              })
-              .catch((err) => {
-                console.log(err)
-              })
+              }
+            })
+          } else {
+            getUpdateClient(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")
@@ -691,7 +684,8 @@
         remark: data.remark || "",
         representative: data.representative || "",
         service_member_id: data.service_member_id || 0,
-        sales_leads_id: data.sales_leads_id || 0
+        sales_leads_id: data.sales_leads_id || 0,
+        contact_id: data.contact_id || 0
       }
       return params
     },
@@ -719,6 +713,16 @@
           }
         }
       })
+    },
+    // 鏌ラ噸
+    async checkNameClient(rule, value, callback) {
+      if (this.editConfig.title === "鏂板缓" || this.clientName !== this.editConfig.infomation.name) {
+        await checkNameClient({ name: value }).then((res) => {
+          if (res.data.code === 700001) {
+            return callback(new Error("瀹㈡埛鍚嶇О閲嶅"))
+          }
+        })
+      }
     }
   }
 }

--
Gitblit v1.8.0