"use client" import { useState } from "react" import { Card, CardContent } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Label } from "@/components/ui/label" import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from "@/components/ui/dropdown-menu" import { CheckCircle2, ChevronDown, ChevronUp, Smartphone } from "lucide-react" import { ScrollArea } from "@/components/ui/scroll-area" import { Badge } from "@/components/ui/badge" export interface DeviceSelectionData { selectedDevices: string[] selectedDatabase: string selectedAudience: string } interface DeviceSelectionProps { initialData: DeviceSelectionData onSave: (data: DeviceSelectionData) => void onBack: () => void } // 模拟设备数据 const mockDevices = [ { id: "1", name: "iPhone 13", status: "online", lastActive: "刚刚" }, { id: "2", name: "华为 P40", status: "offline", lastActive: "3小时前" }, { id: "3", name: "小米 11", status: "online", lastActive: "1小时前" }, { id: "4", name: "OPPO Find X3", status: "offline", lastActive: "昨天" }, { id: "5", name: "vivo X60", status: "online", lastActive: "刚刚" }, ] // 模拟数据库选项 const databaseOptions = [ { id: "all", name: "全部客户" }, { id: "new", name: "新客户" }, { id: "vip", name: "VIP客户" }, ] // 模拟用户群体选项 const audienceOptions = [ { id: "all", name: "全部好友" }, { id: "active", name: "活跃好友" }, { id: "inactive", name: "不活跃好友" }, { id: "recent", name: "最近添加" }, ] export function DeviceSelection({ initialData, onSave, onBack }: DeviceSelectionProps) { const [formData, setFormData] = useState(initialData) const [devices, setDevices] = useState(mockDevices) const [showAllDevices, setShowAllDevices] = useState(false) const toggleDevice = (deviceId: string) => { const newSelectedDevices = formData.selectedDevices.includes(deviceId) ? formData.selectedDevices.filter((id) => id !== deviceId) : [...formData.selectedDevices, deviceId] setFormData({ ...formData, selectedDevices: newSelectedDevices }) } const selectAllDevices = () => { const allDeviceIds = devices.map((device) => device.id) setFormData({ ...formData, selectedDevices: allDeviceIds }) } const clearDeviceSelection = () => { setFormData({ ...formData, selectedDevices: [] }) } // 用于显示的设备 const displayedDevices = showAllDevices ? devices : devices.slice(0, 3) return (
{displayedDevices.map((device) => (
toggleDevice(device.id)} >

{device.name}

{device.status === "online" ? "在线" : "离线"} {device.lastActive}
{formData.selectedDevices.includes(device.id) && }
))} {devices.length > 3 && ( )}

选择需要点赞的目标客户群体

{databaseOptions.map((option) => ( setFormData({ ...formData, selectedDatabase: option.id })} className="flex items-center justify-between cursor-pointer" > {option.name} {formData.selectedDatabase === option.id && } ))}

选择需要点赞的好友范围

{audienceOptions.map((option) => ( setFormData({ ...formData, selectedAudience: option.id })} className="flex items-center justify-between cursor-pointer" > {option.name} {formData.selectedAudience === option.id && } ))}
) }