Procházet zdrojové kódy

refactor(warningManage): 优化预警等级及状态标签展示逻辑

- 替换整体评分判断为直接使用预警等级和状态标签字段筛选
- 调整表格中预警等级和状态标签列显示逻辑,统一调用字典标签函数
- 新增状态标签字典获取函数getStatusLabel,完善标签展示一致性
- 简化预警等级筛选条件,避免对分值区间复杂判定
- 统一引入alert_level和status_label字典,提升代码复用与可维护性
huoyi před 13 hodinami
rodič
revize
60f0453f24

+ 19 - 27
src/views/warningManage/redLineWarning/index.vue

@@ -65,25 +65,23 @@
65 65
                         <el-table-column prop="level2Name" label="二级指标名称" />
66 66
                         <el-table-column prop="totalScore" label="扣分分值合计" sortable />
67 67
                         <el-table-column prop="occurrenceCount" label="发生次数" sortable />
68
-                        <el-table-column prop="overallScore" label="预警等级">
68
+                        <el-table-column prop="warningLevel" label="预警等级">
69 69
                             <template #default="{ row }">
70
-                                <span v-if="row.overallScore < 75" class="status-badge"
71
-                                    style="animation: subtlePulse 1s infinite;"><i
72
-                                        class="fas fa-exclamation-triangle"></i> 红色预警</span>
73
-                                <span v-else-if="row.overallScore >= 90" class="status-excellent"
74
-                                    style="background:#d1fae5; color:#065f46;"><i class="fas fa-star"></i>
75
-                                    优秀标杆</span>
76
-                                <span v-else class="status-warning">正常范围</span>
70
+                                <span v-if="row.warningLevel == '1'" style="color:#b91c1c;" class="status-badge">{{
71
+                                    getAlertLabel(row.warningLevel)
72
+                                    }}</span>
73
+                                <span v-else class="status-excellent"><i class="fas fa-star"></i>
74
+                                    {{ getAlertLabel(row.warningLevel) }}</span>
75
+
77 76
                             </template>
78 77
                         </el-table-column>
79 78
                         <el-table-column prop="coreRisks" label="核心风险" />
80 79
                         <el-table-column prop="statusLabel" label="状态标签">
81 80
                             <template #default="{ row }">
82
-                                <span v-if="row.overallScore < 75" style="color:#b91c1c;"><i class="fas fa-bell"></i>
83
-                                    {{ getAlertLabel(row.statusLabel) }}</span>
84
-                                <span v-else-if="row.overallScore >= 90" style="color:#15803d;"><i
85
-                                        class="fas fa-crown"></i> {{ getAlertLabel(row.statusLabel) }}</span>
86
-                                <span v-else>{{ getAlertLabel(row.statusLabel) }}</span>
81
+                                <span v-if="row.statusLabel == '1'" style="color:#b91c1c;"><i class="fas fa-bell"></i>
82
+                                    {{ getStatusLabel(row.statusLabel) }}</span>
83
+                                <span v-else><i class="fas fa-crown"></i> {{ getStatusLabel(row.statusLabel) }}</span>
84
+
87 85
                             </template>
88 86
                         </el-table-column>
89 87
                     </el-table>
@@ -117,7 +115,7 @@ import { useRoute } from 'vue-router'
117 115
 
118 116
 const route = useRoute()
119 117
 
120
-const { alert_level } = useDict('alert_level')
118
+const { alert_level, status_label } = useDict('alert_level', 'status_label')
121 119
 
122 120
 const dateRangeInput = ref(null)
123 121
 const activeRange = ref('month')
