add.vue
17.1 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
<template>
<div class="scrm-sub-client-container">
<div class="container">
<div>
<!-- 基础信息 -->
<div class="title">基础信息</div>
<div class="info-box">
<div class="info-content">
<!-- <div class="tips-text">
<img src="@/assets/guestCustom/tips.png" class="tips-icon" alt />
<span>企业主体信息需要认证,才可使用该功能。</span>
</div> -->
<el-form :model="basicForm" :rules="basicRules" ref="basicForm" label-width="124px">
<el-form-item label="自定义群名" prop="groupName">
<el-input v-model.trim="basicForm.groupName" size="small" placeholder="为群聊设个自定义组名,如“VIP服务群”" maxlength="10"></el-input>
</el-form-item>
<el-form-item label="群聊命名规则" prop="groupNameRule">
<el-radio-group v-model="basicForm.groupNameRule" style="line-height: 40px; font-size: 14px; max-width: 600px;">
<el-radio v-for="(rule, index) in nameRules" :label="rule.id" :key="index">
{{ rule.rule }}
<span class="rule-tips">{{ rule.tips }}</span>
</el-radio>
</el-radio-group>
<!-- <div class="form-tips">群聊名称后缀将以日期及序号进行累加,如“新车售后一组211011-1群”</div> -->
</el-form-item>
<el-form-item prop="followList">
<label slot="label" class="required">跟进专员</label>
<el-button size="small" @click="openFollow">
<i class="el-icon-plus"></i>
选择跟进专员
</el-button>
<span class="label-text">
已选择
<span>{{ basicForm.followList ? basicForm.followList.length : 0 }}</span>
人
</span>
<div :key="followkey" class="sale-select" v-show="basicForm.followList.length">
<div class="el-input-tag input-tag-wrapper">
<div style="max-height: 64px">
<el-tag v-for="(tag, idx) in basicForm.followList" :key="idx" type="info" closable :disable-transitions="false" @close="removeFollow(idx)">
<!-- <i class="el-icon-user-solid"></i> -->
<img class="headPortrait" src="@/assets/headPortrait.png" />
{{ tag.staffName }}
</el-tag>
</div>
</div>
</div>
<!-- <div class="form-tips">必须配置至少1个跟进专员</div> -->
</el-form-item>
<el-form-item>
<label slot="label">默认成员</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 :key="key" class="sale-select" v-show="basicForm.userList.length">
<div class="el-input-tag input-tag-wrapper">
<div style="max-height: 64px">
<el-tag v-for="(tag, idx) in basicForm.userList" :key="idx" type="info" closable :disable-transitions="false" @close="remove(tag, idx)">
<!-- <i class="el-icon-user-solid"></i> -->
<img class="headPortrait" src="@/assets/headPortrait.png" />
{{ tag.staffName }}
</el-tag>
</div>
</div>
</div>
</el-form-item>
</el-form>
<!-- 编辑入群欢迎语 -->
<!-- <div class="title">编辑入群欢迎语</div> -->
<!-- <div>
<el-form :model="basicForm" label-width="120px">
<el-form-item label="入群欢迎语">
<WelcomeWords ref="welcome" :eventBus="eventBus"></WelcomeWords>
</el-form-item>
</el-form>
</div>-->
</div>
<!-- <div class="preview">
<Preview :eventBus="eventBus"></Preview>
</div>-->
</div>
</div>
</div>
<GLFooter>
<el-button @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleSubmit">确定</el-button>
</GLFooter>
<GLDialog :title="'选择成员'" :visible.sync="membersVisible">
<!-- <SelectMembers islord="false" :selectData="selectData" ref="membersForm"></SelectMembers> -->
<div style="width:100%;overflow:hidden">
<SelectMember ref="membersForm" v-if="membersVisible" :selectData="selectData" :followData="followData"></SelectMember>
</div>
<span slot="footer" class="dialog-footer">
<el-button plain size="small" class="btn-three" @click="membersVisible = false">取消</el-button>
<el-button type="primary" size="small" @click="handleConfirm">确定</el-button>
</span>
</GLDialog>
<!-- <SelectMember ref="membersForm"></SelectMember> -->
<select-follow @selectTable="selectTable" ref="selectEmpForm"></select-follow>
</div>
</template>
<script>
import Vue from 'vue'
// import WelcomeWords from './components/welcomeWords.vue'
import SelectMember from './components/selectMember.vue'
import SelectFollow from './components/selectFollow.vue'
// import Preview from './components/preview.vue'
export default {
name: 'guestGroupAdd',
components: {
// WelcomeWords,
SelectMember,
SelectFollow
// Preview
},
data() {
const validatorUser = (rule, value, callback) => {
const followList = this.basicForm.followList
let userList = []
if (this.basicForm.userList && this.basicForm.userList.length) {
userList = this.basicForm.followList.concat(this.basicForm.userList)
} else {
userList = this.basicForm.followList
}
if (!this.basicForm.followList.length) {
callback(new Error('请选择跟进专员'))
} else {
if (userList.length < 2) {
this.$message({
type: 'error',
message: '必须配置2个及以上成员'
})
// callback(new Error('必须配置2个及以上成员'))
} else {
callback()
}
}
}
// const nameVaild = (rule, value, callback) => {
//
// if (value) {
// const params = {
// templateName: value
// }
// let api = 'nameVaild'
// if (this.$route.params.id) {
// params.id = this.$route.params.id
// api = 'updateNameVaild'
// }
// this.$apis.groupGuest[api](params).then(res => {
// if (res) {
// callback(new Error('群聊名称不可重复'))
// } else {
// callback()
// }
// })
// }
// }
return {
eventBus: new Vue(),
basicForm: {
followList: [],
userList: [],
groupNameRule: 1
},
nameRules: [
{
rule: '车系+客户昵称+自定义群名',
tips: '(车系/客户昵称自动填充,例:“奥迪A6Carr_VIP服务群”)',
id: 1
},
{
rule: '车系+车牌号+自定义群名',
tips: '(车系/客户昵称自动填充,例:“日产轩逸粤B·1V566_VIP服务群”)',
id: 2
},
{
rule: '自定义群名',
id: 0
}
],
basicRules: {
groupName: [
{ required: true, message: '请输入群聊名称', trigger: 'change' }
// { validator: nameVaild, trigger: 'blur' }
],
groupNameRule: [{ required: true, message: '请选择群聊命名规则', trigger: 'change' }],
followList: [
// { required: true, message: '请选择默认成员', trigger: 'change' },
{ validator: validatorUser, trigger: 'change' }
]
},
membersVisible: false,
key: new Date(),
followkey: new Date(),
previewFlag: false,
selectData: [],
followData: [],
editStatus: false,
// 跟进专员
followVisible: false
}
},
beforeDestroy() {
this.$message.closeAll()
},
watch: {
basicForm: {
handler(val) {
this.editStatus = true
},
deep: true
}
// membersVisible(val) {
//
// if (!val) {
// this.$refs.membersForm.resetSearch()
// }
// }
},
mounted() {
this.wxTips()
if (this.$route.params) {
const id = this.$route.params.id
if (id != -1) this.getDetail(id)
}
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: {
wxTips() {
const menu = JSON.parse(sessionStorage['SCRM_BASE_MENULIST'])
menu.forEach(item => {
if (!item.children) {
return
}
item.children.forEach(itm => {
if (itm.path == '/enterpriseWechat/index') {
this.$apis.groupGuest.getStatus({}).then(res => {
if (res.status != 'SUCCESS') {
const h = this.$createElement
this.$message({
showClose: true,
duration: 0,
message: h('p', null, [h('span', null, '此功能需完成【企业微信授权】后方可使用! '), h('span', { on: { click: this.jumpWx }, style: { marginRight: '150px', cursor: 'pointer', color: '#5850ff' } }, ['企业微信授权 ', h('i', { class: 'el-icon-d-arrow-right' }, '')])])
})
}
})
}
})
})
},
jumpWx() {
this.$history.push('/settings/enterpriseWechat/index')
},
openMembers() {
this.membersVisible = !this.membersVisible
},
openFollow() {
const checkMember = this.basicForm.userList.length ? this.basicForm.userList.map(i => i.id) : []
this.$refs.selectEmpForm.init(this.basicForm.followList, checkMember)
},
handleSubmit() {
this.$refs.basicForm.validate(valid => {
if (valid) {
const params = {
groupName: this.basicForm.groupName,
groupNameRule: this.basicForm.groupNameRule
}
const followList = this.basicForm.followList.map(item => {
return {
staffId: item.staffId,
staffName: item.staffName,
follow: 1
}
})
let memberList = []
if (this.basicForm.userList && this.basicForm.userList.map.length) {
memberList = this.basicForm.userList.map(i => {
return {
staffId: i.staffId,
staffName: i.staffName,
follow: 0
}
})
}
params.userList = followList.concat(memberList)
let apiName = 'insert'
if (this.basicForm.id) {
apiName = 'update'
params.id = this.basicForm.id
}
this.$apis.groupGuest[apiName](params)
.then(res => {
if (res) {
this.$message({
type: 'success',
message: '操作成功!'
})
this.$router.push('/guestGroup/index')
} else {
this.$message({
type: 'error',
message: '操作失败'
})
}
})
.catch(err => {
this.$message({
type: 'error',
message: err.message
})
})
}
})
},
getDetail(id) {
this.$apis.groupGuest.detail({ id }).then(res => {
if (res) {
this.basicForm = {
groupName: res.groupName,
id: res.id,
groupNameRule: res.groupNameRule
// userList: res.userList
}
if (res.userList && res.userList.length) {
this.selectData = res.userList.filter(item => item.follow == 0)
this.basicForm.userList = this.selectData
this.basicForm.followList = res.userList.filter(item => item.follow == 1)
}
// this.selectData = res.userList
this.$nextTick(() => {
this.editStatus = false
})
}
})
},
handleCancel() {
if (this.editStatus) {
this.$confirm('当前有内容信息未保存,是否继续返回?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
customClass: 'gl-message-box',
type: 'warning'
})
.then(() => {
this.$router.push('/guestGroup/index')
})
.catch(() => {})
} else {
this.$router.push('/guestGroup/index')
}
},
remove(val, idx) {
if (this.$refs.membersForm) {
this.$refs.membersForm.remove(val)
this.$set(this.basicForm, 'userList', this.$refs.membersForm.innerTags)
this.key = new Date()
} else {
this.basicForm.userList.splice(idx, 1)
this.selectData = this.basicForm.userList
this.key = new Date()
}
},
// 成员弹窗
handleConfirm() {
// this.basicForm.userList = this.$refs.membersForm.innerTags
this.$set(this.basicForm, 'userList', this.$refs.membersForm.innerTags)
this.selectData = this.basicForm.userList
this.openMembers()
},
handleClose() {
this.membersVisible = false
},
selectTable(item) {
this.basicForm.followList = item.map(item => {
return {
staffId: item.id,
staffName: item.staffName
}
})
this.followData = this.basicForm.followList.map(i => i.staffId)
this.followkey = new Date()
},
removeFollow(idx) {
this.basicForm.followList.splice(idx, 1)
this.followData = this.basicForm.followList.map(i => i.staffId)
this.followkey = new Date()
}
}
}
</script>
<style lang="scss" scoped>
@import '@/styles/variables.scss';
.container {
margin-bottom: 20px;
background: #ffffff;
// padding: 20px;
.title {
padding: 20px 0 17px 20px;
font-size: 16px;
color: #333;
font-weight: 600;
border-bottom: 1px solid #d8d8d8;
&::after {
content: '';
}
}
.info-box {
display: inline-flex;
width: 100%;
padding-bottom: 30px;
// align-items: flex-end;
height: calc(100vh - 250px);
justify-content: space-between;
overflow-y: auto;
.info-content {
width: calc(100% - 360px);
// flex: 1;
}
}
.el-form {
padding: 32px 0 20px 24px;
/deep/.el-input {
width: 320px;
}
}
.form-tips {
font-size: 12px;
color: #999;
}
.preview {
margin-right: 24px;
}
}
.label-text {
margin-left: 10px;
font-size: 14px;
span {
color: $btnBlue;
}
}
.form-error {
color: #f56c6c;
font-size: 12px;
margin-left: 186px;
margin-top: 10px;
}
.sale-select {
display: flex;
align-items: center;
}
.input-tag-wrapper {
max-width: 320px;
// 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: 0 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;
line-height: 32px;
i {
color: #75acff;
margin-right: 3px;
font-size: 14px;
}
// // overflow: auto;
// /deep/ input {
// /* input { */
// /* background-color: red!important; 调试用的样式 */
// outline: none !important;
// border: none !important;
// }
// /deep/ .el-input {
// min-width: 150px;
// width: auto;
// flex: 1;
// }
}
.el-tag {
margin-right: 4px;
height: 26px;
line-height: 24px;
margin-bottom: 5px;
}
.tag-input {
background: transparent;
border: none !important;
font-size: 14px;
height: 32px;
outline: none;
padding-left: 0;
width: 100px;
}
/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;
}
}
.tips-text {
display: flex;
width: 616px;
align-items: center;
justify-self: center;
color: #000;
font-size: 14px;
padding: 13px 16px;
margin-top: 20px;
margin-left: 20px;
background-color: rgba(230, 233, 255, 0.49);
border: 1px solid rgba(88, 80, 255, 0.49);
border-radius: 4px;
.tips-icon {
width: 14px;
height: 14px;
margin-right: 8px;
}
}
.rule-tips {
font-size: 14px;
font-weight: 400;
color: #999999;
line-height: 14px;
}
.required:before {
margin-right: 5px;
}
</style>