Просмотр исходного кода

feat: 客户群发 - 多企微标签

zhengxy месяцев назад: 7
Родитель
Сommit
3244f191b9

+ 39 - 10
project/src/components/assembly/screen/enterpriseTag.vue

@@ -81,7 +81,11 @@ export default {
81 81
     disabled: {
82 82
       type: Boolean,
83 83
       default: false
84
-    }
84
+    },
85
+    isTagName: {
86
+      type: Boolean,
87
+      default: false,
88
+    },
85 89
   },
86 90
   watch: {
87 91
     reset () {
@@ -196,16 +200,41 @@ export default {
196 200
           this.old_tag_list = res.rst;
197 201
           this.tagList = res.rst;
198 202
           // 回显
199
-          let arr = [];
200
-          this.tagList.forEach((item) => {
201
-            item.tag_list.forEach((it) => {
202
-              if (this.tag_id_list.indexOf(it.tag_id) != -1) {
203
-                arr.push(it.tag_name)
204
-              }
203
+          if (this.isTagName) { // 按标签name回显
204
+            let arr = [];
205
+            this.tagList.forEach((item) => {
206
+              item.tag_list.forEach((it) => {
207
+                if (this.tag_id_list.indexOf(it.tag_name) != -1) {
208
+                  arr.push(it.tag_name)
209
+                }
210
+              })
205 211
             })
206
-          })
207
-          this.tag_name_list = arr;
208
-          this.oldObj.tag_name_list = arr;
212
+            this.tag_name_list = arr;
213
+            this.oldObj.tag_name_list = arr;
214
+
215
+            // 根据标签name 反查出标签id
216
+            let idArr = []
217
+            this.tagList.forEach((item) => {
218
+              item.tag_list.forEach((it) => {
219
+                if (this.tag_name_list.indexOf(it.tag_name) != -1) {
220
+                  idArr.push(it.tag_id)
221
+                }
222
+              })
223
+            })
224
+            this.tag_id_list = idArr
225
+            this.oldObj.tag_id_list = idArr
226
+          } else { // 默认按标签id回显
227
+            let arr = [];
228
+            this.tagList.forEach((item) => {
229
+              item.tag_list.forEach((it) => {
230
+                if (this.tag_id_list.indexOf(it.tag_id) != -1) {
231
+                  arr.push(it.tag_name)
232
+                }
233
+              })
234
+            })
235
+            this.tag_name_list = arr;
236
+            this.oldObj.tag_name_list = arr;
237
+          }
209 238
         } else if (res.errno != 4002) {
210 239
           this.$message({
211 240
             message: res.err,

+ 87 - 10
project/src/components/customOperate/createMassMsg.vue

@@ -67,7 +67,7 @@
67 67
             <el-radio v-model="customer_filter" :disabled="!editFlag" :label="0" @change="changeEvent">全部客户</el-radio>
68 68
             <el-radio v-model="customer_filter" :disabled="!editFlag" :label="1" @change="changeEvent">筛选客户</el-radio>
69 69
           </div>
70
-          <div class="screeningCustomers" v-if="customer_filter == 1">
70
+          <div class="screeningCustomers" v-show="customer_filter == 1">
71 71
             <div class="screeningItem">
72 72
               <label>性别:</label>
73 73
               <el-checkbox-group class="checkboxGroup" v-model="gender" :disabled="!editFlag" @change="changeEvent">
@@ -108,15 +108,15 @@
108 108
               </div>
109 109
             </div>
110 110
 
111
-            <!-- S 标签相关 单主体模式时显示 -->
112
-            <div v-show="operate_type == 1" class="screeningItem">
111
+            <!-- S 标签相关 单主体模式时传id 多主体模式时传name -->
112
+            <div class="screeningItem">
113 113
               <label>标签:</label>
114
-              <enterprise-tag title="" width="355px" :disabled="!editFlag" :afferent_obj='afferent_tag_obj' :reset='resetFlag' @tagDefine="tagDefine" style="margin:0" />
114
+              <enterprise-tag :isTagName="isTagName" title="" width="355px" :disabled="!editFlag" :afferent_obj='afferent_tag_obj' :reset='resetFlag' @tagDefine="tagDefine" style="margin:0" />
115 115
             </div>
116
-            <div v-show="operate_type == 1" class="screeningItem" style="align-items: flex-start;">
116
+            <div class="screeningItem" style="align-items: flex-start;">
117 117
               <label>排除客户:</label>
118 118
               <div style="flex:1">
119
-                <enterprise-tag title="" width="355px" :disabled="!editFlag" :afferent_obj='afferent_exclude_tag_obj' :excludeFlag="true" :reset='resetFlag' @tagDefine="exclude_tagDefine" style="margin:0" />
119
+                <enterprise-tag :isTagName="isTagName" title="" width="355px" :disabled="!editFlag" :afferent_obj='afferent_exclude_tag_obj' :excludeFlag="true" :reset='resetFlag' @tagDefine="exclude_tagDefine" style="margin:0" />
120 120
                 <p class="screening-hint">可根据标签选择客户,群发时将不会发送给该标签内的客户。若选择了排除的客户,需要较长时间创建本条群发消息哦~</p>
121 121
               </div>
122 122
             </div>
@@ -251,6 +251,7 @@ export default {
251 251
       name: '',//群发标题
252 252
       tag_info: {},//标签
253 253
       exclude_tag_info: {},//排除标签
254
+      isTagName: false,
254 255
       is_for_all: 1,
255 256
       user_id_list: [],
256 257
       customerMatchCountLoading: false,
@@ -313,11 +314,14 @@ export default {
313 314
           }
314 315
           this.isLookCount = false;
315 316
           this.gender = res.rst.gender ? res.rst.gender.split(',') : [];
317
+          this.isTagName = res.rst.operate_type == 2
316 318
           this.afferent_tag_obj = {
319
+            tag_name_list: res.rst.tag_list ? res.rst.tag_list.split(',') : [],
317 320
             tag_id_list: res.rst.tag_list ? res.rst.tag_list.split(',') : [],
318 321
             tag: res.rst.tag_screen_type
319 322
           }
320 323
           this.afferent_exclude_tag_obj.tag_id_list = res.rst.exclude_tag_list ? res.rst.exclude_tag_list.split(',') : [];
324
+          this.afferent_exclude_tag_obj.tag_name_list = res.rst.exclude_tag_list ? res.rst.exclude_tag_list.split(',') : [];
321 325
 
322 326
           // this.tag_info = this.afferent_tag_obj;
323 327
           this.tag_info = {
@@ -326,6 +330,12 @@ export default {
326 330
           }
327 331
 
328 332
           this.exclude_tag_info = this.afferent_exclude_tag_obj
333
+          if(this.isTagName && (res.rst.tag_list || res.rst.exclude_tag_list)) { // 根据标签名 反差标签id
334
+            this.handleSetTagIdInfo()
335
+          } else if (!this.isTagName && (res.rst.tag_list || res.rst.exclude_tag_list)) { // 根据标签id 反差标签名
336
+            this.handleSetTagNameInfo()
337
+          }
338
+
329 339
           this.send_type = res.rst.send_type;
330 340
           this.send_type == 2 ? this.send_time = {
331 341
             date: res.rst.send_time.split(' ')[0],
@@ -463,7 +473,6 @@ export default {
463 473
         })
464 474
         return
465 475
       }
466
-      this.$loading(this.$loadingConfig)
467 476
       let params = {
468 477
         rule_id: this.is_copy ? '' : this.rule_id ? this.rule_id : '',
469 478
         name: this.name,
@@ -496,12 +505,17 @@ export default {
496 505
         params.add_time_end = this.afferent_time && this.afferent_time.length > 1 ? this.afferent_time[1] : '';
497 506
       }
498 507
 
499
-      if (this.operate_type == 1) { // 单主体支持标签 多主体不支持
508
+      if (this.operate_type == 1) { // 单主体支持标签 传标签id
500 509
         params.tag_screen_type = this.tag_info && this.tag_info.tag_type ? this.tag_info.tag_type : 0
501 510
         params.tag_list = this.tag_info && this.tag_info.tag_id_list ? this.tag_info.tag_id_list.join(',') : ''
502 511
         params.exclude_tag_list = this.exclude_tag_info && this.exclude_tag_info.tag_id_list ? this.exclude_tag_info.tag_id_list.join(',') : ''
512
+      } else if (this.operate_type == 2) { // 多主体 传标签name
513
+        params.tag_screen_type = this.tag_info && this.tag_info.tag_type ? this.tag_info.tag_type : 0
514
+        params.tag_list = this.tag_info && this.tag_info.tag_name_list ? this.tag_info.tag_name_list.join(',') : ''
515
+        params.exclude_tag_list = this.exclude_tag_info && this.exclude_tag_info.tag_name_list ? this.exclude_tag_info.tag_name_list.join(',') : ''
503 516
       }
504
-
517
+      console.log('params => ', JSON.parse(JSON.stringify(params)))
518
+      this.$loading(this.$loadingConfig)
505 519
       this.$axios.post(this.URL.BASEURL + this.URL.massMsg_set, params).then((res) => {
506 520
         var res = res.data
507 521
         this.$loading(this.$loadingConfig).close()
@@ -535,17 +549,20 @@ export default {
535 549
       if (data.tag == 1 || data.tag == 2) {
536 550
         if (data.tag_id_list && data.tag_id_list.length != 0) {
537 551
           this.tag_info = {
552
+            tag_name_list: data.tag_name_list,
538 553
             tag_id_list: data.tag_id_list,
539 554
             tag_type: data.tag
540 555
           }
541 556
         } else {
542 557
           this.tag_info = {
558
+            tag_name_list: [],
543 559
             tag_id_list: [],
544 560
             tag_type: 0
545 561
           }
546 562
         }
547 563
       } else {
548 564
         this.tag_info = {
565
+          tag_name_list: [],
549 566
           tag_id_list: [],
550 567
           tag_type: data.tag
551 568
         }
@@ -556,17 +573,20 @@ export default {
556 573
       if (data.tag == 1 || data.tag == 2) {
557 574
         if (data.tag_id_list && data.tag_id_list.length != 0) {
558 575
           this.exclude_tag_info = {
576
+            tag_name_list: data.tag_name_list,
559 577
             tag_id_list: data.tag_id_list,
560 578
             tag_type: data.tag
561 579
           }
562 580
         } else {
563 581
           this.exclude_tag_info = {
582
+            tag_name_list: [],
564 583
             tag_id_list: [],
565 584
             tag_type: 0
566 585
           }
567 586
         }
568 587
       } else {
569 588
         this.exclude_tag_info = {
589
+          tag_name_list: [],
570 590
           tag_id_list: [],
571 591
           tag_type: data.tag
572 592
         }
@@ -596,10 +616,14 @@ export default {
596 616
       }
597 617
       if (this.customer_filter == 1) {//筛选客户
598 618
         params.gender = this.gender && this.gender.join(',');
599
-        if (this.operate_type == 1) { // 单主体支持标签 多主体不支持
619
+        if (this.operate_type == 1) { // 单主体支持标签 传标签id
600 620
           params.tag_screen_type = this.tag_info && this.tag_info.tag_type ? this.tag_info.tag_type : 0;
601 621
           params.tag_list = this.tag_info && this.tag_info.tag_id_list ? this.tag_info.tag_id_list.join(',') : '';
602 622
           params.exclude_tag_list = this.exclude_tag_info && this.exclude_tag_info.tag_id_list ? this.exclude_tag_info.tag_id_list.join(',') : '';
623
+        } else if (this.operate_type == 2) { // 多主体标签 传标签name
624
+          params.tag_screen_type = this.tag_info && this.tag_info.tag_type ? this.tag_info.tag_type : 0;
625
+          params.tag_list = this.tag_info && this.tag_info.tag_name_list ? this.tag_info.tag_name_list.join(',') : '';
626
+          params.exclude_tag_list = this.exclude_tag_info && this.exclude_tag_info.tag_name_list ? this.exclude_tag_info.tag_name_list.join(',') : '';
603 627
         }
604 628
         params.pay_status = this.payInfo.pay_status || this.payInfo.pay_status == 0 ? this.payInfo.pay_status : '';
605 629
         params.pay_num_min = this.payInfo.pay_num_min || this.payInfo.pay_num_min == 0 ? this.payInfo.pay_num_min : '';
@@ -676,6 +700,59 @@ export default {
676 700
       // }
677 701
       this.changeEvent()
678 702
     },
703
+
704
+    handleSetTagIdInfo() {
705
+      this.$axios.get(this.URL.BASEURL + this.URL.tagList, {}).then((res) => {
706
+        var res = res.data
707
+        if (res && res.errno == 0) {
708
+          const allTagList = res.rst;
709
+          const tagIdArr = []
710
+          const tagIdArrExclude = []
711
+          allTagList.forEach(allTag => {
712
+            allTag.tag_list.forEach(tag => {
713
+              const res = this.tag_info.tag_name_list.find(item => item === tag.tag_name)
714
+              if (res) tagIdArr.push(tag.tag_id)
715
+              const resExclude = this.exclude_tag_info.tag_name_list.find(item => item === tag.tag_name)
716
+              if (resExclude) tagIdArrExclude.push(tag.tag_id)
717
+            })
718
+          })
719
+          this.tag_info.tag_id_list = [...tagIdArr]
720
+          this.exclude_tag_info.tag_id_list = [...tagIdArrExclude]
721
+        } else if (res.errno != 4002) {
722
+          this.$message({
723
+            message: res.err,
724
+            type: "warning"
725
+          })
726
+        }
727
+      }).catch((err) => {
728
+      });
729
+    },
730
+    handleSetTagNameInfo() {
731
+      this.$axios.get(this.URL.BASEURL + this.URL.tagList, {}).then((res) => {
732
+        var res = res.data
733
+        if (res && res.errno == 0) {
734
+          const allTagList = res.rst;
735
+          const tagNameArr = []
736
+          const tagNameArrExclude = []
737
+          allTagList.forEach(allTag => {
738
+            allTag.tag_list.forEach(tag => {
739
+              const res = this.tag_info.tag_id_list.find(item => item === tag.tag_id)
740
+              if (res) tagNameArr.push(tag.tag_name)
741
+              const resExclude = this.exclude_tag_info.tag_id_list.find(item => item === tag.tag_id)
742
+              if (resExclude) tagNameArrExclude.push(tag.tag_name)
743
+            })
744
+          })
745
+          this.tag_info.tag_name_list = [...tagNameArr]
746
+          this.exclude_tag_info.tag_name_list = [...tagNameArrExclude]
747
+        } else if (res.errno != 4002) {
748
+          this.$message({
749
+            message: res.err,
750
+            type: "warning"
751
+          })
752
+        }
753
+      }).catch((err) => {
754
+      });
755
+    },
679 756
   }
680 757
 }
681 758
 </script>

+ 34 - 24
project/src/components/customOperate/massMsgDetail/index.vue

@@ -202,35 +202,45 @@ export default {
202 202
 
203 203
     async handleGetTagInfo({ tag_screen_type, tag_list, exclude_tag_list }) {
204 204
       return new Promise(async (resolve, reject) => {
205
-        const tempList = await this.handleGetTagOptions()
206
-        const tagOptions = []
207
-        tempList.forEach(t => {
208
-          t.tag_list.forEach(tag => {
209
-            tagOptions.push(tag)
205
+        console.log('dataInfo => ', this.dataInfo)
206
+        const { operate_type } = this.dataInfo
207
+        if (operate_type == 1) { // 单企微标签
208
+          const tempList = await this.handleGetTagOptions()
209
+          const tagOptions = []
210
+          tempList.forEach(t => {
211
+            t.tag_list.forEach(tag => {
212
+              tagOptions.push(tag)
213
+            })
210 214
           })
211
-        })
212 215
 
213
-        const tag_list_res = []
214
-        if (tag_list && tag_list.length) {
215
-          tag_list.split(',').forEach(t => {
216
-            const isFound = tagOptions.find(tag => tag.tag_id === t)
217
-            if (isFound) tag_list_res.push(isFound.tag_name)
218
-          })
219
-        }
216
+          const tag_list_res = []
217
+          if (tag_list && tag_list.length) {
218
+            tag_list.split(',').forEach(t => {
219
+              const isFound = tagOptions.find(tag => tag.tag_id === t)
220
+              if (isFound) tag_list_res.push(isFound.tag_name)
221
+            })
222
+          }
220 223
 
221
-        const exclude_tag_list_res = []
222
-        if (exclude_tag_list && exclude_tag_list) {
223
-          exclude_tag_list.split(',').forEach(t => {
224
-            const isFound = tagOptions.find(tag => tag.tag_id === t)
225
-            if (isFound) exclude_tag_list_res.push(isFound.tag_name)
224
+          const exclude_tag_list_res = []
225
+          if (exclude_tag_list && exclude_tag_list) {
226
+            exclude_tag_list.split(',').forEach(t => {
227
+              const isFound = tagOptions.find(tag => tag.tag_id === t)
228
+              if (isFound) exclude_tag_list_res.push(isFound.tag_name)
229
+            })
230
+          }
231
+
232
+          resolve({
233
+            tag_screen_type: tagScreenTypeOptions[tag_screen_type],
234
+            tag_list: tag_list_res,
235
+            exclude_tag_list: exclude_tag_list_res,
236
+          })
237
+        } else if (operate_type == 2) { // 多企微标签 - 直接返回接口数据
238
+          resolve({
239
+            tag_screen_type: tagScreenTypeOptions[tag_screen_type],
240
+            tag_list: (tag_list && tag_list.length) ? tag_list.split(',') : [],
241
+            exclude_tag_list: (exclude_tag_list && exclude_tag_list.length) ? exclude_tag_list.split(',') : [],
226 242
           })
227 243
         }
228
-
229
-        resolve({
230
-          tag_screen_type: tagScreenTypeOptions[tag_screen_type],
231
-          tag_list: tag_list_res,
232
-          exclude_tag_list: exclude_tag_list_res,
233
-        })
234 244
       })
235 245
     },
236 246
     handleGetTagOptions() {