From efbc26783eb7f4f5564f0c9f927844f879e7ca6b Mon Sep 17 00:00:00 2001
From: buhuazhen <hua100783@gmail.com>
Date: 星期一, 25 五月 2026 16:01:10 +0800
Subject: [PATCH] feat: 打卡记录死数据重新生成
---
src/views/collaborativeApproval/attendanceManagement/index.vue | 377 ++++++++++++++++++++++-------------------------------
1 files changed, 155 insertions(+), 222 deletions(-)
diff --git a/src/views/collaborativeApproval/attendanceManagement/index.vue b/src/views/collaborativeApproval/attendanceManagement/index.vue
index f6a3e3c..5c669eb 100644
--- a/src/views/collaborativeApproval/attendanceManagement/index.vue
+++ b/src/views/collaborativeApproval/attendanceManagement/index.vue
@@ -447,7 +447,7 @@
const getAttendanceTagType = (status) => {
const tagMap = {
normal: 'success',
- late: 'warning',
+ late: 'warning',
early: 'warning',
absent: 'danger'
}
@@ -458,7 +458,7 @@
const labelMap = {
normal: '姝e父',
late: '杩熷埌',
- early: '鏃╅��',
+ early: '鏃╅��',
absent: '缂哄嫟'
}
return labelMap[status] || status
@@ -849,17 +849,17 @@
// 鎵撳崱璁板綍杩囨护鍔熻兘
const filterAttendanceData = () => {
let filtered = attendanceData.value
-
+
// 鎸夋棩鏈熻繃婊�
if (attendanceDate.value) {
filtered = filtered.filter(item => item.date === attendanceDate.value)
}
-
+
// 鎸夌姸鎬佽繃婊�
if (attendanceStatus.value) {
filtered = filtered.filter(item => item.status === attendanceStatus.value)
}
-
+
filteredAttendanceData.value = filtered
}
@@ -870,227 +870,160 @@
// 鍒濆鍖栨墦鍗¤褰曞亣鏁版嵁
const initAttendanceData = () => {
- const mockData = [
- {
- id: 1,
- employeeName: '闄堝織寮�',
- department: '鎶�鏈儴',
- date: '2025-08-15',
- clockInTime: '09:00:00',
- clockOutTime: '18:00:00',
- workHours: '8.0h',
- status: 'normal',
- location: '鍏徃鎬婚儴',
- remark: ''
- },
- {
- id: 2,
- employeeName: '鏉庨洩姊�',
- department: '甯傚満閮�',
- date: '2025-08-16',
- clockInTime: '08:58:00',
- clockOutTime: '18:05:00',
- workHours: '8.12h',
- status: 'normal',
- location: '鍏徃鎬婚儴',
- remark: ''
- },
- {
- id: 3,
- employeeName: '鐜嬪缓鍗�',
- department: '浜轰簨閮�',
- date: '2025-08-16',
- clockInTime: '09:02:00',
- clockOutTime: '18:00:00',
- workHours: '7.97h',
- status: 'normal',
- location: '鍏徃鎬婚儴',
- remark: ''
- },
- {
- id: 4,
- employeeName: '璧垫檽涓�',
- department: '璐㈠姟閮�',
- date: '2025-09-02',
- clockInTime: '08:55:00',
- clockOutTime: '18:10:00',
- workHours: '8.25h',
- status: 'normal',
- location: '鍏徃鎬婚儴',
- remark: ''
- },
- {
- id: 5,
- employeeName: '寮犲浗搴�',
- department: '鎶�鏈儴',
- date: '2025-09-02',
- clockInTime: '09:00:00',
- clockOutTime: '18:30:00',
- workHours: '8.5h',
- status: 'normal',
- location: '鍏徃鎬婚儴',
- remark: '鍔犵彮'
- },
- {
- id: 6,
- employeeName: '鍒樻槑杈�',
- department: '杩愯惀閮�',
- date: '2025-09-03',
- clockInTime: '09:05:00',
- clockOutTime: '18:00:00',
- workHours: '7.92h',
- status: 'normal',
- location: '鍏徃鎬婚儴',
- remark: ''
- },
- {
- id: 7,
- employeeName: '瀛欎附鍗�',
- department: '璁捐閮�',
- date: '2025-09-03',
- clockInTime: '08:59:00',
- clockOutTime: '18:02:00',
- workHours: '8.05h',
- status: 'normal',
- location: '鍏徃鎬婚儴',
- remark: ''
- },
- {
- id: 8,
- employeeName: '鍛ㄥ缓鍐�',
- department: '閿�鍞儴',
- date: '2025-09-04',
- clockInTime: '09:15:00',
- clockOutTime: '18:00:00',
- workHours: '7.75h',
- status: 'late',
- location: '鍏徃鎬婚儴',
- remark: '浜ら�氬牭濉�'
- },
- {
- id: 9,
- employeeName: '鍚村皬鑺�',
- department: '瀹㈡湇閮�',
- date: '2025-09-04',
- clockInTime: '09:01:00',
- clockOutTime: '18:00:00',
- workHours: '7.98h',
- status: 'normal',
- location: '鍏徃鎬婚儴',
- remark: ''
- },
- {
- id: 10,
- employeeName: '椹枃鏉�',
- department: '鎶�鏈儴',
- date: '2025-09-05',
- clockInTime: '08:57:00',
- clockOutTime: '17:30:00',
- workHours: '7.55h',
- status: 'early',
- location: '鍏徃鎬婚儴',
- remark: '鏈夋�ヤ簨鎻愬墠绂诲紑'
- },
- {
- id: 11,
- employeeName: '鏋楁檽涓�',
- department: '琛屾斂閮�',
- date: '2025-09-05',
- clockInTime: '09:03:00',
- clockOutTime: '18:08:00',
- workHours: '8.08h',
- status: 'normal',
- location: '鍏徃鎬婚儴',
- remark: ''
- },
- {
- id: 12,
- employeeName: '榛勭編鐜�',
- department: '璐㈠姟閮�',
- date: '2025-09-06',
- clockInTime: '',
- clockOutTime: '',
- workHours: '0h',
- status: 'absent',
- location: '',
- remark: '璇风梾鍋�'
- },
- {
- id: 13,
- employeeName: '閮戞捣娑�',
- department: '甯傚満閮�',
- date: '2025-08-14',
- clockInTime: '09:00:00',
- clockOutTime: '18:00:00',
- workHours: '8.0h',
- status: 'normal',
- location: '鍏徃鎬婚儴',
- remark: ''
- },
- {
- id: 14,
- employeeName: '璋附濞�',
- department: '浜轰簨閮�',
- date: '2025-08-20',
- clockInTime: '08:58:00',
- clockOutTime: '18:03:00',
- workHours: '8.08h',
- status: 'normal',
- location: '鍏徃鎬婚儴',
- remark: ''
- },
- {
- id: 15,
- employeeName: '浣曞織浼�',
- department: '鎶�鏈儴',
- date: '2025-08-21',
- clockInTime: '09:10:00',
- clockOutTime: '18:00:00',
- workHours: '7.83h',
- status: 'late',
- location: '鍏徃鎬婚儴',
- remark: ''
- },
- {
- id: 16,
- employeeName: '璁搁泤鑺�',
- department: '璁捐閮�',
- date: '2025-08-22',
- clockInTime: '09:01:00',
- clockOutTime: '18:00:00',
- workHours: '7.98h',
- status: 'normal',
- location: '鍏徃鎬婚儴',
- remark: ''
- },
- {
- id: 17,
- employeeName: '閭撳缓骞�',
- department: '杩愯惀閮�',
- date: '2025-09-10',
- clockInTime: '08:59:00',
- clockOutTime: '18:05:00',
- workHours: '8.1h',
- status: 'normal',
- location: '鍏徃鎬婚儴',
- remark: ''
- },
- {
- id: 18,
- employeeName: '鏇惧皬绾�',
- department: '瀹㈡湇閮�',
- date: '2025-09-11',
- clockInTime: '09:02:00',
- clockOutTime: '18:00:00',
- workHours: '7.97h',
- status: 'normal',
- location: '鍏徃鎬婚儴',
- remark: ''
+ // 灏濊瘯浠巐ocalStorage璇诲彇宸茬紦瀛樼殑鏁版嵁
+ const cachedData = localStorage.getItem('attendanceMockData')
+ const cacheDate = localStorage.getItem('attendanceMockDataDate')
+
+ // 濡傛灉鏈夌紦瀛樻暟鎹笖鏄綋澶╃敓鎴愮殑锛岀洿鎺ヤ娇鐢�
+ const today = new Date().toISOString().split('T')[0]
+ if (cachedData && cacheDate === today) {
+ try {
+ attendanceData.value = JSON.parse(cachedData)
+ filteredAttendanceData.value = attendanceData.value
+ console.log('浣跨敤缂撳瓨鐨勮�冨嫟鏁版嵁')
+ return
+ } catch (e) {
+ console.warn('缂撳瓨鏁版嵁瑙f瀽澶辫触锛岄噸鏂扮敓鎴�')
}
+ }
+
+ // 鍛樺伐鍒楄〃
+ const employees = [
+ { name: '鏈卞�╁��', department: '鎶�鏈儴' },
+ { name: '鑻忛槼', department: '甯傚満閮�' },
+ { name: '鏋楀皬姊�', department: '浜轰簨閮�' },
+ { name: '鑼冩捣椋�', department: '璐㈠姟閮�' },
+ { name: '涓ユ晠鍩�', department: '鎶�鏈儴' },
+ { name: '姹浆姊�', department: '杩愯惀閮�' },
+ { name: '寮犲潳', department: '璁捐閮�' },
+ { name: '寮犲悰', department: '閿�鍞儴' },
+ { name: '鏉ㄨ檸', department: '琛屾斂閮�' },
+ { name: '鎷滃ぉ涔�', department: '瀹㈡湇閮�' }
]
-
+
+ // 2025骞存硶瀹氳妭鍋囨棩
+ const holidays = [
+ // 鍏冩棪
+ '2025-01-01',
+ // 鏄ヨ妭 (1鏈�28鏃�-2鏈�4鏃�)
+ '2025-01-28', '2025-01-29', '2025-01-30', '2025-01-31',
+ '2025-02-01', '2025-02-02', '2025-02-03', '2025-02-04',
+ // 娓呮槑鑺� (4鏈�4鏃�-6鏃�)
+ '2025-04-04', '2025-04-05', '2025-04-06',
+ // 鍔冲姩鑺� (5鏈�1鏃�-5鏃�)
+ '2025-05-01', '2025-05-02', '2025-05-03', '2025-05-04', '2025-05-05',
+ // 绔崍鑺� (5鏈�31鏃�-6鏈�2鏃�)
+ '2025-05-31'
+ ]
+
+ const holidaySet = new Set(holidays)
+
+ // 鍒ゆ柇鏄惁涓哄伐浣滄棩锛堝崟浼戯紝鍛ㄦ棩浼戞伅锛�
+ const isWorkday = (dateStr) => {
+ if (holidaySet.has(dateStr)) return false
+ const date = new Date(dateStr)
+ const dayOfWeek = date.getDay()
+ return dayOfWeek !== 0 // 鍛ㄦ棩浼戞伅
+ }
+
+ // 鐢熸垚鏃ユ湡鑼冨洿鍐呯殑鎵�鏈夊伐浣滄棩
+ const startDate = new Date('2025-01-01')
+ const endDate = new Date('2025-05-25')
+ const workdays = []
+
+ for (let d = new Date(startDate); d <= endDate; d.setDate(d.getDate() + 1)) {
+ const dateStr = d.toISOString().split('T')[0]
+ if (isWorkday(dateStr)) {
+ workdays.push(dateStr)
+ }
+ }
+
+ // 鐢熸垚鎵撳崱璁板綍
+ const mockData = []
+ let id = 1
+
+ // 闅忔満鐢熸垚鎵撳崱鏃堕棿锛堝叏閮ㄦ甯革級
+ const generateClockTime = (isClockIn) => {
+ if (isClockIn) {
+ // 涓婄彮鎵撳崱锛�8:50-9:00涔嬮棿锛堝叏閮ㄦ甯革級
+ const minutes = Math.floor(Math.random() * 11) + 50 // 50-60鍒嗛挓
+ const hour = 8
+ const min = minutes
+ return `${hour.toString().padStart(2, '0')}:${min.toString().padStart(2, '0')}:00`
+ } else {
+ // 涓嬬彮鎵撳崱锛�18:00-18:30涔嬮棿锛堝叏閮ㄦ甯革級
+ const minutes = Math.floor(Math.random() * 31) // 0-30鍒嗛挓
+ const hour = 18
+ return `${hour.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:00`
+ }
+ }
+
+ // 璁$畻宸ヤ綔鏃堕暱
+ const calculateWorkHours = (clockIn, clockOut) => {
+ if (!clockIn || !clockOut) return '0h'
+ const [inH, inM] = clockIn.split(':').map(Number)
+ const [outH, outM] = clockOut.split(':').map(Number)
+ const inMinutes = inH * 60 + inM
+ const outMinutes = outH * 60 + outM
+ const diff = outMinutes - inMinutes
+ const hours = Math.floor(diff / 60)
+ const mins = diff % 60
+ return `${hours}.${Math.round(mins / 6)}h`
+ }
+
+ // 涓烘瘡涓憳宸ョ殑姣忎釜宸ヤ綔鏃ョ敓鎴愭墦鍗¤褰�
+ employees.forEach(employee => {
+ workdays.forEach(date => {
+ // 闅忔満鍐冲畾鏄惁璇峰亣锛�1%姒傜巼锛夋垨鍔犵彮锛�10%姒傜巼锛�
+ const random = Math.random()
+ let clockInTime = ''
+ let clockOutTime = ''
+ let status = 'normal'
+ let remark = ''
+
+ if (random < 0.01) {
+ // 璇峰亣锛�1%姒傜巼锛�
+ remark = Math.random() < 0.5 ? '璇风梾鍋�' : '璇蜂簨鍋�'
+ status = 'absent'
+ } else {
+ clockInTime = generateClockTime(true)
+ clockOutTime = generateClockTime(false)
+ status = 'normal'
+
+ // 鍔犵彮澶囨敞锛�10%姒傜巼锛�
+ if (Math.random() < 0.1) {
+ remark = '鍔犵彮'
+ }
+ }
+
+ mockData.push({
+ id: id++,
+ employeeName: employee.name,
+ department: employee.department,
+ date: date,
+ clockInTime: clockInTime,
+ clockOutTime: clockOutTime,
+ workHours: calculateWorkHours(clockInTime, clockOutTime),
+ status: status,
+ location: '鍏徃鎬婚儴',
+ remark: remark
+ })
+ })
+ })
+
+ // 鎸夋棩鏈熸帓搴�
+ mockData.sort((a, b) => {
+ if (a.date !== b.date) return a.date.localeCompare(b.date)
+ return a.id - b.id
+ })
+
+ // 缂撳瓨鏁版嵁鍒發ocalStorage
+ localStorage.setItem('attendanceMockData', JSON.stringify(mockData))
+ localStorage.setItem('attendanceMockDataDate', today)
+
attendanceData.value = mockData
filteredAttendanceData.value = mockData
+ console.log('鐢熸垚鏂扮殑鑰冨嫟鏁版嵁骞剁紦瀛�')
}
// 鍒犻櫎椤圭洰
--
Gitblit v1.9.3