|
@@ -175,7 +175,7 @@ import editCon from '@/components/assembly/editCon.vue'
|
175
|
175
|
import screenPay from '@/components/assembly/screen/pay.vue'
|
176
|
176
|
import pushGroupDialog from './pushGroupDialog.vue'
|
177
|
177
|
import _lodash from 'lodash'
|
178
|
|
-import { getIntegerNumber } from '@/assets/js/common'
|
|
178
|
+import { getIntegerNumber, isJSON } from '@/assets/js/common'
|
179
|
179
|
|
180
|
180
|
export default {
|
181
|
181
|
components: { selfChannel, selfCustomerservice, customerServiceCorpV2, datePicker, enterpriseTag, editCon, screenPay, pushGroupDialog },
|
|
@@ -271,14 +271,18 @@ export default {
|
271
|
271
|
this.loading = false
|
272
|
272
|
this.isShowEditCon = true
|
273
|
273
|
if (res && res.errno == 0) {
|
|
274
|
+ console.log('res.rst => ', res.rst)
|
274
|
275
|
// 备份接口数据
|
275
|
276
|
this.detailFromApi = Object.freeze(_lodash.cloneDeep(res.rst))
|
276
|
277
|
|
277
|
278
|
// 数据回显
|
278
|
|
- this.user_id_list = res.rst.senders ? res.rst.senders.split(',') : [];
|
279
|
|
- if (res.rst.senders && res.rst.senders.length > 0) {//有值代表部分员工
|
280
|
|
- this.is_all = 0
|
|
279
|
+ if (this.operate_type == 1) {
|
|
280
|
+ this.user_id_list = (res.rst.senders && !isJSON(res.rst.senders)) ? res.rst.senders.split(',') : [];
|
|
281
|
+ if (res.rst.senders && res.rst.senders.length > 0) {//有值代表部分员工
|
|
282
|
+ this.is_all = 0
|
|
283
|
+ }
|
281
|
284
|
}
|
|
285
|
+
|
282
|
286
|
this.gender = res.rst.gender ? res.rst.gender.split(',') : [];
|
283
|
287
|
this.payInfo = {
|
284
|
288
|
pay_status: res.rst.pay_status,
|
|
@@ -297,10 +301,11 @@ export default {
|
297
|
301
|
this.operate_type = res.rst.operate_type ? res.rst.operate_type : 1
|
298
|
302
|
this.is_operation = (res.rst.is_operation || res.rst.is_operation === 0) ? res.rst.is_operation : 1
|
299
|
303
|
this.operator_group_id = res.rst.operator_group_id ? res.rst.operator_group_id : ''
|
300
|
|
- if (this.operate_type == 2 && this.is_operation == 0 && Array.isArray(res.rst.multiple_senders)) {
|
301
|
|
- this.multiple_senders = [...res.rst.multiple_senders]
|
|
304
|
+ if (this.operate_type == 2 && this.is_operation == 0 && Array.isArray(JSON.parse(res.rst.multiple_senders))) {
|
|
305
|
+ const multiple_senders = JSON.parse(res.rst.multiple_senders)
|
|
306
|
+ this.multiple_senders = [...multiple_senders]
|
302
|
307
|
const arr = []
|
303
|
|
- res.rst.multiple_senders.forEach(corp => {
|
|
308
|
+ multiple_senders.forEach(corp => {
|
304
|
309
|
if (corp && corp.user_list && Array.isArray(corp.user_list)) {
|
305
|
310
|
corp.user_list.forEach(userId => {
|
306
|
311
|
arr.push({
|
|
@@ -348,6 +353,7 @@ export default {
|
348
|
353
|
})
|
349
|
354
|
}
|
350
|
355
|
}).catch((err) => {
|
|
356
|
+ console.log('err => ', err)
|
351
|
357
|
this.loading = false
|
352
|
358
|
this.isShowEditCon = true
|
353
|
359
|
});
|
|
@@ -407,35 +413,12 @@ export default {
|
407
|
413
|
return
|
408
|
414
|
}
|
409
|
415
|
|
410
|
|
- let params = {
|
411
|
|
- name: this.name,
|
412
|
|
- is_all: this.is_all,
|
413
|
|
- // 单主体时传 senders
|
414
|
|
- senders: (this.operate_type == 1 && this.is_all == 0) ? this.user_id_list.join(',') : '',
|
415
|
|
- content: this.content,
|
416
|
|
- attachments: this.attachments == '' || this.attachments.length == 0 ? '' : JSON.stringify(this.attachments),
|
417
|
|
- gender: this.gender && this.gender.join(','),
|
418
|
|
- send_conf: JSON.stringify(this.send_conf),
|
419
|
|
- pay_status: this.payInfo.pay_status || this.payInfo.pay_status == 0 ? this.payInfo.pay_status : '',
|
420
|
|
- pay_num_min: this.payInfo.pay_num_min || this.payInfo.pay_num_min == 0 ? Number(this.payInfo.pay_num_min) : '',
|
421
|
|
- pay_num_max: this.payInfo.pay_num_max || this.payInfo.pay_num_max == 0 ? Number(this.payInfo.pay_num_max) : '',
|
422
|
|
-
|
423
|
|
- operate_type: this.operate_type,
|
424
|
|
- is_operation: this.operate_type == 1 ? 0 : this.is_operation, // 单主体模式 该字段传0
|
425
|
|
- operator_group_id: (this.operate_type == 2 && this.is_operation == 1) ? this.operator_group_id : '',
|
426
|
|
- multiple_senders: (this.operate_type == 2 && this.is_operation == 0 && this.multiple_senders.length) ? JSON.stringify(this.multiple_senders) : '',
|
427
|
|
-
|
428
|
|
- group_id: this.group_id ? this.group_id : 0,
|
429
|
|
- }
|
430
|
416
|
|
431
|
|
- if (this.operate_type == 1) { // 单主体支持标签 多主体不支持
|
432
|
|
- params.tag_screen_type = this.tag_info && this.tag_info.tag_type ? this.tag_info.tag_type : 0
|
433
|
|
- params.tag_list = this.tag_info && this.tag_info.tag_id_list ? this.tag_info.tag_id_list.join(',') : ''
|
434
|
|
- params.exclude_tag_list = this.exclude_tag_info && this.exclude_tag_info.tag_id_list ? this.exclude_tag_info.tag_id_list.join(',') : ''
|
435
|
|
- }
|
|
417
|
+ let params = this.handleGetParams()
|
436
|
418
|
|
437
|
419
|
if (this.isCopy) {
|
438
|
420
|
const isSameParams = this.handleGetIsSameParams(params)
|
|
421
|
+ console.log('isSameParams => ', isSameParams)
|
439
|
422
|
if (isSameParams) {
|
440
|
423
|
this.$message.warning('推送规则及内容重复!')
|
441
|
424
|
return
|
|
@@ -492,26 +475,47 @@ export default {
|
492
|
475
|
});
|
493
|
476
|
},
|
494
|
477
|
|
495
|
|
- // 复制操作 => 获取当前规则未修改时的参数
|
496
|
|
- handleGetOldParams() {
|
497
|
|
- let oldParams = {
|
|
478
|
+ // 根据当前页面视图 获取参数
|
|
479
|
+ handleGetParams() {
|
|
480
|
+ let params = {
|
498
|
481
|
name: this.name,
|
499
|
482
|
is_all: this.is_all,
|
500
|
|
- senders: this.is_all == 0 ? this.user_id_list.join(',') : '',
|
|
483
|
+ // 单主体时传 senders
|
|
484
|
+ senders: (this.operate_type == 1 && this.is_all == 0) ? this.user_id_list.join(',') : '',
|
501
|
485
|
content: this.content,
|
502
|
486
|
attachments: this.attachments == '' || this.attachments.length == 0 ? '' : JSON.stringify(this.attachments),
|
503
|
487
|
gender: this.gender && this.gender.join(','),
|
504
|
488
|
send_conf: JSON.stringify(this.send_conf),
|
505
|
|
- tag_screen_type: this.tag_info && this.tag_info.tag_type ? this.tag_info.tag_type : 0,
|
506
|
|
- tag_list: this.tag_info && this.tag_info.tag_id_list ? this.tag_info.tag_id_list.join(',') : '',
|
507
|
|
- exclude_tag_list: this.exclude_tag_info && this.exclude_tag_info.tag_id_list ? this.exclude_tag_info.tag_id_list.join(',') : '',
|
508
|
489
|
pay_status: this.payInfo.pay_status || this.payInfo.pay_status == 0 ? this.payInfo.pay_status : '',
|
509
|
490
|
pay_num_min: this.payInfo.pay_num_min || this.payInfo.pay_num_min == 0 ? Number(this.payInfo.pay_num_min) : '',
|
510
|
491
|
pay_num_max: this.payInfo.pay_num_max || this.payInfo.pay_num_max == 0 ? Number(this.payInfo.pay_num_max) : '',
|
|
492
|
+
|
|
493
|
+ operate_type: this.operate_type,
|
|
494
|
+ is_operation: this.operate_type == 1 ? 0 : this.is_operation, // 单主体模式 该字段传0
|
|
495
|
+ operator_group_id: (this.operate_type == 2 && this.is_operation == 1) ? this.operator_group_id : '',
|
|
496
|
+ multiple_senders: (this.operate_type == 2 && this.is_operation == 0 && this.multiple_senders.length) ? JSON.stringify(this.multiple_senders) : '',
|
|
497
|
+
|
|
498
|
+ group_id: this.group_id ? this.group_id : 0,
|
511
|
499
|
}
|
|
500
|
+
|
|
501
|
+ if (this.operate_type == 1) { // 单主体支持标签 多主体不支持
|
|
502
|
+ params.tag_screen_type = this.tag_info && this.tag_info.tag_type ? this.tag_info.tag_type : 0
|
|
503
|
+ params.tag_list = this.tag_info && this.tag_info.tag_id_list ? this.tag_info.tag_id_list.join(',') : ''
|
|
504
|
+ params.exclude_tag_list = this.exclude_tag_info && this.exclude_tag_info.tag_id_list ? this.exclude_tag_info.tag_id_list.join(',') : ''
|
|
505
|
+ }
|
|
506
|
+
|
|
507
|
+ return JSON.parse(JSON.stringify(params))
|
|
508
|
+ },
|
|
509
|
+
|
|
510
|
+ // 复制操作 => 获取当前规则未修改时的参数
|
|
511
|
+ handleGetOldParams() {
|
|
512
|
+ let oldParams = this.handleGetParams()
|
512
|
513
|
this.oldParams = JSON.parse(JSON.stringify(oldParams))
|
513
|
514
|
},
|
514
|
515
|
handleGetIsSameParams(newParams) {
|
|
516
|
+ console.log('newParams => ', JSON.parse(JSON.stringify(newParams)))
|
|
517
|
+ console.log('oldParams => ', JSON.parse(JSON.stringify(this.oldParams)))
|
|
518
|
+
|
515
|
519
|
let isSameParams = true
|
516
|
520
|
// 先比较“非多选”的属性
|
517
|
521
|
const _newParams = JSON.parse(JSON.stringify(newParams))
|
|
@@ -519,54 +523,94 @@ export default {
|
519
|
523
|
delete _newParams.gender
|
520
|
524
|
delete _newParams.tag_list
|
521
|
525
|
delete _newParams.exclude_tag_list
|
|
526
|
+ delete _newParams.multiple_senders
|
|
527
|
+ console.log('_newParams => ', _newParams)
|
522
|
528
|
|
523
|
529
|
const _oldParams = JSON.parse(JSON.stringify(this.oldParams))
|
524
|
530
|
delete _oldParams.senders
|
525
|
531
|
delete _oldParams.gender
|
526
|
532
|
delete _oldParams.tag_list
|
527
|
533
|
delete _oldParams.exclude_tag_list
|
|
534
|
+ delete _oldParams.multiple_senders
|
|
535
|
+ console.log('_oldParams => ', _oldParams)
|
528
|
536
|
|
529
|
537
|
const isEqual = _lodash.isEqual(_newParams, _oldParams)
|
|
538
|
+ console.log('isEqual => ', isEqual)
|
530
|
539
|
if (!isEqual) { // “非多选”的属性不相同 => 直接返回结果
|
531
|
540
|
isSameParams = false
|
532
|
541
|
} else { // “非多选”的属性相同 => 比较"多选项"属性
|
533
|
|
- const { senders, gender, tag_list, exclude_tag_list } = newParams
|
534
|
|
- // 使用员工
|
535
|
|
- if (senders.length !== this.oldParams.senders.length) {
|
536
|
|
- isSameParams = false
|
537
|
|
- } else {
|
538
|
|
- const isNotSameS = senders.split(',').some(item => !this.oldParams.senders.includes(item))
|
539
|
|
- if (isNotSameS) {
|
|
542
|
+ const { senders, gender, tag_list, exclude_tag_list, operate_type, is_operation, multiple_senders } = newParams
|
|
543
|
+
|
|
544
|
+ if (operate_type == 1) { // 单企微模式
|
|
545
|
+ // 使用员工
|
|
546
|
+ if (senders.length !== this.oldParams.senders.length) {
|
540
|
547
|
isSameParams = false
|
|
548
|
+ } else {
|
|
549
|
+ const isNotSameS = senders.split(',').some(item => !this.oldParams.senders.includes(item))
|
|
550
|
+ if (isNotSameS) {
|
|
551
|
+ isSameParams = false
|
|
552
|
+ }
|
541
|
553
|
}
|
542
|
|
- }
|
543
|
554
|
|
544
|
|
- // 规则配置 => 性别
|
545
|
|
- if (gender.length !== this.oldParams.gender.length) {
|
546
|
|
- isSameParams = false
|
547
|
|
- } else {
|
548
|
|
- const isNotSameG = gender.split(',').some(item => !this.oldParams.gender.includes(item))
|
549
|
|
- if (isNotSameG) {
|
|
555
|
+ // 规则配置 => 标签
|
|
556
|
+ if (tag_list.length !== this.oldParams.tag_list.length) {
|
550
|
557
|
isSameParams = false
|
|
558
|
+ } else {
|
|
559
|
+ const isNotSameTG = tag_list.split(',').some(item => !this.oldParams.tag_list.includes(item))
|
|
560
|
+ if (isNotSameTG) {
|
|
561
|
+ isSameParams = false
|
|
562
|
+ }
|
|
563
|
+ }
|
|
564
|
+
|
|
565
|
+ // 规则配置 => 排除客户
|
|
566
|
+ if (exclude_tag_list.length !== this.oldParams.exclude_tag_list.length) {
|
|
567
|
+ isSameParams = false
|
|
568
|
+ } else {
|
|
569
|
+ const isNotSameETL = exclude_tag_list.split(',').some(item => !this.oldParams.exclude_tag_list.includes(item))
|
|
570
|
+ if (isNotSameETL) {
|
|
571
|
+ isSameParams = false
|
|
572
|
+ }
|
551
|
573
|
}
|
552
|
574
|
}
|
553
|
575
|
|
554
|
|
- // 规则配置 => 标签
|
555
|
|
- if (tag_list.length !== this.oldParams.tag_list.length) {
|
556
|
|
- isSameParams = false
|
557
|
|
- } else {
|
558
|
|
- const isNotSameTG = tag_list.split(',').some(item => !this.oldParams.tag_list.includes(item))
|
559
|
|
- if (isNotSameTG) {
|
|
576
|
+ if (operate_type == 2 && is_operation != 1) { // 多企微模式 - 使用员工
|
|
577
|
+ if (multiple_senders.length !== this.oldParams.multiple_senders.length) {
|
560
|
578
|
isSameParams = false
|
|
579
|
+ } else {
|
|
580
|
+ const multiple_senders = JSON.parse(newParams.multiple_senders)
|
|
581
|
+ const old_multiple_senders = JSON.parse(this.oldParams.multiple_senders)
|
|
582
|
+ console.log('multiple_senders => ', multiple_senders)
|
|
583
|
+ console.log('old_multiple_senders => ', old_multiple_senders)
|
|
584
|
+
|
|
585
|
+ // 判断企微主体是否相同
|
|
586
|
+ const corpids = multiple_senders.map(m => m.corpid)
|
|
587
|
+ const old_corpids = old_multiple_senders.map(m => m.corpid)
|
|
588
|
+ const isNotSameCorp = corpids.some(item => !old_corpids.includes(item))
|
|
589
|
+ if (isNotSameCorp) {
|
|
590
|
+ isSameParams = false
|
|
591
|
+ }
|
|
592
|
+
|
|
593
|
+ // 判断相同企微主体下的客服人员是否相同
|
|
594
|
+ multiple_senders.forEach(m => {
|
|
595
|
+ const new_user_list = m.user_list
|
|
596
|
+ const new_corpid = m.corpid
|
|
597
|
+ const old_corp = old_multiple_senders.find(o => o.corpid === new_corpid)
|
|
598
|
+ if (old_corp) {
|
|
599
|
+ const isNotSameUser = new_user_list.some(item => !old_corp.user_list.includes(item))
|
|
600
|
+ if (isNotSameUser) {
|
|
601
|
+ isSameParams = false
|
|
602
|
+ }
|
|
603
|
+ }
|
|
604
|
+ })
|
561
|
605
|
}
|
562
|
606
|
}
|
563
|
607
|
|
564
|
|
- // 规则配置 => 排除客户
|
565
|
|
- if (exclude_tag_list.length !== this.oldParams.exclude_tag_list.length) {
|
|
608
|
+ // 规则配置 => 性别
|
|
609
|
+ if (gender.length !== this.oldParams.gender.length) {
|
566
|
610
|
isSameParams = false
|
567
|
611
|
} else {
|
568
|
|
- const isNotSameETL = exclude_tag_list.split(',').some(item => !this.oldParams.exclude_tag_list.includes(item))
|
569
|
|
- if (isNotSameETL) {
|
|
612
|
+ const isNotSameG = gender.split(',').some(item => !this.oldParams.gender.includes(item))
|
|
613
|
+ if (isNotSameG) {
|
570
|
614
|
isSameParams = false
|
571
|
615
|
}
|
572
|
616
|
}
|