"use client" import { useState } from "react" import { BarChart3, Plus, Play, Search, Users, Clock, CheckCircle, XCircle, RefreshCw, Download, Filter, } from "lucide-react" import { Card, CardContent } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Badge } from "@/components/ui/badge" import { Progress } from "@/components/ui/progress" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { CreateAssessmentTaskDialog } from "@/components/dialogs/create-assessment-task-dialog" interface AssessmentTask { id: string name: string model: string targetCrowd: string userCount: number status: "running" | "completed" | "failed" | "scheduled" progress: number createdAt: string completedAt: string | null schedule: string resultSummary?: { avgScore: number highValue: number mediumValue: number lowValue: number } } const MOCK_TASKS: AssessmentTask[] = [ { id: "1", name: "全量用户CLV评估", model: "CLV预测模型 v2.3.1", targetCrowd: "全部用户", userCount: 4028567890, status: "completed", progress: 100, createdAt: "2025-12-12 00:00:00", completedAt: "2025-12-12 03:45:00", schedule: "每周一", resultSummary: { avgScore: 65.8, highValue: 15.2, mediumValue: 45.6, lowValue: 39.2, }, }, { id: "2", name: "活跃用户RFM评分", model: "RFM评分模型 v1.5.0", targetCrowd: "近30天活跃用户", userCount: 1256789012, status: "running", progress: 67, createdAt: "2025-12-12 10:00:00", completedAt: null, schedule: "每天", }, { id: "3", name: "流失风险预警", model: "流失预警模型 v3.1.2", targetCrowd: "沉默用户", userCount: 456789012, status: "completed", progress: 100, createdAt: "2025-12-11 22:00:00", completedAt: "2025-12-12 00:30:00", schedule: "每天", resultSummary: { avgScore: 0.45, highValue: 8.5, mediumValue: 25.3, lowValue: 66.2, }, }, { id: "4", name: "高价值用户细分", model: "用户分群模型 v1.0.0", targetCrowd: "价值评分>80用户", userCount: 125678901, status: "scheduled", progress: 0, createdAt: "2025-12-12 14:00:00", completedAt: null, schedule: "每周", }, { id: "5", name: "欺诈风险扫描", model: "欺诈检测模型 v2.0.0", targetCrowd: "近7天交易用户", userCount: 89012345, status: "failed", progress: 45, createdAt: "2025-12-12 08:00:00", completedAt: null, schedule: "实时", }, ] const STATUS_CONFIG = { running: { label: "运行中", color: "bg-blue-100 text-blue-700", icon: RefreshCw }, completed: { label: "已完成", color: "bg-green-100 text-green-700", icon: CheckCircle }, failed: { label: "失败", color: "bg-red-100 text-red-700", icon: XCircle }, scheduled: { label: "已排期", color: "bg-yellow-100 text-yellow-700", icon: Clock }, } export default function AssessmentServicePage() { const [tasks, setTasks] = useState(MOCK_TASKS) const [searchQuery, setSearchQuery] = useState("") const [statusFilter, setStatusFilter] = useState("all") const [showCreateDialog, setShowCreateDialog] = useState(false) const formatNumber = (num: number): string => { if (num >= 1000000000) return `${(num / 1000000000).toFixed(2)}B` if (num >= 1000000) return `${(num / 1000000).toFixed(1)}M` if (num >= 1000) return `${(num / 1000).toFixed(1)}K` return num.toString() } const filteredTasks = tasks.filter((task) => { const matchesSearch = task.name.toLowerCase().includes(searchQuery.toLowerCase()) const matchesStatus = statusFilter === "all" || task.status === statusFilter return matchesSearch && matchesStatus }) const stats = { total: tasks.length, running: tasks.filter((t) => t.status === "running").length, completed: tasks.filter((t) => t.status === "completed").length, totalEvaluated: tasks.filter((t) => t.status === "completed").reduce((sum, t) => sum + t.userCount, 0), } return (
{/* Header */}

评估服务

执行价值评估任务

{/* Stats */}
总任务数
{stats.total}
运行中
{stats.running}
已完成
{stats.completed}
已评估用户
{formatNumber(stats.totalEvaluated)}
{/* Filters */}
setSearchQuery(e.target.value)} className="pl-10 bg-white/60" />
{/* Task List */}
{filteredTasks.map((task) => { const StatusIcon = STATUS_CONFIG[task.status].icon return (

{task.name}

{STATUS_CONFIG[task.status].label}
模型: {task.model} 目标: {task.targetCrowd} 用户数: {formatNumber(task.userCount)} 周期: {task.schedule}
{task.status === "completed" && ( )} {(task.status === "scheduled" || task.status === "failed") && ( )}
{task.status === "running" && (
执行进度 {task.progress}%
)} {task.resultSummary && (
{task.resultSummary.avgScore}
平均分
{task.resultSummary.highValue}%
高价值
{task.resultSummary.mediumValue}%
中价值
{task.resultSummary.lowValue}%
低价值
)}
创建时间: {task.createdAt} {task.completedAt && 完成时间: {task.completedAt}}
) })}
{/* Create Task Dialog */}
) }