index.vue
12 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
<template>
<d2-container class="customer-tags">
<div
class="header"
slot="header"
>
<d2-search
ref="showSearch"
class="show-search"
:search-form="searchForm"
:label-width="'100px'"
:form-data="showFormData"
>
</d2-search>
<div class="up-btns">
<el-button
size="small"
type="primary"
@click="handleSearch"
>
查询
</el-button>
<el-button
size="small"
@click="handleReset"
>
重置
</el-button>
</div>
</div>
<div class="d2-container-content">
<div class="static-box">
<template v-for="(i,index) in staticList">
<div
:key="index"
class="static-item"
>
<div class="static-title">{{i.title}}</div>
<template v-if="i.formatter">
<div
class="static-value"
:style="{color:i.color}"
v-html="i.formatter(staticData)"
></div>
</template>
<template v-else>
<div
class="static-value"
:style="{color:i.color}"
>
{{staticData[i.key] || 0}}
</div>
</template>
</div>
</template>
</div>
<d2-table-header title="档案列表">
<el-button
size="small"
type="primary"
@click="exportTable"
>
导出
</el-button>
</d2-table-header>
<d2-table
ref="table"
:get-list-api="getListApi"
:search-form="searchFormSearch"
:table-params="tableParams"
:before-search-fn="beforeSearchFn"
>
<template
slot="customerTagName"
slot-scope="scope"
>
<template v-if="scope.scope.customerVisitsLabelInfoDTOList && scope.scope.customerVisitsLabelInfoDTOList.length > 1">
<div class="tag-item">
<span class="tag">{{ customerTagName(scope.scope.customerVisitsLabelInfoDTOList) }}</span>
<el-popover
placement="top"
width="fit-content"
trigger="hover"
>
<div class="tags-popover">
{{ customerTagName(scope.scope.customerVisitsLabelInfoDTOList) }}
</div>
<span
class="more-info"
slot="reference"
>({{ scope.scope.customerVisitsLabelInfoDTOList.length }})</span>
</el-popover>
</div>
</template>
<template v-else>
<span>{{ scope.scope.customerTagName || '-' }}</span>
</template>
</template>
<template
slot="auth-button"
slot-scope="scope"
>
<el-button
type="text"
@click="jumpDetail(scope.scope)"
>
话术管理
</el-button>
</template>
</d2-table>
</div>
</d2-container>
</template>
<script type='text/ecmascript-6'>
import { Util, deepClone } from '@/common/util'
import { SCENE_OPTIONS } from "../constant"
import { getCustomerFilePage, exportCustomerFile, getCustomerFileStatic } from '@api/contentManager'
import noDataImg from "@/assets/empty.png"
import dayjs from "dayjs"
import { listShop4sByRef } from "@api/merchant"
export default {
name: 'customerFile',
data () {
return {
noDataImg,
classifyVisible: false,
searchForm: {
bussinessScene: '',
merchantId: '',
scriptMatching: '',
receptionist: '',
solutionBrowsing: '',
searchdate:[new Date(),new Date()]
},
searchFormSearch: {},
currentItem: {},
showFormData: [{
label: '业务类型',
name: 'bussinessScene',
type: 'select',
optionList: deepClone([{
id: "",
label: "全部"
}, ...SCENE_OPTIONS]),
optionId: "id",
optionLabel: "label"
}, {
label: "归属门店",
name: "merchantId",
type: "select",
maxlength: 50,
optionList: [
{
merchantName: '全部',
merchantId: ''
}
],
optionId: "merchantId",
optionLabel: "merchantName",
}, {
label: '话术匹配',
name: 'scriptMatching',
type: 'select',
optionList: [
{
label: "全部",
id: ""
},
{
label: "是",
id: "1"
},
{
label: "否",
id: "0"
}
],
optionId: "id",
optionLabel: "label"
}, {
label: '销售姓名',
name: 'receptionist',
type: 'input',
isClear: true,
maxlength: 20
}, {
label: '方案浏览',
name: 'solutionBrowsing',
type: 'select',
optionList: [
{
label: "全部",
id: ""
},
{
label: "是",
id: "1"
},
{
label: "否",
id: "0"
}
],
optionId: "id",
optionLabel: "label"
}, {
label: "创建日期",
name: "searchdate",
type: "datePicker",
isClear: false,
pickerOptions: "rangePickerOptions"
}],
getListApi: getCustomerFilePage,
// 表格参数
tableParams: {
listName: 'list',
tableOption: {
width: '100'
},
tableColumns: [
{
label: '门店名称',
prop: 'merchantName',
minWidth: 260,
}, {
label: '业务类型',
minWidth: 144,
prop: 'bussinessSceneName'
}, {
label: '销售姓名',
prop: 'receptionist',
}, {
label: '客户姓名',
prop: 'ownerName',
minWidth: 140
},
{
label: '品牌车型',
prop: 'brandModel',
minWidth: 140
},
{
label: '接待场景',
prop: 'receptionSceneName',
}, {
label: '话术匹配',
formatter: (cellValue) => {
return cellValue.scriptMatchingCount || 0
},
},
{
label: '方案浏览',
formatter: (cellValue) => {
return cellValue.solutionBrowsingCount || 0
},
}, {
label: '客户标签',
minWidth: 270,
addHtml: "customerTagName",
}, {
label: '创建时间',
formatter: (cellValue) => {
return cellValue.createdDate ? Util.dateFormate(cellValue.createdDate, 'YYYY-MM-DD HH:mm:ss') : '-'
},
minWidth: 180
}
]
},
staticList: [
{
title: '新增档案数',
key: 'visitCount',
color: '#2A58AD'
},
{
title: '已适配话术档案数',
key: 'scriptMatchingCount',
color: '#27CD5A'
},
{
title: '营销话术浏览次数',
key: 'solutionBrowsingCount',
color: '#F47F13'
},
{
title: '营销话术浏览时长',
color: '#2A58AD',
formatter (cell) {
const secondsToMinutesAndSeconds = (seconds) => {
const minutes = Math.floor(seconds / 60),
remainingSeconds = seconds % 60
let str = ''
if (minutes > 0) str += `${minutes}<div class="static-unit">分钟</div>`
return str += `${remainingSeconds}<div class="static-unit">秒</div>`
}
return cell.solutionBrowsingDurationCount ? secondsToMinutesAndSeconds(cell.solutionBrowsingDurationCount) : '0<div class="static-unit">秒</div>'
}
// unit: '分钟'
}
],
staticData: {}
}
},
created () {
},
mounted () {
this.getServiceStore()
this.getCustomerFileStatic()
},
methods: {
beforeSearchFn (type = 1) {
return new Promise((resolve, reject) => {
this.searchFormSearch = deepClone(this.searchForm)
if (this.searchForm?.searchdate?.length) {
let [searchStartDate, searchEndDate] = this.searchForm.searchdate
this.searchFormSearch.startTime = Util.dateFormate(
searchStartDate,
"YYYY-MM-DD"
)
this.searchFormSearch.endTime = Util.dateFormate(
searchEndDate,
"YYYY-MM-DD"
)
const date1 = dayjs(searchStartDate),
date2 = dayjs(searchEndDate),
day = date2.diff(date1, "day") + 1
if (day > 30) {
reject(`${type == 1 ? "查询" : "导出"}的时间跨度最大为30天,请重新选择日期范围`)
}
}
delete this.searchFormSearch.searchdate
resolve()
})
},
handleSearch () {
this.page = this.$options.data.call(this).page
this.$refs.table.refreshTable(true, true)
this.getCustomerFileStatic()
},
handleReset () {
this.searchForm = this.$options.data.call(this).searchForm
this.handleSearch()
},
async exportTable () {
try {
await this.beforeSearchFn()
const res = await exportCustomerFile({
...this.searchFormSearch
})
console.log(res)
if (res) window.open(res)
} catch (error) {
if (error) this.$message.error(error)
}
},
customerTagName (list) {
let tag = []
list.map(e => {
tag.push(e.labelName)
})
return tag.join('|')
},
getServiceStore () {
listShop4sByRef({}).then((res) => {
res ||= []
this.showFormData.forEach((item, index) => {
if (item.type === "select" && item.name == 'merchantId') {
this.$set(
this.showFormData[index],
"optionList",
[{
merchantName: '全部',
merchantId: ''
}, ...res]
)
}
})
})
},
async getCustomerFileStatic () {
try {
await this.beforeSearchFn()
const res = await getCustomerFileStatic({
...this.searchFormSearch
})
console.log(res)
this.staticData = res || {}
} catch (error) {
if (error) this.$message.error(error)
}
},
jumpDetail (row) {
this.$router.push({
name: "customerFileDetails",
query: {
id: row.id,
receptionSceneName: row.receptionSceneName,
receptionScene: row.receptionScene,
scene: row.bussinessScene
}
})
}
}
}
</script>
<style scoped lang='scss'>
.emptyBg {
display: flex;
flex-direction: column;
align-items: center;
padding: 120px 0;
.noDataImg {
width: 64px;
height: 40px;
}
}
.error-input {
::v-deep.el-input__inner {
border-color: red;
}
}
.tag-item {
display: flex;
align-items: center;
padding: 0 10px;
justify-content: center;
.tag {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.more-info {
white-space: nowrap;
color: #2a58ad;
cursor: pointer;
margin-left: 2px;
}
}
::v-deep.tags-popover {
max-width: 50vw;
}
.static-box {
display: flex;
gap: 0 16px;
margin-bottom: 12px;
.static-item {
flex: 1;
flex-shrink: 0;
height: 82px;
background: #f8faff;
border-radius: 5px;
box-sizing: border-box;
padding: 16px 20px;
.static-title {
font-size: 14px;
color: #333333;
line-height: 20px;
margin-bottom: 4px;
}
.static-value {
display: flex;
font-weight: 700;
font-size: 24px;
line-height: 30px;
align-items: baseline;
::v-deep.static-unit {
font-weight: 600;
font-size: 14px;
margin:0 2px;
}
}
}
}
</style>