xiuli.gao 2 years ago
parent
commit
36070159ad

+ 5 - 2
project/src/components/assembly/tagDialog.vue

@@ -8,9 +8,9 @@
8 8
         <el-radio :label="3">无任何标签</el-radio>
9 9
       </el-radio-group>
10 10
     </div> -->
11
-    <div class="self-hint" style="border:none">
11
+    <div class="self-hint" style="border:none;margin-top:-10px">
12 12
       <i class="el-icon-message-solid"></i>
13
-      <span>将给选择的1个客户批量{{tagType==1?'打':'移除'}}标签,请选择标签</span>
13
+      <span>将给选择的{{userLength}}个客户批量{{tagType==1?'打':'移除'}}标签,请选择标签</span>
14 14
     </div>
15 15
     <template v-if="radio!=3">
16 16
       <div class="self-input">
@@ -40,6 +40,9 @@ export default {
40 40
     tagType: {
41 41
       type: Number | String,
42 42
       default: 1
43
+    },
44
+    userLength: {
45
+      type: Number
43 46
     }
44 47
   },
45 48
   data () {

+ 93 - 10
project/src/components/customManage/customerTransfer.vue

@@ -2,8 +2,8 @@
2 2
   <div v-loading="loading">
3 3
     <div class="topTagBox flex">
4 4
       <div class="left flex-align-center">
5
-        <div :class="['tagItem',type==1?'tagItem_active':'']" @click="type=1;resetEvent()">离职迁移</div>
6
-        <div :class="['tagItem',type==2?'tagItem_active':'']" @click="type=2;resetEvent()">在职迁移</div>
5
+        <div :class="['tagItem',type==1?'tagItem_active':'']" @click="changeType(1);">离职迁移</div>
6
+        <div :class="['tagItem',type==2?'tagItem_active':'']" @click="changeType(2);">在职迁移</div>
7 7
       </div>
8 8
       <div class="right">
9 9
         <el-button type="primary" size="mini" @click="goReord"><i class="el-icon-document"></i> 分配记录</el-button>
@@ -46,19 +46,19 @@
46 46
           <!-- <div class="smalLine"></div> -->
47 47
           <!-- <el-button type="primary" plain size="mini"><i class="el-icon-refresh-right"></i> 更新数据</el-button> -->
48 48
         </div>
49
-        <div class="selectCustom">已择0个客户</div>
49
+        <div class="selectCustom">已择{{multipleArr.length}}个客户</div>
50 50
       </div>
51 51
       <div class="flex">
52
-        <el-button type="primary" size="mini">分配</el-button>
52
+        <el-button type="primary" size="mini" @click="toDistribution">分配</el-button>
53 53
       </div>
54 54
     </div>
55 55
     <!-- table -->
56
-    <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
56
+    <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange" @select-all="handleSelectAll">
57 57
       <el-table-column type="selection" width="55" align="center"></el-table-column>
58 58
       <el-table-column width="200" fixed="left">
59 59
         <template slot-scope="scope" slot="header">
60
-          <div class="customTitle" slot="reference">{{pageOptionValue==2?'选择当前页面客户':'选择全部客户'}}<i class="el-icon-arrow-down"></i>
61
-            <el-select v-model="pageOptionValue" class="customTitleSelect" placeholder="请选择" size="mini">
60
+          <div class="customTitle" slot="reference">{{old_pageOptionValue==2?'选择当前页面客户':'选择全部客户'}}<i class="el-icon-arrow-down"></i>
61
+            <el-select v-model="pageOptionValue" class="customTitleSelect" placeholder="请选择" size="mini" @change="pageOptionSelect" @visible-change="pageOptionValue=''">
62 62
               <el-option v-for="item in pageOptions" :key="item.id" :label="item.name" :value="item.id">
63 63
               </el-option>
64 64
             </el-select>
@@ -94,7 +94,7 @@
94 94
         <template slot-scope="scope">
95 95
           <div class="customerServiceTagBox biaoqian">
96 96
             <div class="customerServiceTag" v-if="scope.row.gender==1||scope.row.gender==2">{{scope.row.gender==1?'男':scope.row.gender==2?'女':''}}</div>
97
-            <div class="customerServiceTag" v-for="(item) in scope.row.tag_list" :key="item">{{item}}</div>
97
+            <div class="customerServiceTag" v-for="(item,index) in scope.row.tag_list" :key="index">{{item}}</div>
98 98
           </div>
99 99
         </template>
100 100
       </el-table-column>
@@ -169,6 +169,7 @@ export default {
169 169
         { name: '当前页面', id: 2 },
170 170
       ],
171 171
       pageOptionValue: 2,
172
+      old_pageOptionValue: 2,
172 173
       input_keyword: '',
173 174
       tableData: [],
174 175
       user_id_list: [],//客服user_id列表
@@ -184,6 +185,10 @@ export default {
184 185
       resetFlag: false,//重置
185 186
       otherData: {},
186 187
       shieldingData: {},//拉黑的数据
188
+      multipleSelection: {},
189
+      exclude_multiple_selection: {},
190
+      multipleArr: [],
191
+      isAll: false,//是否选择全部
187 192
     }
188 193
   },
