/** * 员工 Hub 首页 — 员工端统一入口 * 展示个人概览、待办事项、快捷入口、公司公告 */ import { useQuery } from '@tanstack/react-query' import { Link } from 'react-router-dom' import { DollarSign, FileText, CalendarCheck, ScrollText, CalendarClock, AlertCircle, ChevronRight, UserX, PenTool, } from 'lucide-react' import { portalApi } from '../../lib/api-services' import Card from '../../components/ui/Card' import { InlineAlert } from '../../components/ui/InlineAlert' /** 金额格式化 */ const fmt = (n: number) => (n || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) /** 快捷入口配置 */ const QUICK_ACTIONS = [ { path: '/portal/payslip', label: '工资条', icon: DollarSign, color: 'bg-emerald-50 text-emerald-600' }, { path: '/portal/contract', label: '我的合同', icon: FileText, color: 'bg-blue-50 text-blue-600' }, { path: '/portal/esign', label: '电子签署', icon: PenTool, color: 'bg-violet-50 text-violet-600' }, { path: '/portal/attendance', label: '我的考勤', icon: CalendarCheck, color: 'bg-purple-50 text-purple-600' }, { path: '/portal/leave', label: '休假申请', icon: CalendarClock, color: 'bg-cyan-50 text-cyan-600' }, { path: '/portal/policies', label: '规章制度', icon: ScrollText, color: 'bg-amber-50 text-amber-600' }, ] export default function EmployeeHome() { const employee = (() => { try { return JSON.parse(localStorage.getItem('portalEmployee') || '{}') } catch { return {} } })() /** 获取员工首页概览数据 */ const { data: overview, isLoading } = useQuery({ queryKey: ['portal-home-overview'], queryFn: async () => { return await portalApi.homeOverview() }, }) if (isLoading) { return
} const latestPayslip = overview?.latestPayslip const contractInfo = overview?.contract const pendingTasks = overview?.pendingTasks || [] const announcements = overview?.announcements || [] const attendanceSummary = overview?.attendance return (
{/* 欢迎卡片 */}

你好,{employee.name || '同事'}

{employee.department || ''} · {employee.position || ''}

本月实发
¥{fmt(latestPayslip?.netPay || 0)}
{/* 待办提醒 */} {pendingTasks.length > 0 && (

待办事项({pendingTasks.length})

{pendingTasks.map((task: any, i: number) => ( {task.message} ))}
)} {/* 快捷入口 */}

快捷入口

{QUICK_ACTIONS.map((action) => { const Icon = action.icon return (
{action.label} ) })}
{/* 最新工资条 */} {latestPayslip && (

最新工资条

查看全部
月份
{latestPayslip.month}
应发合计
¥{fmt(latestPayslip.grossPay)}
实发合计
¥{fmt(latestPayslip.netPay)}
)} {/* 合同状态 */} {contractInfo && (

合同信息

详情
合同类型 {contractInfo.typeLabel || '—'}
合同期间 {contractInfo.startDate} ~ {contractInfo.endDate || '无固定期'}
{contractInfo.daysToExpire !== null && contractInfo.daysToExpire !== undefined && (
到期天数 {contractInfo.daysToExpire > 0 ? `${contractInfo.daysToExpire}天后到期` : '已到期'}
)}
)} {/* 考勤概览 */} {attendanceSummary && (

本月考勤

详情
{attendanceSummary.normalDays || 0}
正常
{attendanceSummary.lateCount || 0}
迟到
{attendanceSummary.leaveDays || 0}
请假
{attendanceSummary.absentDays || 0}
缺勤
)} {/* 公司公告 */} {announcements.length > 0 && (

公司公告

{announcements.slice(0, 3).map((ann: any, i: number) => (
{ann.title}
{ann.date} · {ann.author}
))}
)} {/* 辞职申请入口 */}
辞职申请
提交辞职申请
) }