任务池和历史任务 数据接入

This commit is contained in:
mmc
2026-06-03 14:30:56 +08:00
parent e70dd000b8
commit 95758e7a39
2 changed files with 30 additions and 23 deletions

View File

@@ -310,7 +310,13 @@ export default function RobotTaskPage() {
const res = await getDeviceTastPool(params);
if (res.code === 200) {
setTaskPoolList(res.rows || []);
const list = res.rows || [];
list.sort((a, b) => {
const aEmpty = !a.planId;
const bEmpty = !b.planId;
return aEmpty ? -1 : bEmpty ? 1 : 0;
});
setTaskPoolList(list);
}
} catch (err) {
console.error('获取任务池失败:', err);
@@ -339,7 +345,7 @@ export default function RobotTaskPage() {
const res = await getSiteDeviceTaskHistory(params);
if (res.code === 200) {
setTaskHistoryList(res.data || []);
setTaskHistoryList(res.rows || []);
}
} catch (err) {
console.error('获取历史任务失败:', err);
@@ -628,42 +634,43 @@ export default function RobotTaskPage() {
// 历史任务表格列
const taskHistoryColumns = [
{
title: '任务名称',
dataIndex: 'planName',
width: 160,
ellipsis: true,
},
{
title: '设备',
dataIndex: 'deviceId',
width: 150,
width: 250,
},
{
title: '状态',
dataIndex: 'taskStaus',
dataIndex: 'taskStausTranslate',
width: 100,
render: (status, record) => {
const statusMap = {
'FINISH': { color: 'success', text: '执行成功' },
'FAILED': { color: 'error', text: '执行失败' },
'CANCELLED': { color: 'default', text: '已取消' }
};
const item = statusMap[status] || { color: 'default', text: '未知' };
return <Tag color={item.color}>{item.text}</Tag>;
}
render: (text, record) => {
const status = record.taskStaus; // 原始状态值
let color = 'default';
if (status === 'NEW') color = 'default';
else if (status === 'EXECUTING') color = 'processing';
else if (status === 'PAUSE') color = 'warning';
else if (status === 'FINISH') color = 'success';
else if (status === 'FAILED') color = 'error';
return <Tag color={color} style={{ margin: 0 }}>{text}</Tag>;
},
},
{
title: '开始时间',
dataIndex: 'startTime',
width: 170,
render: t => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
},
{
title: '结束时间',
dataIndex: 'finishTime',
width: 170,
render: t => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
}, {
title: '创建时间',
dataIndex: 'createTime',
width: 170,
}
];
@@ -1008,7 +1015,7 @@ export default function RobotTaskPage() {
columns={taskHistoryColumns}
dataSource={taskHistoryList}
pagination={false}
scroll={{ x: 800 }}
scroll={{ x: 800, y: 150 }}
/>
</>
)}