QualityTable.vue
4.13 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
<template>
<div class="quality-table-box">
<div class="title">话术标签</div>
<div class="tag-box" ref="tagBox">
<div class="tag-item" v-for="item in tagList" :key="item.tagId">
{{ item.tagGroupName }} - {{ item.tagName }}
</div>
</div>
<div class="title">质检明细</div>
<div class="quality-table">
<div class="quality-content">
<el-table
:data="processedQualityList"
border
style="width: 100%"
:height="tableHeight"
:max-height="tableHeight">
<el-table-column type="index" label="序号" align="center" width="80">
</el-table-column>
<el-table-column prop="tagGroupName" label="一级分类" align="center" width="120">
</el-table-column>
<el-table-column label="质检得分" align="center" width="100">
<template slot-scope="scope">
{{ scope.row.score }}/{{ scope.row.sumScore }}
</template>
</el-table-column>
<el-table-column prop="processedScriptRec" label="命中文本" align="center">
<template slot-scope="scope">
<template v-if="scope.row.processedScriptRec">
<el-tooltip placement="top" effect="light" popper-class="quality-tooltip">
<div slot="content" v-html="scope.row.processedScriptRec"></div>
<div class="text-ellipsis" v-html="scope.row.processedScriptRec"></div>
</el-tooltip>
</template>
<template v-else>
<div class="text-ellipsis">暂无命中文本</div>
</template>
</template>
</el-table-column>
</el-table>
</div>
</div>
</div>
</template>
<script type='text/ecmascript-6'>
import {getRecordTagList, getQualityList} from '@/api/resident'
export default {
props: ['batchId', 'qualityData'],
data() {
return {
qualityList: [],
tagList: [],
tableHeight: 430
}
},
computed: {
processedQualityList() {
return this.qualityData.map(item => {
let hitTextArr = ''
try {
hitTextArr = JSON.parse(item.hitText);
} catch (e) {
hitTextArr = '';
}
return {
...item,
processedScriptRec: (hitTextArr && hitTextArr.length)
? hitTextArr.map(text => text.replace(/\n/g, '<br>')).join('')
: ''
}
})
}
},
mounted() {
this.getRecordTagList()
this.calculateTableHeight()
// this.getQualityList()
},
methods: {
async getRecordTagList() {
this.tagList = await getRecordTagList({
batchId: this.batchId
})
this.$nextTick(() => {
this.calculateTableHeight()
})
},
calculateTableHeight() {
// 获取屏幕高度
const screenHeight = window.innerHeight
// 获取话术标签box的高度
const tagBoxHeight = this.$refs.tagBox ? this.$refs.tagBox.offsetHeight : 0
// 其他固定元素的高度(标题、间距等)
const otherHeight = 260 // 标题高度 + 间距
// 计算表格高度 = 屏幕高度 - 话术标签box高度 - 其他固定元素高度
this.tableHeight = screenHeight - tagBoxHeight - otherHeight
},
// async getQualityList() {
// this.qualityList = await getQualityList({
// batchId: this.batchId
// })
// }
}
}
</script>
<style scoped lang='scss'>
.quality-table-box {
font-size: 16px;
color: #1D1D1D;
.title {
font-size: 16px;
color: #1D1D1D;
font-weight: 500;
margin-bottom: 10px;
}
.tag-box {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-bottom: 20px;
.tag-item {
padding: 8px 12px;
border-radius: 4px;
background-color: #EAEEF7;
border: 1px solid #2A58AD;
color: #333;
font-size: 14px;
}
}
}
.text-ellipsis {
text-align: left;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
/* 定义文本的行数 */
overflow: hidden;
text-overflow: ellipsis;
}
</style>
<style lang="scss">
.quality-tooltip {
width: 640px !important;
}
</style>