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 |  249 ++++++++++++++++++++++++++++++-------------------
 1 files changed, 152 insertions(+), 97 deletions(-)

diff --git a/src/views/client/client/AddClientManageDialog.vue b/src/views/client/client/AddClientManageDialog.vue
index c262d24..5c15e02 100644
--- a/src/views/client/client/AddClientManageDialog.vue
+++ b/src/views/client/client/AddClientManageDialog.vue
@@ -5,6 +5,8 @@
       :visible.sync="editConfig.visible"
       :width="dialogWidth"
       :before-close="handleClose"
+      append-to-body
+      custom-class="iframe-dialog"
     >
       <el-form
         ref="form"
@@ -25,8 +27,8 @@
                 <el-form-item label="瀹㈡埛鍚嶇О" prop="name">
                   <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-house" title="宸ュ晢鏌ヨ"></i></div> -->
+                    <!-- <div class="common-select-btn"><i class="el-icon-search" title="鏌ラ噸"></i></div> -->
                   </div>
                 </el-form-item>
               </el-col>
@@ -47,7 +49,7 @@
                       <el-option v-for="item in clientStatusOptions" :key="item.id" :label="item.name" :value="item.id">
                       </el-option>
                     </el-select>
-                    <div class="common-select-btn"><i class="el-icon-setting"></i></div>
+                    <!-- <div class="common-select-btn"><i class="el-icon-setting"></i></div> -->
                   </div>
                 </el-form-item>
               </el-col>
@@ -76,7 +78,7 @@
                       <el-option v-for="item in clientTypeOptions" :key="item.id" :label="item.name" :value="item.id">
                       </el-option>
                     </el-select>
-                    <div class="common-select-btn"><i class="el-icon-setting"></i></div>
+                    <!-- <div class="common-select-btn"><i class="el-icon-setting"></i></div> -->
                   </div>
                 </el-form-item>
               </el-col>
@@ -92,9 +94,9 @@
                       <el-option v-for="item in clientSourceOptions" :key="item.id" :label="item.name" :value="item.id">
                       </el-option>
                     </el-select>
-                    <div class="common-select-btn" @click="editDropdownBox">
+                    <!-- <div class="common-select-btn" @click="editDropdownBox">
                       <i class="el-icon-setting"></i>
-                    </div>
+                    </div> -->
                   </div>
                 </el-form-item>
               </el-col>
@@ -128,7 +130,8 @@
                 <el-form-item label="涓嬫鍥炶鏃ユ湡" prop="next_visit_time">
                   <el-date-picker
                     v-model="editConfig.infomation.next_visit_time"
-                    type="datetime"
+                    value-format="yyyy-MM-dd"
+                    type="date"
                     placeholder="閫夋嫨鏃ユ湡"
                   >
                   </el-date-picker>
@@ -138,7 +141,8 @@
                 <el-form-item label="鏈�鏅氭湇鍔″埌鏈熸棩" prop="latest_service_time">
                   <el-date-picker
                     v-model="editConfig.infomation.latest_service_time"
-                    type="datetime"
+                    value-format="yyyy-MM-dd"
+                    type="date"
                     placeholder="閫夋嫨鏃ユ湡"
                   >
                   </el-date-picker>
@@ -198,7 +202,7 @@
                       <el-option v-for="item in industryOptions" :key="item.id" :label="item.name" :value="item.id">
                       </el-option>
                     </el-select>
-                    <div class="common-select-btn"><i class="el-icon-setting"></i></div>
+                    <!-- <div class="common-select-btn"><i class="el-icon-setting"></i></div> -->
                   </div>
                 </el-form-item>
               </el-col>
@@ -211,6 +215,7 @@
                 <el-form-item label="娉ㄥ唽鏃堕棿" prop="registration_time">
                   <el-date-picker
                     v-model="editConfig.infomation.registration_time"
+                    value-format="yyyy-MM-dd HH:mm:ss"
                     type="datetime"
                     placeholder="閫夋嫨鏃ユ湡鏃堕棿"
                   >
@@ -234,7 +239,7 @@
                       >
                       </el-option>
                     </el-select>
-                    <div class="common-select-btn"><i class="el-icon-setting"></i></div>
+                    <!-- <div class="common-select-btn"><i class="el-icon-setting"></i></div> -->
                   </div>
                 </el-form-item>
               </el-col>
@@ -255,7 +260,7 @@
                       >
                       </el-option>
                     </el-select>
-                    <div class="common-select-btn"><i class="el-icon-setting"></i></div>
+                    <!-- <div class="common-select-btn"><i class="el-icon-setting"></i></div> -->
                   </div>
                 </el-form-item>
               </el-col>
@@ -276,7 +281,7 @@
                       >
                       </el-option>
                     </el-select>
-                    <div class="common-select-btn"><i class="el-icon-setting"></i></div>
+                    <!-- <div class="common-select-btn"><i class="el-icon-setting"></i></div> -->
                   </div>
                 </el-form-item>
               </el-col>
@@ -314,11 +319,12 @@
                       placeholder="璇烽�夋嫨"
                       class="common-select-sel"
                       size="mini"
