/** * TaskCenter 任务中心组件 — 展示待办队列、人员动态和下一步行动 * 从 /dashboard/workspace/next-actions 获取数据,按优先级分组展示 */ import { useQuery } from '@tanstack/react-query' import { Link } from 'react-router-dom' import { AlertCircle, Layers, FileText, Heart, ArrowRight, ListTodo, Wallet } from 'lucide-react' import { dashboardApi } from '../../lib/api-services' import { InlineAlert } from '../../components/ui/InlineAlert' interface NextAction { id: string title: string subtitle?: string type?: string level?: string dueDate?: string link: string } interface ActionGroup { category: string priority: 'high' | 'medium' | 'low' items: NextAction[] } const categoryIcons: Record = { '待办事项': AlertCircle, '发薪批次': Layers, '发薪提醒': Wallet, '合同到期': FileText, '特殊状态': Heart, } const priorityColors: Record = { high: 'text-danger', medium: 'text-warning', low: 'text-info', } /** * 任务中心 — 首页核心组件,聚合展示需要关注的行动项 */ export function TaskCenter() { const { data, isLoading } = useQuery<{ actions: ActionGroup[]; totalCount: number }>({ queryKey: ['next-actions'], queryFn: async () => { return await dashboardApi.nextActions() }, staleTime: 60_000, }) if (isLoading) { return (

任务中心

{[1, 2, 3].map(i => (
))}
) } if (!data || data.totalCount === 0) { return (

任务中心

当前没有需要处理的事项,一切正常。
) } return (

任务中心

{data.totalCount} 项待处理
{data.actions.map((group) => { const Icon = categoryIcons[group.category] || AlertCircle return (
{/* 分类标题 */}
{group.category} ({group.items.length})
{/* 行动项列表 */}
{group.items.map((item) => (
{item.title}
{item.subtitle && (
{item.subtitle}
)}
{item.dueDate && ( {item.dueDate} )} ))} {group.items.length > 5 && ( 查看全部 {group.items.length} 项 → )}
) })}
) }