"use client" import { useState } from "react" import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" import { ChevronLeft, ChevronRight } from "lucide-react" interface ScheduleCalendarDialogProps { open: boolean onOpenChange: (open: boolean) => void } const MOCK_SCHEDULE = [ { day: 12, tasks: [ { name: "数据同步", type: "sync" }, { name: "CLV训练", type: "model" }, ], }, { day: 13, tasks: [{ name: "标签计算", type: "tagging" }] }, { day: 14, tasks: [ { name: "数据清洗", type: "cleaning" }, { name: "RFM评估", type: "model" }, ], }, { day: 15, tasks: [{ name: "流失预警", type: "model" }] }, { day: 16, tasks: [{ name: "数据同步", type: "sync" }] }, { day: 18, tasks: [{ name: "用户分群", type: "tagging" }] }, { day: 20, tasks: [{ name: "数据清洗", type: "cleaning" }] }, ] const TYPE_COLORS: Record = { sync: "bg-blue-100 text-blue-700", cleaning: "bg-green-100 text-green-700", tagging: "bg-purple-100 text-purple-700", model: "bg-orange-100 text-orange-700", } export function ScheduleCalendarDialog({ open, onOpenChange }: ScheduleCalendarDialogProps) { const [currentMonth, setCurrentMonth] = useState(new Date(2025, 11)) const daysInMonth = new Date(currentMonth.getFullYear(), currentMonth.getMonth() + 1, 0).getDate() const firstDayOfMonth = new Date(currentMonth.getFullYear(), currentMonth.getMonth(), 1).getDay() const days = Array.from({ length: daysInMonth }, (_, i) => i + 1) const emptyDays = Array.from({ length: firstDayOfMonth }, (_, i) => i) const getTasksForDay = (day: number) => { return MOCK_SCHEDULE.find((s) => s.day === day)?.tasks || [] } return ( 调度日历
{currentMonth.getFullYear()}年{currentMonth.getMonth() + 1}月
{["日", "一", "二", "三", "四", "五", "六"].map((day) => (
{day}
))} {emptyDays.map((i) => (
))} {days.map((day) => { const tasks = getTasksForDay(day) return (
{day}
{tasks.slice(0, 2).map((task, i) => ( {task.name} ))} {tasks.length > 2 && +{tasks.length - 2}更多}
) })}
图例: 数据同步 数据清洗 标签计算 模型训练
) }