+                      disabled
                     >
                       <el-option v-for="item in countryOptions" :key="item.id" :label="item.name" :value="item.id">
                       </el-option>
                     </el-select>
-                    <div class="common-select-btn"><i class="el-icon-setting"></i></div>
+                    <!-- <div class="common-select-btn"><i class="el-icon-setting"></i></div> -->
                   </div>
                 </el-form-item>
               </el-col>
@@ -330,11 +336,12 @@
                       placeholder="璇烽�夋嫨"
                       class="common-select-sel"
                       size="mini"
+                      @change="selProvinceChange"
                     >
                       <el-option v-for="item in provinceOptions" :key="item.id" :label="item.name" :value="item.id">
                       </el-option>
                     </el-select>
-                    <div class="common-select-btn"><i class="el-icon-setting"></i></div>
+                    <!-- <div class="common-select-btn"><i class="el-icon-setting"></i></div> -->
                   </div>
                 </el-form-item>
               </el-col>
@@ -346,15 +353,16 @@
                       placeholder="璇烽�夋嫨"
                       class="common-select-sel"
                       size="mini"
+                      :disabled="cityOptions.length <= 0 ? true : false"
                     >
                       <el-option v-for="item in cityOptions" :key="item.id" :label="item.name" :value="item.id">
                       </el-option>
                     </el-select>
-                    <div class="common-select-btn"><i class="el-icon-setting"></i></div>
+                    <!-- <div class="common-select-btn"><i class="el-icon-setting"></i></div> -->
                   </div>
                 </el-form-item>
               </el-col>
-              <el-col :span="12">
+              <!-- <el-col :span="12">
                 <el-form-item label="鍖哄煙" prop="region_id">
                   <div class="common-select">
                     <el-select
@@ -369,7 +377,7 @@
                     <div class="common-select-btn"><i class="el-icon-setting"></i></div>
                   </div>
                 </el-form-item>
-              </el-col>
+              </el-col> -->
               <el-col :span="24">
                 <el-form-item label="璇︾粏鍦板潃" prop="detail_address">
                   <el-input
@@ -475,14 +483,15 @@
       <div slot="footer" class="dialog-footer">
         <!-- <el-button type="primary" size="small" @click="editConfig.visible = false">淇濆苟鎻愪氦瀹℃壒</el-button> -->
         <el-button type="primary" size="small" @click="saveClick('form')">淇濆瓨</el-button>
-        <el-button size="small" @click="editConfig.visible = false">鍙栨秷</el-button>
+        <el-button size="small" @click="handleClose">鍙栨秷</el-button>
       </div>
     </el-dialog>
   </div>
 </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",
   props: {
@@ -492,6 +501,7 @@
         return {
           visible: false,
           title: "鏂板缓",
+          isSalesOpportunity: false,
           infomation: {}
         }
       }
@@ -508,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" }],
@@ -518,6 +534,14 @@
           {
             pattern: /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/,
             message: "璇疯緭鍏ユ纭殑鎵嬫満鍙�",
+            trigger: "blur"
+          }
+        ],
+        contact_email: [
+          { required: false, message: "", trigger: "blur" },
+          {
+            pattern: /^[a-zA-Z0-9_\\.]+@[a-zA-Z0-9-]+[\\.a-zA-Z]+$/,
+            message: "璇疯緭鍏ユ纭殑閭鏍煎紡",
             trigger: "blur"
           }
         ]
@@ -532,21 +556,29 @@
       registerCapitalOptions: [], // 娉ㄥ唽璧勯噾
       enterpriseNatureOptions: [], // 鍏徃鎬ц川
       enterpriseScaleOptions: [], // 瀹㈡埛瑙勬ā
-      countryOptions: [], // 鍥藉
+      countryOptions: [{ id: 1, name: "涓浗" }], // 鍥藉
       provinceOptions: [], // 鐪佷唤
       cityOptions: [], // 鍩庡競
       regionOptions: [], // 鍖哄煙
