"use client" import { useState } from "react" import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog" import { Button } from "@/components/ui/button" import { Label } from "@/components/ui/label" import { Checkbox } from "@/components/ui/checkbox" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Progress } from "@/components/ui/progress" import { RefreshCw, Database, Clock, AlertTriangle } from "lucide-react" interface BatchRecalculateDialogProps { open: boolean onOpenChange: (open: boolean) => void } const DATA_SOURCES = [ { id: "1", name: "存客宝-用户主库", records: 128956342 }, { id: "2", name: "触客宝-行为数据", records: 89234567 }, { id: "3", name: "数智员工-账号API", records: 45678901 }, ] const AI_RULES = [ { id: 1, name: "用户数据智能清洗", selected: true }, { id: 2, name: "交易流水异常检测", selected: true }, { id: 3, name: "聊天记录语义清洗", selected: false }, ] export function BatchRecalculateDialog({ open, onOpenChange }: BatchRecalculateDialogProps) { const [isProcessing, setIsProcessing] = useState(false) const [progress, setProgress] = useState(0) const [selectedRules, setSelectedRules] = useState(AI_RULES.filter((r) => r.selected).map((r) => r.id)) const [scope, setScope] = useState("incremental") const handleStart = () => { setIsProcessing(true) setProgress(0) const interval = setInterval(() => { setProgress((prev) => { if (prev >= 100) { clearInterval(interval) setIsProcessing(false) return 100 } return prev + 10 }) }, 500) } return ( 批量重算 重新执行选中的AI清洗规则,处理全量或增量数据 {isProcessing ? (

正在重算...

已处理 {progress}%

预计剩余时间: {Math.ceil(((100 - progress) / 10) * 0.5)} 分钟
) : (
{AI_RULES.map((rule) => (
{ if (checked) { setSelectedRules([...selectedRules, rule.id]) } else { setSelectedRules(selectedRules.filter((id) => id !== rule.id)) } }} /> {rule.name}
))}

注意

{scope === "full" ? "全量重算将处理所有历史数据,预计耗时较长,请确认后执行。" : "增量重算仅处理新增或变更的数据,速度较快。"}

预计处理量

{scope === "full" ? "128.9M" : scope === "failed" ? "3.4K" : "15.6K"} 条

预计耗时

{scope === "full" ? "约 2 小时" : scope === "failed" ? "约 5 分钟" : "约 15 分钟"}

)} {!isProcessing && ( )}
) }