diff --git a/src/components/devices/WayLinePage.tsx b/src/components/devices/WayLinePage.tsx
index 49df1ec..5d2d2c7 100644
--- a/src/components/devices/WayLinePage.tsx
+++ b/src/components/devices/WayLinePage.tsx
@@ -1,7 +1,7 @@
import React, { useState, useEffect } from 'react';
import {
Row, Col, Card, Button, Space, Table, Tag, Typography, Progress, Badge,
- Tabs, Input, Switch, Divider, Tooltip, Timeline, Select, message
+ Tabs, Input, Switch, Divider, Tooltip, Timeline, Select, message, DatePicker
} from 'antd';
import {
PlusOutlined, ImportOutlined, NodeIndexOutlined,
@@ -22,6 +22,7 @@ import utils from '@/lib/utils';
import CesiumMap from '../Map';
const { Text, Title } = Typography;
+const { RangePicker } = DatePicker;
export default function WayLinePage({ planedevices }) {
const fontSmall = 'clamp(10px, 0.7vw, 11px)';
@@ -30,9 +31,18 @@ export default function WayLinePage({ planedevices }) {
const fontLarge = 'clamp(18px, 1.1vw, 24px)';
const cardStyle = { borderRadius: 12, border: 'none', boxShadow: '0 2px 12px rgba(0,0,0,0.04)' };
- const [selectedDrone, setSelectedDrone] = useState(null);
- const [taskList, setTaskList] = useState([]); // 真实任务列表
- const [points, setPoints] = useState([]); // 航线轨迹点
+
+ // 任务列表 独立筛选状态
+ const [listDrone, setListDrone] = useState(null);
+ const [listDateRange, setListDateRange] = useState(null);
+ const [taskList, setTaskList] = useState([]);
+
+ // 工作看板 独立筛选状态
+ const [boardDrone, setBoardDrone] = useState(null);
+ const [boardDateRange, setBoardDateRange] = useState(null);
+ const [boardTaskList, setBoardTaskList] = useState([]);
+
+ const [points, setPoints] = useState([]);
// 顶部统计
const topCards = [
@@ -44,40 +54,62 @@ export default function WayLinePage({ planedevices }) {
{ title: '覆盖装备', value: '4 类 / 9 台', unit: '', desc: '全部在线', icon: , color: '#165DFF' },
];
- // 获取真实任务
- const getTaskList = async (drone) => {
- if (!drone || !drone.device_sn) return;
+ // 获取任务列表数据
+ const getListTask = async () => {
+ if (!planedevices?.length) return;
try {
- const data = {
- sn: [drone.gateway_sn]
- }
- const res = await getsinglePlan(data);
- if (res?.code === 0) {
- setTaskList(res.data?.list || []);
- }
+ const defaultStart = dayjs().startOf('day').valueOf();
+ const defaultEnd = dayjs().endOf('day').valueOf();
+ const [beginAt, endAt] = listDateRange?.length === 2
+ ? [dayjs(listDateRange[0]).valueOf(), dayjs(listDateRange[1]).valueOf()]
+ : [defaultStart, defaultEnd];
+
+ const sns = listDrone ? [listDrone.gateway_sn] : planedevices.map(item => item.gateway_sn);
+ const res = await getsinglePlan({ sns, beginAt, endAt });
+ if (res?.code === 0) setTaskList(res.data?.list || []);
} catch (err) {
- message.error('获取任务失败');
+ message.error('任务列表数据获取失败');
}
};
- // 默认选中第一个无人机
+ // 获取看板任务数据
+ const getBoardTask = async () => {
+ if (!planedevices?.length) return;
+ try {
+ const defaultStart = dayjs().startOf('day').valueOf();
+ const defaultEnd = dayjs().endOf('day').valueOf();
+ const [beginAt, endAt] = boardDateRange?.length === 2
+ ? [dayjs(boardDateRange[0]).valueOf(), dayjs(boardDateRange[1]).valueOf()]
+ : [defaultStart, defaultEnd];
+
+ const sns = boardDrone ? [boardDrone.gateway_sn] : planedevices.map(item => item.gateway_sn);
+ const res = await getsinglePlan({ sns, beginAt, endAt });
+ if (res?.code === 0) setBoardTaskList(res.data?.list || []);
+ } catch (err) {
+ message.error('任务看板数据获取失败');
+ }
+ };
+
+ // 初始化默认全部设备
useEffect(() => {
if (planedevices?.length) {
- setSelectedDrone(planedevices[0]);
- const data = planedevices.map(i => i.gateway_sn);
- getTaskList(data);
+ setListDrone(null);
+ setBoardDrone(null);
}
}, [planedevices]);
- // 切换无人机时刷新任务
+ // 各自筛选变更独立请求
useEffect(() => {
- getTaskList(selectedDrone);
- }, [selectedDrone]);
+ getListTask();
+ }, [listDrone, listDateRange]);
- // 任务状态颜色
+ useEffect(() => {
+ getBoardTask();
+ }, [boardDrone, boardDateRange]);
+
+ // 任务状态标签
const getStatusTag = (status) => {
const statusMap = {
- // 基础状态
success: { color: 'success', text: '执行成功' },
running: { color: 'processing', text: '执行中' },
failed: { color: 'error', text: '执行失败' },
@@ -89,15 +121,13 @@ export default function WayLinePage({ planedevices }) {
terminated: { color: 'default', text: '已终止' },
timeout: { color: 'error', text: '执行超时' },
};
-
const item = statusMap[status] || { color: 'default', text: status };
return {item.text};
};
- // 任务表格列
+ // 列表表格列
const taskColumns = [
{ title: '任务名称', dataIndex: 'name', width: 260, ellipsis: true, fixed: "left" },
-
{ title: '任务UUID', dataIndex: 'uuid', width: 260, ellipsis: true },
{ title: '设备SN', dataIndex: 'sn', width: 140 },
{ title: '状态', dataIndex: 'status', width: 80, render: getStatusTag },
@@ -114,39 +144,38 @@ export default function WayLinePage({ planedevices }) {
render: t => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
},
];
- // 表格行点击事件
+
+ // 表格行点击查看轨迹
const handleRowClick = async (record) => {
try {
- getsinglePlanTrack(record).then(res => {
- if (res.code == 0 && res.data.track?.points?.length) {
- const points = res.data.track.points.map(item => ({
- lon: item.longitude || item.lon,
- lat: item.latitude || item.lat
- }));
- setPoints(points);
-
- } else {
- utils.message.warning("暂无航线数据");
- setPoints([]);
- }
- })
- // ======================
- // 在这里写你的接口请求
- // ======================
- // 示例:
- // const res = await getTaskDetail(record.uuid);
- // if (res.code === 0) {
- // message.success('获取成功');
- // console.log('任务详情:', res.data);
- // }
-
+ const res = await getsinglePlanTrack(record);
+ if (res.code === 0 && res.data.track?.points?.length) {
+ const points = res.data.track.points.map(item => ({
+ lon: item.longitude || item.lon,
+ lat: item.latitude || item.lat
+ }));
+ setPoints(points);
+ } else {
+ utils.message.warning("暂无航线数据");
+ setPoints([]);
+ }
} catch (err) {
message.error('请求失败');
console.error(err);
}
};
+
+ // 看板数据分组处理
+ const groupBoardData = () => {
+ const waitList = boardTaskList.filter(item => ['waiting', 'suspended', 'terminated'].includes(item.status));
+ const runList = boardTaskList.filter(item => ['running', 'executing', 'restored'].includes(item.status));
+ const finishList = boardTaskList.filter(item => ['success'].includes(item.status));
+ return { waitList, runList, finishList };
+ };
+ const { waitList, runList, finishList } = groupBoardData();
+
return (
-
+
{topCards.map((item, index) => (
@@ -191,20 +220,7 @@ export default function WayLinePage({ planedevices }) {
style={{ ...cardStyle, marginBottom: 10 }}
>
- {/*
*/}
-
-
-
+
无人机航线
@@ -219,29 +235,37 @@ export default function WayLinePage({ planedevices }) {
- {/* 真实任务列表表格 */}
+ {/* 独立筛选 - 设备任务列表 */}
-
- 设备任务列表
-
-
}
size="small"
@@ -258,11 +282,9 @@ export default function WayLinePage({ planedevices }) {
pagination={false}
scroll={{ y: 260 }}
style={{ height: '100%' }}
- // 关键:行点击事件
onRow={(record) => ({
onClick: () => handleRowClick(record),
- style: { cursor: 'pointer' } // 👈 就是这一行,显示小手
-
+ style: { cursor: 'pointer' }
})}
/>
@@ -367,14 +389,12 @@ export default function WayLinePage({ planedevices }) {
-
{[
{
label: '风速',
- value: `${selectedDrone?.wind_speed ?? '-'} m/s`,
+ value: `${listDrone?.wind_speed ?? '-'} m/s`,
icon: ,
color: '#165DFF',
- // 飞行条件:≤ 5 m/s 适宜
judge: (val) => {
const speed = parseFloat(val);
if (isNaN(speed)) return { desc: '未知', color: '#86909C' };
@@ -385,10 +405,9 @@ export default function WayLinePage({ planedevices }) {
},
{
label: '温度',
- value: `${selectedDrone?.environment_temperature ?? '-'}℃`,
+ value: `${listDrone?.environment_temperature ?? '-'}℃`,
icon: ,
color: '#FF7D00',
- // 飞行条件:0℃ ~ 40℃ 适宜
judge: (val) => {
const temp = parseFloat(val);
if (isNaN(temp)) return { desc: '未知', color: '#86909C' };
@@ -398,15 +417,13 @@ export default function WayLinePage({ planedevices }) {
},
{
label: '降雨',
- value: `${selectedDrone?.rainfall} `,
+ value: `${listDrone?.rainfall ?? '-'} `,
icon: ,
color: '#FF7D00',
judge: (val) => {
if (val?.trim() === "no_rain") {
- console.log('✅ 匹配到无雨 → 适宜');
return { desc: '适宜', color: '#52C41A' };
} else {
- console.log('❌ 未匹配 → 不适宜');
return { desc: '不适宜', color: '#F53F3F' };
}
}
@@ -414,7 +431,7 @@ export default function WayLinePage({ planedevices }) {
{
label: '信号质量',
value: (() => {
- const q = selectedDrone?.network_state?.quality;
+ const q = listDrone?.network_state?.quality;
if (q === 'good') return '优';
if (q === 'better') return '良';
if (q === 'moderate') return '中';
@@ -424,7 +441,6 @@ export default function WayLinePage({ planedevices }) {
})(),
icon: ,
color: '#00B42A',
- // 信号质量:优 / 良 → 适宜,中 → 谨慎,差/极差 → 不适宜
judge: (val) => {
if (val === '优' || val === '良' || val === '正常') return { desc: '适宜', color: '#52C41A' };
if (val === '中') return { desc: '谨慎', color: '#FF7D00' };
@@ -432,7 +448,6 @@ export default function WayLinePage({ planedevices }) {
}
},
].map((item, idx) => {
- // 自动计算状态文案和颜色
const status = item.judge(item.value);
return (
@@ -452,13 +467,7 @@ export default function WayLinePage({ planedevices }) {
{item.value}
-
@@ -479,7 +488,6 @@ export default function WayLinePage({ planedevices }) {
{/* 底部内容区 */}
- {/* 甘特图/排班视图 */}
任务甘特视图 / 排班视图 今日 (2025-05-24)}
@@ -489,14 +497,12 @@ export default function WayLinePage({ planedevices }) {
style={{ ...cardStyle, height: '100%' }}
>
- {/* 时间轴头部 */}
08:0010:0012:0014:0016:0018:00
- {/* 甘特条 */}
{[
{ label: '无人机机场 A01', sub: '(UAV-A01)', tasks: [{ start: '25%', width: '18%', title: 'FL-03 热斑巡检', time: '10:00-11:20', color: '#165DFF' }, { start: '75%', width: '12%', title: 'FL-07 复检', time: '16:30-17:10', color: '#165DFF' }] },
@@ -525,7 +531,6 @@ export default function WayLinePage({ planedevices }) {
))}
- {/* 当前时间红线 */}
@@ -533,10 +538,39 @@ export default function WayLinePage({ planedevices }) {
- {/* 任务看板 */}
工作任务看板}
+ title={
+
+ 工作任务看板
+
+ setBoardDateRange(val)}
+ placeholder={['开始', '结束']}
+ />
+ ({
+ value: item.device_sn,
+ label: item.drone_callsign || item.device_sn
+ }))}
+ value={boardDrone?.device_sn}
+ onChange={(val) => {
+ const find = planedevices.find(i => i.device_sn === val);
+ setBoardDrone(find || null);
+ }}
+ />
+
+
+ }
bordered={false}
bodyStyle={{ padding: 16 }}
style={{ ...cardStyle, height: '100%' }}
@@ -544,26 +578,31 @@ export default function WayLinePage({ planedevices }) {
{[
{
- title: '待执行', count: 3, color: '#4E5969', bg: '#F7F8FA',
- list: [
- { id: 'FL-07', name: 'AI 复检航线', device: 'UAV-A01', target: '区块 B-01-B-20' },
- { id: 'CL-05', name: '组件清洗', device: 'UAV-C01', target: '区块 C-01-C-18' },
- { id: 'RB-03', name: '围栏巡检', device: 'RBT-01', target: '围栏全线' }
- ]
+ title: '待执行', count: waitList.length, color: '#4E5969', bg: '#F7F8FA',
+ list: waitList.map(item => ({
+ id: item.sn?.slice(-5) || '',
+ name: item.name,
+ device: item.sn,
+ target: ''
+ }))
},
{
- title: '执行中', count: 2, color: '#165DFF', bg: '#E8F3FF',
- list: [
- { id: 'FL-03', name: '无人机巡检', device: 'UAV-A01', target: '区块 B-01-B-20', gain: '8.2%' },
- { id: 'GR-04', name: '阵列除草', device: 'GR-01', target: '区块 D-01-D-16', gain: '6.5%' }
- ]
+ title: '执行中', count: runList.length, color: '#165DFF', bg: '#E8F3FF',
+ list: runList.map(item => ({
+ id: item.sn?.slice(-5) || '',
+ name: item.name,
+ device: item.sn,
+ target: ''
+ }))
},
{
- title: '已完成', count: 4, color: '#00B42A', bg: '#E8FFEA',
- list: [
- { id: 'FL-01', name: '组件巡检', device: 'UAV-A01', time: '08:20', gain: '7.1%' },
- { id: 'CL-01', name: '组件清洗', device: 'UAV-C01', time: '07:45', gain: '5.9%' }
- ]
+ title: '已完成', count: finishList.length, color: '#00B42A', bg: '#E8FFEA',
+ list: finishList.map(item => ({
+ id: item.sn?.slice(-5) || '',
+ name: item.name,
+ device: item.sn,
+ time: item.completed_at ? dayjs(item.completed_at).format('HH:mm') : ''
+ }))
},
].map((col, idx) => (
@@ -578,7 +617,6 @@ export default function WayLinePage({ planedevices }) {
装备: {task.device || 'UAV-A01'}
{task.target &&
目标: {task.target}
}
- {task.gain &&
预计收益: ↑ {task.gain}
}
{task.time &&
完成时间: {task.time}
}
diff --git a/src/components/useWebRTCStream.tsx b/src/components/useWebRTCStream.tsx
index afbb2eb..d295118 100644
--- a/src/components/useWebRTCStream.tsx
+++ b/src/components/useWebRTCStream.tsx
@@ -47,8 +47,8 @@ export function useWebRTCPlayer(deviceId: string, url: string) {
v.style.height = '100%';
v.style.objectFit = 'contain';
videoRef.current = v;
- const token = "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjY0MDVjNDgwLTAxNDYtNDAwNS1iY2RiLTFhMTM2YzlmYmFiMCJ9.V1GQiLr0xgu9LB59pGyYPFeVJfKwDsUtTacFrQDpXdEvD81uOkJO304tROF5Ewev6eXkZFuunUAEiMLWEfh2_w"
- //const token = localStorage.getItem('videotoken') || JSON.parse(localStorage.getItem('userInfo') || '{}')?.token;
+ //const token = "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjY0MDVjNDgwLTAxNDYtNDAwNS1iY2RiLTFhMTM2YzlmYmFiMCJ9.V1GQiLr0xgu9LB59pGyYPFeVJfKwDsUtTacFrQDpXdEvD81uOkJO304tROF5Ewev6eXkZFuunUAEiMLWEfh2_w"
+ const token = localStorage.getItem('videotoken') || JSON.parse(localStorage.getItem('userInfo') || '{}')?.token;
const videoUrl = `${url}?token=${token}`;
try {