lty/qy-lty-admin/components/home-decor/export-cards-dialog.tsx
2026-03-17 13:17:02 +08:00

136 lines
4.8 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 { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Label } from "@/components/ui/label"
import { Checkbox } from "@/components/ui/checkbox"
import { FileDown, Loader2 } from "lucide-react"
interface ExportCardsDialogProps {
decorId: string
}
export function ExportCardsDialog({ decorId }: ExportCardsDialogProps) {
const [open, setOpen] = useState(false)
const [format, setFormat] = useState("csv")
const [range, setRange] = useState("all")
const [includeHeaders, setIncludeHeaders] = useState(true)
const [includeMetadata, setIncludeMetadata] = useState(true)
const [isExporting, setIsExporting] = useState(false)
const handleExport = async () => {
setIsExporting(true)
// 模拟导出操作
await new Promise((resolve) => setTimeout(resolve, 2000))
setIsExporting(false)
setOpen(false)
}
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<Button variant="outline" className="border-purple-200 hover:bg-purple-50 hover:text-purple-700">
<FileDown className="mr-2 h-4 w-4" />
ID
</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader>
<DialogTitle className="text-xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-purple-600 to-pink-600">
ID
</DialogTitle>
<DialogDescription>
<span className="font-medium">{decorId}</span> ID
</DialogDescription>
</DialogHeader>
<div className="grid gap-4 py-4">
<div className="space-y-2">
<Label htmlFor="format"></Label>
<Select value={format} onValueChange={setFormat}>
<SelectTrigger id="format">
<SelectValue placeholder="选择格式" />
</SelectTrigger>
<SelectContent>
<SelectItem value="csv">CSV文件</SelectItem>
<SelectItem value="excel">Excel文件</SelectItem>
<SelectItem value="pdf">PDF文件</SelectItem>
<SelectItem value="json">JSON文件</SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<Label htmlFor="range"></Label>
<Select value={range} onValueChange={setRange}>
<SelectTrigger id="range">
<SelectValue placeholder="选择范围" />
</SelectTrigger>
<SelectContent>
<SelectItem value="all"></SelectItem>
<SelectItem value="unused"></SelectItem>
<SelectItem value="used"></SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-3 pt-2">
<div className="flex items-center space-x-2">
<Checkbox
id="includeHeaders"
checked={includeHeaders}
onCheckedChange={(checked) => setIncludeHeaders(!!checked)}
/>
<Label htmlFor="includeHeaders" className="text-sm font-normal cursor-pointer">
</Label>
</div>
<div className="flex items-center space-x-2">
<Checkbox
id="includeMetadata"
checked={includeMetadata}
onCheckedChange={(checked) => setIncludeMetadata(!!checked)}
/>
<Label htmlFor="includeMetadata" className="text-sm font-normal cursor-pointer">
</Label>
</div>
</div>
</div>
<DialogFooter>
<Button variant="outline" onClick={() => setOpen(false)} disabled={isExporting}>
</Button>
<Button
className="bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600"
onClick={handleExport}
disabled={isExporting}
>
{isExporting ? (
<>
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
...
</>
) : (
<>
<FileDown className="mr-2 h-4 w-4" />
</>
)}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}