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 |  321 +++++++++++++++++++++++++++++-----------------------
 1 files changed, 178 insertions(+), 143 deletions(-)

diff --git a/src/views/client/client/AddClientManageDialog.vue b/src/views/client/client/AddClientManageDialog.vue
index 53bb234..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"
@@ -23,10 +25,10 @@
             <el-row>
               <el-col :span="12">
                 <el-form-item label="瀹㈡埛鍚嶇О" prop="name">
-                  <div class="client-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>
@@ -126,7 +128,12 @@
               </el-col> -->
               <el-col :span="12">
                 <el-form-item label="涓嬫鍥炶鏃ユ湡" prop="next_visit_time">
-                  <el-date-picker v-model="editConfig.infomation.next_visit_time" type="date" placeholder="閫夋嫨鏃ユ湡">
+                  <el-date-picker
+                    v-model="editConfig.infomation.next_visit_time"
+                    value-format="yyyy-MM-dd"
+                    type="date"
+                    placeholder="閫夋嫨鏃ユ湡"
+                  >
                   </el-date-picker>
                 </el-form-item>
               </el-col>
@@ -134,6 +141,7 @@
                 <el-form-item label="鏈�鏅氭湇鍔″埌鏈熸棩" prop="latest_service_time">
                   <el-date-picker
                     v-model="editConfig.infomation.latest_service_time"
+                    value-format="yyyy-MM-dd"
                     type="date"
                     placeholder="閫夋嫨鏃ユ湡"
                   >
@@ -153,12 +161,17 @@
               </el-col>
               <el-col :span="12">
                 <el-form-item label="鑱旂郴浜烘墜鏈�" prop="contact_phone">
-                  <el-input v-model="editConfig.infomation.contact_phone"></el-input>
+                  <el-input
+                    v-model="editConfig.infomation.contact_phone"
+                    maxlength="11"
+                    show-word-limit
+                    oninput="value=value.replace(/[^\d]/g,'')"
+                  ></el-input>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
-                <el-form-item label="鑱旂郴浜鸿亴鍔�" prop="contact_duties">
-                  <el-input v-model="editConfig.infomation.contact_duties"></el-input>
+                <el-form-item label="鑱旂郴浜鸿亴鍔�" prop="position">
+                  <el-input v-model="editConfig.infomation.position"></el-input>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
@@ -189,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>
@@ -202,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="閫夋嫨鏃ユ湡鏃堕棿"
                   >
@@ -225,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>
@@ -246,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>
@@ -267,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>
@@ -305,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>
@@ -321,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>
@@ -337,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
@@ -360,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
@@ -466,15 +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 { dateFormat } from "@/common/config/index"
+import { getAllData, getAddClient, getUpdateClient, checkNameClient } from "@/api/client/client"
+import { getCityList } from "@/api/common/address"
 export default {
   name: "AddClientManageDialog",
   props: {
@@ -484,36 +501,8 @@
         return {
           visible: false,
           title: "鏂板缓",
-          infomation: {
-            name: "",
-            number: "AC6521",
-            client_status_id: "",
-            member_id: "5",
-            client_type_id: "",
-            clientSource: "",
-            client_level_id: "",
-            service_member_id: "",
-            next_visit_time: "",
-            latest_service_time: "",
-            contact_name: "",
-            contact_phone: "",
-            contact_duties: "",
-            contact_wechat: "1",
-            contact_email: "",
-            industry_id: "",
-            representative: "",
-            registration_time: "",
-            registered_capital_id: "",
-            enterprise_nature_id: "",
-            enterprise_scale_id: "",
-            business_scope: "",
-            country_id: "",
-            province_id: "",
-            city_id: "",
-            region_id: "",
-            detail_address: "",
-            remark: ""
-          }
+          isSalesOpportunity: false,
+          infomation: {}
         }
       }
     }
@@ -529,10 +518,33 @@
       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" }]
+        approvalOpinion: [{ required: true, message: "璇疯緭鍏ュ鎵规剰瑙�", trigger: "blur" }],
+        contact_phone: [
+          { required: false, message: "", trigger: "blur" },
+          { len: 11, message: "闀垮害鍦�11涓瓧绗�", trigger: "blur" },
+          {
+            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"
+          }
+        ]
       },
       memberOptions: [],
       clientStatusOptions: [], // 瀹㈡埛鐘舵��
@@ -544,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
@@ -568,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) => {
@@ -579,6 +598,9 @@
     },
     handleClose() {
       this.editConfig.visible = false
+      if (this.editConfig.title === "鏂板缓" && this.editConfig.infomation.sales_leads_id) {
+        this.$parent.handleClose()
+      }
     },
     // 淇濆瓨
     saveClick(formName) {
@@ -588,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")
@@ -631,24 +645,24 @@
       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,
         client_type_id: data.client_type_id || 0,
         contact: {
-          birthday: "1970-01-01 08:00:00",
+          birthday: "",
           city_id: 0,
           client_id: 0,
           country_id: 0,
-          desc: "string",
+          desc: "",
           email: data.contact_email || "",
           is_first: true,
           member_id: 0,
           name: data.contact_name || "",
-          number: "string",
+          number: "",
           phone: data.contact_phone || "",
-          position: data.contact_duties || "",
+          position: data.position || "",
           province_id: 0,
           region_id: 0,
           wechat: data.contact_wechat || ""
@@ -658,18 +672,20 @@
         enterprise_nature_id: data.enterprise_nature_id || 0,
         enterprise_scale_id: data.enterprise_scale_id || 0,
         industry_id: data.industry_id || 0,
-        latest_service_time: dateFormat("YYYY-mm-dd HH:MM:ss", data.latest_service_time) || "",
+        latest_service_time: data.latest_service_time || "",
         member_id: parseInt(data.member_id) || 0,
         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
     },
@@ -682,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("瀹㈡埛鍚嶇О閲嶅"))
+          }
+        })
+      }
     }
   }
 }
@@ -689,62 +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;
-      .client-name {
-        display: flex;
-        .common-select-btn {
-          margin-left: 5px;
-          font-size: 18px;
+::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;
+          }
         }
       }
-      .common-select {
+      .annex-view {
         display: flex;
-        .common-select-sel {
-          width: 270px;
-        }
-        .common-select-btn {
-          margin-left: 5px;
-          font-size: 16px;
-          cursor: pointer;
+        color: #6166d3;
+        .setFormat {
+          margin-left: 10px;
         }
       }
     }
-    // .address-view {
-    //   margin-top: 10px;
-    //   padding-right: 40px;
-    // }
-    .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