Browse Source

fix: 修复人才端考勤记录数据一致性问题

- 工作日全部正常打卡(08:30-17:30),周末不打卡
- 统计数据与明细记录保持一致
- 解决本月出勤与考勤数据不一致问题

Generated with [Claude Code](https://claude.com/claude-code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
yourname 8 hours ago
parent
commit
ca6e880b1f
1 changed files with 10 additions and 23 deletions
  1. 10 23
      mini-ui-packages/rencai-attendance-ui/src/utils/mockAttendanceData.ts

+ 10 - 23
mini-ui-packages/rencai-attendance-ui/src/utils/mockAttendanceData.ts

@@ -47,7 +47,7 @@ function isWeekend(date: Date): boolean {
 
 /**
  * 生成指定月份的模拟考勤数据
- * 注:使用固定值作为展示层修复(业务需求:22天,100%)
+ * 使用固定值:22天正常出勤,100%出勤率,无迟到早退
  * @param year 年份
  * @param month 月份 (1-12)
  * @returns 考勤统计数据和打卡记录
@@ -58,6 +58,7 @@ export function generateMockAttendanceData(year: number, month: number): {
 } {
   const dates = getDatesInMonth(year, month)
   const records: AttendanceRecord[] = []
+  let workDayCount = 0
 
   // 从后向前生成记录(倒序)
   for (let i = dates.length - 1; i >= 0; i--) {
@@ -75,37 +76,22 @@ export function generateMockAttendanceData(year: number, month: number): {
         status: AttendanceStatus.NORMAL
       })
     } else {
-      // 工作日随机生成打卡记录
-      const random = Math.random()
-      let status = AttendanceStatus.NORMAL
-      let checkInTime = '08:30'
-      let checkOutTime = '17:30'
-
-      // 10%概率迟到
-      if (random < 0.1) {
-        status = AttendanceStatus.LATE
-        checkInTime = '09:15'
-      }
-      // 10%概率早退(排除迟到的情况)
-      else if (random >= 0.1 && random < 0.2) {
-        status = AttendanceStatus.EARLY_LEAVE
-        checkOutTime = '16:30'
-      }
-
+      // 工作日全部正常打卡
+      workDayCount++
       records.push({
         date: formatDate(date),
         weekday,
-        checkInTime,
-        checkOutTime,
-        status
+        checkInTime: '08:30',
+        checkOutTime: '17:30',
+        status: AttendanceStatus.NORMAL
       })
     }
   }
 
-  // 使用固定值作为展示层修复(业务需求:22天,100%)
+  // 固定统计数据:符合业务需求
   const stats: AttendanceStats = {
     attendanceRate: 100,
-    normalDays: 22,
+    normalDays: workDayCount,
     lateCount: 0,
     earlyLeaveCount: 0,
     absentCount: 0
@@ -154,3 +140,4 @@ export function getNextMonth(year: number, month: number): { year: number; month
   }
   return { year, month: month + 1 }
 }
+