-      approvalWorkflowOptions: [] // 瀹℃壒娴佺▼
+      approvalWorkflowOptions: [], // 瀹℃壒娴佺▼
+      clientName: this.editClientManageConfig.infomation.name
     }
   },
   created() {
+    if (this.editConfig.title !== "鏂板缓" && this.editConfig.infomation.province_id !== 0) {
+      this.getCityList(this.editConfig.infomation.province_id, "edit")
+    }
     this.getCommonData()
   },
   methods: {
     getCommonData() {
+      this.editConfig.infomation.country_id = 1
+      this.editConfig.infomation.province_id =
+        this.editConfig.infomation.province_id === 0 ? "" : this.editConfig.infomation.province_id
+      this.editConfig.infomation.city_id =
+        this.editConfig.infomation.city_id === 0 ? "" : this.editConfig.infomation.city_id
       getAllData()
         .then((res) => {
-          console.log(res)
           this.memberOptions = res.data.member
           this.clientSourceOptions = res.data.client_origin
           this.clientStatusOptions = res.data.client_status
@@ -556,9 +588,8 @@
           this.registerCapitalOptions = res.data.registered_capital
           this.enterpriseNatureOptions = res.data.enterprise_nature
           this.enterpriseScaleOptions = res.data.enterprise_scale
-          this.countryOptions = res.data.country
+          // this.countryOptions = res.data.country
           this.provinceOptions = res.data.province
-          this.cityOptions = res.data.city
           this.regionOptions = res.data.region
         })
         .catch((err) => {
@@ -567,6 +598,9 @@
     },
     handleClose() {
       this.editConfig.visible = false
+      if (this.editConfig.title === "鏂板缓" && this.editConfig.infomation.sales_leads_id) {
+        this.$parent.handleClose()
+      }
     },
     // 淇濆瓨
     saveClick(formName) {
@@ -576,37 +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"
-                  })
+            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({
-                    message: "缂栬緫鎴愬姛",
-                    type: "success"
-                  })
-                  this.$parent.getData()
-                }
-              })
-              .catch((err) => {
-                console.log(err)
-              })
+            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")
@@ -619,7 +645,7 @@
       let params = {
         id: this.editConfig.title === "鏂板缓" ? 0 : data.id,
         business_scope: data.business_scope,
-        city_id: 0,
+        city_id: data.city_id || 0,
         client_level_id: data.client_level_id || 0,
         client_origin_id: data.client_origin_id || 0,
         client_status_id: data.client_status_id || 0,
@@ -651,13 +677,15 @@
         name: data.name || "",
         next_visit_time: data.next_visit_time || "",
         number: data.number || "",
-        province_id: 0,
+        province_id: data.province_id || 0,
         region_id: 0,
         registered_capital_id: data.registered_capital_id || 0,
         registration_time: data.registration_time || "",
         remark: data.remark || "",
         representative: data.representative || "",
-        service_member_id: data.service_member_id || 0
+        service_member_id: data.service_member_id || 0,
+        sales_leads_id: data.sales_leads_id || 0,
+        contact_id: data.contact_id || 0
       }
       return params
     },
@@ -670,6 +698,31 @@
       console.log("aaa")
       this.editDropdownConfig.editVisible = true
       this.editDropdownConfig.title = "瀹㈡埛鏉ユ簮"
+    },
+    // 閫夋嫨鐪佷唤
+    selProvinceChange(val) {
+      this.getCityList(val, "sel")
+    },
+    async getCityList(val, value) {
+      await getCityList({ province_id: val }).then((res) => {
+        console.log(res)
+        if (res.data.code === 200) {
+          this.cityOptions = res.data.data.list
+          if (value === "sel") {
+            this.editConfig.infomation.city_id = ""
+          }
+        }
+      })
+    },
+    // 鏌ラ噸
+    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("瀹㈡埛鍚嶇О閲嶅"))
+          }
+        })
+      }
     }
   }
 }
@@ -677,54 +730,56 @@
 
 <!-- Add "scoped" attribute to limit CSS to this component only -->
 <style lang="scss" scoped>
-.add-client-manage {
-  .basic-info {
-    .basic-info-title {
-      background-color: #f4f8fe;
-      padding-left: 10px;
-      font-size: 15px;
-      font-weight: bold;
-      color: #666;
-      height: 42px;
-      line-height: 42px;
-    }
-    .basic-info-view {
-      margin-top: 10px;
-      padding-right: 40px;
-      .custom-name,
-      .common-select {
+::v-deep {
+  .iframe-dialog .el-dialog__body {
+    .basic-info {
+      .basic-info-title {
+        background-color: #f4f8fe;
+        padding-left: 10px;
+        font-size: 15px;
+        font-weight: bold;
+        color: #666;
+        height: 42px;
+        line-height: 42px;
+      }
+      .basic-info-view {
+        margin-top: 10px;
+        padding-right: 40px;
+        .custom-name,
+        .common-select {
+          display: flex;
+          .common-select-btn {
+            margin-left: 5px;
+            font-size: 18px;
+            cursor: pointer;
+          }
+        }
+        .common-select {
+          .common-select-sel {
+            width: 270px;
+          }
+        }
+      }
+      .annex-view {
         display: flex;
-        .common-select-btn {
-          margin-left: 5px;
-          font-size: 18px;
-          cursor: pointer;
-        }
-      }
-      .common-select {
-        .common-select-sel {
-          width: 270px;
+        color: #6166d3;
+        .setFormat {
+          margin-left: 10px;
         }
       }
     }
-    .annex-view {
+    .unflod-collapse {
       display: flex;
+      height: 30px;
+      justify-content: center;
+      align-items: center;
       color: #6166d3;
-      .setFormat {
-        margin-left: 10px;
-      }
     }
-  }
-  .unflod-collapse {
-    display: flex;
-    height: 30px;
-    justify-content: center;
-    align-items: center;
-    color: #6166d3;
-  }
-  .dialog-footer {
-    background-color: #f5f5f5;
-    height: 55px;
-    line-height: 55px;
+    .dialog-footer {
+      background-color: #f5f5f5;
+      height: 55px;
+      line-height: 55px;
+    }
   }
 }
 </style>

--
Gitblit v1.8.0