设备任务列表和 工作任务看板
This commit is contained in:
@@ -54,7 +54,6 @@ export default function WayLinePage({ planedevices }) {
|
||||
{ title: '覆盖装备', value: '4 类 / 9 台', unit: '', desc: '全部在线', icon: <Satellite size={22} />, 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={<PlusOutlined style={{ cursor: 'pointer', color: '#165DFF', fontSize: 12, marginLeft: 10 }} />}
|
||||
bordered={false}
|
||||
bodyStyle={{ padding: 0 }}
|
||||
bodyStyle={{ padding: 0, display: 'flex', flexDirection: 'column', flex: 1 }}
|
||||
style={{ ...cardStyle, flex: 1 }}
|
||||
>
|
||||
<Table
|
||||
@@ -576,7 +603,7 @@ export default function WayLinePage({ planedevices }) {
|
||||
}
|
||||
bordered={false}
|
||||
bodyStyle={{ padding: 16 }}
|
||||
style={{ ...cardStyle, height: '100%' }}
|
||||
style={{ ...cardStyle, height: '100%', maxHeight: 480, overflow: "auto" }}
|
||||
>
|
||||
<Row gutter={10}>
|
||||
{[
|
||||
@@ -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 }) {
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
||||
{col.list.map((task, tidx) => (
|
||||
<div key={tidx} style={{ background: '#fff', borderRadius: 8, padding: 10, boxShadow: '0 2px 4px rgba(0,0,0,0.04)', border: '1px solid #F1F2F5' }}>
|
||||
<div style={{ fontSize: 11, fontWeight: 700, color: '#165DFF', marginBottom: 6 }}>{task.id} {task.name}</div>
|
||||
<div style={{ fontSize: 10, color: '#86909C' }}>
|
||||
<div style={{ fontSize: 11, fontWeight: 700, color: '#165DFF', marginBottom: 6, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
|
||||
{task.name}
|
||||
</div> <div style={{ fontSize: 10, color: '#86909C' }}>
|
||||
<div style={{ marginBottom: 2 }}>装备: {task.device || 'UAV-A01'}</div>
|
||||
{task.target && <div style={{ marginBottom: 2 }}>目标: {task.target}</div>}
|
||||
{task.time && <div style={{ marginTop: 2 }}>完成时间: {task.time}</div>}
|
||||
{task.begin_at && <div style={{ marginTop: 2 }}>开始时间: {task.begin_at}</div>}
|
||||
{task.completed_at && <div style={{ marginTop: 2 }}>完成时间: {task.completed_at}</div>}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
@@ -629,9 +658,9 @@ export default function WayLinePage({ planedevices }) {
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
<div style={{ textAlign: 'center', marginTop: 12 }}>
|
||||
{/*<div style={{ textAlign: 'center', marginTop: 12 }}>
|
||||
<Button type="link" size="small" style={{ fontSize: 12, color: '#86909C' }}>查看全部 <ArrowRightOutlined style={{ fontSize: 10 }} /></Button>
|
||||
</div>
|
||||
</div>*/}
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
Reference in New Issue
Block a user