189 194
   created () {
@@ -223,6 +228,17 @@ export default {
223 228
       this.pay_num_max = '';
224 229
       this.init(1)
225 230
     },
231
+    changeType (type) {
232
+      this.type = type;
233
+      this.multipleSelection = {};
234
+      this.exclude_multiple_selection = {};
235
+      this.multipleArr = [];
236
+      this.isAll = false;
237
+      this.resetEvent()
238
+    },
239
+    toDistribution () {//去分配
240
+
241
+    },
226 242
     shieldingUserCancel (type) {
227 243
       if (type == 'update') {
228 244
         this.init(1)
@@ -313,6 +329,27 @@ export default {
313 329
           }
314 330
           this.total = res.rst.pageInfo.total;
315 331
           this.pages = res.rst.pageInfo.pages;
332
+
333
+
334
+          // 回显选择
335
+          let page_multiple_data = [];
336
+          if (this.isAll && (!this.multipleSelection[this.page])) {
337
+            page_multiple_data = this.tableData
338
+          } else {
339
+            let multiple_id = this.multipleSelection[this.page] ? this.multipleSelection[this.page].map((v) => {
340
+              return v.user_id + '-' + v.customer_id
341
+            }) : []
342
+            this.tableData.forEach((item) => {
343
+              if (multiple_id.indexOf((item.user_id + '-' + item.customer_id)) != -1) {
344
+                page_multiple_data.push(item)
345
+              }
346
+            })
347
+          }
348
+          this.$nextTick(() => {
349
+            page_multiple_data.forEach((row) => {
350
+              this.$refs.multipleTable.toggleRowSelection(row, true);
351
+            })
352
+          })
316 353
         } else if (res.errno != 4002) {
317 354
           this.$message({
318 355
             message: res.err,
@@ -326,8 +363,54 @@ export default {
326 363
     handleCurrentChange (val) {
327 364
       this.init(val)
328 365
     },
329
-    handleSelectionChange () {
330
-
366
+    handleSelectionChange (row) {
367
+      this.multipleSelection[this.page] = row && row.length != 0 ? row : null;
368
+      if (this.isAll) {//全选状态下被排除的用户
369
+        let page_multiple_data = [];
370
+        let multiple_id = this.multipleSelection[this.page] ? this.multipleSelection[this.page].map((v) => {
371
+          return v.user_id + '-' + v.customer_id
372
+        }) : []
373
+        this.tableData.forEach((item) => {
374
+          if (multiple_id.indexOf((item.user_id + '-' + item.customer_id)) != -1) {
375
+            page_multiple_data.push(item)
376
+          }
377
+        })
378
+        this.exclude_multiple_selection[this.page] = page_multiple_data
379
+      }
380
+      this.userChange()
381
+    },
382
+    pageOptionSelect (val) {//选择
383
+      if (val && val != '') {
384
+        this.old_pageOptionValue = val;
385
+      }
386
+      this.exclude_multiple_selection = {}
387
+      if (this.pageOptionValue == 1) {
388
+        this.isAll = true
389
+      } else {//选择当前页面
390
+        this.isAll = false
391
+        let current_page_data = this.multipleSelection[this.page];
392
+        this.multipleSelection = {};
393
+        this.multipleSelection[this.page] = current_page_data ? current_page_data : null;
394
+      }
395
+      this.tableData.forEach((row) => {
396
+        this.$refs.multipleTable.toggleRowSelection(row, true);
397
+      });
398
+      this.userChange()
399
+    },
400
+    handleSelectAll (row) {//点击了全选
401
+      if (this.isAll && row.length == 0) {
402
+        this.multipleSelection = {}
403
+        this.exclude_multiple_selection = {}
404
+        this.isAll = false
405
+        this.userChange()
406
+      }
407
+    },
408
+    userChange () {
409
+      let multipleArr = []
410
+      for (var i in this.multipleSelection) {
411
+        multipleArr = multipleArr.concat(this.multipleSelection[1] ? this.multipleSelection[1] : [])
412
+      }
413
+      this.multipleArr = multipleArr;
331 414
     },
332 415
     showDetial () {
333 416
       this.drawerSize = '60%'

+ 161 - 85
project/src/components/customManage/manage.vue

@@ -34,12 +34,12 @@
34 34
           <!-- <div class="smalLine"></div> -->
35 35
           <!-- <el-button type="primary" plain size="mini"><i class="el-icon-refresh-right"></i> 更新数据</el-button> -->
36 36
         </div>
37
-        <div class="selectCustom">已择0个客户</div>
37
+        <div class="selectCustom">已择{{multipleArr.length}}个客户</div>
38 38
       </div>
39 39
       <div class="flex">
40 40
         <el-button type="primary" plain size="mini" @click="setCustomerTag(1)">批量打标签</el-button>
41 41
         <el-button type="primary" plain size="mini" @click="setCustomerTag(2)">批量移除标签</el-button>
42
-        <el-button type="primary" plain size="mini">导出Excel</el-button>
42
+        <el-button type="primary" plain size="mini" @click="init(1,'export')">导出Excel</el-button>
43 43
       </div>
44 44
     </div>
45 45
     <!-- table -->
@@ -135,7 +135,7 @@
135 135
     </el-drawer>
136 136
     <!-- 批量打标签 -->
137 137
     <el-dialog :title="tagType==1?'批量打标签':'批量移除标签'" :visible.sync="tagVisible" width="600px" center top="15vh">
138
-      <tag-dialog @closeTagDialog="closeTagDialog" :tagType='tagType'></tag-dialog>
138
+      <tag-dialog @closeTagDialog="closeTagDialog" :tagType='tagType' :userLength='multipleArr.length'></tag-dialog>
139 139
     </el-dialog>
140 140
   </div>
141 141
 </template>
@@ -162,7 +162,7 @@ export default {
162 162
       page: 1,
163 163
       pages: 0,
164 164
       total: 0,
165
-      page_size: 2,
165
+      page_size: 20,
166 166
       shieldingFlag: false,
167 167
       pageOptions: [
168 168
         { name: '全部', id: 1 },
@@ -188,8 +188,9 @@ export default {
188 188
       rowPro: {},//去详情的此条对象
189 189
       multipleSelection: {},
190 190
       exclude_multiple_selection: {},
191
+      multipleArr: [],
191 192
       isAll: false,//是否选择全部
192
-      tagVisible: true,
193
+      tagVisible: false,
193 194
       tagType: 1
194 195
     }
195 196
   },
@@ -199,56 +200,37 @@ export default {
199 200
   methods: {
200 201
     closeTagDialog (val) {
201 202
       if (val && val.length != 0) {
202
-        this.page = page ? page : this.page;
203
-        this.loading = true
204
-        this.$axios.get(this.URL.BASEURL + this.URL.customer_setCustomerTag, {
205
-          params: {
206
-            user_id_list: this.user_id_list,
207
-            customer_name: this.input_keyword,
208
-            add_date_start: this.add_date_start,
209
-            add_date_end: this.add_date_end,
210
-            add_way: this.add_way,
211
-            pay_status: this.pay_status,
212
-            pay_num_min: this.pay_num_min,
213
-            pay_num_max: this.pay_num_max,
214
-            tag_type: this.tag_type,
215
-            tag_id_list: this.tag_id_list,
216
-            loss_status: this.loss_status,
217
-            page: this.page,
218
-            page_size: this.page_size
219
-          }
203
+        let customer_list = [];
204
+        customer_list = this.multipleArr.map((v) => {
205
+          return { customer_id: v.customer_id, user_id: v.user_id }
206
+        })
207
+        this.$loading(this.$loadingConfig);
208
+        this.$axios.post(this.URL.BASEURL + this.URL.customer_setCustomerTag, {
209
+          // user_id_list: this.user_id_list,
210
+          // customer_name: this.input_keyword,
211
+          // add_date_start: this.add_date_start,
212
+          // add_date_end: this.add_date_end,
213
+          // add_way: this.add_way,
214
+          // pay_status: this.pay_status,
215
+          // pay_num_min: this.pay_num_min,
216
+          // pay_num_max: this.pay_num_max,
217
+          // tag_type: this.tag_type,
218
+          // tag_id_list: this.tag_id_list,
219
+          // loss_status: this.loss_status,
220
+
221
+          type: this.tagType,
222
+          tag_list: val,
223
+          customer_list: customer_list
220 224
         }).then((res) => {
221 225
           var res = res.data
222
-          this.loading = false
226
+          this.$loading(this.$loadingConfig).close();
223 227
           if (res && res.errno == 0) {
224
-            this.tableData = res.rst.data.list;
225
-            this.otherData = {
226
-              count: res.rst.data.count,
227
-              exclude_count: res.rst.data.exclude_count
228
-            }
229
-            this.total = res.rst.pageInfo.total;
230
-            this.pages = res.rst.pageInfo.pages;
231
-
232
-            // 回显选择
233
-            let page_multiple_data = [];
234
-            if (this.isAll && (!this.multipleSelection[this.page])) {
235
-              page_multiple_data = this.tableData
236
-            } else {
237
-              let multiple_id = this.multipleSelection[this.page] ? this.multipleSelection[this.page].map((v) => {
238
-                return v.user_id + '-' + v.customer_id
239
-              }) : []
240
-              this.tableData.forEach((item) => {
241
-                if (multiple_id.indexOf((item.user_id + '-' + item.customer_id)) != -1) {
242
-                  page_multiple_data.push(item)
243
-                }
244
-              })
245
-            }
246
-            this.$nextTick(() => {
247
-              page_multiple_data.forEach((row) => {
248
-                this.$refs.multipleTable.toggleRowSelection(row, true);
249
-              })
250
-            })
251
-
228
+            this.$notify.info({
229
+              title: '提示',
230
+              message: `批量${this.tagType == 1 ? '打' : '移除'}标签进行中,请耐心等待!`,
231
+              duration: 0
232
+            });
233
+            this.customer_batchMarkTagResult(res.rst.id)
252 234
           } else if (res.errno != 4002) {
253 235
             this.$message({
254 236
               message: res.err,
@@ -256,11 +238,64 @@ export default {
256 238
             })
257 239
           }
258 240
         }).catch((err) => {
259
-          this.loading = false
241
+          this.$loading(this.$loadingConfig).close();
260 242
         });
261 243
       }
262 244
       this.tagVisible = false
263 245
     },
246
+    customer_batchMarkTagResult (id) {//批量编辑标签结果
247
+      this.$axios.get(this.URL.BASEURL + this.URL.customer_batchMarkTagResult, {
248
+        params: {
249
+          id: id
250
+        }
251
+      }).then((res) => {
252
+        var res = res.data
253
+        if (res && res.errno == 0) {
254
+          if (res.rst.status == 3) {
255
+            this.$notify.closeAll()
256
+            this.$notify({
257
+              title: '成功',
258
+              message: '标签编辑成功!',
259
+              type: 'success',
260
+              duration: 0
261
+            });
262
+            this.multipleSelection = {};
263
+            this.exclude_multiple_selection = {};
264
+            this.multipleArr = [];
265
+            this.isAll = false;
266
+            this.init(this.page)
267
+          } else if (res.rst.status == 3) {
268
+            this.$notify.closeAll()
269
+            this.$notify.error({
270
+              title: '错误',
271
+              message: '标签编辑失败!',
272
+              type: 'success',
273
+              duration: 0
274
+            });
275
+          } else {
276
+            setTimeout(() => {
277
+              this.customer_batchMarkTagResult(id)
278
+            }, 2000)
279
+          }
280
+        } else if (res.errno != 4002) {
281
+          this.$notify.closeAll()
282
+          this.$notify.error({
283
+            title: '错误',
284
+            message: res.err,
285
+            type: 'success',
286
+            duration: 0
287
+          });
288
+        }
289
+      }).catch((err) => {
290
+        this.$notify.closeAll()
291
+        this.$notify.error({
292
+          title: '错误',
293
+          message: '标签编辑失败,服务器错误!',
294
+          type: 'success',
295
+          duration: 0
296
+        });
297
+      });
298
+    },
264 299
     resetEvent () {//重置
265 300
       this.resetFlag = !this.resetFlag
266 301
       this.input_keyword = '';
@@ -328,8 +363,18 @@ export default {
328 363
       }
329 364
       this.init(1)
330 365
     },
331
-    init (page) {
332
-      this.page = page ? page : this.page;
366
+    init (page, type) {
367
+      if (type != 'export') {
368
+        this.page = page ? page : this.page;
369
+      } else {
370
+        if (this.total == 0) {
371
+          this.$message({
372
+            message: '暂无数据可导出',
373
+            type: "warning"
374
+          })
375
+          return
376
+        }
377
+      }
333 378
       this.loading = true
334 379
       this.$axios.get(this.URL.BASEURL + this.URL.customerList, {
335 380
         params: {
@@ -344,41 +389,44 @@ export default {
344 389
           tag_type: this.tag_type,
345 390
           tag_id_list: this.tag_id_list,
346 391
           loss_status: this.loss_status,
347
-          page: this.page,
348
-          page_size: this.page_size
392
+          page: type == 'export' ? 1 : this.page,
393
+          page_size: type == 'export' ? this.$store.state.exportNumber : this.page_size
349 394
         }
350 395
       }).then((res) => {
351 396
         var res = res.data
352 397
         this.loading = false
353 398
         if (res && res.errno == 0) {
354
-          this.tableData = res.rst.data.list;
355
-          this.otherData = {
356
-            count: res.rst.data.count,
357
-            exclude_count: res.rst.data.exclude_count
358
-          }
359
-          this.total = res.rst.pageInfo.total;
360
-          this.pages = res.rst.pageInfo.pages;
361
-
362
-          // 回显选择
363
-          let page_multiple_data = [];
364
-          if (this.isAll && (!this.multipleSelection[this.page])) {
365
-            page_multiple_data = this.tableData
399
+          if (type == 'export') {
400
+            this.exportEvent(res.rst.data.list)
366 401
           } else {
367
-            let multiple_id = this.multipleSelection[this.page] ? this.multipleSelection[this.page].map((v) => {
368
-              return v.user_id + '-' + v.customer_id
369
-            }) : []
370
-            this.tableData.forEach((item) => {
371
-              if (multiple_id.indexOf((item.user_id + '-' + item.customer_id)) != -1) {
372
-                page_multiple_data.push(item)
373
-              }
402
+            this.tableData = res.rst.data.list;
403
+            this.otherData = {
404
+              count: res.rst.data.count,
405
+              exclude_count: res.rst.data.exclude_count
406
+            }
407
+            this.total = res.rst.pageInfo.total;
408
+            this.pages = res.rst.pageInfo.pages;
409
+
410
+            // 回显选择
411
+            let page_multiple_data = [];
412
+            if (this.isAll && (!this.multipleSelection[this.page])) {
413
+              page_multiple_data = this.tableData
414
+            } else {
415
+              let multiple_id = this.multipleSelection[this.page] ? this.multipleSelection[this.page].map((v) => {
416
+                return v.user_id + '-' + v.customer_id
417
+              }) : []
418
+              this.tableData.forEach((item) => {
419
+                if (multiple_id.indexOf((item.user_id + '-' + item.customer_id)) != -1) {
420
+                  page_multiple_data.push(item)
421
+                }
422
+              })
423
+            }
424
+            this.$nextTick(() => {
425
+              page_multiple_data.forEach((row) => {
426
+                this.$refs.multipleTable.toggleRowSelection(row, true);
427
+              })
374 428
             })
375 429
           }
376
-          this.$nextTick(() => {
377
-            page_multiple_data.forEach((row) => {
378
-              this.$refs.multipleTable.toggleRowSelection(row, true);
379
-            })
380
-          })
381
-
382 430
         } else if (res.errno != 4002) {
383 431
           this.$message({
384 432
             message: res.err,
@@ -389,13 +437,17 @@ export default {
389 437
         this.loading = false
390 438
       });
391 439
     },
392
-    setCustomerTag (type) {//批量打标签、移除标签
393
-      //type 操作类型 1添加标签 2移除标签
440
+    userChange () {
394 441
       let multipleArr = []
395 442
       for (var i in this.multipleSelection) {
396 443
         multipleArr = multipleArr.concat(this.multipleSelection[1] ? this.multipleSelection[1] : [])
397 444
       }
398
-      if (multipleArr.length == 0) {
445
+      this.multipleArr = multipleArr;
446
+    },
447
+    setCustomerTag (type) {//批量打标签、移除标签
448
+      //type 操作类型 1添加标签 2移除标签
449
+      this.userChange()
450
+      if (this.multipleArr.length == 0) {
399 451
         this.$message({
400 452
           message: '请选择客户!',
401 453
           type: "warning"
@@ -413,6 +465,7 @@ export default {
413 465
         this.multipleSelection = {}
414 466
         this.exclude_multiple_selection = {}
415 467
         this.isAll = false
468
+        this.userChange()
416 469
       }
417 470
     },
418 471
     handleSelectionChange (row) {//点击选择变化
@@ -429,6 +482,7 @@ export default {
429 482
         })
430 483
         this.exclude_multiple_selection[this.page] = page_multiple_data
431 484
       }
485
+      this.userChange()
432 486
     },
433 487
     pageOptionSelect (val) {//选择
434 488
       if (val && val != '') {
@@ -446,6 +500,7 @@ export default {
446 500
       this.tableData.forEach((row) => {
447 501
         this.$refs.multipleTable.toggleRowSelection(row, true);
448 502
       });
503
+      this.userChange()
449 504
     },
450 505
     changeDrawerSize () {
451 506
       this.drawerSize = this.drawerSize == '100%' ? '60%' : '100%'
@@ -461,6 +516,27 @@ export default {
461 516
         this.$refs.detial.acIdx = 0
462 517
         this.$refs.detial.init()
463 518
       })
519
+    },
520
+    exportEvent (data) {
521
+      let list = data;
522
+      let tHeader = ['客户id', '客户名称', '客户备注', '客户头像', '外部联系人的类型', '客户状态', '所属客服', '客服ID', '所属部门', '标签', '性别', '添加时间', '添加渠道', '付费情况']
523
+      let filterVal = ['customer_id', 'name', 'remark', 'avatar', 'self_type', 'self_customer_enable', 'self_user_name', 'user_id', 'department_list', 'tag_list', 'self_gender', 'createtime', 'add_way', 'self_pay_num']
524
+      list.forEach((item) => {
525
+        item.self_pay_num = item.pay_num > 0 ? ('已付费(' + item.pay_num + '次)') : '未付费';
526
+        item.self_gender = item.gender == 1 ? '男' : item.gender == 2 ? '女' : '';
527
+        item.self_user_name = item.user_list.name;
528
+        item.self_type = item.type == 1 ? '微信用户' : item.type == 2 ? '' : '企业微信';
529
+        item.self_customer_enable = item.customer_enable == 0 ? '禁用' : item.customer_enable == 1 ? '可用' : item.customer_enable == 3 ? '已流失' : ''
530
+      })
531
+      let excelDatas = [
532
+        {
533
+          tHeader: tHeader, // sheet表一头部
534
+          filterVal: filterVal, // 表一的数据字段
535
+          tableDatas: list, // 表一的整体json数据
536
+          sheetName: ''// 表一的sheet名字
537
+        }
538
+      ]
539
+      this.$exportOrder({ excelDatas, name: `客户管理(导出时间:${this.$getDay(0)})` })
464 540
     }
465 541
   }
466 542
 }