addCustomer.vue
27.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
<template>
<div class>
<div class="container">
<div>
<!-- 基础信息 -->
<div class="title">基础信息</div>
<div class="info-box">
<div class="info-content">
<el-form
class="basic-form"
:model="basicForm"
:rules="basicRules"
ref="basicForm"
label-width="120px"
>
<el-form-item prop="userList">
<label slot="label" class="required">选择群发账号</label>
<el-button size="small" @click="openMembers">
<i class="el-icon-plus"></i>
选择成员
</el-button>
<!-- <span class="label-text">
已选择
<span>{{ basicForm.userList ? basicForm.userList.length : 0 }}</span>
人
</span>-->
<div
class="sale-select"
v-show="basicForm.userList && basicForm.userList.length != 0"
>
<div :key="key" class="el-input-tag input-tag-wrapper">
<el-tag
effect="plain"
type="info"
v-for="(tag, idx) in basicForm.userList"
:key="idx"
closable
:disable-transitions="false"
@close="remove(tag)"
>
<i class="el-icon-user-solid"></i>
{{ tag.staffName }}
</el-tag>
</div>
<!-- <div :key="key" class="el-input-tag input-tag-wrapper">
<el-tag
v-for="(tag, idx) in basicForm.userList"
:key="idx"
:size="size"
closable
:disable-transitions="false"
@close="remove(tag)"
>{{ tag.staffName }}</el-tag>
<el-input size="small" style="outline: none; border: none"></el-input>
</div>-->
</div>
</el-form-item>
<el-form-item label="选择客户" prop="selectType">
<el-radio-group v-model="basicForm.selectType" @change="radioChange">
<el-radio :label="1">全部客户</el-radio>
<el-radio :label="2">筛选客户</el-radio>
</el-radio-group>
<div class="filter-box" v-show="basicForm.selectType == 2">
<div class="filter-memeber">
<el-form :model="basicForm.condition" label-width="120px">
<el-form-item label="性别">
<el-radio-group v-model="basicForm.condition.sex" @change="valueChange">
<el-radio label>全部</el-radio>
<el-radio :label="1">男性</el-radio>
<el-radio :label="2">女性</el-radio>
<el-radio :label="0">未知性别</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="所在群聊">
<el-select
v-model="basicForm.condition.chat"
@change="valueChange"
@focus="groupFocus"
:size="size"
value-key="id"
multiple
collapse-tags
placeholder="请选择"
>
<el-option
v-for="item in groupList"
:key="item.id"
:label="item.groupName"
:value="item"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="添加客户时间">
<el-date-picker
v-model="basicForm.condition.date"
@change="valueChange"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
:size="size"
style="width: 320px;"
></el-date-picker>
</el-form-item>
<!-- <el-form-item label="标签筛选">
<el-button size="small" @click="openLabel">
<i class="el-icon-plus"></i>
标签筛选
</el-button>
<div
v-show="tagging.length != 0"
:key="key"
class="el-input-tag input-tag-wrapper"
>
<el-tag
v-for="(tag, idx) in tagging"
:key="idx"
:size="size"
type="info"
closable
:disable-transitions="false"
@close="removeTag(tag, idx)"
>{{ tag.name }}</el-tag>
</div>
<div class="sale-select" v-show="basicForm.condition.labelList">
<div :key="key" class="el-input-tag input-tag-wrapper">
<el-tag
v-for="(tag, idx) in basicForm.condition.labelList"
:key="idx"
:size="size"
type="info"
closable
:disable-transitions="false"
@close="remove(tag)"
>{{ tag.staffName }}</el-tag>
<el-input size="small" style="outline: none; border: none"></el-input>
</div>
</div>
</el-form-item>-->
</el-form>
</div>
</div>
<div class="filter-footer">
<!-- <span>将消息发送给客户符合条件的客户</span> -->
<div class="filter-number">
查看预计群发人数
<span v-show="isUpdate" @click="viewMembers">查看</span>
<span v-show="!isUpdate">{{groupNumber}}</span>
</div>
</div>
</el-form-item>
</el-form>
<!-- 编辑入群欢迎语 -->
<div class="title">编辑群发内容</div>
<div class="group-content">
<el-form :model="basicForm" :rules="basicRules" ref="groupForm" label-width="120px">
<el-form-item prop="attachmentList">
<label slot="label" class="required">群发内容</label>
<WelcomeWords
ref="welcome"
:form="'customer'"
:btnList="btnList"
:eventBus="eventBus"
></WelcomeWords>
</el-form-item>
<el-form-item label="发送时间" prop="sendType">
<el-radio-group v-model="basicForm.sendType">
<el-radio :label="1">立即发送</el-radio>
<el-radio :label="2">定时发送</el-radio>
</el-radio-group>
<div v-show="basicForm.sendType == 2" class="date-picker">
<el-date-picker
v-model="basicForm.sendTime"
size="small"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择日期"
:picker-options="dateOptions"
@change="changeValue"
></el-date-picker>-
<el-time-picker
v-model="basicForm.sendDate"
size="small"
value-format="HH:mm:ss"
placeholder="选择时间"
:picker-options="timeOptions"
></el-time-picker>
</div>
</el-form-item>
</el-form>
</div>
</div>
<div class="preview">
<Preview :eventBus="eventBus"></Preview>
</div>
</div>
</div>
<glsx-dialog
:title="'选择成员'"
:width="'712px'"
:isVisible="membersVisible"
@confirmDialog="handleConfirm"
@closeDialog="membersVisible = !membersVisible"
>
<SelectMembers islord="false" :selectData="selectData" ref="membersForm"></SelectMembers>
</glsx-dialog>
</div>
<div
class="footer-panel"
:style="{
left: footerLeft + 'px',
width: footerWidth + 'px'
}"
>
<el-button type="primary" v-loading="addLoading" @click="handleSubmit">确定</el-button>
<el-button @click="handleCancel">取消</el-button>
</div>
<SelectLabel ref="selectLabel" @tagSelected="handleSelect" :dialogVisible="dialogVisible"></SelectLabel>
</div>
</template>
<script>
import Vue from 'vue'
import WelcomeWords from './components/welcomeWords.vue'
import SelectMembers from './components/selectMembers.vue'
import Preview from './components/preview.vue'
import SelectLabel from './components/selectLabel.vue'
import * as dayjs from 'dayjs'
export default {
components: {
WelcomeWords,
SelectMembers,
Preview,
SelectLabel
},
data() {
const validatorUser = (rule, value, callback) => {
const userList = this.basicForm.userList
if (userList && userList.length != 0) {
callback()
} else {
callback(new Error('请选择默认成员'))
}
}
const validatorAttachment = (rule, value, callback) => {
const previewList = this.$refs.welcome.previewList
if (previewList.length != 0) {
this.basicForm.attachmentList = previewList
}
if (this.basicForm.attachmentList) {
if (this.basicForm.attachmentList.length > 9) {
callback(new Error('附件不可超过9个'))
} else {
callback()
}
} else {
callback(new Error('请输入群发内容'))
}
}
const validatorSendType = (rule, value, callback) => {
if (value) {
if (value == 2) {
if (!this.basicForm.sendTime) {
callback(new Error('请选择日期'))
}
if (!this.basicForm.sendDate) {
callback(new Error('请选择时间'))
}
if (this.basicForm.sendTime && this.basicForm.sendDate) {
callback()
}
} else {
callback()
}
}
}
return {
addLoading: false,
eventBus: new Vue(),
btnList: [
{
id: 1,
name: '表情',
funcName: '',
type: 'expression',
limitSize: 10
},
{
id: 2,
name: '图片',
funcName: '',
type: 'img',
limitSize: 10
},
// {
// id: 3,
// name: '昵称',
// type: 'nickname',
// funName: 'nickname'
// },
{
id: 4,
name: '活动',
type: 'acivity',
funName: 'activity'
}
],
basicForm: {
selectType: 1,
condition: {
sex: '',
chat: []
}
},
basicRules: {
userList: [
// { required: true, message: '请选择群发账号', trigger: 'blur' },
{ validator: validatorUser, trigger: 'change' }
],
selectType: [{ required: true, message: '请选择客户类型', trigger: 'change' }],
attachmentList: [
// { required: true, message: '请输入入群欢迎语' },
{ validator: validatorAttachment, trigger: 'change' }
],
sendType: [
{ required: true, message: '请选择发送时间', trigger: 'change' },
{ validator: validatorSendType, trigger: 'change' }
]
},
membersVisible: false,
groupList: [],
key: new Date(),
dialogVisible: false,
previewFlag: false,
selectData: [],
// 是否有修改筛选成员
isUpdate: true,
tagging: [],
groupNumber: 0,
dateOptions: {
disabledDate(time) {
let now = new Date()
now.setTime(now.getTime() - 3600 * 1000 * 24)
return time.getTime() < now
}
},
timeOptions: {
selectableRange: '00:00:00 - 23:59:59'
},
editStatus: false,
firstFlag: true
}
},
watch: {
basicForm: {
handler(val) {
if (this.firstFlag) {
this.firstFlag = false
} else {
this.editStatus = true
}
},
deep: true
}
},
mounted() {
let clientHeight = document.documentElement.clientHeight
this.footerLeft = document.querySelector('.base-container-right').offsetLeft
this.footerWidth = document.documentElement.clientWidth - this.footerLeft
this.boxHeight = clientHeight - 200
},
methods: {
openMembers() {
this.membersVisible = !this.membersVisible
},
handleCancel() {
if (this.editStatus || this.$refs.welcome.previewList.length > 0) {
this.$confirm('当前有内容信息未保存,是否继续返回?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.$router.push('/customerTransform/index')
})
.catch(() => {})
} else {
this.$router.push('/customerTransform/index')
}
},
// 成员弹窗
handleConfirm() {
if (this.$refs.membersForm.innerTags.length != 0) {
this.basicForm.userList = this.$refs.membersForm.innerTags
this.openMembers()
this.isUpdate = true
this.editStatus = true
} else {
this.$message({
type: 'error',
message: '请选择成员'
})
}
},
remove(val) {
this.$refs.membersForm.remove(val)
this.$set(this.basicForm, 'userList', this.$refs.membersForm.innerTags)
this.key = new Date()
this.isUpdate = true
},
openLabel() {
this.dialogVisible = !this.dialogVisible
this.$refs.selectLabel.init()
},
handleSubmit() {
this.$refs.basicForm.validate(valid => {
if (valid) {
this.$refs.groupForm.validate(v => {
if (v) {
const params = this.getSiftMembers()
params.type = 1
if (this.basicForm.condition.chat.length && this.basicForm.condition.chat.length > 100) {
this.$message({
type: 'error',
message: '所在群聊不可超过100个'
})
return false
}
// params.attachmentList = this.basicForm.attachmentList
params.sendType = this.basicForm.sendType
const previewList = this.$common ? this.$common.utils.deepClone(this.$refs.welcome.previewList) : this.$refs.welcome.previewList
const attachmentList = previewList.map(item => {
if (item.attType == 1) {
const list = [
'微笑',
'撇嘴',
'色',
'发呆',
'得意',
'流泪',
'害羞',
'闭嘴',
'睡',
'大哭',
'尴尬',
'发怒',
'调皮',
'呲牙',
'惊讶',
'难过',
'酷',
'冷汗',
'抓狂',
'吐',
'偷笑',
'可爱',
'白眼',
'傲慢',
'饥饿',
'困',
'惊恐',
'流汗',
'憨笑',
'大兵',
'奋斗',
'咒骂',
'疑问',
'嘘',
'晕',
'折磨',
'衰',
'骷髅',
'敲打',
'再见',
'擦汗',
'抠鼻',
'鼓掌',
'糗大了',
'坏笑',
'左哼哼',
'右哼哼',
'哈欠',
'鄙视',
'委屈',
'快哭了',
'阴险',
'亲亲',
'吓',
'可怜',
'菜刀',
'西瓜',
'啤酒',
'篮球',
'乒乓',
'咖啡',
'饭',
'猪头',
'玫瑰',
'凋谢',
'示爱',
'爱心',
'心碎',
'蛋糕',
'闪电',
'炸弹',
'刀',
'足球',
'瓢虫',
'便便',
'月亮',
'太阳',
'礼物',
'拥抱',
'强',
'弱',
'握手',
'胜利',
'抱拳',
'勾引',
'拳头',
'差劲',
'爱你',
'NO',
'OK',
'爱情',
'飞吻',
'跳跳',
'发抖',
'怄火',
'转圈',
'磕头',
'回头',
'跳绳',
'挥手',
'激动',
'街舞',
'献吻',
'左太极',
'右太极'
]
const cutImg = item.attContent.replaceAll('<img src="https://res.wx.qq.com/mpres/htmledition/images/icon/emotion/', '')
const replaceImg = cutImg.replace(/(\d){1,2}.gif">/g, function(str) {
let s = list[str.split('.')[0]]
return `[${s}]`
})
item.attContent = replaceImg.substring(0, 600)
// item.attContent = item.attContent.replaceAll('@昵称', '[@昵称]')
} else if (item.attType == 7) {
item.attContent = JSON.stringify(item.attContent)
}
return item
})
params.attachmentList = attachmentList
// const params = {
// type: 1,
// attachmentList: this.basicForm.attachmentList,
// selectType: this.basicForm.selectType,
// sendType: this.basicForm.sendType
// }
// params.userList = this.basicForm.userList.map(item => {
// return {
// staffId: item.staffId,
// staffName: item.staffName
// }
// })
if (params.sendType == 2) {
params.sendTimeStr = this.basicForm.sendTime + ' ' + this.basicForm.sendDate
}
this.addLoading = true
this.$apis.customerTransform.insert(params).then(res => {
if (res.code == '-1') {
this.$message({
type: 'error',
message: res.message
})
} else if (res.code == 0) {
this.$message({
type: 'success',
message: '操作成功!'
})
} else {
this.$message({
type: 'error',
message: res.message
})
}
this.addLoading = false
this.$router.push('/customerTransform/index')
})
}
})
}
})
},
handleSelect(val) {
this.isUpdate = true
const arr = []
if (val.length != 0) {
val.forEach(item => {
if (item.labelList.length != 0) {
item.labelList.map(i => arr.push(i))
}
// arr.push(item.labelList)
})
}
this.tagging = arr
},
// 删除标签
removeTag(item, idx) {
this.tagging.splice(idx, 1)
this.isUpdate = true
// this.$refs.selectLabel.init(this.tagging)
},
valueChange(val) {
this.isUpdate = true
},
getGroupList() {
if (this.basicForm.userList && this.basicForm.userList.length != 0) {
const staffIds = this.basicForm.userList.map(item => item.staffId)
this.$apis.customerTransform.groupList({ staffIds }).then(res => {
this.groupList = res
})
} else {
this.$message({
type: 'error',
message: '请选择群发账号'
})
}
},
getSiftMembers() {
const chatFlag = this.basicForm.condition.chat && this.basicForm.condition.chat.length
const tagFlag = this.tagging && this.tagging.length
const params = {
selectType: this.basicForm.selectType,
condition: {
sex: this.basicForm.condition.sex,
chatId: chatFlag ? this.basicForm.condition.chat.map(item => item.id).join(',') : '',
chatName: chatFlag ? this.basicForm.condition.chat.map(item => item.groupName).join(',') : '',
tagId: tagFlag ? this.tagging.map(item => item.id).join(',') : '',
tagName: tagFlag ? this.tagging.map(item => item.name).join(',') : ''
// tagId: JSON.stringify(this.tagging)
}
}
if (this.basicForm.condition.date) {
params.condition.sTime = dayjs(this.basicForm.condition.date[0]).format('YYYY-MM-DD')
params.condition.eTime = dayjs(this.basicForm.condition.date[1]).format('YYYY-MM-DD')
}
params.userList = this.basicForm.userList.map(item => {
return {
staffId: item.staffId,
staffName: item.staffName
}
})
return params
},
// 查看群发人数
viewMembers() {
if (!this.basicForm.userList || this.basicForm.userList.length == 0) {
this.$message({
type: 'error',
message: '请选择群发账号'
})
return
}
const params = this.getSiftMembers()
this.$apis.customerTransform
.customerCount(params)
.then(res => {
// if (res) {
this.groupNumber = res
// }
this.isUpdate = false
})
.catch(err => {
this.groupNumber = 0
})
},
// 选择客户change事件
radioChange(val) {
this.isUpdate = true
this.basicForm.condition = {
sex: ''
}
},
// 发送时间change事件
changeValue(v) {
const date = new Date(v).getTime()
if (date < Date.now()) {
this.timeOptions = {
selectableRange: `${dayjs()
.add(1, 'm')
.format('HH:mm')}:00 - 23:59:59`
}
} else {
this.timeOptions = {
selectableRange: '00:00:00 - 23:59:59'
}
}
},
// 点击所在群聊
groupFocus() {
if (this.basicForm.condition && this.basicForm.condition.chatId) {
this.basicForm.condition.chat = {}
this.groupList = []
this.isUpdate = true
}
this.getGroupList()
}
}
}
</script>
<style lang="scss" scoped>
.container {
margin-bottom: 84px;
background: #ffffff;
box-shadow: 0 10px 20px 0 rgba(88, 80, 255, 0.1);
// padding: 20px;
.title {
padding: 20px 0 17px 20px;
font-size: 16px;
color: #333;
font-weight: 600;
border-bottom: 1px solid #d8d8d8;
}
.info-box {
display: inline-flex;
width: 100%;
padding-bottom: 30px;
align-items: flex-end;
justify-content: space-between;
.info-content {
width: calc(100% - 360px);
.filter-box {
// margin-left: 120px;
margin-bottom: 10px;
min-width: 656px;
background-color: #f7f7f7;
.filter-memeber {
padding: 20px 0;
// border-bottom: 1px solid #dcdfe6;
.el-form {
padding: 0;
}
}
}
.filter-footer {
display: flex;
// padding: 14px 20px;
justify-content: space-between;
align-items: center;
color: #999;
font-size: 14px;
.filter-number {
display: inline-block;
line-height: 20px;
padding: 7px 14px;
background-color: #e6e9ff;
color: #333;
span {
color: #5850ff;
cursor: pointer;
}
}
}
.basic-form {
padding: 32px 0 20px 20px;
/deep/.el-input {
width: 320px;
}
}
}
}
.form-tips {
font-size: 12px;
color: #999;
}
.preview {
margin-right: 24px;
margin-bottom: 100px;
}
}
.footer-panel {
display: flex;
align-items: center;
justify-content: center;
position: fixed;
bottom: 0px;
height: 64px;
width: 100%;
background: #ffffff;
box-shadow: 0px -1px 1px 0px rgba(88, 80, 255, 0.1);
}
.label-text {
margin-left: 10px;
font-size: 14px;
span {
color: #5850ff;
}
}
.sale-select {
display: flex;
align-items: center;
}
.input-tag-wrapper {
max-height: 68px;
overflow: auto;
position: relative;
font-size: 14px;
background-color: #fff;
background-image: none;
border-radius: 4px;
border: 1px solid #dcdfe6;
box-sizing: border-box;
color: #666;
display: inline-block;
outline: none;
padding: 5px 5px 0px 5px;
flex-wrap: wrap;
transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
width: 450px;
display: flex;
align-items: center;
margin-top: 6px;
font-size: 14px;
i {
color: #75acff;
margin-right: 3px;
font-size: 14px;
}
}
.el-tag {
margin-right: 4px;
height: 26px;
line-height: 24px;
margin-bottom: 5px;
// background: #fff !important;
}
.tag-input {
background: transparent;
border: none !important;
font-size: 14px;
height: 32px;
outline: none;
padding-left: 0;
width: 100px;
}
.form-error {
color: #f56c6c;
font-size: 12px;
margin-left: 186px;
margin-top: 10px;
}
/deep/ {
.el-form-item .el-form-item {
margin-bottom: 22px;
}
.required {
display: inline-block;
line-height: 40px;
}
.required::before {
content: '*';
color: #f56c6c;
margin-right: 4 px;
}
.el-loading-spinner {
transform: translateY(8px);
}
}
.group-content {
padding: 22px 0 20px 20px;
}
</style>