|
|
@@ -0,0 +1,817 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <view class="qa-analysis mobile-section">
|
|
|
3
|
+ <!-- 抽问抽答标题 -->
|
|
|
4
|
+ <view class="section-title">
|
|
|
5
|
+ <text class="title-text">抽问抽答</text>
|
|
|
6
|
+ </view>
|
|
|
7
|
+
|
|
|
8
|
+ <!-- 三个横向均分的内容区域 -->
|
|
|
9
|
+ <view class="three-panel-layout">
|
|
|
10
|
+ <!-- 第一个:答题完成趋势 -->
|
|
|
11
|
+ <view class="panel-item">
|
|
|
12
|
+ <view class="panel-header">
|
|
|
13
|
+ <text class="header-text">答题完成趋势</text>
|
|
|
14
|
+ </view>
|
|
|
15
|
+
|
|
|
16
|
+ <!-- 描述卡片 -->
|
|
|
17
|
+ <view class="describe-card">
|
|
|
18
|
+ <view class="describe-content">
|
|
|
19
|
+ {{ completionTrendDescription }}
|
|
|
20
|
+ </view>
|
|
|
21
|
+ </view>
|
|
|
22
|
+
|
|
|
23
|
+ <!-- 折线图 -->
|
|
|
24
|
+ <view class="chart-container">
|
|
|
25
|
+ <view ref="completionTrendChartRef" class="echarts-chart"></view>
|
|
|
26
|
+ </view>
|
|
|
27
|
+ </view>
|
|
|
28
|
+
|
|
|
29
|
+ <!-- 第二个:错题分布 -->
|
|
|
30
|
+ <view class="panel-item">
|
|
|
31
|
+ <view class="panel-header">
|
|
|
32
|
+ <text class="header-text">错题分布</text>
|
|
|
33
|
+ </view>
|
|
|
34
|
+
|
|
|
35
|
+ <!-- 描述卡片 -->
|
|
|
36
|
+ <view class="describe-card">
|
|
|
37
|
+ <view class="describe-content">
|
|
|
38
|
+ {{ errorDistributionDescription }}
|
|
|
39
|
+ </view>
|
|
|
40
|
+ </view>
|
|
|
41
|
+
|
|
|
42
|
+ <!-- 饼图 -->
|
|
|
43
|
+ <view class="chart-container">
|
|
|
44
|
+ <view ref="errorDistributionChartRef" class="echarts-chart"></view>
|
|
|
45
|
+ </view>
|
|
|
46
|
+ </view>
|
|
|
47
|
+
|
|
|
48
|
+ <!-- 第三个:各科错题分布对比 -->
|
|
|
49
|
+ <view class="panel-item" v-show="isStationType">
|
|
|
50
|
+ <view class="panel-header">
|
|
|
51
|
+ <text class="header-text">各科错题分布对比</text>
|
|
|
52
|
+ </view>
|
|
|
53
|
+
|
|
|
54
|
+ <!-- 描述卡片 -->
|
|
|
55
|
+ <view class="describe-card">
|
|
|
56
|
+ <view class="describe-content">
|
|
|
57
|
+ {{ departmentComparisonDescription }}
|
|
|
58
|
+ </view>
|
|
|
59
|
+ </view>
|
|
|
60
|
+
|
|
|
61
|
+ <!-- 雷达图 -->
|
|
|
62
|
+ <view class="chart-container">
|
|
|
63
|
+ <view ref="departmentComparisonChartRef" class="echarts-chart"></view>
|
|
|
64
|
+ </view>
|
|
|
65
|
+ </view>
|
|
|
66
|
+ </view>
|
|
|
67
|
+ </view>
|
|
|
68
|
+</template>
|
|
|
69
|
+
|
|
|
70
|
+<script>
|
|
|
71
|
+import * as echarts from 'echarts'
|
|
|
72
|
+import { getCompletionTrend, getWrongAnalysisOverview, getWrongAnalysisRadar } from '@/api/qualityControlAnalysisReport/qualityControlAnalysisReport'
|
|
|
73
|
+
|
|
|
74
|
+export default {
|
|
|
75
|
+ name: 'QaAnalysis',
|
|
|
76
|
+ props: {
|
|
|
77
|
+ queryForm: {
|
|
|
78
|
+ type: Object,
|
|
|
79
|
+ default: () => ({})
|
|
|
80
|
+ }
|
|
|
81
|
+ },
|
|
|
82
|
+ data() {
|
|
|
83
|
+ return {
|
|
|
84
|
+ completionTrendDescription: '',
|
|
|
85
|
+ errorDistributionDescription: '',
|
|
|
86
|
+ departmentComparisonDescription: '',
|
|
|
87
|
+ loading: false,
|
|
|
88
|
+ completionTrendChart: null,
|
|
|
89
|
+ errorDistributionChart: null,
|
|
|
90
|
+ departmentComparisonChart: null
|
|
|
91
|
+ }
|
|
|
92
|
+ },
|
|
|
93
|
+
|
|
|
94
|
+ computed: {
|
|
|
95
|
+ // 计算属性:检查是否为STATION类型
|
|
|
96
|
+ isStationType() {
|
|
|
97
|
+ const roles = this.$store.state?.user?.roles || []
|
|
|
98
|
+
|
|
|
99
|
+
|
|
|
100
|
+ return roles.includes('zhijianke') || roles.includes('test')
|
|
|
101
|
+ }
|
|
|
102
|
+ },
|
|
|
103
|
+
|
|
|
104
|
+ mounted() {
|
|
|
105
|
+ this.loadData()
|
|
|
106
|
+ this.$nextTick(() => {
|
|
|
107
|
+ this.initCharts()
|
|
|
108
|
+ })
|
|
|
109
|
+ },
|
|
|
110
|
+
|
|
|
111
|
+ beforeDestroy() {
|
|
|
112
|
+ this.disposeCharts()
|
|
|
113
|
+ },
|
|
|
114
|
+
|
|
|
115
|
+ watch: {
|
|
|
116
|
+ queryForm: {
|
|
|
117
|
+ handler() {
|
|
|
118
|
+ this.loadData()
|
|
|
119
|
+ },
|
|
|
120
|
+ deep: true
|
|
|
121
|
+ },
|
|
|
122
|
+
|
|
|
123
|
+ },
|
|
|
124
|
+
|
|
|
125
|
+ methods: {
|
|
|
126
|
+ // 初始化图表
|
|
|
127
|
+ initCharts() {
|
|
|
128
|
+ // 答题完成趋势折线图
|
|
|
129
|
+ if (this.$refs.completionTrendChartRef) {
|
|
|
130
|
+ this.initCompletionTrendChart()
|
|
|
131
|
+ }
|
|
|
132
|
+
|
|
|
133
|
+ // 错题分布饼图
|
|
|
134
|
+ if (this.$refs.errorDistributionChartRef) {
|
|
|
135
|
+ this.initErrorDistributionChart()
|
|
|
136
|
+ }
|
|
|
137
|
+
|
|
|
138
|
+ // 各科错题分布对比雷达图
|
|
|
139
|
+ if (this.$refs.departmentComparisonChartRef) {
|
|
|
140
|
+ this.initDepartmentComparisonChart()
|
|
|
141
|
+ }
|
|
|
142
|
+ },
|
|
|
143
|
+
|
|
|
144
|
+ // 初始化答题完成趋势折线图
|
|
|
145
|
+ initCompletionTrendChart() {
|
|
|
146
|
+ const completionTrendOptions = {
|
|
|
147
|
+ tooltip: {
|
|
|
148
|
+ trigger: 'axis'
|
|
|
149
|
+ },
|
|
|
150
|
+ legend: {
|
|
|
151
|
+ data: []
|
|
|
152
|
+ },
|
|
|
153
|
+ grid: {
|
|
|
154
|
+ left: '10%',
|
|
|
155
|
+ right: '8%',
|
|
|
156
|
+ top: '45%',
|
|
|
157
|
+ bottom: '10%',
|
|
|
158
|
+ // containLabel: true
|
|
|
159
|
+ },
|
|
|
160
|
+ xAxis: {
|
|
|
161
|
+ type: 'category',
|
|
|
162
|
+ boundaryGap: false,
|
|
|
163
|
+ data: []
|
|
|
164
|
+ },
|
|
|
165
|
+ yAxis: {
|
|
|
166
|
+ type: 'value'
|
|
|
167
|
+ },
|
|
|
168
|
+ series: []
|
|
|
169
|
+ }
|
|
|
170
|
+
|
|
|
171
|
+ this.completionTrendChart = this.createEChartsInstance(this.$refs.completionTrendChartRef, completionTrendOptions)
|
|
|
172
|
+ },
|
|
|
173
|
+
|
|
|
174
|
+ // 初始化错题分布饼图
|
|
|
175
|
+ initErrorDistributionChart() {
|
|
|
176
|
+ const errorDistributionOptions = {
|
|
|
177
|
+ tooltip: {
|
|
|
178
|
+ trigger: 'item',
|
|
|
179
|
+ formatter: '{a} <br/>{b}: {c} ({d}%)'
|
|
|
180
|
+ },
|
|
|
181
|
+ legend: {
|
|
|
182
|
+ orient: 'horizontal',
|
|
|
183
|
+
|
|
|
184
|
+ top: 0
|
|
|
185
|
+ },
|
|
|
186
|
+ series: [
|
|
|
187
|
+ {
|
|
|
188
|
+ name: '错题分布',
|
|
|
189
|
+ type: 'pie',
|
|
|
190
|
+ radius: ['40%', '70%'],
|
|
|
191
|
+ avoidLabelOverlap: false,
|
|
|
192
|
+ itemStyle: {
|
|
|
193
|
+ borderRadius: 10,
|
|
|
194
|
+ borderColor: '#fff',
|
|
|
195
|
+ borderWidth: 2
|
|
|
196
|
+ },
|
|
|
197
|
+ emphasis: {
|
|
|
198
|
+ label: {
|
|
|
199
|
+ show: true,
|
|
|
200
|
+ fontSize: 12,
|
|
|
201
|
+ fontWeight: 'bold'
|
|
|
202
|
+ }
|
|
|
203
|
+ },
|
|
|
204
|
+ label: {
|
|
|
205
|
+ show: true,
|
|
|
206
|
+ formatter: '{b}\n{c} ({d}%)',
|
|
|
207
|
+ fontSize: 12,
|
|
|
208
|
+ fontWeight: 'normal'
|
|
|
209
|
+ },
|
|
|
210
|
+ labelLine: {
|
|
|
211
|
+ show: true,
|
|
|
212
|
+ length: 10,
|
|
|
213
|
+ length2: 20
|
|
|
214
|
+ },
|
|
|
215
|
+ data: []
|
|
|
216
|
+ }
|
|
|
217
|
+ ]
|
|
|
218
|
+ }
|
|
|
219
|
+
|
|
|
220
|
+ this.errorDistributionChart = this.createEChartsInstance(this.$refs.errorDistributionChartRef, errorDistributionOptions)
|
|
|
221
|
+ },
|
|
|
222
|
+
|
|
|
223
|
+ // 初始化各科错题分布对比雷达图
|
|
|
224
|
+ initDepartmentComparisonChart() {
|
|
|
225
|
+ const departmentComparisonOptions = {
|
|
|
226
|
+ tooltip: {
|
|
|
227
|
+ trigger: 'item'
|
|
|
228
|
+ },
|
|
|
229
|
+ legend: {
|
|
|
230
|
+ show: true,
|
|
|
231
|
+ orient: 'horizontal',
|
|
|
232
|
+ top: 0
|
|
|
233
|
+ },
|
|
|
234
|
+ // grid: {
|
|
|
235
|
+
|
|
|
236
|
+
|
|
|
237
|
+ // top: '30%',
|
|
|
238
|
+
|
|
|
239
|
+
|
|
|
240
|
+ // },
|
|
|
241
|
+ radar: {
|
|
|
242
|
+ indicator: [],
|
|
|
243
|
+ radius: '50%', // 缩小雷达图半径
|
|
|
244
|
+ center: ['50%', '65%'] // 调整雷达图位置
|
|
|
245
|
+ },
|
|
|
246
|
+ series: [
|
|
|
247
|
+ {
|
|
|
248
|
+ type: 'radar',
|
|
|
249
|
+ data: [],
|
|
|
250
|
+ areaStyle: {}
|
|
|
251
|
+ }
|
|
|
252
|
+ ]
|
|
|
253
|
+ }
|
|
|
254
|
+
|
|
|
255
|
+ this.departmentComparisonChart = this.createEChartsInstance(this.$refs.departmentComparisonChartRef, departmentComparisonOptions)
|
|
|
256
|
+ },
|
|
|
257
|
+
|
|
|
258
|
+ // 创建ECharts实例(适配uni-app环境)
|
|
|
259
|
+ createEChartsInstance(chartRef, options) {
|
|
|
260
|
+ if (!chartRef) return null
|
|
|
261
|
+
|
|
|
262
|
+ // 获取DOM元素
|
|
|
263
|
+ const chartDom = chartRef.$el || chartRef
|
|
|
264
|
+ if (!chartDom) return null
|
|
|
265
|
+
|
|
|
266
|
+ // 创建ECharts实例
|
|
|
267
|
+ const chartInstance = echarts.init(chartDom)
|
|
|
268
|
+
|
|
|
269
|
+ // 设置初始选项
|
|
|
270
|
+ if (options) {
|
|
|
271
|
+ chartInstance.setOption(options)
|
|
|
272
|
+ }
|
|
|
273
|
+
|
|
|
274
|
+ return chartInstance
|
|
|
275
|
+ },
|
|
|
276
|
+
|
|
|
277
|
+ // 销毁图表
|
|
|
278
|
+ disposeCharts() {
|
|
|
279
|
+ if (this.completionTrendChart) {
|
|
|
280
|
+ this.completionTrendChart.dispose()
|
|
|
281
|
+ this.completionTrendChart = null
|
|
|
282
|
+ }
|
|
|
283
|
+ if (this.errorDistributionChart) {
|
|
|
284
|
+ this.errorDistributionChart.dispose()
|
|
|
285
|
+ this.errorDistributionChart = null
|
|
|
286
|
+ }
|
|
|
287
|
+ if (this.departmentComparisonChart) {
|
|
|
288
|
+ this.departmentComparisonChart.dispose()
|
|
|
289
|
+ this.departmentComparisonChart = null
|
|
|
290
|
+ }
|
|
|
291
|
+ },
|
|
|
292
|
+
|
|
|
293
|
+ // 加载数据
|
|
|
294
|
+ async loadData() {
|
|
|
295
|
+ if (this.loading) return
|
|
|
296
|
+
|
|
|
297
|
+ this.loading = true
|
|
|
298
|
+ try {
|
|
|
299
|
+ // 检查是否为站类型
|
|
|
300
|
+ this.checkStationType()
|
|
|
301
|
+
|
|
|
302
|
+ // 加载答题完成趋势数据
|
|
|
303
|
+ await this.fetchCompletionTrendData()
|
|
|
304
|
+
|
|
|
305
|
+ // 加载错题分布数据
|
|
|
306
|
+ await this.fetchWrongAnalysisOverviewData()
|
|
|
307
|
+
|
|
|
308
|
+ // 如果是站类型,加载各科错题分布对比数据
|
|
|
309
|
+ if (this.isStationType) {
|
|
|
310
|
+ await this.fetchWrongAnalysisRadarData()
|
|
|
311
|
+ }
|
|
|
312
|
+
|
|
|
313
|
+ } catch (error) {
|
|
|
314
|
+ console.error('加载抽问抽答数据失败:', error)
|
|
|
315
|
+ // 模拟数据作为备选
|
|
|
316
|
+ this.setMockData()
|
|
|
317
|
+ } finally {
|
|
|
318
|
+ this.loading = false
|
|
|
319
|
+ }
|
|
|
320
|
+ },
|
|
|
321
|
+
|
|
|
322
|
+ // 检查是否为站类型(已废弃,使用computed属性替代)
|
|
|
323
|
+ checkStationType() {
|
|
|
324
|
+ // 此方法已废弃,角色判断现在通过computed属性实现
|
|
|
325
|
+ },
|
|
|
326
|
+
|
|
|
327
|
+ // 处理查询参数
|
|
|
328
|
+ processQueryParams() {
|
|
|
329
|
+ const processedParams = { ...this.queryForm }
|
|
|
330
|
+
|
|
|
331
|
+
|
|
|
332
|
+
|
|
|
333
|
+ return {
|
|
|
334
|
+ ...processedParams,
|
|
|
335
|
+ scopeType: processedParams.scopedType == 'TEAMS' ? 'TEAM' : processedParams.scopedType,
|
|
|
336
|
+ scopeId: processedParams.scopedId,
|
|
|
337
|
+ yearOnYear: '',
|
|
|
338
|
+ chainRatio: ''
|
|
|
339
|
+ }
|
|
|
340
|
+ },
|
|
|
341
|
+
|
|
|
342
|
+ // 获取答题完成趋势数据
|
|
|
343
|
+ async fetchCompletionTrendData() {
|
|
|
344
|
+ try {
|
|
|
345
|
+ const processedParams = this.processQueryParams()
|
|
|
346
|
+ const response = await getCompletionTrend(processedParams)
|
|
|
347
|
+
|
|
|
348
|
+ if (response.code === 200) {
|
|
|
349
|
+ const { processedData, xAxisData } = this.processApiData(response || {})
|
|
|
350
|
+
|
|
|
351
|
+ // 生成描述文本
|
|
|
352
|
+ this.completionTrendDescription = this.generateCompletionTrendDescription(processedData, xAxisData)
|
|
|
353
|
+
|
|
|
354
|
+ // 更新图表
|
|
|
355
|
+ this.updateCompletionTrendChart(processedData, xAxisData)
|
|
|
356
|
+ }
|
|
|
357
|
+
|
|
|
358
|
+ } catch (error) {
|
|
|
359
|
+ console.error('获取答题完成趋势数据失败:', error)
|
|
|
360
|
+ throw error
|
|
|
361
|
+ }
|
|
|
362
|
+ },
|
|
|
363
|
+
|
|
|
364
|
+ // 获取错题分布数据
|
|
|
365
|
+ async fetchWrongAnalysisOverviewData() {
|
|
|
366
|
+ try {
|
|
|
367
|
+ const processedParams = this.processQueryParams()
|
|
|
368
|
+ const response = await getWrongAnalysisOverview(processedParams)
|
|
|
369
|
+
|
|
|
370
|
+
|
|
|
371
|
+ const pieData = this.processOverviewData(response || {})
|
|
|
372
|
+
|
|
|
373
|
+ // 生成描述文本
|
|
|
374
|
+ this.errorDistributionDescription = this.generateErrorDistributionDescription(pieData)
|
|
|
375
|
+
|
|
|
376
|
+ // 更新图表
|
|
|
377
|
+ this.updateErrorDistributionChart(pieData)
|
|
|
378
|
+
|
|
|
379
|
+ } catch (error) {
|
|
|
380
|
+ console.error('获取错题分布数据失败:', error)
|
|
|
381
|
+ throw error
|
|
|
382
|
+ }
|
|
|
383
|
+ },
|
|
|
384
|
+
|
|
|
385
|
+ // 获取各科错题分布对比数据
|
|
|
386
|
+ async fetchWrongAnalysisRadarData() {
|
|
|
387
|
+ try {
|
|
|
388
|
+ const processedParams = this.processQueryParams()
|
|
|
389
|
+ const response = await getWrongAnalysisRadar(processedParams)
|
|
|
390
|
+
|
|
|
391
|
+ // if (response.code === 200) {
|
|
|
392
|
+ const radarData = this.processRadarData(response || {})
|
|
|
393
|
+
|
|
|
394
|
+ // 生成描述文本
|
|
|
395
|
+ this.departmentComparisonDescription = this.generateDepartmentComparisonDescription(radarData)
|
|
|
396
|
+
|
|
|
397
|
+ // 更新图表
|
|
|
398
|
+ this.updateDepartmentComparisonChart(radarData)
|
|
|
399
|
+ // }
|
|
|
400
|
+
|
|
|
401
|
+ } catch (error) {
|
|
|
402
|
+ console.error('获取各科错题分布对比数据失败:', error)
|
|
|
403
|
+ throw error
|
|
|
404
|
+ }
|
|
|
405
|
+ },
|
|
|
406
|
+
|
|
|
407
|
+ // 处理API数据
|
|
|
408
|
+ processApiData(apiData) {
|
|
|
409
|
+ if (!apiData || !apiData.model) {
|
|
|
410
|
+ return { processedData: [], xAxisData: [] }
|
|
|
411
|
+ }
|
|
|
412
|
+
|
|
|
413
|
+ const { xAxis, series } = apiData.model
|
|
|
414
|
+
|
|
|
415
|
+ // 处理x轴数据
|
|
|
416
|
+ const xAxisData = xAxis || []
|
|
|
417
|
+
|
|
|
418
|
+ // 处理系列数据
|
|
|
419
|
+ const processedData = []
|
|
|
420
|
+
|
|
|
421
|
+ if (series && series.length > 0) {
|
|
|
422
|
+ for (let i = 0; i < series.length; i++) {
|
|
|
423
|
+ const numericData = series[i].data.map(item => {
|
|
|
424
|
+ if (typeof item === 'string') {
|
|
|
425
|
+ return parseFloat(item) || 0
|
|
|
426
|
+ }
|
|
|
427
|
+ return Number(item) || 0
|
|
|
428
|
+ })
|
|
|
429
|
+
|
|
|
430
|
+ processedData.push({
|
|
|
431
|
+ name: series[i].name,
|
|
|
432
|
+ type: 'line',
|
|
|
433
|
+ data: numericData,
|
|
|
434
|
+ symbol: 'circle',
|
|
|
435
|
+ symbolSize: 6,
|
|
|
436
|
+ smooth: true,
|
|
|
437
|
+ lineStyle: {
|
|
|
438
|
+ width: 3
|
|
|
439
|
+ }
|
|
|
440
|
+ })
|
|
|
441
|
+ }
|
|
|
442
|
+ }
|
|
|
443
|
+
|
|
|
444
|
+ return { processedData, xAxisData }
|
|
|
445
|
+ },
|
|
|
446
|
+
|
|
|
447
|
+ // 处理总体问题分布数据
|
|
|
448
|
+ processOverviewData(apiData) {
|
|
|
449
|
+ const { categories } = apiData.model
|
|
|
450
|
+
|
|
|
451
|
+ if (!categories || !categories.length) return []
|
|
|
452
|
+
|
|
|
453
|
+ return categories.map(category => ({
|
|
|
454
|
+ id: category.id,
|
|
|
455
|
+ value: category.count,
|
|
|
456
|
+ name: category.name
|
|
|
457
|
+ }))
|
|
|
458
|
+ },
|
|
|
459
|
+
|
|
|
460
|
+ // 处理雷达图数据
|
|
|
461
|
+ processRadarData(apiData) {
|
|
|
462
|
+ const { indicators, series } = apiData.model
|
|
|
463
|
+
|
|
|
464
|
+ if (!apiData || !indicators || !series) return { indicators: [], series: [] }
|
|
|
465
|
+
|
|
|
466
|
+ return { indicators, series }
|
|
|
467
|
+ },
|
|
|
468
|
+
|
|
|
469
|
+ // 生成答题完成趋势描述
|
|
|
470
|
+ generateCompletionTrendDescription(processedData, xAxisData) {
|
|
|
471
|
+ if (!processedData.length || !xAxisData.length) {
|
|
|
472
|
+ return '暂无数据'
|
|
|
473
|
+ }
|
|
|
474
|
+
|
|
|
475
|
+
|
|
|
476
|
+
|
|
|
477
|
+ // 找到全站数据
|
|
|
478
|
+ let stationData = processedData.find(item => item.name === '全站')?.data || []
|
|
|
479
|
+
|
|
|
480
|
+ // 找到除了全站之外的其他主管数据
|
|
|
481
|
+ const otherDepartments = processedData.filter(item => item.name !== '全站')
|
|
|
482
|
+
|
|
|
483
|
+ let maxData = null
|
|
|
484
|
+ let maxDataPercent = '0.00'
|
|
|
485
|
+
|
|
|
486
|
+ if (otherDepartments.length > 0) {
|
|
|
487
|
+ // 如果有其他主管数据,找出完成人数最多的主管
|
|
|
488
|
+ maxData = otherDepartments.reduce((max, item) => {
|
|
|
489
|
+ if (item.data[item.data.length - 1] > max.data[max.data.length - 1]) {
|
|
|
490
|
+ return item
|
|
|
491
|
+ }
|
|
|
492
|
+ return max
|
|
|
493
|
+ }, otherDepartments[0])
|
|
|
494
|
+
|
|
|
495
|
+ // 防止除数为0或NaN
|
|
|
496
|
+ const stationLastValue = stationData[stationData.length - 1] || 0
|
|
|
497
|
+ if (stationLastValue > 0) {
|
|
|
498
|
+ maxDataPercent = ((maxData.data[maxData.data.length - 1] / stationLastValue) * 100).toFixed(2)
|
|
|
499
|
+ } else {
|
|
|
500
|
+ maxDataPercent = '0.00'
|
|
|
501
|
+ }
|
|
|
502
|
+ }
|
|
|
503
|
+
|
|
|
504
|
+ // 安全获取数组元素,防止NaN
|
|
|
505
|
+ const lastValue = stationData[stationData.length - 1] || 0
|
|
|
506
|
+ const firstValue = stationData[0] || 0
|
|
|
507
|
+ const secondValue = stationData[1] || 0
|
|
|
508
|
+
|
|
|
509
|
+ // 计算同比
|
|
|
510
|
+ let tongValue = 0
|
|
|
511
|
+ if (firstValue > 0) {
|
|
|
512
|
+ tongValue = ((lastValue - firstValue) / firstValue) * 100
|
|
|
513
|
+ }
|
|
|
514
|
+ let tong = firstValue === 0 ? '--' : (tongValue > 0 ? '+' : '') + tongValue.toFixed(2)
|
|
|
515
|
+
|
|
|
516
|
+ // 计算环比
|
|
|
517
|
+ let huanValue = 0
|
|
|
518
|
+ if (secondValue > 0) {
|
|
|
519
|
+ huanValue = ((lastValue - secondValue) / secondValue) * 100
|
|
|
520
|
+ }
|
|
|
521
|
+ let huan = secondValue === 0 ? '--' : (huanValue > 0 ? '+' : '') + huanValue.toFixed(2)
|
|
|
522
|
+
|
|
|
523
|
+ // 安全获取maxData数组元素,防止NaN
|
|
|
524
|
+ let maxDataLastValue = 0
|
|
|
525
|
+ let maxDataFirstValue = 0
|
|
|
526
|
+ let maxDataSecondValue = 0
|
|
|
527
|
+ let maxDataTong = '--'
|
|
|
528
|
+ let maxDataHuan = '--'
|
|
|
529
|
+
|
|
|
530
|
+ if (maxData && maxData.data) {
|
|
|
531
|
+ maxDataLastValue = maxData.data[maxData.data.length - 1] || 0
|
|
|
532
|
+ maxDataFirstValue = maxData.data[0] || 0
|
|
|
533
|
+ maxDataSecondValue = maxData.data[1] || 0
|
|
|
534
|
+
|
|
|
535
|
+ // 计算maxData同比
|
|
|
536
|
+ let maxDataTongValue = 0
|
|
|
537
|
+ if (maxDataFirstValue > 0) {
|
|
|
538
|
+ maxDataTongValue = ((maxDataLastValue - maxDataFirstValue) / maxDataFirstValue) * 100
|
|
|
539
|
+ }
|
|
|
540
|
+ maxDataTong = maxDataFirstValue === 0 ? '--' : (maxDataTongValue > 0 ? '+' : (maxDataTongValue < 0 ? '' : '')) + maxDataTongValue.toFixed(2)
|
|
|
541
|
+
|
|
|
542
|
+ // 计算maxData环比
|
|
|
543
|
+ let maxDataHuanValue = 0
|
|
|
544
|
+ if (maxDataSecondValue > 0) {
|
|
|
545
|
+ maxDataHuanValue = ((maxDataLastValue - maxDataSecondValue) / maxDataSecondValue) * 100
|
|
|
546
|
+ }
|
|
|
547
|
+ maxDataHuan = maxDataSecondValue === 0 ? '--' : (maxDataHuanValue > 0 ? '+' : (maxDataHuanValue < 0 ? '' : '')) + maxDataHuanValue.toFixed(2)
|
|
|
548
|
+ }
|
|
|
549
|
+
|
|
|
550
|
+ // 根据查询条件决定显示内容
|
|
|
551
|
+ let descriptionText = ''
|
|
|
552
|
+ let totalPerson = stationData[stationData.length - 1] || 0
|
|
|
553
|
+
|
|
|
554
|
+ if (maxData) {
|
|
|
555
|
+ // 有其他主管数据时显示主管信息
|
|
|
556
|
+ if (this.queryForm.dateRangeQueryType === 'YEAR') {
|
|
|
557
|
+ const firstYearStr = this.isStationType ? `${maxData.name}共答题${totalPerson}人次,同比${tong}%,` : ''
|
|
|
558
|
+ const secondYearStr = this.isStationType ? `${maxData.name}共答题${maxData.data[maxData.data.length - 1]}人次,占比最高为${maxDataPercent}%。` : `${maxData.name}完成${maxDataLastValue}人次,同比${maxDataTong}%。`
|
|
|
559
|
+ // 年查询:只显示同比,隐藏环比
|
|
|
560
|
+ descriptionText = `${firstYearStr}${secondYearStr}`
|
|
|
561
|
+ } else {
|
|
|
562
|
+ const firstNotYearStr = this.isStationType ? `${maxData.name}共答题${totalPerson}人次,同比${tong}%,环比${huan}%,` : ''
|
|
|
563
|
+ const secondNotYearStr = this.isStationType ? `${maxData.name}共答题${maxData.data[maxData.data.length - 1]}人次,占比最高为${maxDataPercent}%。` : `${maxData.name}完成${maxDataLastValue}人次,同比${maxDataTong}%,环比${maxDataHuan}%。`
|
|
|
564
|
+ // 季度或月查询:显示同比和环比
|
|
|
565
|
+ descriptionText = `${firstNotYearStr}${secondNotYearStr}`
|
|
|
566
|
+ }
|
|
|
567
|
+ } else {
|
|
|
568
|
+ // 只有全站数据时显示简化的描述
|
|
|
569
|
+ if (this.queryForm.dateRangeQueryType === 'YEAR') {
|
|
|
570
|
+ descriptionText = `${maxData.name}共答题${totalPerson}人次,同比${tong}%。`
|
|
|
571
|
+ } else {
|
|
|
572
|
+ descriptionText = `${maxData.name}共答题${totalPerson}人次,同比${tong}%,环比${huan}%。`
|
|
|
573
|
+ }
|
|
|
574
|
+ }
|
|
|
575
|
+
|
|
|
576
|
+ return descriptionText
|
|
|
577
|
+ },
|
|
|
578
|
+
|
|
|
579
|
+ // 生成错题分布描述
|
|
|
580
|
+ generateErrorDistributionDescription(pieData) {
|
|
|
581
|
+ if (!pieData.length) {
|
|
|
582
|
+ return '暂无数据'
|
|
|
583
|
+ }
|
|
|
584
|
+
|
|
|
585
|
+ const sortedData = pieData.sort((a, b) => b.value - a.value)
|
|
|
586
|
+ const total = pieData.reduce((acc, cur) => acc + cur.value, 0)
|
|
|
587
|
+
|
|
|
588
|
+ const firstPercentage = total > 0 ? ((sortedData[0]?.value / total) * 100).toFixed(2) : '0.00'
|
|
|
589
|
+ const secondPercentage = total > 0 ? ((sortedData[1]?.value / total) * 100).toFixed(2) : '0.00'
|
|
|
590
|
+
|
|
|
591
|
+ return `错题主要集中于:${sortedData[0]?.name || '--'},占比:${firstPercentage}%;其次为:${sortedData[1]?.name || '--'},占比:${secondPercentage}%,为靶向培训、题库优化提供核心依据。`
|
|
|
592
|
+ },
|
|
|
593
|
+
|
|
|
594
|
+ // 生成各科错题分布对比描述
|
|
|
595
|
+ generateDepartmentComparisonDescription(radarData) {
|
|
|
596
|
+ if (!radarData.series || !radarData.series.length) {
|
|
|
597
|
+ return '暂无数据'
|
|
|
598
|
+ }
|
|
|
599
|
+
|
|
|
600
|
+ const series = radarData.series.map(ele => {
|
|
|
601
|
+ if (ele.data.every(item => item === 0)) {
|
|
|
602
|
+ return ''
|
|
|
603
|
+ }
|
|
|
604
|
+ let maxIndex = ele.data.indexOf(Math.max(...ele.data))
|
|
|
605
|
+ return `${ele.name}:问题主要集中于${radarData.indicators[maxIndex]}`
|
|
|
606
|
+ }).filter(element => !!element).join(';')
|
|
|
607
|
+
|
|
|
608
|
+ return `${series}${series.length > 0 ? ',' : '暂无问题'},可精准识别主管管理短板,分配质控资源。`
|
|
|
609
|
+ },
|
|
|
610
|
+
|
|
|
611
|
+ // 更新答题完成趋势图表
|
|
|
612
|
+ updateCompletionTrendChart(processedData, xAxisData) {
|
|
|
613
|
+ if (this.completionTrendChart) {
|
|
|
614
|
+ const newOptions = {
|
|
|
615
|
+ legend: {
|
|
|
616
|
+ data: processedData.map(item => item.name)
|
|
|
617
|
+ },
|
|
|
618
|
+ xAxis: {
|
|
|
619
|
+ data: xAxisData
|
|
|
620
|
+ },
|
|
|
621
|
+ series: processedData
|
|
|
622
|
+ }
|
|
|
623
|
+
|
|
|
624
|
+ this.completionTrendChart.setOption(newOptions)
|
|
|
625
|
+ }
|
|
|
626
|
+ },
|
|
|
627
|
+
|
|
|
628
|
+ // 更新错题分布图表
|
|
|
629
|
+ updateErrorDistributionChart(pieData) {
|
|
|
630
|
+ if (this.errorDistributionChart) {
|
|
|
631
|
+ const newOptions = {
|
|
|
632
|
+ series: [
|
|
|
633
|
+ {
|
|
|
634
|
+ data: pieData
|
|
|
635
|
+ }
|
|
|
636
|
+ ]
|
|
|
637
|
+ }
|
|
|
638
|
+
|
|
|
639
|
+ this.errorDistributionChart.setOption(newOptions)
|
|
|
640
|
+ }
|
|
|
641
|
+ },
|
|
|
642
|
+
|
|
|
643
|
+ // 更新各科错题分布对比图表
|
|
|
644
|
+ updateDepartmentComparisonChart(radarData) {
|
|
|
645
|
+
|
|
|
646
|
+ if (this.departmentComparisonChart) {
|
|
|
647
|
+ const maxValue = this.calculateRadarMaxValue(radarData.series)
|
|
|
648
|
+
|
|
|
649
|
+ const newOptions = {
|
|
|
650
|
+ radar: {
|
|
|
651
|
+ indicator: radarData.indicators.map(indicator => ({
|
|
|
652
|
+ name: indicator,
|
|
|
653
|
+ max: maxValue || 100
|
|
|
654
|
+ }))
|
|
|
655
|
+ },
|
|
|
656
|
+ series: [
|
|
|
657
|
+ {
|
|
|
658
|
+ type: 'radar',
|
|
|
659
|
+ data: radarData.series.map(seriesItem => ({
|
|
|
660
|
+ value: seriesItem.data,
|
|
|
661
|
+ name: seriesItem.name
|
|
|
662
|
+ })),
|
|
|
663
|
+ areaStyle: {}
|
|
|
664
|
+ }
|
|
|
665
|
+ ]
|
|
|
666
|
+ }
|
|
|
667
|
+
|
|
|
668
|
+ this.departmentComparisonChart.setOption(newOptions)
|
|
|
669
|
+ }
|
|
|
670
|
+ },
|
|
|
671
|
+
|
|
|
672
|
+ // 计算雷达图数据的最大值
|
|
|
673
|
+ calculateRadarMaxValue(radarData) {
|
|
|
674
|
+ if (!radarData || radarData.length === 0) return 100
|
|
|
675
|
+
|
|
|
676
|
+ let maxValue = 0
|
|
|
677
|
+
|
|
|
678
|
+ radarData.forEach(series => {
|
|
|
679
|
+ if (series.data && Array.isArray(series.data)) {
|
|
|
680
|
+ const seriesMax = Math.max(...series.data)
|
|
|
681
|
+ if (seriesMax > maxValue) {
|
|
|
682
|
+ maxValue = seriesMax
|
|
|
683
|
+ }
|
|
|
684
|
+ }
|
|
|
685
|
+ })
|
|
|
686
|
+
|
|
|
687
|
+ return maxValue
|
|
|
688
|
+ },
|
|
|
689
|
+
|
|
|
690
|
+ // 设置模拟数据
|
|
|
691
|
+ setMockData() {
|
|
|
692
|
+ // 答题完成趋势数据
|
|
|
693
|
+ const mockCompletionData = {
|
|
|
694
|
+ processedData: [
|
|
|
695
|
+ {
|
|
|
696
|
+ name: '全站',
|
|
|
697
|
+ type: 'line',
|
|
|
698
|
+ data: [85, 88, 92, 90, 87, 89, 91, 93, 95, 94, 92, 90],
|
|
|
699
|
+ symbol: 'circle',
|
|
|
700
|
+ symbolSize: 6,
|
|
|
701
|
+ smooth: true,
|
|
|
702
|
+ lineStyle: { width: 3 }
|
|
|
703
|
+ }
|
|
|
704
|
+ ],
|
|
|
705
|
+ xAxisData: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
|
|
|
706
|
+ }
|
|
|
707
|
+
|
|
|
708
|
+ this.completionTrendDescription = '全站共答题120人次,同比+5.2%,环比+2.1%,旅检一科共答题45人次,占比最高为37.5%。'
|
|
|
709
|
+ this.updateCompletionTrendChart(mockCompletionData.processedData, mockCompletionData.xAxisData)
|
|
|
710
|
+
|
|
|
711
|
+ // 错题分布数据
|
|
|
712
|
+ const mockPieData = [
|
|
|
713
|
+ { value: 45.3, name: '操作执行类' },
|
|
|
714
|
+ { value: 28.7, name: '设施设备类' },
|
|
|
715
|
+ { value: 15.2, name: '勤务组织类' },
|
|
|
716
|
+ { value: 8.4, name: '安全知识类' },
|
|
|
717
|
+ { value: 2.4, name: '其他' }
|
|
|
718
|
+ ]
|
|
|
719
|
+
|
|
|
720
|
+ this.errorDistributionDescription = '错题主要集中于:操作执行类,占比:45.30%;其次为:设施设备类,占比:28.70%,为靶向培训、题库优化提供核心依据。'
|
|
|
721
|
+ this.updateErrorDistributionChart(mockPieData)
|
|
|
722
|
+
|
|
|
723
|
+ // 各科错题分布对比数据
|
|
|
724
|
+ const mockRadarData = {
|
|
|
725
|
+ indicators: ['操作执行类', '设施设备类', '勤务组织类', '安全知识类', '其他'],
|
|
|
726
|
+ series: [
|
|
|
727
|
+ { name: '旅检一科', data: [85, 45, 30, 60, 10] },
|
|
|
728
|
+ { name: '旅检二科', data: [40, 80, 55, 70, 15] },
|
|
|
729
|
+ { name: '旅检三科', data: [35, 50, 90, 45, 20] }
|
|
|
730
|
+ ]
|
|
|
731
|
+ }
|
|
|
732
|
+
|
|
|
733
|
+ this.departmentComparisonDescription = '旅检一科:问题主要集中于操作执行类;旅检二科:问题主要集中于设施设备类;旅检三科:问题主要集中于勤务组织类,可精准识别主管管理短板,分配质控资源。'
|
|
|
734
|
+ this.updateDepartmentComparisonChart(mockRadarData)
|
|
|
735
|
+ }
|
|
|
736
|
+ }
|
|
|
737
|
+}
|
|
|
738
|
+</script>
|
|
|
739
|
+
|
|
|
740
|
+<style lang="scss" scoped>
|
|
|
741
|
+.qa-analysis {
|
|
|
742
|
+ // padding: 24rpx;
|
|
|
743
|
+ background: #fff;
|
|
|
744
|
+ border-radius: 16rpx;
|
|
|
745
|
+ margin-bottom: 24rpx;
|
|
|
746
|
+}
|
|
|
747
|
+
|
|
|
748
|
+.section-title {
|
|
|
749
|
+ margin-bottom: 24rpx;
|
|
|
750
|
+
|
|
|
751
|
+ .title-text {
|
|
|
752
|
+ font-size: 32rpx;
|
|
|
753
|
+ font-weight: bold;
|
|
|
754
|
+ color: #333;
|
|
|
755
|
+ }
|
|
|
756
|
+}
|
|
|
757
|
+
|
|
|
758
|
+.three-panel-layout {
|
|
|
759
|
+ display: flex;
|
|
|
760
|
+ flex-direction: column;
|
|
|
761
|
+ gap: 32rpx;
|
|
|
762
|
+}
|
|
|
763
|
+
|
|
|
764
|
+.panel-item {
|
|
|
765
|
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
|
766
|
+ border-radius: 12rpx;
|
|
|
767
|
+ padding: 20rpx;
|
|
|
768
|
+ margin-bottom: 16rpx;
|
|
|
769
|
+}
|
|
|
770
|
+
|
|
|
771
|
+.panel-header {
|
|
|
772
|
+ margin-bottom: 16rpx;
|
|
|
773
|
+
|
|
|
774
|
+ .header-text {
|
|
|
775
|
+ font-size: 28rpx;
|
|
|
776
|
+ font-weight: 600;
|
|
|
777
|
+ color: #333;
|
|
|
778
|
+ }
|
|
|
779
|
+}
|
|
|
780
|
+
|
|
|
781
|
+.describe-card {
|
|
|
782
|
+ background: #f8f9fa;
|
|
|
783
|
+ border-radius: 8rpx;
|
|
|
784
|
+ padding: 16rpx;
|
|
|
785
|
+ margin-bottom: 16rpx;
|
|
|
786
|
+
|
|
|
787
|
+ .describe-content {
|
|
|
788
|
+ font-size: 24rpx;
|
|
|
789
|
+ line-height: 1.5;
|
|
|
790
|
+ color: #666;
|
|
|
791
|
+ }
|
|
|
792
|
+}
|
|
|
793
|
+
|
|
|
794
|
+.chart-container {
|
|
|
795
|
+ background: #fff;
|
|
|
796
|
+ border-radius: 8rpx;
|
|
|
797
|
+ padding: 16rpx;
|
|
|
798
|
+ height: 500rpx;
|
|
|
799
|
+
|
|
|
800
|
+ .echarts-chart {
|
|
|
801
|
+ width: 100%;
|
|
|
802
|
+ height: 100%;
|
|
|
803
|
+ }
|
|
|
804
|
+}
|
|
|
805
|
+
|
|
|
806
|
+@media (min-width: 768px) {
|
|
|
807
|
+ .three-panel-layout {
|
|
|
808
|
+ flex-direction: row;
|
|
|
809
|
+ flex-wrap: wrap;
|
|
|
810
|
+ }
|
|
|
811
|
+
|
|
|
812
|
+ .panel-item {
|
|
|
813
|
+ flex: 1 1 calc(33.333% - 32rpx);
|
|
|
814
|
+ min-width: 300rpx;
|
|
|
815
|
+ }
|
|
|
816
|
+}
|
|
|
817
|
+</style>
|