@@ -214,19 +212,7 @@ const allFilteredEmployees = computed(() => {
214 212
 
215 213
     // 预警等级筛选
216 214
     if (selectedAlertLevel.value) {
217
-        // 根据字典值判断筛选条件(红色预警 <75,优秀标杆 >=90,正常范围 75-89)
218
-        // 可以根据字典的 value 或 label 来判断
219
-        const alertItem = alert_level.value.find(item => item.value === selectedAlertLevel.value)
220
-        if (alertItem) {
221
-            const label = alertItem.label
222
-            if (label.includes('红色') || label.includes('预警')) {
223
-                result = result.filter(emp => emp.overallScore < 75)
224
-            } else if (label.includes('优秀') || label.includes('标杆')) {
225
-                result = result.filter(emp => emp.overallScore >= 90)
226
-            } else if (label.includes('正常')) {
227
-                result = result.filter(emp => emp.overallScore >= 75 && emp.overallScore < 90)
228
-            }
229
-        }
215
+        result = result.filter(emp => emp.warningLevel == selectedAlertLevel.value)
230 216
     }
231 217
 
232 218
     return result
@@ -273,6 +259,12 @@ const getAlertLabel = (value) => {
273 259
     return item ? item.label : value
274 260
 }
275 261
 
262
+const getStatusLabel = (value) => {
263
+    if (!value) return ''
264
+    const item = status_label.value.find(d => d.value === value)
265
+    return item ? item.label : value
266
+}
267
+
276 268
 const setActiveRange = (range) => {
277 269
     activeRange.value = range
278 270
     // 清除自定义日期

+ 19 - 28
src/views/warningManage/warningPage/index.vue

@@ -97,24 +97,23 @@
97 97
                 <span v-else style="font-weight:600;">{{ row.overallScore }} 分</span>
98 98
               </template>
99 99
             </el-table-column>
100
-            <el-table-column prop="overallScore" label="预警等级">
100
+            <el-table-column prop="warningLevel" label="预警等级">
101 101
               <template #default="{ row }">
102
-                <span v-if="row.overallScore < 75" class="status-badge" style="animation: subtlePulse 1s infinite;"><i
103
-                    class="fas fa-exclamation-triangle"></i> 红色预警</span>
104
-                <span v-else-if="row.overallScore >= 90" class="status-excellent"
105
-                  style="background:#d1fae5; color:#065f46;"><i class="fas fa-star"></i>
106
-                  优秀标杆</span>
107
-                <span v-else class="status-warning">正常范围</span>
102
+                <span v-if="row.warningLevel == '1'" class="status-badge" style="color:#b91c1c;"><i
103
+                    class="fas fa-exclamation-triangle"></i> {{ getAlertLabel(row.warningLevel) }}</span>
104
+                <span v-else class="status-excellent"><i class="fas fa-star"></i>
105
+                  {{ getAlertLabel(row.warningLevel) }}</span>
106
+
108 107
               </template>
109 108
             </el-table-column>
110 109
             <el-table-column prop="coreRisksOrOutstandingAchievements" label="核心风险/优秀事迹" />
111 110
             <el-table-column prop="statusLabel" label="状态标签">
112 111
               <template #default="{ row }">
113
-                <span v-if="row.overallScore < 75" style="color:#b91c1c;"><i class="fas fa-bell"></i>
114
-                  {{ getAlertLabel(row.statusLabel) }}</span>
115
-                <span v-else-if="row.overallScore >= 90" style="color:#15803d;"><i class="fas fa-crown"></i> {{
116
-                  getAlertLabel(row.statusLabel) }}</span>
117
-                <span v-else>{{ getAlertLabel(row.statusLabel) }}</span>
112
+                <span v-if="row.statusLabel == '1'" style="color:#b91c1c;"><i class="fas fa-bell"></i>
113
+                  {{ getStatusLabel(row.statusLabel) }}</span>
114
+                <span v-else ><i class="fas fa-crown"></i> {{
115
+                  getStatusLabel(row.statusLabel) }}</span>
116
+
118 117
               </template>
119 118
             </el-table-column>
120 119
             <el-table-column label="详情" width="80">
@@ -167,7 +166,7 @@ import { useRoute } from "vue-router";
167 166
 const route = useRoute();
168 167
 const router = useRouter();
169 168
 
170
-const { alert_level } = useDict("alert_level");
169
+const { alert_level, status_label } = useDict("alert_level", "status_label");
171 170
 
172 171
 const dateRangeInput = ref(null);
173 172
 const activeRange = ref("month");
@@ -366,21 +365,7 @@ const allFilteredEmployees = computed(() => {
366 365
 
367 366
   // 预警等级筛选
368 367
   if (selectedAlertLevel.value) {
369
-    // 根据字典值判断筛选条件(红色预警 <75,优秀标杆 >=90,正常范围 75-89)
370
-    // 可以根据字典的 value 或 label 来判断
371
-    const alertItem = alert_level.value.find(
372
-      (item) => item.value === selectedAlertLevel.value
373
-    );
374
-    if (alertItem) {
375
-      const label = alertItem.label;
376
-      if (label.includes("红色") || label.includes("预警")) {
377
-        result = result.filter((emp) => emp.overallScore < 75);
378
-      } else if (label.includes("优秀") || label.includes("标杆")) {
379
-        result = result.filter((emp) => emp.overallScore >= 90);
380
-      } else if (label.includes("正常")) {
381
-        result = result.filter((emp) => emp.overallScore >= 75 && emp.overallScore < 90);
382
-      }
383
-    }
368
+    result = result.filter((emp) => emp.warningLevel == selectedAlertLevel.value);
384 369
   }
385 370
 
386 371
   return result;
@@ -463,6 +448,12 @@ const getAlertLabel = (value) => {
463 448
   return item ? item.label : value;
464 449
 };
465 450
 
451
+const getStatusLabel = (value) => {
452
+  if (!value) return "";
453
+  const item = status_label.value.find((d) => d.value === value);
454
+  return item ? item.label : value;
455
+};
456
+
466 457
 const setActiveRange = (range) => {
467 458
   activeRange.value = range;
468 459
   if (range !== "custom") {