detail.vue
15.4 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
<template>
<div>
<div class="expert-detail">
<div class="header">
<span class="title">基础信息</span>
<span class="tip">该配置页面用于配置「精品升级」小程序质保卡客户拉新,配置订单类型后,客户扫码质保卡活码即可添加员工企微号。</span>
</div>
<div class="detail-wrap">
<glsx-combi-form class="form" ref="form" :formRules="basicRule" labelWidth="154px" defaultWidth="432px" :formObj="basicForm" :formData="basicFormData">
<div slot="staffSlot">
<span v-if="selectPerson.staffName" class="tag-info">
<i class="el-icon-user-solid person"></i>
<span class="client name">{{ selectPerson.staffName }}</span>
<i class="el-icon-close del" @click="delPerson"></i>
</span>
<el-button class="checkNumber" v-else size="small" icon="el-icon-plus" @click="openMembers">
选择成员
</el-button>
<span v-if="selectPerson.departmentName" class="depart-name">{{ selectPerson.departmentName }}</span>
</div>
<div slot="welcomeSlot">
<GLEditor ref="welcome" :form="'customer'" :btnList="btnList" @previewWord="previewForm"></GLEditor>
<div class="tips-text">
<p>当「精品升级」小程序提交升级订单时,</p>
<p>
客户扫描订单质保码添加
<span style="color:#409eff">{{ ' ' }}{{ selectPerson.staffName || '待选择' }}</span>
,
</p>
<p>客户添加成功自动推送欢迎语,建议插入质保链接。</p>
</div>
</div>
</glsx-combi-form>
</div>
<glsx-dialog mode="big" bigTitle="选择成员" btnSize="small" :isVisible="membersVisible" @confirmDialog="handleConfirm" @closeDialog="membersVisible = !membersVisible">
<SelectMember ref="membersForm" v-if="membersVisible" :selectData="selectData"></SelectMember>
</glsx-dialog>
</div>
<div class="operate-btn flex_cc">
<el-button style="background-color:transparent" @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleSave">提交</el-button>
</div>
</div>
</template>
<script>
const ATT_TYPE = {
TEXT: 1,
IMAGE: 2,
VEDIO: 3,
URL: 4,
MINIPROGRAM: 5,
FILE: 6,
ACTIVITY: 7,
MATERIAL: 10
}
import Vue from 'vue'
import emoji from '@/util/emo'
import WelcomeWords from './components/welcomeWords.vue'
import SelectMember from './components/selectMember.vue'
import glsxDialog from '@/components/glsx-dialog/index.vue'
import glsxCombiForm from '@/components/glsx-combi-form'
import { pictureUpload } from '@/api/modules/common'
import util from '@/util/util'
export default {
name: 'expert_detail',
components: {
WelcomeWords,
SelectMember,
glsxDialog,
glsxCombiForm
},
data() {
return {
btnList: [
{
name: '表情',
funcName: '',
type: 'expression',
limitSize: 10
},
{
name: '图片',
funcName: '',
type: 'img',
togetherItem: [ATT_TYPE.TEXT], //只允许文本和图片
// limitPx: 1000
// limitSize: 10, //限制图片大小
// limitNum: 2, //限制图片数量
// limitWidth: 10000, //限制单张图片宽度
// limitHeight: 10000,//限制单张图片高度
// Isdraggable: true, //图片拖拽
uploadApi: pictureUpload
},
{
name: '昵称',
type: 'nickname',
funName: 'nickname'
},
{
name: '活动',
type: 'activity',
funName: 'activity',
togetherItem: [ATT_TYPE.TEXT, ATT_TYPE.FILE],
funParams: [
{
itemName: '权益卡试用',
itemValue: 3,
itemType: 'card',
getInterfaceApi: this.$apis.welcomeword.getCard,
params: {
tryAble: 1,
merchantId: this.$globalState.session.merchantId
}
},
{
itemName: '权益套餐',
itemValue: 4,
itemType: 'package',
getInterfaceApi: this.$apis.welcomeword.getPackage,
params: {}
},
{
itemName: '商城券',
itemValue: 2,
itemType: 'coupon',
getInterfaceApi: this.$apis.welcomeword.getMerchant,
params: {
discountTypes: [2, 3, 4],
directionalFlag: 1, // 1所有人可用2定向礼包专用3关联优惠券
validType: 'valid'
}
},
{
itemName: '秒杀活动',
itemValue: 5,
itemType: 'activity',
getInterfaceApi: this.$apis.welcomeword.getActivity,
params: {
activityStatus: 2,
currentPage: 1
}
},
{
itemName: '无忧服务',
itemValue: 6,
itemType: 'merchant',
getInterfaceApi: this.$apis.welcomeword.merchant,
merchantOpen: {
merchantOpenApi: this.$apis.welcomeword.merchantOpen,
params: {
merchantId: this.$globalState.session.merchantId
}
},
params: {
merchantId: this.$globalState.session.merchantId
}
}
]
},
{
name: '插入质保链接',
type: 'link',
funName: 'link',
text: '车主朋友,您好!<br>我是您的福利官,欢迎您领取电子质保卡,<br>请点击下方链接进行领取及查看:<br><span style="color:#409eff;">https://dj.glsx.com.cn/dj-car-boutique-work-wechat/#/</span><br>祝您用车愉快!<br>'
}
// {
// name: '插入推荐频道',
// type: 'channelLink',
// funName: 'channelLink',
// getMerchantList: this.$apis.welcomeword.getMerchantList,
// channelPreview: this.$apis.welcomeword.channelPreview
// }
],
size: 'small',
eventBus: new Vue(),
expertId: '',
merchantId: '',
routeInfo: {},
expertTypeList: [],
basicRule: {
businessType: [{ required: true, message: '请选择客户类型', trigger: 'change' }],
staffId: [{ required: true, message: '请选择指定成员', trigger: 'change' }],
expertType: [{ required: true, message: '请选择专家类型', trigger: 'change' }]
},
membersVisible: false,
selectData: [],
basicForm: {
businessType: 1,
staffId: '',
expertType: 1,
staffUserId: ''
},
selectPerson: {},
numberTypeList: [],
basicFormData: [
{
label: '专家类型',
name: 'expertType',
type: 'select',
optionList: [],
optionId: 'dictValue',
optionLabel: 'dictLabel',
isClear: true
},
{
label: '客户类型',
name: 'businessType',
type: 'select',
optionList: [],
optionId: 'dictValue',
optionLabel: 'dictLabel',
isClear: true,
isDisabled: false
},
{
label: '指定成员',
name: 'staffId',
addHtml: 'staffSlot'
},
{
label: '欢迎语',
name: '',
addHtml: 'welcomeSlot'
}
]
}
},
watch: {
'basicForm.businessType': {
handler(nVal) {
console.log(nVal)
if (nVal && nVal != 1) {
this.btnList = this.btnList.filter(item => item.type != 'link')
}
},
immediate: true
},
selectPerson: {
handler(val) {
console.log(val)
this.basicForm.staffId = val.staffId || ''
this.basicForm.staffUserId = val.userId || ''
},
deep: true
}
},
created() {
if (util.isShowBtn(null, '插入推荐频道')) {
this.btnList.push({
name: '插入推荐频道',
type: 'channelLink',
funName: 'channelLink',
getMerchantList: this.$apis.welcomeword.findMerchantListByPage,
channelPreview: this.$apis.welcomeword.channelPreview
})
}
},
mounted() {
const urlParam = this.$route.params
this.routeInfo = JSON.parse(urlParam.id)
if (this.routeInfo.expertId) {
this.getDetail(this.routeInfo.expertId)
let target = this.basicFormData.find(item => item.name === 'businessType')
target.isDisabled = true
}
this.getTypeList()
},
methods: {
getTypeList() {
this.$apis.expert.getMenberType({ dictType: 'operation_type' }).then(res => {
if (res) {
this.numberTypeList = res
let target = this.basicFormData.find(item => item.name === 'businessType')
target.optionList = res
}
})
this.$apis.expert.getMenberType({ dictType: 'expert_type' }).then(res => {
if (res) {
this.expertTypeList = res
let target = this.basicFormData.find(item => item.name === 'expertType')
target.optionList = res
}
})
},
getDetail(id) {
this.$apis.expert.expertDetail({ id }).then(res => {
if (res?.id) {
this.selectPerson = res
// this.$refs.welcome.setDetail(res.welcomeInfo)
if (res.welcomeInfo.length != 0) {
const previewList = res.welcomeInfo.map(item => {
if (item.attType == 7) item.attContent = JSON.parse(item.attContent)
return item
})
this.$refs.welcome.updateList(previewList)
}
this.basicForm.businessType = res.businessType
this.basicForm.expertType = res.expertType
this.merchantId = res.merchantId
}
})
},
delPerson() {
this.selectPerson = {}
this.merchantId = ''
},
// 成员弹窗
handleConfirm() {
let selectPerson = this.$refs.membersForm.activeName == 1 ? this.$refs.membersForm.selectPerson : this.$refs.membersForm.otherPersonal
if (selectPerson) {
this.selectPerson = { ...selectPerson }
if (this.$refs.membersForm.activeName == 2) {
this.selectPerson.staffId = selectPerson.id
}
this.merchantId = this.$refs.membersForm.activeName == 2 ? selectPerson.merchantId : ''
this.openMembers()
} else {
this.$message({
type: 'error',
message: '请选择成员'
})
}
},
openMembers() {
this.membersVisible = !this.membersVisible
},
edit() {
this.$apis.expert.editExpert().then(res => {
if (res) {
this.$router.push({
path: '/expert/index'
})
}
})
},
handleSave() {
this.$refs.form.$refs.formRef.validate(valid => {
if (valid) {
let preList = [...this.$refs.welcome.previewList]
preList.forEach(item => {
if (item.attType == 1 && !item.attContent.trim()) {
item.attContent = '\n' //欢迎语textArea为空时传换行符
} else if (item.attType == 1) {
item.attContent = item.attContent.replaceAll('@昵称', '[@昵称]')
}
if (item.attType == 7 || item.attType == 5) {
item.attContent = JSON.stringify(item.attContent)
}
})
const typeItem = preList.find(item => {
return item.attType == 1
})
if (!typeItem) {
preList.unshift({ attType: '1', attContent: '\n' }) //欢迎语textArea为空时传换行符
}
// const targetItem = this.numberTypeList.find(item => {
// return item.dictLabel == this.clientType
// })
// let params = {
// businessType: targetItem.dictValue,
// staffId: this.selectPerson.staffId,
// // welcomeInfo: this.$refs.welcome.previewList
// welcomeInfo: preList
// }
let params = { ...this.basicForm }
params.welcomeInfo = preList
if (this.merchantId) params.merchant = this.merchantId
console.log(params, 'params')
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)'
})
let API = this.routeInfo.expertId ? this.$apis.expert.editExpert : this.$apis.expert.saveExpert
if (this.routeInfo.expertId) {
params.id = this.routeInfo.expertId
params.businessUuid = this.routeInfo.businessUuid
params.configId = this.routeInfo.configId
}
API(params).then(res => {
loading.close()
if (res) {
this.$message({
type: 'success',
message: '提交成功'
})
this.$router.push({
path: '/expert/index'
})
}
})
}
})
},
handleCancel() {
this.$router.push({
path: '/expert/index'
})
}
}
}
</script>
<style lang="scss" scoped>
.operate-btn {
margin-top: 16px;
}
.expert-detail {
background-color: #fff;
min-height: calc(100vh - 144px);
/deep/ .checkNumber {
padding: 8px 12px;
& > span {
margin-left: 4px;
}
}
.numberDialog {
/deep/ .el-dialog__header {
height: 56px;
padding: 0 20px;
line-height: 56px;
font-size: 18px;
font-weight: 600;
color: #000000;
.el-dialog__headerbtn {
top: 17px;
}
}
/deep/ .el-dialog__body {
padding-top: 0;
}
/deep/ .el-dialog__footer > div {
display: flex;
flex-direction: row-reverse;
.el-button:first-child {
margin-left: 16px;
}
}
}
.header {
height: 56px;
font-size: 16px;
color: #333;
font-weight: 600;
border-bottom: 1px solid #d8d8d8;
line-height: 56px;
padding: 0 24px;
.tip {
font-size: 14px;
font-weight: 400;
color: #999999;
line-height: 20px;
margin-left: 8px;
}
}
.detail-wrap {
padding: 32px 20px;
min-height: 520px;
.client {
color: #333;
}
.tag-info {
display: inline-block;
border: 1px solid #e8e8ea !important;
border-radius: 4px;
min-width: 78px;
padding: 0 8px;
height: 28px;
line-height: 28px;
text-align: center;
.name {
margin: 0 5px;
}
.person {
color: #75acff;
}
.del {
cursor: pointer;
}
}
.depart-name {
font-size: 14px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
line-height: 20px;
margin-left: 8px;
}
.form {
/deep/.el-form-item {
display: block;
margin-bottom: 20px;
& > .el-form-item__label {
padding: 0;
font-size: 14px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #333;
}
}
}
.tips-text {
margin-top: 8px;
font-size: 14px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #999999;
line-height: 24px;
}
}
}
</style>