Files
users/components/dialogs/cleaning-rule-settings-dialog.tsx
v0 b17b488f8e refactor: restructure navigation and module layout
Reorganize navigation and module structure based on new requirements.

Co-authored-by: null <4804959+fnvtk@users.noreply.github.com>
2026-01-31 04:32:36 +00:00

224 lines
8.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client"
import { useState } from "react"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { Textarea } from "@/components/ui/textarea"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Switch } from "@/components/ui/switch"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import { Settings, Code, Clock, Bell } from "lucide-react"
interface CleaningRuleSettingsDialogProps {
open: boolean
onOpenChange: (open: boolean) => void
rule?: {
id: string
name: string
description: string
type: string
sourceTable: string
targetTable: string
status: string
}
}
export function CleaningRuleSettingsDialog({ open, onOpenChange, rule }: CleaningRuleSettingsDialogProps) {
const [activeTab, setActiveTab] = useState("basic")
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-2xl">
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
<Settings className="w-5 h-5" />
- {rule?.name || "清洗规则"}
</DialogTitle>
<DialogDescription></DialogDescription>
</DialogHeader>
<Tabs value={activeTab} onValueChange={setActiveTab}>
<TabsList className="grid w-full grid-cols-4">
<TabsTrigger value="basic"></TabsTrigger>
<TabsTrigger value="logic"></TabsTrigger>
<TabsTrigger value="schedule"></TabsTrigger>
<TabsTrigger value="alert"></TabsTrigger>
</TabsList>
<TabsContent value="basic" className="space-y-4 mt-4">
<div className="grid grid-cols-2 gap-4">
<div className="space-y-2">
<Label></Label>
<Input defaultValue={rule?.name} />
</div>
<div className="space-y-2">
<Label></Label>
<Select defaultValue={rule?.type}>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="format"></SelectItem>
<SelectItem value="dedup"></SelectItem>
<SelectItem value="mapping"></SelectItem>
<SelectItem value="validate"></SelectItem>
<SelectItem value="transform"></SelectItem>
</SelectContent>
</Select>
</div>
</div>
<div className="space-y-2">
<Label></Label>
<Textarea defaultValue={rule?.description} rows={3} />
</div>
<div className="grid grid-cols-2 gap-4">
<div className="space-y-2">
<Label></Label>
<Input defaultValue={rule?.sourceTable} />
</div>
<div className="space-y-2">
<Label></Label>
<Input defaultValue={rule?.targetTable} />
</div>
</div>
<div className="flex items-center justify-between p-4 bg-slate-50 rounded-lg">
<div>
<p className="font-medium"></p>
<p className="text-sm text-slate-500"></p>
</div>
<Switch defaultChecked={rule?.status === "active"} />
</div>
</TabsContent>
<TabsContent value="logic" className="space-y-4 mt-4">
<div className="space-y-2">
<Label className="flex items-center gap-2">
<Code className="w-4 h-4" />
SQL逻辑
</Label>
<div className="bg-slate-900 rounded-lg p-4 font-mono text-sm text-green-400 min-h-[200px]">
<pre>{`-- 清洗逻辑示例
SELECT
user_id,
TRIM(LOWER(email)) as email,
REGEXP_REPLACE(phone, '[^0-9]', '') as phone
FROM ${rule?.sourceTable || "source_table"}
WHERE email IS NOT NULL;`}</pre>
</div>
</div>
<div className="grid grid-cols-2 gap-4">
<div className="space-y-2">
<Label></Label>
<Input type="number" defaultValue="10000" />
</div>
<div className="space-y-2">
<Label>线</Label>
<Input type="number" defaultValue="4" />
</div>
</div>
<div className="flex items-center justify-between p-4 bg-slate-50 rounded-lg">
<div>
<p className="font-medium"></p>
<p className="text-sm text-slate-500"></p>
</div>
<Switch defaultChecked />
</div>
</TabsContent>
<TabsContent value="schedule" className="space-y-4 mt-4">
<div className="space-y-2">
<Label className="flex items-center gap-2">
<Clock className="w-4 h-4" />
</Label>
<Select defaultValue="cron">
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="manual"></SelectItem>
<SelectItem value="interval"></SelectItem>
<SelectItem value="cron">Cron表达式</SelectItem>
<SelectItem value="realtime"></SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<Label>Cron表达式</Label>
<Input defaultValue="0 */1 * * *" placeholder="例: 0 */1 * * * (每小时执行)" />
<p className="text-xs text-slate-500"></p>
</div>
<div className="grid grid-cols-2 gap-4">
<div className="space-y-2">
<Label>()</Label>
<Input type="number" defaultValue="30" />
</div>
<div className="space-y-2">
<Label></Label>
<Input type="number" defaultValue="3" />
</div>
</div>
</TabsContent>
<TabsContent value="alert" className="space-y-4 mt-4">
<div className="flex items-center justify-between p-4 bg-slate-50 rounded-lg">
<div className="flex items-center gap-2">
<Bell className="w-4 h-4" />
<div>
<p className="font-medium"></p>
<p className="text-sm text-slate-500"></p>
</div>
</div>
<Switch defaultChecked />
</div>
<div className="flex items-center justify-between p-4 bg-slate-50 rounded-lg">
<div className="flex items-center gap-2">
<Bell className="w-4 h-4" />
<div>
<p className="font-medium"></p>
<p className="text-sm text-slate-500"></p>
</div>
</div>
<Switch defaultChecked />
</div>
<div className="space-y-2">
<Label>(%)</Label>
<Input type="number" defaultValue="5" />
</div>
<div className="space-y-2">
<Label></Label>
<Select defaultValue="all">
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="email"></SelectItem>
<SelectItem value="sms"></SelectItem>
<SelectItem value="webhook">Webhook</SelectItem>
<SelectItem value="all"></SelectItem>
</SelectContent>
</Select>
</div>
</TabsContent>
</Tabs>
<DialogFooter>
<Button variant="outline" onClick={() => onOpenChange(false)}>
</Button>
<Button onClick={() => onOpenChange(false)}></Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}