qualityAnalyse.vue
15.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
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
<template>
<div
class="analyse"
v-loading="loading"
>
<el-tabs
v-model="activeName"
@tab-click="tabClick"
:data-track="JSON.stringify({
batchId:detailObj.id
})"
:data-event-code="tabsEventCode"
>
<el-tab-pane
label="质检明细"
name="first"
></el-tab-pane>
<el-tab-pane
label="攻防明细"
name="second"
></el-tab-pane>
<el-tab-pane
label="开口明细"
name="third"
></el-tab-pane>
</el-tabs>
<template v-if="activeName === 'first'">
<d2-search
ref="showSearch"
:search-form="searchForm"
:form-data="showFormData"
>
<div slot="firstClassify">
<el-select
v-model="searchForm.firstClassify"
clearable
placeholder="请选择"
@change="changeClassify"
>
<el-option
v-for="item in baseData.firstClassifyList"
:key="item"
:label="item"
:value="item"
>
</el-option>
</el-select>
</div>
<div slot="secondClassify">
<el-select
v-model="searchForm.secondClassify"
clearable
placeholder="请选择"
>
<el-option
v-for="item in baseData.secondClassifyList"
:key="item"
:label="item"
:value="item"
>
</el-option>
</el-select>
</div>
<template slot="score">
<el-input-range
start-placeholder="请输入"
end-placeholder="请输入"
:display-value="searchForm.qualityTestScore"
></el-input-range>
</template>
<div class="up-btns">
<el-button
@click="handleSearch"
size="small"
type="primary"
:data-track="JSON.stringify(searchForm)"
data-event-code="quality_inspection_search"
>
查询
</el-button>
<el-button
size="small"
@click="handleReset"
:data-track="JSON.stringify(searchForm)"
data-event-code="quality_inspection_search"
> 重置 </el-button>
</div>
</d2-search>
<div class="theader">
<div class="title">话术列表</div>
<el-radio-group
v-model="searchForm.hitResult"
size="small"
@input="radioReport"
>
<el-radio-button label="">全部</el-radio-button>
<el-radio-button label="1">命中</el-radio-button>
<el-radio-button label="0">未命中</el-radio-button>
</el-radio-group>
</div>
<d2-table
class="table-wrap"
ref="analyseTable"
:search-form="searchFormSearch"
:table-params="tableParams"
:before-search-fn="beforeSearchFn"
:hasPage="false"
:has-num="false"
:table-data="analyseList"
:array-span-method="arraySpanMethod"
noDataText="数据分析中,请稍等…"
:noDataImg="noDataImg"
height="100%"
@scroll="watchScrollTrack($event,'verbal_trick_list')"
>
<div
slot="scoreHtml"
slot-scope="scope"
>
<template v-if="scope.scope.score || scope.scope.score === 0">
{{ scope.scope.score }}
</template>
<template v-else>--</template>
</div>
<template
slot="suggestions"
slot-scope="scope"
>
<el-tooltip
v-if="scope.scope.suggestions"
effect="light"
placement="top"
>
<div
slot="content"
v-html="scope.scope.suggestions"
></div>
<div
class="two-line"
v-html="scope.scope.suggestions"
></div>
</el-tooltip>
<div v-else>--</div>
</template>
<template
slot="hitText"
slot-scope="scope"
>
<div v-if="!scope.scope.score">--</div>
<template v-else>
<el-tooltip
v-if="scope.scope.hitText"
effect="light"
placement="top"
>
<div
slot="content"
v-html="scope.scope.hitText"
></div>
<div
class="two-line"
v-html="scope.scope.hitText"
></div>
</el-tooltip>
<div v-else>--</div>
</template>
</template>
<template
slot="hitResult"
slot-scope="scope"
>
<div :class="['tag', scope.scope.hitResult == 1 ? 'gre' : 'red']">
{{ scope.scope.hitResult == 1 ? "是" : "否" }}
</div>
</template>
</d2-table>
</template>
<template v-else-if="activeName === 'second'">
<attack-detail :detailObj="detailObj" />
</template>
<template v-else>
<d2-table
class="table-wrap"
ref="analyseTable"
:table-params="openTableParams"
:hasPage="false"
:table-data="analyseOpen"
noDataText="暂无开口明细"
:noDataImg="noDataImg"
height="100%"
>
<div
slot="mentionedTime"
class="open-time"
slot-scope="scope"
@click="setAudioTime(scope.scope.mentionedTime)"
>
{{ scope.scope.mentionedTime }}
<img src="@/assets/open-time.png" />
</div>
<template
slot="mentionedContext"
slot-scope="scope"
>
<el-tooltip
v-if="scope.scope.mentionedContext"
effect="light"
placement="top"
>
<div slot="content">{{ scope.scope.mentionedContext }}</div>
<div class="one-line">{{ scope.scope.mentionedContext }}</div>
</el-tooltip>
<div v-else>--</div>
</template>
</d2-table>
</template>
</div>
</template>
<script>
import ElInputRange from "../el-input-range"
import { Util, deepClone } from "@/common/util"
import {
conversationCheckList,
getPointCategory,
findAxbByBatchId
} from "@api/resident"
import noDataImg from "@/assets/empty-2.png"
import AttackDetail from "./attackDetail"
import watchScrollTrackMixin from '@/mixins/watchScrollTrackMixin'
export default {
mixins: [watchScrollTrackMixin],
components: {
ElInputRange,
AttackDetail
},
props: {
detailObj: {
type: Object,
default: {}
}
},
data () {
return {
activeName: "first",
noDataImg,
analyseList: [],
analyseOpen: [],
spanArr1: [],
spanIndex1: 0,
searchForm: {
// firstClassify: "",
// secondClassify: "",
qualityTestScore: [],
hitResult: ""
},
searchFormSearch: {},
showFormData: [
// {
// label: "一级分类",
// name: "firstClassify",
// addHtml: "firstClassify"
// },
// {
// label: "二级分类",
// name: "secondClassify",
// addHtml: "secondClassify"
// },
{
label: "质检评分",
name: "qualityTestScore",
addHtml: "score"
}
],
select: "全部",
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: "list",
tableOption: false,
tableColumns: [
{
label: "一级分类",
prop: "firstClassify",
width: "120px"
},
{
label: "二级分类",
prop: "secondClassify",
width: "140px"
},
{
label: "质检评分",
prop: "score",
width: "100px",
addHtml: "scoreHtml"
},
{
label: "是否命中",
prop: "hitResult",
width: "100px",
addHtml: "hitResult"
},
{
label: "命中文本",
prop: "hitText",
addHtml: "hitText",
align: "left"
},
{
label: "话术建议",
prop: "suggestions",
addHtml: "suggestions",
align: "left"
}
]
},
openTableParams: {
tableOption: false,
tableColumns: [
{
label: "开口时间",
prop: "mentionedTime",
addHtml: "mentionedTime"
},
{
label: "开口类型",
prop: "mentionedType"
},
{
label: "开口内容",
prop: "mentionedContext",
addHtml: "mentionedContext"
}
]
},
baseData: {
firstClassifyList: [],
secondClassifyList: []
},
loading: true,
tabsEventCode: ''
}
},
watch: {
"searchForm.hitResult" () {
this.getList()
}
},
mounted () {
this.$refs.analyseTable.tableHeightValues = "100%"
// this.getPointCategory()
this.getList()
this.findAxbByBatchId()
},
methods: {
setAudioTime (val) {
const time = this.formatTime(val)
console.log(time)
this.$EventBus.$emit("setAudioTime", time)
},
formatTime (time) {
const arr = time.split(":")
let second =
arr.length == 3
? arr[0] * 60 * 60 + arr[1] * 60 + arr[2] * 1
: arr[0] * 60 + arr[1] * 1
return second
},
findAxbByBatchId () {
findAxbByBatchId({ batchId: this.detailObj.id }).then((res) => {
this.analyseOpen = res || []
})
},
async getList () {
this.loading = true
try {
await this.beforeSearchFn()
const { list } = await conversationCheckList(this.searchFormSearch)
let titleList = Array.from(
new Set([...list.map((e) => e.firstClassify)])
),
arr = []
titleList.map((i) => {
list.map((e) => {
e.suggestions = this.formatSrt(e.suggestions)
e.hitText = this.formatSrt(e.hitText)
if (i == e.firstClassify) arr.push(e)
})
})
console.log(arr)
this.analyseList = arr
this.merge(arr)
this.loading = false
} catch (error) {
console.log(error)
this.loading = false
}
},
formatSrt (str) {
return str?.replace(/\n/g, "<br/>") || ""
},
getPointCategory () {
this.classifyMap = new Map()
getPointCategory().then((res) => {
console.log(res)
this.baseData.firstClassifyList = Object.keys(res)
for (const item in res) {
this.classifyMap.set(item, res[item])
}
})
},
changeClassify () {
this.searchForm.secondClassify = ""
this.baseData.secondClassifyList = this.classifyMap.get(
this.searchForm.firstClassify
)
},
beforeSearchFn () {
return new Promise((resolve) => {
this.searchFormSearch = deepClone(this.searchForm)
this.searchFormSearch.batchId = this.detailObj.id
this.searchFormSearch.pageSize = 99999
if (this.searchFormSearch.qualityTestScore) {
this.searchFormSearch.qualityTestScoreBegin =
this.searchFormSearch.qualityTestScore[0]
this.searchFormSearch.qualityTestScoreEnd =
this.searchFormSearch.qualityTestScore[1]
}
delete this.searchFormSearch.qualityTestScore
resolve()
})
},
handleSearch () {
this.getList()
},
handleReset () {
this.searchForm = {
// firstClassify: "",
// secondClassify: "",
qualityTestScore: [],
hitResult: ""
}
this.baseData.secondClassifyList = []
this.getList()
},
// 初始化合并行数组
mergeInit () {
this.spanArr1 = [] //
this.spanIndex1 = 0 //
},
// 合并表格
merge (data) {
this.mergeInit()
if (data.length > 0) {
for (var i = 0; i < data.length; i++) {
if (i === 0) {
// 第一行必须存在,以第一行为基准
this.spanArr1.push(1)
this.spanIndex1 = 0
} else {
if (data[i].firstClassify == data[i - 1].firstClassify) {
this.spanArr1[this.spanIndex1] += 1
this.spanArr1.push(0)
} else {
this.spanArr1.push(1)
this.spanIndex1 = i
}
}
}
}
},
// 合并单元格
arraySpanMethod ({ row, column, rowIndex, columnIndex }) {
const len = this.analyseList.length
if (columnIndex === 0) {
// 第一列
const _row_1 = this.spanArr1[rowIndex]
const _col_1 = _row_1 > 0 ? 1 : 0
return {
rowspan: _row_1,
colspan: _col_1
}
} else if (rowIndex === len) {
return {
rowspan: 1,
colspan: 1
}
}
},
tabClick (e) {
let { index } = e
this.tabsEventCode = ['quality_inspection_detail', 'offense_and_defense_detail', 'safety_bag'][index]
},
radioReport (e) {
console.log(e)
let eventCode = {
1: 'hit',
0: 'miss'
}[e]
if (eventCode) this.setReportTrackData(0, eventCode, JSON.stringify({
batchId: this.detailObj.id
}))
}
}
}
</script>
<style lang="scss" scoped>
.analyse {
background-color: #fff;
padding: 20px;
height: 100%;
box-sizing: border-box;
::v-deep.d2-search-block {
display: flex;
align-items: flex-start;
padding: 0;
.item-height {
float: none;
width: fit-content;
.el-form-item {
width: 100%;
}
.el-form-item__content {
width: 200px;
}
}
}
::v-deep.cell {
padding: 10px 7px;
}
.d2-table {
height: calc(100% - 97px);
::v-deep.el-table__empty-block {
.el-table__empty-text {
height: 100%;
box-sizing: border-box;
padding-top: 96px;
}
}
}
.theader {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
padding-top: 6px;
.title {
font-size: 16px;
color: #333333;
font-weight: 600;
}
}
.table-wrap {
height: calc(100% - 150px);
// overflow-y: auto;
}
.up-btns {
padding: 0;
width: fit-content;
display: flex;
}
.tag {
width: 30px;
height: 24px;
border-radius: 2px;
padding: 0 8px;
line-height: 24px;
box-sizing: border-box;
font-size: 14px;
margin: 0 auto;
}
.gre {
color: #2cca74;
background: #e9f9f1;
}
.red {
color: #eb4e4e;
background: #fdeded;
}
}
::v-deep.two-line {
display: -webkit-box;
-webkit-box-orient: vertical;
word-break: break-all;
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.open-time {
cursor: pointer;
img {
width: 16px;
height: 16px;
vertical-align: middle;
}
}
.one-line {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>