diff --git a/src/api/device.ts b/src/api/device.ts index 9c314a7..970a83a 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -313,4 +313,37 @@ export function pauseRoute(data) { }) } +//恢复任务 + +export function recoverRoute(data) { + return request({ + url: `/iot/deviceTask/recoveryTask`, + method: 'post', + data + + }) +} + +//当前执行和待执行的任务 + +export function getDeviceTastPool(data) { + return request({ + url: `/iot/deviceTask/deviceTaskPool`, + method: 'post', + data + + }) +} +//获取历史任务 +export function getSiteDeviceTaskHistory(data) { + return request({ + url: `/iot/deviceTas/getSiteDeviceTaskHistory`, + method: 'post', + data + + }) +} + + + diff --git a/src/components/devices/DeviceOverviewPage.tsx b/src/components/devices/DeviceOverviewPage.tsx index 2e71ffa..385e1f7 100644 --- a/src/components/devices/DeviceOverviewPage.tsx +++ b/src/components/devices/DeviceOverviewPage.tsx @@ -425,7 +425,7 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS name: d.deviceAlias || d.deviceName || d.callsign || '未知设备', type: d.productName || '未知类型', status: d.onlineStatus === 1 ? '在线' : '离线', - mode: d.status === 4 ? '待命' : '作业中', + mode: d.feStatus == 1 ? '作业中' : d.feStatus == 2 ? '空闲' : d.mode_code == 0 ? '空闲' : d.mode_code == 1 ? '现场调试' : d.mode_code == 2 ? '远程调试' : d.mode_code == 3 ? '固件升级中' : '作业中', capacity_percent: d.capacity_percent || 100, position: d.position || '站内', task: d.status === 4 ? '待命' : '作业中', @@ -551,19 +551,23 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS return {text}; } }, { - title: '模式', dataIndex: 'feStatus', width: 70, render: (feStatus) => { - console.log('feStatus:', feStatus); - const text = feStatus == 1 ? '任务中' : feStatus == 2 ? '空闲' : '离线'; - const color = feStatus === 1 ? 'processing' : feStatus === 2 ? 'success' : 'default'; + title: '模式', dataIndex: 'mode', width: 70, render: (text) => { + let color = 'default'; + if (text === '作业中') color = 'processing'; + if (text === '空闲') color = 'success'; + if (text === '空闲中') color = 'success'; + if (text === '现场调试') color = 'warning'; + if (text === '远程调试') color = 'warning'; + if (text === '固件升级中') color = 'error'; return {text}; } }, { title: '电量', - dataIndex: 'lastrunning', + dataIndex: 'lastRunningStatus', width: 70, - render: (lastrunning) => { - const v = lastrunning?.battery || 0; + render: (lastRunningStatus) => { + const v = lastRunningStatus?.battery || 100; return ; } }, { title: '位置', dataIndex: 'position', width: 90 }, - { title: '当前任务', dataIndex: 'task', width: 100 }, - { title: '通讯状态', dataIndex: 'comm', width: 70, render: v => }, + //{ title: '当前任务', dataIndex: 'task', width: 100 }, + { title: '通讯状态', dataIndex: 'comm', width: 100, render: v => }, { title: '操作', key: 'action', width: 80, render: () => + ) } ]; + // 任务池表格列 + const taskPoolColumns = [ + + { + title: '设备', + dataIndex: 'deviceId', + width: 150, + }, + { + title: '状态', + dataIndex: 'taskStaus', + width: 100, + render: (status, record) => { + const statusMap = { + 'NEW': { color: 'default', text: '新建' }, + 'EXECUTING': { color: 'processing', text: '执行中' }, + 'PAUSE': { color: 'warning', text: '暂停中' }, + 'FINISH': { color: 'success', text: '执行成功' }, + 'FAILED': { color: 'error', text: '执行失败' } + }; + const item = statusMap[status] || { color: 'default', text: '未知' }; + return {item.text}; + } + }, + { + title: '创建时间', + dataIndex: 'createTime', + width: 170, + }, + { + title: '操作', + width: 50, + fixed: 'right', + render: (_, record) => ( + + {record.taskStaus === 'NEW' && ( + handleCancelTask(record)} + okText="确定" + cancelText="取消" + > + + + )} + {record.taskStaus === 'EXECUTING' && ( + handlePauseTask(record)} + okText="确定" + cancelText="取消" + > + + + )} + {record.taskStaus === 'PAUSE' && ( + handleRecoverTask(record)} + okText="确定" + cancelText="取消" + > + + + )} + + ) + } + ]; + + // 历史任务表格列 + const taskHistoryColumns = [ + { + title: '任务名称', + dataIndex: 'planName', + width: 160, + ellipsis: true, + }, + { + title: '设备', + dataIndex: 'deviceId', + width: 150, + }, + { + title: '状态', + dataIndex: 'taskStaus', + 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}; + } + }, + { + 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') : '-' + } + ]; + const handleRowClick = (record) => { if (record.longitude && record.latitude) { setFocusLocation({ @@ -526,84 +801,218 @@ export default function RobotTaskPage() { - {/* 机器人任务列表 + 右侧 新建任务加号按钮 */} + {/* 机器人任务模块,带Tab切换 */} - 机器人任务列表 - - { - setFilterForm(prev => ({ ...prev, dateRange: dates })); - }} - /> - ({ - value: item.serialNumber, - label: item.deviceAlias || item.deviceName - }))} - value={filterForm.robot?.serialNumber} - onChange={(val) => { - if (!val) { - setFilterForm(prev => ({ ...prev, robot: null })); - return; - } - const robot = devices.find(i => i.serialNumber === val); - setFilterForm(prev => ({ ...prev, robot: robot })); - }} - /> - - {/* 🔥 新建任务按钮(加号) */} - - setIsTaskModalOpen(true)} - /> - - - - } size="small" bordered={false} - bodyStyle={{ padding: 0, display: 'flex', flexDirection: 'column', height: "calc(100% - 40px)", overflow: "auto" }} - style={{ ...cardStyle, maxHeight: "250px", flex: 1, marginBottom: 0 }} + bodyStyle={{ padding: 0, display: 'flex', flexDirection: 'column', height: "calc(100%)", overflow: "auto" }} + style={{ ...cardStyle, maxHeight: "300px", flex: 1, marginBottom: 0 }} > - ({ - onClick: () => handleRowClick(record), - style: { cursor: 'pointer' } - })} + style={{ padding: '0 12px' }} + items={[ + { + key: 'task', + label: '任务列表', + }, + { + key: 'pool', + label: '任务池', + }, + { + key: 'history', + label: '历史任务', + } + ]} + tabBarExtraContent={ + + setIsTaskModalOpen(true)} + /> + + } /> + +
+ {/* 任务列表Tab */} + {activeTab === 'task' && ( + <> +
+ { + setFilterForm(prev => ({ ...prev, dateRange: dates })); + }} + /> + ({ + value: item.serialNumber, + label: item.deviceAlias || item.deviceName + }))} + value={filterForm.robot?.serialNumber} + onChange={(val) => { + if (!val) { + setFilterForm(prev => ({ ...prev, robot: null })); + return; + } + const robot = devices.find(i => i.serialNumber === val); + setFilterForm(prev => ({ ...prev, robot: robot })); + }} + /> +
+
({ + onClick: () => handleRowClick(record), + style: { cursor: 'pointer' } + })} + /> + + )} + + {/* 任务池Tab */} + {activeTab === 'pool' && ( + <> +
+ ({ + value: item.serialNumber, + label: item.deviceAlias || item.deviceName + }))} + value={poolFilterForm.robot?.serialNumber} + onChange={(val) => { + if (!val) { + setPoolFilterForm(prev => ({ ...prev, robot: null })); + return; + } + const robot = devices.find(i => i.serialNumber === val); + setPoolFilterForm(prev => ({ ...prev, robot: robot })); + }} + /> +
+
+ + )} + + {/* 历史任务Tab */} + {activeTab === 'history' && ( + <> +
+ { + setHistoryFilterForm(prev => ({ ...prev, dateRange: dates })); + }} + showTime + /> + ({ + value: item.serialNumber, + label: item.deviceAlias || item.deviceName + }))} + value={historyFilterForm.robot?.serialNumber} + onChange={(val) => { + if (!val) { + setHistoryFilterForm(prev => ({ ...prev, robot: null })); + return; + } + const robot = devices.find(i => i.serialNumber === val); + setHistoryFilterForm(prev => ({ ...prev, robot: robot })); + }} + /> +
+
+ + )} +