Przeglądaj źródła

feat(排名展示): 添加大队合格率排行功能并支持排序

在测试角色和质检科角色下,新增大队合格率排行展示,包含正序倒序切换功能
同时修改相关数据获取逻辑和状态管理,支持大队维度的排名展示
huoyi 3 tygodni temu
rodzic
commit
a2c7ac9d24

+ 48 - 0
src/pages/home-new/components/type-detail.vue

@@ -69,6 +69,52 @@
69 69
 
70 70
                 <!-- test角色特殊显示:主管合格率排行和班组合格率排行 -->
71 71
                 <div class="rank-section" v-if="role && (role.includes('test') || role.includes('zhijianke'))">
72
+
73
+                    <!-- 大队合格率排行 -->
74
+                    <div class="rank-header">
75
+                        <div class="rank-title">{{ item.title === '查获上报' ? '大队查获总数排名' : item.title == '抽问抽答' ? '大队正确率排名'
76
+                            :
77
+                            '大队合格率排名' }}</div>
78
+                        <div class="sort-buttons">
79
+                            <div :class="['sort-btn', { 'active': item.brigadeSortType === 'asc' }]"
80
+                                @click="$emit('sort-change', item.title, 'brigade', 'asc')">正序</div>
81
+                            <div :class="['sort-btn', { 'active': item.brigadeSortType === 'desc' }]"
82
+                                @click="$emit('sort-change', item.title, 'brigade', 'desc')">倒序</div>
83
+                        </div>
84
+                    </div>
85
+
86
+                    <!-- 大队排名显示 -->
87
+                    <template v-if="item.brigadeSortType === 'asc'">
88
+                        <div v-for="(brigade, i) in (item.brigadeRank || []).slice(0, 5)" :key="'brigade-asc-' + i"
89
+                            class="rank-item">
90
+                            <div class="rank-label">{{ brigade.name }}</div>
91
+                            <div class="rank-progress">
92
+                                <h-rank-line
93
+                                    :percentage="item.title !== '查获上报' ? Number(brigade.passRate || 0) : getPercentage(brigade.passRate, item.brigadeRank)"
94
+                                    endType="round" :height="10" :color="['#A8E6CF', '#4CAF50']">
95
+                                    <div class="rank-info"><span style="color: #999999">{{ brigade.passRate || 0
96
+                                            }}</span>
97
+                                    </div>
98
+                                </h-rank-line>
99
+                            </div>
100
+                        </div>
101
+                    </template>
102
+                    <template v-else>
103
+                        <div v-for="(brigade, i) in (item.bottomBrigadeRank || []).slice(0, 5)"
104
+                            :key="'brigade-desc-' + i" class="rank-item">
105
+                            <div class="rank-label">{{ brigade.name }}</div>
106
+                            <div class="rank-progress">
107
+                                <h-rank-line
108
+                                    :percentage="item.title !== '查获上报' ? Number(brigade.passRate || 0) : getPercentage(brigade.passRate, item.bottomBrigadeRank)"
109
+                                    endType="round" :height="10" :color="['#A8E6CF', '#4CAF50']">
110
+                                    <div class="rank-info"><span style="color: #999999">{{ brigade.passRate || 0
111
+                                            }}</span>
112
+                                    </div>
113
+                                </h-rank-line>
114
+                            </div>
115
+                        </div>
116
+                    </template>
117
+
72 118
                     <!-- 主管合格率排行 -->
73 119
                     <div class="rank-header">
