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 }) { const [activeTab, setActiveTab] = useState('drone'); const [selectedDevice, setSelectedDevice] = useState(''); const [currentDevice, setCurrentDevice] = useState(null); 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('已触发急停!'); // 数字保留两位小数 const fix2 = (val) => { if (val === null || val === undefined || isNaN(val)) return '-'; return Number(val).toFixed(2); }; // 安全取值 const getVal = (val) => val == "no_rain" ? "无" : '-'; // 默认选中第一个 useEffect(() => { if (devicesAll && devicesAll.length > 0) { const first = devicesAll[0]; setSelectedDevice(first.device_sn); setCurrentDevice(first); } }, [devicesAll]); // 切换设备 const handleDeviceChange = (sn) => { setSelectedDevice(sn); const target = devicesAll.find(item => item.device_sn === sn); setCurrentDevice(target); }; return (
{topCards.map((card, idx) => (
{card.icon}
{card.title}
{card.value}
{card.sub &&
{card.sub}
}
))}
装备协同态势图} extra={