import { useState } from 'react' import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query' import { toast } from 'sonner' import { CalendarCheck, CheckCircle, Clock, AlertCircle, Upload } from 'lucide-react' import api from '../lib/api' import Card from '../components/ui/Card' import Button from '../components/ui/Button' import EmptyState from '../components/ui/EmptyState' const STATUS_CONFIG: Record = { PENDING: { label: '待确认', color: 'text-amber-700', bg: 'bg-amber-100', icon: Clock }, CONFIRMED: { label: '已确认', color: 'text-green-700', bg: 'bg-green-100', icon: CheckCircle }, DISPUTED: { label: '有异议', color: 'text-red-700', bg: 'bg-red-100', icon: AlertCircle }, } /** * 考勤确认管理页面 */ export default function Attendance() { const queryClient = useQueryClient() const [month, setMonth] = useState(new Date().toISOString().slice(0, 7)) const { data: list, isLoading } = useQuery({ queryKey: ['attendance', month], queryFn: async () => { const res = await api.get(`/attendance?month=${month}`) as any return res.data }, }) const { data: stats } = useQuery({ queryKey: ['attendance-stats', month], queryFn: async () => { const res = await api.get(`/attendance/stats?month=${month}`) as any return res.data }, }) return (

考勤确认

月度考勤数据确认与异议管理

setMonth(e.target.value)} className="px-3 py-1.5 text-sm border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary" />
{/* 统计卡片 */} {stats && (
{[ { label: '总计', value: stats.total, color: 'text-gray-700' }, { label: '待确认', value: stats.pending, color: 'text-amber-600' }, { label: '已确认', value: stats.confirmed, color: 'text-green-600' }, { label: '有异议', value: stats.disputed, color: 'text-red-600' }, ].map(s => (
{s.value}
{s.label}
))}
)} {isLoading ? (
加载中...
) : !list || list.length === 0 ? ( ) : (
{list.map((item: any) => { const config = STATUS_CONFIG[item.status] || STATUS_CONFIG.PENDING const StatusIcon = config.icon return (
{item.employee?.name} {item.employee?.department}
出勤 {item.workDays} 天 工作日加班 {item.weekdayHours}h 周末加班 {item.weekendHours}h 法定加班 {item.holidayHours}h 加班费 ¥{item.overtimePay?.toFixed(2)}
{item.disputeNote && (
异议说明:{item.disputeNote}
)}
{config.label}
) })}
)}
) }