Files
web-Iot/src/components/devices/WayLinePage.tsx
2026-05-11 16:34:44 +08:00

357 lines
20 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.

import React, { useState } from 'react';
import {
Row, Col, Card, Button, Space, Table, Tag, Typography, Progress, Badge,
Tabs, Input, Switch, Divider, Tooltip, Timeline
} from 'antd';
import {
PlusOutlined, ImportOutlined, NodeIndexOutlined, SafetyCertificateOutlined,
SaveOutlined, FullscreenOutlined, EnvironmentOutlined, RobotOutlined,
BranchesOutlined, CloudOutlined, ThunderboltOutlined, CheckCircleOutlined,
InfoCircleOutlined, ClockCircleOutlined, RiseOutlined, FallOutlined,
SettingOutlined, WarningOutlined, ArrowRightOutlined, CloudSyncOutlined
} from '@ant-design/icons';
const { Text, Title } = Typography;
export default function WayLinePage() {
const [activeMainTab, setActiveTab] = useState('wayline');
const cardStyle = { borderRadius: 8, border: 'none', boxShadow: '0 2px 8px rgba(0,0,0,0.05)' };
// 模拟数据
const topCards = [
{ title: '今日航线计划', value: '18', unit: '条', trend: '较昨日 +2', color: '#165DFF', icon: <NodeIndexOutlined /> },
{ title: '执行中任务', value: '6', unit: '个', desc: '进行中', color: '#165DFF', icon: <NodeIndexOutlined /> },
{ title: '待审批任务', value: '4', unit: '个', trend: '较昨日 -1', color: '#FF7D00', icon: <SafetyCertificateOutlined /> },
{ title: '任务完成率', value: '92', unit: '%', trend: '较昨日 +6%', color: '#00B42A', icon: <CheckCircleOutlined /> },
{ title: 'AI 优化收益', value: '+7.8', unit: '%', trend: '较昨日 +1.2%', color: '#722ED1', icon: <RiseOutlined /> },
{ title: '覆盖装备', value: '4类 / 9台', unit: '', desc: '全部在线', color: '#165DFF', icon: <RobotOutlined /> },
];
return (
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: '0px 24px' }}>
{/* 顶部统计卡片 */}
<Row gutter={12} style={{ marginBottom: 16 }}>
{topCards.map((item, index) => (
<Col span={4} key={index}>
<Card bordered={false} bodyStyle={{ padding: 16 }} style={cardStyle}>
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
<div style={{ width: 40, height: 40, background: `${item.color}15`, borderRadius: 8, display: 'flex', justifyContent: 'center', alignItems: 'center', color: item.color, fontSize: 20 }}>
{item.icon}
</div>
<div>
<div style={{ fontSize: 12, color: '#86909C' }}>{item.title}</div>
<div style={{ display: 'flex', alignItems: 'baseline', gap: 4 }}>
<span style={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }}>{item.value}</span>
<span style={{ fontSize: 12, color: '#4E5969' }}>{item.unit}</span>
</div>
<div style={{ fontSize: 11, color: item.trend?.includes('+') ? '#00B42A' : '#F53F3F' }}>
{item.trend || item.desc}
</div>
</div>
</div>
</Card>
</Col>
))}
</Row>
{/* 中间主要内容区 */}
<Row gutter={12} style={{ marginBottom: 16 }}>
{/* 左侧:航线编辑与路径规划 */}
<Col span={14}>
<Card
title={<span style={{ fontSize: 14, fontWeight: 700 }}>航线编辑与路径规划</span>}
extra={
<Space>
<Button size="small" icon={<PlusOutlined />}>新增航线</Button>
<Button size="small" icon={<ImportOutlined />}>导入模板</Button>
<Button size="small" icon={<NodeIndexOutlined />}>路径优化</Button>
<Button size="small" icon={<SafetyCertificateOutlined />}>风险检查</Button>
<Button size="small" icon={<SaveOutlined />}>保存草稿</Button>
<Button size="small" icon={<FullscreenOutlined />} />
</Space>
}
bordered={false}
bodyStyle={{ padding: 0, position: 'relative' }}
style={{ ...cardStyle, marginBottom: "16px" }}
>
{/* 模拟地图区域 */}
<div style={{ width: '100%', height: 500, background: '#e8f3ff url(https://picsum.photos/seed/solarfarm_map/1200/800) center/cover', position: 'relative' }}>
{/* 左侧图例 */}
<div style={{ position: 'absolute', top: 16, left: 16, background: 'rgba(255,255,255,0.9)', padding: 12, borderRadius: 4, width: 140 }}>
<div style={{ fontSize: 12, display: 'flex', flexDirection: 'column', gap: 8 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ width: 12, height: 2, background: '#165DFF' }}></span> 无人机航线</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ width: 12, height: 2, background: '#FF7D00' }}></span> 巡检机器人路线</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ width: 12, height: 2, background: '#00B42A' }}></span> 除草路线</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ width: 12, height: 2, background: '#13C2C2' }}></span> 清洗航线</div>
<Divider style={{ margin: '4px 0' }} />
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><div style={{ width: 16, height: 16, background: '#165DFF', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center', color: '#fff', fontSize: 10 }}>H</div> 无人机机场</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>< ThunderboltOutlined style={{ color: '#00B42A' }} /> 充电点</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><CloudSyncOutlined style={{ color: '#165DFF' }} /> 补水点</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><WarningOutlined style={{ color: '#F53F3F' }} /> 禁飞区</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><div style={{ width: 12, height: 12, border: '1px dashed #F53F3F' }} /> 高优先级巡检区</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><div style={{ width: 12, height: 12, background: 'rgba(255,125,0,0.3)' }} /> 障碍物区域</div>
</div>
</div>
{/* 地图上的模拟标注 */}
<div style={{ position: 'absolute', top: '20%', left: '20%', color: '#fff', textAlign: 'center' }}>
<div style={{ background: '#165DFF', borderRadius: '50%', width: 24, height: 24, display: 'inline-flex', justifyContent: 'center', alignItems: 'center' }}>H</div>
<div style={{ fontSize: 10, background: 'rgba(0,0,0,0.5)', padding: '0 4px' }}>无人机机场 A01</div>
</div>
<div style={{ position: 'absolute', top: '40%', left: '50%', border: '2px dashed #F53F3F', width: 120, height: 80, display: 'flex', justifyContent: 'center', alignItems: 'center', color: '#fff' }}>
<div style={{ fontSize: 10, background: 'rgba(0,0,0,0.5)', padding: '0 4px' }}>高优先级巡检区 B-12</div>
</div>
</div>
</Card>
<Card
title={<span style={{ fontSize: 14, fontWeight: 700 }}>航点列表 <Text type="secondary" style={{ fontSize: 11, fontWeight: 400 }}>航线:FL-03 (无人机热斑巡检)</Text></span>}
extra={<PlusOutlined style={{ cursor: 'pointer' }} />}
bordered={false}
bodyStyle={{ padding: 0 }}
style={cardStyle}
>
<Table
size="small"
pagination={false}
scroll={{ y: 240 }}
dataSource={[
{ key: '1', point: 'WP-01', coord: '30.32921, 120.12345', action: '起飞', height: 35, speed: 6.0, stay: 0, remark: '从机场起飞' },
{ key: '2', point: 'WP-02', coord: '区块 B-01', action: '拍摄', height: 35, speed: 6.0, stay: 2, remark: '组件可见光' },
{ key: '3', point: 'WP-03', coord: '区块 B-05', action: '热成像', height: 35, speed: 6.0, stay: 3, remark: '热斑检测' },
{ key: '4', point: 'WP-04', coord: '区块 B-09', action: '悬停', height: 35, speed: 0.0, stay: 10, remark: '重点检查' },
{ key: '5', point: 'WP-05', coord: '区块 B-12', action: '热成像', height: 35, speed: 6.0, stay: 3, remark: '高优先区' },
{ key: '6', point: 'WP-06', coord: '区块 B-16', action: '拍摄', height: 35, speed: 6.0, stay: 2, remark: '组件可见光' },
{ key: '7', point: 'WP-07', coord: '区块 B-20', action: '悬停', height: 35, speed: 0.0, stay: 10, remark: '末端确认' },
{ key: '8', point: 'WP-08', coord: '30.32910, 120.12380', action: '返航', height: 35, speed: 6.0, stay: 0, remark: '返回机场' },
]}
columns={[
{ title: '航点', dataIndex: 'point', width: 60 },
{ title: '坐标/区域', dataIndex: 'coord', width: 100, ellipsis: true },
{ title: '动作', dataIndex: 'action', width: 60 },
{ title: '高度(m)', dataIndex: 'height', width: 60 },
{ title: '速度(m/s)', dataIndex: 'speed', width: 80 },
{ title: '停留(s)', dataIndex: 'stay', width: 60 },
{ title: '备注', dataIndex: 'remark', ellipsis: true },
]}
/>
</Card>
</Col>
{/* 右侧:任务编排、参数与天气 */}
<Col span={10}>
<Card
title={<span style={{ fontSize: 14, fontWeight: 700 }}>任务编排与 AI 建议</span>}
bordered={false}
bodyStyle={{ padding: 12 }}
style={{ ...cardStyle, marginBottom: 12 }}
>
<Table
size="small"
pagination={false}
dataSource={[
{ key: '1', id: 'FL-03', device: 'UAV-A01', type: '无人机热斑巡检', level: '高', time: '10:00 - 11:20', duration: '1h20m', status: '建议执行' },
{ key: '2', id: 'RB-02', device: 'RBT-01', type: '围栏巡检', level: '高', time: '11:30 - 12:30', duration: '1h00m', status: '建议执行' },
{ key: '3', id: 'CL-05', device: 'UAV-C01', type: '组件清洗', level: '中', time: '14:00 - 16:00', duration: '2h00m', status: '等待执行' },
{ key: '4', id: 'GR-04', device: 'GR-01', type: '阵列除草', level: '中', time: '09:30 - 11:30', duration: '2h00m', status: '建议执行' },
{ key: '5', id: 'FL-07', device: 'UAV-A01', type: 'AI 复检航线', level: '低', time: '16:30 - 17:10', duration: '0h40m', status: '待审批' },
]}
columns={[
{ title: '任务编号', dataIndex: 'id', width: 80, render: (t) => <Text style={{ color: '#165DFF' }}>{t}</Text> },
{ title: '装备', dataIndex: 'device' },
{ title: '类型', dataIndex: 'type', ellipsis: true },
{ title: '优先级', dataIndex: 'level', render: (l) => <span style={{ color: l === '高' ? '#F53F3F' : l === '中' ? '#FF7D00' : '#86909C' }}>▲ {l}</span> },
{ title: '建议时间', dataIndex: 'time' },
{ title: '预计时长', dataIndex: 'duration' },
{ title: '状态', dataIndex: 'status', render: (s) => <Text style={{ color: s.includes('建议') ? '#165DFF' : '#86909C' }}>{s}</Text> },
]}
/>
<div style={{ background: '#F2F3F5', padding: '8px 12px', borderRadius: 4, marginTop: 12, display: 'flex', gap: 12, fontSize: 12 }}>
<span style={{ fontWeight: 700 }}>AI 建议:</span>
<Space split={<Divider type="vertical" />}>
<span><CheckCircleOutlined style={{ color: '#165DFF' }} /> 推荐优先执行 FL-03 航线</span>
<span><ClockCircleOutlined style={{ color: '#165DFF' }} /> 14:00-16:00 风速最佳</span>
<span><WarningOutlined style={{ color: '#FF7D00' }} /> 区块 B-12 存在高温风险</span>
</Space>
</div>
<Row gutter={12} style={{ marginTop: 12 }}>
<Col span={8}><Button type="primary" block style={{ background: '#165DFF' }}>一键排程</Button></Col>
<Col span={8}><Button type="primary" block style={{ background: '#165DFF' }}>智能分配</Button></Col>
<Col span={8}><Button type="primary" block style={{ background: '#165DFF' }}>生成工单</Button></Col>
</Row>
</Card>
<Card
title={<span style={{ fontSize: 14, fontWeight: 700 }}>航线参数 / 作业参数</span>}
extra={<Text type="secondary" style={{ fontSize: 12 }}>当前航线:FL-03</Text>}
bordered={false}
bodyStyle={{ padding: 12 }}
style={{ ...cardStyle, marginBottom: 12 }}
>
<Row gutter={[24, 12]}>
{[
{ label: '飞行高度', value: '35', unit: 'm' },
{ label: '速度', value: '6', unit: 'm/s' },
{ label: '航向重叠', value: '75', unit: '%' },
{ label: '旁向重叠', value: '65', unit: '%' },
{ label: '安全返航电量', value: '25', unit: '%' },
{ label: '清洗喷洒量', value: '120', unit: 'ml/㎡' },
{ label: '除草宽幅', value: '1.2', unit: 'm' },
{ label: '巡检采样频率', value: '2', unit: 'Hz' },
].map((item, idx) => (
<Col span={6} key={idx}>
<div style={{ fontSize: 11, color: '#86909C', marginBottom: 4 }}>{item.label}</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
<Input size="small" defaultValue={item.value} style={{ width: 40, height: 22, padding: '0 4px', fontSize: 12 }} />
<span style={{ fontSize: 11 }}>{item.unit}</span>
</div>
</Col>
))}
</Row>
<Divider style={{ margin: '12px 0' }} />
<Space size="large">
<Space>
<span style={{ fontSize: 12 }}>避障开关</span>
<Switch size="small" defaultChecked />
</Space>
<Space>
<span style={{ fontSize: 12 }}>夜航限制</span>
<Switch size="small" />
</Space>
</Space>
</Card>
<Card
title={<span style={{ fontSize: 14, fontWeight: 700 }}>天气窗口与执行约束</span>}
bordered={false}
bodyStyle={{ padding: 12 }}
style={cardStyle}
>
<Row gutter={12} align="middle">
<Col span={5}>
<div style={{ textAlign: 'center', background: '#F6FFED', padding: '8px 4px', borderRadius: 4, border: '1px solid #B7EB8F' }}>
<div style={{ fontSize: 11, color: '#52C41A', fontWeight: 700 }}>适宜执行</div>
<div style={{ width: 16, height: 16, background: '#52C41A', borderRadius: '50%', margin: '4px auto', display: 'flex', justifyContent: 'center', alignItems: 'center', color: '#fff', fontSize: 10 }}><CheckCircleOutlined /></div>
<div style={{ fontSize: 10, color: '#86909C' }}>适宜执行</div>
</div>
</Col>
{[
{ label: '风速', value: '2.8 m/s', desc: '适宜', icon: <CloudSyncOutlined />, color: '#165DFF' },
{ label: '温度', value: '28℃', desc: '适宜', icon: < ThunderboltOutlined />, color: '#FF7D00' },
{ label: '降水概率', value: '10%', desc: '极低', icon: <CloudOutlined />, color: '#165DFF' },
{ label: 'GNSS质量', value: '良好', desc: '适宜', icon: <EnvironmentOutlined />, color: '#00B42A' },
].map((item, idx) => (
<Col span={4.5} key={idx} style={{ flex: 1 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<div style={{ color: item.color, fontSize: 16 }}>{item.icon}</div>
<div>
<div style={{ fontSize: 10, color: '#86909C' }}>{item.label}</div>
<div style={{ fontSize: 12, fontWeight: 700 }}>{item.value}</div>
<div style={{ fontSize: 10, color: '#86909C' }}>{item.desc}</div>
</div>
</div>
</Col>
))}
</Row>
<div style={{ marginTop: 12, display: 'flex', justifyContent: 'space-between', fontSize: 11, color: '#86909C' }}>
<span><InfoCircleOutlined style={{ color: '#FF7D00' }} /> 16:30 后风速升高,建议提前完成任务</span>
<span><ClockCircleOutlined style={{ color: '#165DFF' }} /> 预计 14:00-16:00 为最佳执行窗口</span>
</div>
</Card>
</Col>
</Row>
{/* 底部内容区 */}
<Row gutter={12}>
{/* 甘特图/排班视图 */}
<Col span={14}>
<Card
title={<span style={{ fontSize: 14, fontWeight: 700 }}>任务甘特视图 / 排班视图 <Text type="secondary" style={{ fontSize: 11, fontWeight: 400 }}>今日 (2025-05-24)</Text></span>}
extra={<SettingOutlined style={{ cursor: 'pointer' }} />}
bordered={false}
bodyStyle={{ padding: 12 }}
style={{ ...cardStyle, height: '100%' }} // 👈 高度 100%
>
<div style={{ height: 260, position: 'relative', border: '1px solid #F2F3F5', borderRadius: 4, padding: 8 }}>
{/* 模拟时间轴头部 */}
<div style={{ display: 'flex', justifyContent: 'space-between', fontSize: 10, color: '#86909C', borderBottom: '1px solid #F2F3F5', paddingBottom: 4 }}>
<div style={{ width: 100 }}></div>
<div style={{ flex: 1, display: 'flex', justifyContent: 'space-around' }}>
<span>08:00</span><span>10:00</span><span>12:00</span><span>14:00</span><span>16:00</span><span>18:00</span>
</div>
</div>
{/* 模拟甘特条 */}
<div style={{ display: 'flex', flexDirection: 'column', gap: 12, marginTop: 12 }}>
{[
{ label: '无人机机场 A01 (UAV-A01)', tasks: [{ start: '25%', width: '15%', title: 'FL-03 巡检', color: '#165DFF' }, { start: '70%', width: '10%', title: 'FL-07 复检', color: '#165DFF' }] },
{ label: '巡检机器人 RBT-01', tasks: [{ start: '40%', width: '15%', title: 'RB-02 巡检', color: '#FF7D00' }] },
{ label: '除草机器人 GR-01', tasks: [{ start: '10%', width: '25%', title: 'GR-04 阵列除草', color: '#00B42A' }] },
{ label: '清洗无人机 UAV-C01', tasks: [{ start: '60%', width: '20%', title: 'CL-05 组件清洗', color: '#13C2C2' }] },
].map((row, idx) => (
<div key={idx} style={{ display: 'flex', alignItems: 'center' }}>
<div style={{ width: 100, fontSize: 10, color: '#4E5969' }}>{row.label}</div>
<div style={{ flex: 1, height: 32, background: '#F7F8FA', borderRadius: 4, position: 'relative' }}>
{row.tasks.map((task, tidx) => (
<div key={tidx} style={{ position: 'absolute', left: task.start, width: task.width, height: '100%', background: task.color, opacity: 0.8, borderRadius: 4, color: '#fff', fontSize: 9, padding: '2px 4px', display: 'flex', flexDirection: 'column', justifyContent: 'center' }}>
<div>{task.title}</div>
<div>10:00-11:20</div>
</div>
))}
</div>
</div>
))}
</div>
{/* 垂直当前时间红线 */}
<div style={{ position: 'absolute', left: '35%', top: 0, bottom: 0, width: 1, background: '#F53F3F', zIndex: 1 }} />
</div>
</Card>
</Col>
{/* 任务看板 */}
<Col span={10}>
<Card
title={<span style={{ fontSize: 14, fontWeight: 700 }}>工作任务看板</span>}
bordered={false}
bodyStyle={{ padding: 12 }}
style={{ ...cardStyle, height: '100%', display: 'flex', flexDirection: 'column' }} // 👈 高度 100%
>
<div style={{ flex: 1, display: 'flex', flexDirection: 'column' }}> {/* 👈 自动撑满 */}
<Row gutter={8}>
{[
{ title: '待执行 (3)', bg: '#F7F8FA', list: [{ id: 'FL-07', name: 'AI 复检航线', device: 'UAV-A01', handler: '王工' }, { id: 'CL-05', name: '组件清洗', device: 'UAV-C01', handler: '李工' }] },
{ title: '执行中 (2)', bg: '#E8F3FF', list: [{ id: 'FL-03', name: '无人机热斑巡检', device: 'UAV-A01', handler: '王工', gain: '+8.2%' }, { id: 'GR-04', name: '阵列除草', device: 'GR-01', handler: '赵工' }] },
{ title: '已完成 (4)', bg: '#E8FFEA', list: [{ id: 'FL-01', name: '组件巡检', device: 'UAV-A01', handler: '王工', gain: '+7.1%', time: '08:20' }, { id: 'CL-01', name: '组件清洗', device: 'UAV-C01', handler: '李工', gain: '+5.9%', time: '07:45' }] },
].map((col, idx) => (
<Col span={8} key={idx}>
<div style={{ background: col.bg, borderRadius: 4, padding: 8, height: '100%', minHeight: 260 }}>
<div style={{ fontSize: 12, fontWeight: 700, marginBottom: 8 }}>{col.title}</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
{col.list.map((task, tidx) => (
<div key={tidx} style={{ background: '#fff', borderRadius: 4, padding: 8, boxShadow: '0 1px 2px rgba(0,0,0,0.05)' }}>
<div style={{ fontSize: 11, fontWeight: 700, color: '#165DFF' }}>{task.id} {task.name}</div>
<div style={{ fontSize: 10, color: '#86909C', marginTop: 4 }}>装备: {task.device} | 负责人: {task.handler}</div>
{task.gain && <div style={{ fontSize: 10, color: '#00B42A', marginTop: 4 }}>预计收益: {task.gain}</div>}
{task.time && <div style={{ fontSize: 10, color: '#86909C', marginTop: 2 }}>完成时间: {task.time}</div>}
</div>
))}
</div>
</div>
</Col>
))}
</Row>
</div>
<div style={{ textAlign: 'right', marginTop: 8 }}>
<Button type="link" size="small">查看全部 <ArrowRightOutlined /></Button>
</div>
</Card>
</Col>
</Row>
</div>
);
}