Ver Fonte

考勤明细状态tag按英文码上色

lihaiting há 1 semana atrás
pai
commit
2f487914f9
2 ficheiros alterados com 34 adições e 15 exclusões
  1. 4 1
      src/api/hr/attendance.js
  2. 30 14
      src/views/attendance/daily/index.vue

+ 4 - 1
src/api/hr/attendance.js

@@ -1896,7 +1896,10 @@ export function adaptDailyAttendance(raw = {}) {
     sourceType: item.sourceTypeName || '',
     /* 上下班分组「打卡地点」列:punchRecords 内的 address 直取(2026-11-03 用户指定字段) */
     address: item.address || '',
-    status: item.statusName || '',
+    /* 打卡状态判定码:后端 punchRecords[].status 原始码(VALID=正常、其它码=异常,2026-11-11 用户口径),
+       只用于列表 tag 上色。显示文案仍直取中文 statusName,前端不做码→文案映射、不编造默认状态。 */
+    status: item.status || '',
+    statusName: item.statusName || '',
     statusText: item.statusName || '',
     punchAddress: item.punchAddress || '',
   });

+ 30 - 14
src/views/attendance/daily/index.vue

@@ -49,8 +49,9 @@
         </template>
 
         <template slot="statusNameList" slot-scope="{ row }">
+          <!-- 文案直取后端中文 statusNameList;颜色按同序英文码 statusList 判断(2026-11-11 用户口径) -->
           <div v-for="(name, index) in row.statusNameList" :key="index" class="status-tag-line">
-            <el-tag size="mini" :type="attendanceStatusTagType(name)" class="punch-tag">
+            <el-tag size="mini" :type="attendanceStatusTagType(row.statusList[index])" class="punch-tag">
               {{ name }}
             </el-tag>
           </div>
@@ -335,20 +336,35 @@ export default {
       return { list: this.currentRows, count: data.count };
     },
     punchStatusTagType(item) {
-      /* 文案与色值均按后端中文字段判断:statusName=有效/已作废/待审批,sourceType=移动端/考勤设备/补卡 */
-      if (item.sourceType === '补卡' || item.statusText === '已作废') return 'danger';
-      if (item.statusText === '有效') return 'success';
-      if (item.statusText === '待审批') return 'warning';
-      return 'info';
+      /* 打卡状态 tag 颜色按 punchRecords[].status 原始码判断(2026-11-11 用户口径):
+         VALID = 正常 → 绿色 success;其它码 = 异常 → 红色 danger。
+         status 未返回时没有判定依据 → 灰色 info,绝不把「字段缺失」当成异常;
+         文案仍是后端中文 statusName 直取,未返回就留空,前端不兜底。 */
+      const code = String(item.status || '');
+      if (!code) return 'info';
+      return code === 'VALID' ? 'success' : 'danger';
     },
-    /* 出勤情况 tag 颜色:按后端状态中文字段判断(正常=绿,迟到/早退/缺卡类=橙,旷工=红,其他=灰) */
-    attendanceStatusTagType(name) {
-      const text = String(name || '');
-      if (!text) return 'info';
-      if (text.includes('正常')) return 'success';
-      if (text.includes('旷工')) return 'danger';
-      if (text.includes('迟到') || text.includes('早退') || text.includes('缺')) return 'warning';
-      return 'info';
+    /* 出勤情况 tag 颜色:按行级 statusList 英文码判断(2026-11-11 用户口径:英文值判色、
+       中文 statusNameList 显示)。两者同序,按 index 配对。
+       码表 = 用户提供的 AttendanceConstants.DAILY_*(前 6 项,实际字符串按本页 STATUS_OPTIONS
+       一直在用的 NORMAL/LATE/EARLY_LEAVE/MISSING_IN/MISSING_OUT/ABSENT)+ LEAVE/BUSINESS_TRIP/OUTING/OVERTIME。
+       码未返回、两数组不同序或出现码表外的值 → 灰(没有配色依据),不把缺失/未知当成异常。 */
+    attendanceStatusTagType(code) {
+      const types = {
+        NORMAL: 'success',
+        LATE: 'warning',
+        EARLY_LEAVE: 'warning',
+        MISSING_IN: 'warning',
+        MISSING_OUT: 'warning',
+        ABSENT: 'danger',
+        LEAVE: 'info',
+        BUSINESS_TRIP: 'info',
+        OUTING: 'info',
+        OVERTIME: 'info',
+      };
+      const value = String(code || '');
+      if (!value) return 'info';
+      return types[value] || 'info';
     },
     minuteText(value) {
       return value === null || value === undefined ? '' : String(value);