From acdff03246ce648082192dfb069c3a006a7fbee6 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期三, 09 八月 2023 18:46:06 +0800
Subject: [PATCH] 客户管理模块 批量删除、推进、跟进接口联调

---
 src/views/client/contacts/AddContactsDialog.vue |  198 +++++++++++++++++++++++++++++++------------------
 1 files changed, 124 insertions(+), 74 deletions(-)

diff --git a/src/views/client/contacts/AddContactsDialog.vue b/src/views/client/contacts/AddContactsDialog.vue
index 031c837..f0f79e6 100644
--- a/src/views/client/contacts/AddContactsDialog.vue
+++ b/src/views/client/contacts/AddContactsDialog.vue
@@ -5,6 +5,9 @@
       :visible.sync="editConfig.visible"
       :width="dialogWidth"
       :before-close="handleClose"
+      :close-on-click-modal="false"
+      append-to-body
+      custom-class="iframe-dialog"
     >
       <el-form
         ref="form"
@@ -31,18 +34,31 @@
                 </el-form-item>
               </el-col>
               <el-col :span="12">
-                <el-form-item label="瀹㈡埛鍚嶇О" prop="client_id">
+                <el-form-item label="瀹㈡埛鍚嶇О" prop="client_name">
                   <div class="custom-name">
-                    <el-input v-model="editConfig.infomation.client_id"></el-input>
-                    <div class="common-select-btn">
-                      <i class="el-icon-circle-plus-outline"></i>
+                    <el-autocomplete
+                      v-model="editConfig.infomation.client_name"
+                      :fetch-suggestions="querySearchAsync"
+                      value-key="name"
+                      @select="handleSelectClient"
+                    ></el-autocomplete>
+                    <div class="common-select-btn" @click="selClientClick">
+                      <i class="el-icon-circle-plus-outline" title="閫夋嫨"></i>
+                    </div>
+                    <div class="common-select-btn" @click="clearupClient">
+                      <i class="el-icon-edit-outline" title="娓呴櫎"></i>
                     </div>
                   </div>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
                 <el-form-item label="鎵嬫満" prop="phone">
-                  <el-input v-model="editConfig.infomation.phone"></el-input>
+                  <el-input
+                    v-model="editConfig.infomation.phone"
+                    maxlength="11"
+                    show-word-limit
+                    oninput="value=value.replace(/[^\d]/g,'')"
+                  ></el-input>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
@@ -162,12 +178,12 @@
           <div v-if="isUnflod" class="basic-info-view">
             <el-row>
               <el-col :span="24">
-                <el-form-item label="澶囨敞" prop="notes">
+                <el-form-item label="澶囨敞" prop="desc">
                   <el-input
                     type="textarea"
                     :autosize="{ minRows: 2, maxRows: 4 }"
                     placeholder="璇疯緭鍏ュ唴瀹�"
-                    v-model="editConfig.infomation.notes"
+                    v-model="editConfig.infomation.desc"
                   ></el-input>
                 </el-form-item>
               </el-col>
@@ -212,6 +228,12 @@
         <el-button type="primary" size="small" @click="saveClick('form')">淇� 瀛�</el-button>
         <el-button size="small" @click="editConfig.visible = false">鍙� 娑�</el-button>
       </div>
+      <!-- 閫夋嫨瀹㈡埛 -->
+      <SelectClientDialog
+        v-if="editSelectClientConfig.editVisible"
+        :edit-common-config="editSelectClientConfig"
+        @selClient="selClient"
+      />
     </el-dialog>
   </div>
 </template>
@@ -219,6 +241,7 @@
 <script>
 import { getAddContact, getUpdateContact } from "@/api/client/contacts"
 import { getAllData } from "@/api/client/client"
+import SelectClientDialog from "@/views/other/commonDialog/SelectClientDialog"
 export default {
   name: "AddContactsDialog",
   props: {
@@ -228,31 +251,17 @@
         return {
           visible: false,
           title: "鏂板缓",
-          infomation: {
-            name: "",
-            number: "LEA50",
-            client_id: "",
-            phone: "",
-            position: "",
-            member_id: "5",
-            is_first: false,
-            wechat: "1",
-            birthday: "",
-            email: "",
-            nextFollowupDate: "",
-            country_id: "",
-            province_id: "",
-            city_id: "",
-            region_id: "",
-            postalCode: "",
-            notes: ""
-          }
+          infomation: {}
         }
       }
     }
   },
-  components: {},
-  computed: {},
+  components: { SelectClientDialog },
+  computed: {
+    clientList() {
+      return this.$store.state.getClientName.clientList
+    }
+  },
   data() {
     return {
       dialogWidth: "80%",
@@ -260,7 +269,16 @@
       rules: {
         name: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
         number: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-        member_id: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }]
+        member_id: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+        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"
+          }
+        ]
       },
       businessSourceOptions: [
         { value: "1", label: "鍚庡彴娉ㄥ唽" },
@@ -278,10 +296,16 @@
       cityOptions: [], // 鍩庡競
       regionOptions: [], // 鍖哄煙
       unflodCollapseStr: "鏀惰捣",
-      isUnflod: true
+      isUnflod: true,
+      editSelectClientConfig: {
+        editVisible: false,
+        title: "",
+        infomation: {}
+      }
     }
   },
   created() {
+    this.$store.dispatch("geClient")
     this.getCommonData()
   },
   methods: {
@@ -351,9 +375,10 @@
     saveParams() {
       let data = this.editConfig.infomation
       let params = {
+        id: this.editConfig.title === "鏂板缓" ? 0 : data.id,
         birthday: data.birthday || "",
         city_id: data.city_id || 0,
-        client_id: 0,
+        client_id: parseInt(data.client_id) || 0,
         country_id: data.country_id || 0,
         desc: data.desc || "",
         email: data.email || "",
@@ -368,6 +393,33 @@
         wechat: data.wechat || ""
       }
       return params
+    },
+    // 閫夋嫨瀹㈡埛鐩稿叧鏂规硶
+    querySearchAsync(queryString, cb) {
+      var restaurants = this.clientList
+      var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants
+      cb(results)
+    },
+    createStateFilter(queryString) {
+      return (state) => {
+        return state.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0
+      }
+    },
+    handleSelectClient(item) {
+      this.editConfig.infomation.client_id = item.id
+    },
+    selClientClick() {
+      this.editSelectClientConfig.editVisible = true
+    },
+    selClient(row) {
+      console.log(row)
+      this.editConfig.infomation.client_name = row.name
+      this.editConfig.infomation.client_id = row.id
+    },
+    // 娓呴櫎宸查�夋嫨鐢ㄦ埛
+    clearupClient() {
+      this.editConfig.infomation.client_name = ""
+      this.editConfig.infomation.client_id = 0
     },
     // 娣诲姞闄勪欢
     addAnnexClick() {},
@@ -389,58 +441,56 @@
 
 <!-- Add "scoped" attribute to limit CSS to this component only -->
 <style lang="scss" scoped>
-.add-contacts {
-  .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 {
-        display: flex;
-        .common-select-btn {
-          margin-left: 5px;
-          font-size: 16px;
+::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;
         }
       }
     }
-    .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