"use client" import { useState, useEffect } from "react" import { Smartphone, Wifi, WifiOff } from "lucide-react" import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Button } from "@/components/ui/button" import { Checkbox } from "@/components/ui/checkbox" import { ScrollArea } from "@/components/ui/scroll-area" interface Device { id: string name: string imei: string status: "online" | "offline" wechatAccount?: string } interface DeviceConfigDialogProps { open: boolean onOpenChange: (open: boolean) => void selectedDevices: string[] onSelect: (devices: string[]) => void } export function DeviceConfigDialog({ open, onOpenChange, selectedDevices, onSelect }: DeviceConfigDialogProps) { const [devices, setDevices] = useState([]) const [selected, setSelected] = useState(selectedDevices) const [loading, setLoading] = useState(true) useEffect(() => { if (open) { loadDevices() } }, [open]) const loadDevices = async () => { setLoading(true) try { // 模拟加载设备列表 await new Promise((resolve) => setTimeout(resolve, 500)) setDevices([ { id: "1", name: "设备1", imei: "sd123123", status: "online", wechatAccount: "wxid_abc123", }, { id: "2", name: "设备2", imei: "sd123124", status: "online", wechatAccount: "wxid_xyz789", }, { id: "3", name: "设备3", imei: "sd123125", status: "offline", wechatAccount: "wxid_def456", }, ]) } finally { setLoading(false) } } const handleToggle = (deviceId: string) => { setSelected((prev) => (prev.includes(deviceId) ? prev.filter((id) => id !== deviceId) : [...prev, deviceId])) } const handleConfirm = () => { onSelect(selected) } return ( 选择执行设备 选择用于执行电话获客任务的设备 {loading ? (
加载设备列表中...
) : ( <>
{devices.map((device) => (
handleToggle(device.id)} disabled={device.status === "offline"} />
{device.name}
{device.status === "online" ? ( ) : ( )}

IMEI: {device.imei}

{device.wechatAccount &&

微信: {device.wechatAccount}

}
))}

已选择 {selected.length} 个设备

)}
) }