WXL
2025-12-28 1b736033f6d01b774d58b4c2d7cd2ce8607a44fa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<template>
  <div class="attendance-calendar">
    <el-calendar v-model="calendarValue">
      <template #date-cell="{ data }">
        <div class="calendar-date">
          <div class="date-number">{{ data.day.split('-')[2] }}</div>
          <div class="date-events">
            <div
              v-for="event in getDateEvents(data.day)"
              :key="event.id"
              class="event-item"
              :class="event.type"
            >
              <span class="event-dot"></span>
              <span class="event-text">{{ event.text }}</span>
            </div>
          </div>
        </div>
      </template>
    </el-calendar>
  </div>
</template>
 
<script>
export default {
  name: 'AttendanceCalendar',
  props: {
    attendanceData: Array,
    businessTripData: Array
  },
  data() {
    return {
      calendarValue: new Date()
    }
  },
  methods: {
    getDateEvents(date) {
      const events = []
 
      // 检查出勤记录
      const attendance = this.attendanceData.find(item => item.date === date)
      if (attendance) {
        events.push({
          id: `attendance-${date}`,
          type: 'attendance',
          text: `${attendance.checkIn}-${attendance.checkOut}`
        })
      }
 
      // 检查出差记录
      const businessTrip = this.businessTripData.find(item =>
        date >= item.startDate && date <= item.endDate
      )
      if (businessTrip) {
        events.push({
          id: `business-trip-${date}`,
          type: 'business-trip',
          text: `出差: ${businessTrip.endCity}`
        })
      }
 
      return events
    }
  }
}
</script>
 
<style scoped>
.attendance-calendar {
  padding: 20px;
}
 
.calendar-date {
  height: 100%;
  display: flex;
  flex-direction: column;
}
 
.date-number {
  font-weight: bold;
  margin-bottom: 4px;
}
 
.date-events {
  flex: 1;
  overflow: hidden;
}
 
.event-item {
  display: flex;
  align-items: center;
  margin-bottom: 2px;
  font-size: 12px;
}
 
.event-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
}
 
.event-item.attendance .event-dot {
  background-color: #67c23a;
}
 
.event-item.business-trip .event-dot {
  background-color: #409eff;
}
 
.event-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
</style>