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

147 lines
5.3 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 { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
import { FileDown, Loader2 } from "lucide-react"
interface ExportCardsDialogProps {
propId: string
}
export function ExportCardsDialog({ propId }: ExportCardsDialogProps) {
const [open, setOpen] = useState(false)
const [format, setFormat] = useState("csv")
const [exportScope, setExportScope] = 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, 1500))
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-[500px]">
<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">{propId}</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></Label>
<RadioGroup value={exportScope} onValueChange={setExportScope} className="flex flex-col space-y-1">
<div className="flex items-center space-x-2">
<RadioGroupItem value="all" id="all" />
<Label htmlFor="all" className="font-normal">
ID
</Label>
</div>
<div className="flex items-center space-x-2">
<RadioGroupItem value="unused" id="unused" />
<Label htmlFor="unused" className="font-normal">
ID
</Label>
</div>
<div className="flex items-center space-x-2">
<RadioGroupItem value="used" id="used" />
<Label htmlFor="used" className="font-normal">
ID
</Label>
</div>
</RadioGroup>
</div>
<div className="space-y-3 pt-2">
<Label></Label>
<div className="flex items-center space-x-2">
<Checkbox
id="headers"
checked={includeHeaders}
onCheckedChange={(checked) => setIncludeHeaders(!!checked)}
/>
<Label htmlFor="headers" className="text-sm font-normal">
</Label>
</div>
<div className="flex items-center space-x-2">
<Checkbox
id="metadata"
checked={includeMetadata}
onCheckedChange={(checked) => setIncludeMetadata(!!checked)}
/>
<Label htmlFor="metadata" className="text-sm font-normal">
</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>
)
}