74 120
                         <div class="rank-title">{{ item.title === '查获上报' ? '主管查获总数排名' : item.title == '抽问抽答' ? '主管正确率排名'
@@ -153,6 +199,8 @@
153 199
                             </div>
154 200
                         </div>
155 201
                     </template>
202
+
203
+
156 204
                 </div>
157 205
 
158 206
             </div>

+ 17 - 5
src/pages/home-new/index.vue

@@ -118,9 +118,9 @@ export default {
118 118
             ],
119 119
             // 排序状态管理
120 120
             sortStates: {
121
-                '查获上报': { teamSortType: 'asc', deptSortType: 'asc' },
122
-                '抽问抽答': { teamSortType: 'asc', deptSortType: 'asc' },
123
-                '巡检': { teamSortType: 'asc', deptSortType: 'asc' }
121
+                '查获上报': { teamSortType: 'asc', deptSortType: 'asc', brigadeSortType: 'asc' },
122
+                '抽问抽答': { teamSortType: 'asc', deptSortType: 'asc', brigadeSortType: 'asc' },
123
+                '巡检': { teamSortType: 'asc', deptSortType: 'asc', brigadeSortType: 'asc' }
124 124
             },
125 125
             // 排名数据
126 126
             rankData: {
@@ -211,13 +211,16 @@ export default {
211 211
                     statTitle: '查获数量',
212 212
                     teamSortType: this.sortStates['查获上报'].teamSortType,
213 213
                     deptSortType: this.sortStates['查获上报'].deptSortType,
214
+                    brigadeSortType: this.sortStates['查获上报'].brigadeSortType,
214 215
                     dividerIndex: this.isBrigade ? 1 : 0,
215 216
                     dataItems: this.getSeizeDataItems(),
216 217
                     rankList: this.getSeizeRankList(),
217 218
                     departmentRank: this.seizeData.stationMasterData && this.seizeData.stationMasterData.topThreeDepartmentRankings ? this.seizeData.stationMasterData.topThreeDepartmentRankings.map(item => ({ ...item, passRate: item.seizureCount.toFixed(2), name: item.departmentName })) : [],
218
-                    bottomDepartmentRank: this.seizeData.stationMasterData && this.seizeData.stationMasterData.botomThreeDepartmentRankings && this.seizeData.stationMasterData.departmentRankings ? [...this.seizeData.stationMasterData.departmentRankings].sort((a, b) => (a.seizureCount || 0) - (b.seizureCount || 0)).slice(0, 3).map(item => ({ ...item, passRate: item.seizureCount.toFixed(2), name: item.departmentName })) : [],
219
+                    bottomDepartmentRank: this.seizeData.stationMasterData && this.seizeData.stationMasterData.botomThreeDepartmentRankings ? [...this.seizeData.stationMasterData.botomThreeDepartmentRankings].sort((a, b) => (a.seizureCount || 0) - (b.seizureCount || 0)).slice(0, 3).map(item => ({ ...item, passRate: item.seizureCount.toFixed(2), name: item.departmentName })) : [],
219 220
                     teamRank: this.seizeData.stationMasterData && this.seizeData.stationMasterData.topThreeTeamRankings ? this.seizeData.stationMasterData.topThreeTeamRankings.map(item => ({ ...item, passRate: item.seizureCount.toFixed(2), name: item.teamName })) : [],
220 221
                     bottomTeamRank: this.seizeData.stationMasterData && this.seizeData.stationMasterData.botomThreeTeamRankings ? this.seizeData.stationMasterData.botomThreeTeamRankings.map(item => ({ ...item, passRate: item.seizureCount.toFixed(2), name: item.teamName })) : [],
222
+                    brigadeRank: this.seizeData.stationMasterData && this.seizeData.stationMasterData.brigadeRankings ? [...this.seizeData.stationMasterData.brigadeRankings].sort((a, b) => (b.seizureCount || 0) - (a.seizureCount || 0)).slice(0, 5).map(item => ({ ...item, passRate: item.seizureCount.toFixed(2), name: item.brigadeName })) : [],
223
+                    bottomBrigadeRank: this.seizeData.stationMasterData && this.seizeData.stationMasterData.brigadeRankings ? [...this.seizeData.stationMasterData.brigadeRankings].sort((a, b) => (a.seizureCount || 0) - (b.seizureCount || 0)).slice(0, 5).map(item => ({ ...item, passRate: item.seizureCount.toFixed(2), name: item.brigadeName })) : [],
221 224
                 },
222 225
                 {
223 226
                     title: '抽问抽答',
@@ -226,6 +229,7 @@ export default {
226 229
                     statTitle: '正确率(%)',
227 230
                     teamSortType: this.sortStates['抽问抽答'].teamSortType,
228 231
                     deptSortType: this.sortStates['抽问抽答'].deptSortType,
232
+                    brigadeSortType: this.sortStates['抽问抽答'].brigadeSortType,
229 233
                     dividerIndex: this.isBrigade ? 1 : 0,
230 234
                     dataItems: this.getQuestionDataItems(),
231 235
                     rankList: this.getQuestionRankList(),
@@ -233,6 +237,8 @@ export default {
233 237
                     bottomDepartmentRank: this.accuracyStatistics.bottomDepts && [...this.accuracyStatistics.topDepts].sort((a, b) => (a.accuracy || 0) - (b.accuracy || 0)).map(item => ({ ...item, passRate: item.accuracy.toFixed(2), name: item.name })),
234 238
                     teamRank: this.accuracyStatistics.topTeamsInSite && this.accuracyStatistics.topTeamsInSite.map(item => ({ ...item, passRate: item.accuracy.toFixed(2), name: item.name })),
235 239
                     bottomTeamRank: this.accuracyStatistics.bottomTeamsInSite && this.accuracyStatistics.bottomTeamsInSite.map(item => ({ ...item, passRate: item.accuracy.toFixed(2), name: item.name })),
240
+                    brigadeRank: this.accuracyStatistics.brigadeRankingList && [...this.accuracyStatistics.brigadeRankingList].sort((a, b) => (b.accuracy || 0) - (a.accuracy || 0)).slice(0, 5).map(item => ({ ...item, passRate: item.accuracy.toFixed(2), name: item.name })),
241
+                    bottomBrigadeRank: this.accuracyStatistics.brigadeRankingList && [...this.accuracyStatistics.brigadeRankingList].sort((a, b) => (a.accuracy || 0) - (b.accuracy || 0)).slice(0, 5).map(item => ({ ...item, passRate: item.accuracy.toFixed(2), name: item.name })),
236 242
                 },
237 243
                 {
238 244
                     title: '巡检',
@@ -241,6 +247,7 @@ export default {
241 247
                     statTitle: '合格率(%)',
242 248
                     teamSortType: this.sortStates['巡检'].teamSortType,
243 249
                     deptSortType: this.sortStates['巡检'].deptSortType,
250
+                    brigadeSortType: this.sortStates['巡检'].brigadeSortType,
244 251
                     dividerIndex: this.isBrigade ? 1 : 0,
245 252
                     dataItems: this.getInspectionDataItems(),
246 253
                     completed: this.inspectionData.doneNumber,
@@ -250,6 +257,8 @@ export default {
250 257
                     bottomDepartmentRank: this.inspectionData.reverseDepartmentRankingList && [...this.inspectionData.reverseDepartmentRankingList].sort((a, b) => (a.passRate || 0) - (b.passRate || 0)).slice(0, 5).map(item => ({ ...item, passRate: (item.passRate * 100).toFixed(2) })),
251 258
                     teamRank: this.inspectionData.teamRankingList && this.inspectionData.teamRankingList.map(item => ({ ...item, passRate: (item.passRate * 100).toFixed(2) })),
252 259
                     bottomTeamRank: this.inspectionData.reverseTeamRankingList && this.inspectionData.reverseTeamRankingList.map(item => ({ ...item, passRate: (item.passRate * 100).toFixed(2) })),
260
+                    brigadeRank: this.inspectionData.brigadeRankingList && [...this.inspectionData.brigadeRankingList].sort((a, b) => (a.rank || 0) - (b.rank || 0)).slice(0, 5).map(item => ({ ...item, passRate: (item.passRate * 100).toFixed(2), name: item.name })),
261
+                    bottomBrigadeRank: this.inspectionData.brigadeRankingList && [...this.inspectionData.brigadeRankingList].sort((a, b) => (b.rank || 0) - (a.rank || 0)).slice(0, 5).map(item => ({ ...item, passRate: (item.passRate * 100).toFixed(2), name: item.name })),
253 262
                 }
254 263
             ]
255 264
         },
@@ -523,13 +532,14 @@ export default {
523 532
                     startTime: startDate,
524 533
                     endTime: endDate,
525 534
                     sortField: 'totalScore',
526
-                    dimension: '3'
535
+                    dimension: '4'
527 536
                 };
528 537
 
529 538
                 getMetrics(params).then(res => {
530 539
 
531 540
                     if (res && res.data) {
532 541
                         this.performanceData = res.data;
542
+
533 543
                         resolve(res.data);
534 544
                     } else {
535 545
                         resolve([]);
@@ -900,6 +910,8 @@ export default {
900 910
                     this.sortStates[title].teamSortType = sortType;
901 911
                 } else if (type === 'dept') {
902 912
                     this.sortStates[title].deptSortType = sortType;
913
+                } else if (type === 'brigade') {
914
+                    this.sortStates[title].brigadeSortType = sortType;
903 915
                 }
904 916
             }
905 917
         },