From 18e0143f7060c1738fbef0128f64a4d8ebe4d671 Mon Sep 17 00:00:00 2001
From: mmc <1556375442@qq.com>
Date: Fri, 22 May 2026 12:42:33 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=BB=BB=E5=8A=A1=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E5=92=8C=20=E5=B7=A5=E4=BD=9C=E4=BB=BB=E5=8A=A1?=
=?UTF-8?q?=E7=9C=8B=E6=9D=BF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/devices/WayLinePage.tsx | 71 ++++++++++++++++++--------
1 file changed, 50 insertions(+), 21 deletions(-)
diff --git a/src/components/devices/WayLinePage.tsx b/src/components/devices/WayLinePage.tsx
index bb553ce..d2a1a6a 100644
--- a/src/components/devices/WayLinePage.tsx
+++ b/src/components/devices/WayLinePage.tsx
@@ -54,7 +54,6 @@ export default function WayLinePage({ planedevices }) {
{ title: '覆盖装备', value: '4 类 / 9 台', unit: '', desc: '全部在线', icon: , color: '#165DFF' },
];
- // 获取任务列表数据
// 获取任务列表数据 【时间戳已改为秒级】
const getListTask = async () => {
if (!planedevices?.length) return;
@@ -68,7 +67,16 @@ export default function WayLinePage({ planedevices }) {
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 || []);
+ if (res?.code === 200) {
+ // 处理嵌套数据结构:data: { [sn]: { list: [] } }
+ let combinedList = [];
+ if (res.data) {
+ Object.values(res.data).forEach((item: any) => {
+ if (item.list) combinedList = combinedList.concat(item.list);
+ });
+ }
+ setTaskList(combinedList);
+ }
} catch (err) {
message.error('任务列表数据获取失败');
}
@@ -87,7 +95,16 @@ export default function WayLinePage({ planedevices }) {
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 || []);
+ if (res?.code === 200) {
+ // 处理嵌套数据结构
+ let combinedList = [];
+ if (res.data) {
+ Object.values(res.data).forEach((item: any) => {
+ if (item.list) combinedList = combinedList.concat(item.list);
+ });
+ }
+ setBoardTaskList(combinedList);
+ }
} catch (err) {
message.error('任务看板数据获取失败');
}
@@ -96,8 +113,8 @@ export default function WayLinePage({ planedevices }) {
// 初始化默认全部设备
useEffect(() => {
if (planedevices?.length) {
- setListDrone(null);
- setBoardDrone(null);
+ setListDrone(planedevices[0]); // 默认显示第一个无人机
+ setBoardDrone(null); // 默认显示所有
}
}, [planedevices]);
@@ -114,6 +131,7 @@ export default function WayLinePage({ planedevices }) {
const getStatusTag = (status) => {
const statusMap = {
success: { color: 'success', text: '执行成功' },
+ preparing: { color: 'blue', text: '准备中' },
running: { color: 'processing', text: '执行中' },
failed: { color: 'error', text: '执行失败' },
waiting: { color: 'default', text: '待开始' },
@@ -131,7 +149,7 @@ export default function WayLinePage({ planedevices }) {
// 列表表格列
const taskColumns = [
{ title: '任务名称', dataIndex: 'name', width: 260, ellipsis: true, fixed: "left" },
- { title: '任务UUID', dataIndex: 'uuid', width: 260, ellipsis: true },
+ //{ title: '任务UUID', dataIndex: 'uuid', width: 260, ellipsis: true },
{ title: '设备SN', dataIndex: 'sn', width: 140 },
{ title: '状态', dataIndex: 'status', width: 80, render: getStatusTag },
{
@@ -142,7 +160,7 @@ export default function WayLinePage({ planedevices }) {
},
{
title: '结束时间',
- dataIndex: 'completed_at',
+ dataIndex: 'end_at',
width: 170,
render: t => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
},
@@ -170,9 +188,18 @@ export default function WayLinePage({ planedevices }) {
// 看板数据分组处理
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));
+ // 待执行 = 准备中 + 待开始 + 已挂起 + 已终止
+ const waitList = boardTaskList.filter(item =>
+ ['preparing', '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();
@@ -274,7 +301,7 @@ export default function WayLinePage({ planedevices }) {
size="small"
extra={}
bordered={false}
- bodyStyle={{ padding: 0 }}
+ bodyStyle={{ padding: 0, display: 'flex', flexDirection: 'column', flex: 1 }}
style={{ ...cardStyle, flex: 1 }}
>
{[
@@ -586,7 +613,7 @@ export default function WayLinePage({ planedevices }) {
id: item.sn?.slice(-5) || '',
name: item.name,
device: item.sn,
- target: ''
+ begin_at: ''
}))
},
{
@@ -595,7 +622,7 @@ export default function WayLinePage({ planedevices }) {
id: item.sn?.slice(-5) || '',
name: item.name,
device: item.sn,
- target: ''
+ begin_at: ''
}))
},
{
@@ -604,7 +631,8 @@ export default function WayLinePage({ planedevices }) {
id: item.sn?.slice(-5) || '',
name: item.name,
device: item.sn,
- time: item.completed_at ? dayjs(item.completed_at).format('HH:mm') : ''
+ begin_at: item.begin_at,
+ completed_at: item.completed_at
}))
},
].map((col, idx) => (
@@ -616,11 +644,12 @@ export default function WayLinePage({ planedevices }) {
{col.list.map((task, tidx) => (
-
{task.id} {task.name}
-
+
+ {task.name}
+
装备: {task.device || 'UAV-A01'}
- {task.target &&
目标: {task.target}
}
- {task.time &&
完成时间: {task.time}
}
+ {task.begin_at &&
开始时间: {task.begin_at}
}
+ {task.completed_at &&
完成时间: {task.completed_at}
}
))}
@@ -629,9 +658,9 @@ export default function WayLinePage({ planedevices }) {
))}
-
*/}