From 95758e7a393a580c0b5e3f176ce00c45fc48f098 Mon Sep 17 00:00:00 2001 From: mmc <1556375442@qq.com> Date: Wed, 3 Jun 2026 14:30:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=B1=A0=E5=92=8C=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E4=BB=BB=E5=8A=A1=20=E6=95=B0=E6=8D=AE=E6=8E=A5?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/device.ts | 2 +- src/components/devices/RobotTaskPage.tsx | 51 ++++++++++++++---------- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/api/device.ts b/src/api/device.ts index 75e4cdf..8f68ab5 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -337,7 +337,7 @@ export function getDeviceTastPool(data) { //获取历史任务 export function getSiteDeviceTaskHistory(data) { return request({ - url: `/iot/deviceTas/getSiteDeviceTaskHistory`, + url: `/iot/deviceTask/getSiteDeviceTaskHistory`, method: 'post', data diff --git a/src/components/devices/RobotTaskPage.tsx b/src/components/devices/RobotTaskPage.tsx index c7d38ff..cc10e6c 100644 --- a/src/components/devices/RobotTaskPage.tsx +++ b/src/components/devices/RobotTaskPage.tsx @@ -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 {item.text}; - } + 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 {text}; + }, + }, { 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 }} /> )}