4a04cfe15b
- 添加vite环境类型定义文件 - 优化考勤记录视图 - 修复后端时间戳处理问题 - 重构管理仪表盘响应式布局 - 改进工人历史视图卡片式布局 - 优化人员管理组件表格响应式 - 增强二维码管理组件移动端适配 - 重构考勤报表组件添加全选功能
111 lines
2.4 KiB
Vue
111 lines
2.4 KiB
Vue
<template>
|
|
<div class="history-container card">
|
|
<h2 class="card-header">My Clock History</h2>
|
|
<router-link to="/worker/dashboard" class="back-link">← Back to Dashboard</router-link>
|
|
<div v-if="!clockHistory.length" class="no-data">You have no clocking history.</div>
|
|
<div v-for="event in clockHistory" :key="event.id" class="clock-card">
|
|
<div class="card-content">
|
|
<div class="event-type" :class="event.event_type">
|
|
{{ event.event_type.replace('_', ' ') }}
|
|
</div>
|
|
<div class="timestamp">
|
|
{{ new Date(event.timestamp).toLocaleString() }}
|
|
</div>
|
|
<div class="location">
|
|
{{ event.qrCodeUsedName }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, onMounted } from 'vue'
|
|
import { useRouter } from 'vue-router'
|
|
|
|
const router = useRouter()
|
|
const clockHistory = ref([])
|
|
|
|
// --- ALIGNMENT CHANGE ---
|
|
const userId = sessionStorage.getItem('userId')
|
|
|
|
onMounted(async () => {
|
|
if (!userId) {
|
|
router.push('/')
|
|
return
|
|
}
|
|
try {
|
|
const response = await fetch(`
|
|
${import.meta.env.VITE_API_BASE_URL}/api/worker/clock-history/${userId}`)
|
|
if (response.ok) {
|
|
clockHistory.value = await response.json()
|
|
}
|
|
} catch (error) {
|
|
console.error('Failed to fetch clock history:', error)
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<style scoped>
|
|
.history-container {
|
|
max-width: 800px;
|
|
margin: auto;
|
|
}
|
|
.card-header {
|
|
margin-top: 2;
|
|
}
|
|
.back-link {
|
|
color: var(--c-primary);
|
|
text-decoration: none;
|
|
font-weight: 500;
|
|
margin-bottom: 1.5rem;
|
|
display: inline-block;
|
|
}
|
|
.no-data {
|
|
text-align: center;
|
|
padding: 2rem;
|
|
color: var(--c-text-secondary);
|
|
}
|
|
.event-type {
|
|
padding: 4px 8px;
|
|
border-radius: 6px;
|
|
color: var(--c-primary-text);
|
|
font-size: 0.85rem;
|
|
text-transform: capitalize;
|
|
white-space: nowrap; /* Prevent line breaks */
|
|
display: inline-block;
|
|
}
|
|
.event-type.clock_in {
|
|
background-color: var(--c-success);
|
|
}
|
|
.event-type.clock_out {
|
|
background-color: var(--c-secondary);
|
|
}
|
|
|
|
/* Card styles */
|
|
.clock-card {
|
|
background-color: var(--c-background-secondary);
|
|
border-radius: 8px;
|
|
box-shadow: var(--shadow-md);
|
|
padding: 16px;
|
|
margin-bottom: 16px;
|
|
}
|
|
.card-content {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
.timestamp,
|
|
.location {
|
|
margin-left: 12px;
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
/* Responsive styles */
|
|
@media (max-width: 600px) {
|
|
.history-container {
|
|
max-width: 100%;
|
|
padding: 0 1rem;
|
|
}
|
|
}
|
|
</style>
|