import React, { useState, useEffect } from 'react'; import { Layout, Card, Row, Col, Statistic, Tag, Button, Table, Typography, Space, Progress, Badge, Timeline, message, Select } from 'antd'; import { EnvironmentOutlined, RobotOutlined, BranchesOutlined, ThunderboltOutlined, CheckCircleOutlined, PauseOutlined, RocketOutlined, SyncOutlined, WarningOutlined, CloudOutlined, ClockCircleOutlined, ReloadOutlined, AimOutlined, ApiOutlined, SettingOutlined, PlusOutlined, ArrowRightOutlined, EditOutlined } from '@ant-design/icons'; import { useSelector } from 'react-redux'; import { getDeviceListApi, getPlaneDeviceList } from '../../api/device.ts'; import { RootState } from '@/src/store'; const { Content } = Layout; const { Text, Title } = Typography; // 模拟数据 const topCards = [ { title: '无人机机场状态', icon: , value: '2 / 2', desc: '在线', sub: '可调度 2 架', color: '#1890ff' }, { title: '巡检机器人', icon: , value: '3 台', desc: '', sub: '执行中 2', color: '#722ed1' }, { title: '除草机器人', icon: , value: '2 台', desc: '', sub: '作业中 1', color: '#13c2c2' }, { title: '清洗无人机', icon: , value: '2 架', desc: '', sub: '待命 1', color: '#eb2f96' }, { title: '设备平均电量', icon: , value: '86%', desc: '', sub: '', color: '#52c41a' }, { title: '今日任务执行', icon: , value: '12 / 15', desc: '', sub: '完成率 80%', color: '#2f54eb' }, ]; const scheduleList = [ { id: 1, name: '无人机机场 A01', type: '无人机机场', status: '在线', mode: '待命', battery: 100, position: '开压站旁', task: '待命', comm: '良好' }, { id: 2, name: '巡检机器人 RBT-01', type: '巡检机器人', status: '作业中', mode: '自主巡检', battery: 68, position: '区块 B-03', task: '巡检航线 P-02', comm: '良好' }, { id: 3, name: '巡检机器人 RBT-02', type: '巡检机器人', status: '在线', mode: '待命', battery: 92, position: '区块 D-06', task: '待命', comm: '良好' }, { id: 4, name: '除草机器人 GR-01', type: '除草机器人', status: '充电中', mode: '回充', battery: 35, position: '充电桩 1', task: '回充中', comm: '良好' }, { id: 5, name: '清洗无人机 UAV-C01', type: '清洗无人机', status: '作业中', mode: '自主清洗', battery: 72, position: '清洗区 C-05', task: '清洗航线 C-05', comm: '良好' }, { id: 6, name: '清洗无人机 UAV-C02', type: '清洗无人机', status: '待命', mode: '待命', battery: 96, position: '无人机机场 A01', task: '待命', comm: '良好' }, ]; const taskTimeline = [ { time: '10:24:18', color: 'blue', text: 'UAV-C01 开始执行清洗航线 C-05', status: '任务开始' }, { time: '10:21:35', color: 'orange', text: 'RBT-01 开始执行巡检航线 P-02', status: '任务开始' }, { time: '10:18:02', color: 'green', text: 'GR-02 开始除草作业 G-01', status: '任务开始' }, { time: '10:15:47', color: 'gray', text: 'UAV-C02 任务待命就绪', status: '待命就绪' }, { time: '10:12:33', color: 'blue', text: 'UAV-C01 再次返机补水', status: '返机补给' }, { time: '09:58:10', color: 'green', text: 'RBT-02 完成巡检航线 P-01', status: '任务完成' }, ]; const logs = [ { time: '10:24:35', device: 'UAV-C01', type: '命令', desc: '起飞指令下发,开始作业' }, { time: '10:21:40', device: 'RBT-01', type: '命令', desc: '开始巡检任务 P-02' }, { time: '10:20:11', device: 'UAV-C02', type: '命令', desc: '转入待命状态' }, { time: '10:18:05', device: 'GR-02', type: '命令', desc: '除草作业开始 G-01' }, { time: '10:12:35', device: 'UAV-C01', type: '告警', desc: '返航补水' }, { time: '10:05:22', device: 'RBT-01', type: '事件', desc: '电量较低,建议回充', level: '低电量' }, ]; // 设备总览组件 export default function DeviceOverviewPage({ devices, planedevices, devicesAll }) { console.log(devicesAll) const [activeTab, setActiveTab] = useState('drone'); const [selectedDevice, setSelectedDevice] = useState(''); const controlTabs = [ { key: 'airport', label: '无人机机场' }, { key: 'robot', label: '巡检机器人' }, { key: 'mower', label: '除草机器人' }, { key: 'clean', label: '清洗无人机' }, { key: 'machine', label: '机械设备' }, ]; const handleStart = () => message.success('任务已启动'); const handlePause = () => message.info('任务已暂停'); const handleReturn = () => message.info('返航指令已下发'); const handleRecharge = () => message.info('回充指令已下发'); const handleEmergencyStop = () => message.error('已触发急停!'); useEffect(() => { if (devicesAll.length > 0) { setSelectedDevice(devicesAll[0].device_sn); } }, [devicesAll]) return ( {topCards.map((card, idx) => ( {card.icon} {card.title} {card.value} {card.sub && {card.sub}} ))} {/* 装备协同态势图 */} 装备协同态势图>} extra={} />} bordered={false} style={{ borderRadius: 12, marginBottom: 16 }} bodyStyle={{ padding: 0 }}> 图例说明 ——— 巡检航线 ——— 机器人路径 ——— 清洗路径 ● 设备位置 ● 补给/充电点 ■ 障碍/禁入区 装备调度列表>} bordered={false} style={{ borderRadius: 12, marginBottom: 16 }}> {s} }, { title: '模式', dataIndex: 'mode', width: 80 }, { title: '电量', dataIndex: 'battery', width: 80, render: v => }, { title: '位置', dataIndex: 'position', width: 100 }, { title: '当前任务', dataIndex: 'task', width: 120 }, { title: '通讯状态', dataIndex: 'comm', width: 80, render: v => }, { title: '操作', key: 'action', width: 100, render: () => } />} /> } ]} dataSource={scheduleList} scroll={{ x: 'max-content' }} /> 控制日志 / 告警记录>} bordered={false} style={{ borderRadius: 12 }} extra={全部级别 ▼}> {t} }, { title: '设备', dataIndex: 'device', width: 120, render: t => {t} }, { title: '类型', dataIndex: 'type', width: 80, render: t => { let c = '#52c41a'; if (t === '告警') c = '#fa8c16'; if (t === '事件') c = '#1890ff'; return {t} } }, { title: '描述', dataIndex: 'desc', render: t => {t} }, { title: '', width: 80, render: (_, r) => r.level ? {r.level} : null } ]} /> 查看更多日志 设备控制面板>} bordered={false} style={{ borderRadius: 12, marginBottom: 16 }} bodyStyle={{ padding: 16, paddingBottom: 0 }}> { return { value: item.device_sn, label: item.drone_callsign } })} value={selectedDevice} // 必须加 onChange={setSelectedDevice}// 必须加 /> 清洗无人机 UAV-C01 作业中 电量 72% 信号强度 强 当前模式自主清洗模式 当前位置清洗区域 C-05 当前任务清洗航线 C-05 预计剩余时间00:18:36 启动任务 暂停 返航 回充 实时画面 2025-05-24 10:24:18 高度 12.5m速度 4.2m/s距离 86m 切换手动 急停 AI分析与操作建议>} bordered={false} style={{ borderRadius: 12, marginBottom: 16 }}> 🔥热斑疑似2 处 杂草高发区3 块 组件风险区4 块 围栏异常1 处 建议操作 ⦿优先执行巡检航线 P-03 ⦿先行安排除草任务 G-02 ⦿建议生成清洗工单 生成任务 AI优化路径 一键联动作业 风速2.6 m/s轻风 温度28.7℃适宜 辐照度812W/m²较高 降雨概率10%低 GNSS状态正常定位稳定 禁飞状态未禁飞可执行 适宜执行 可正常开展作业 任务执行时间线>} bordered={false} style={{ borderRadius: 12 }} extra={今天 2025-05-24}> {taskTimeline.map((item, idx) => ( {item.time}}> {item.text} {item.status} ))} 查看更多 ); }