接入 执行路线接口
This commit is contained in:
@@ -21,7 +21,8 @@ import {
|
||||
getRobotRouteList,
|
||||
getPlaneDeviceListAll, saveDeviceTask, getRobotTaskList,
|
||||
deleteDeviceTask,
|
||||
getSiteDevice
|
||||
getSiteDevice,
|
||||
excuetRoute
|
||||
} from '../../api/device';
|
||||
import dayjs from 'dayjs';
|
||||
import utils from '../../lib/utils';
|
||||
@@ -69,6 +70,11 @@ export default function RobotTaskPage() {
|
||||
const [routeSearch, setRouteSearch] = useState('');
|
||||
const [routeList, setRouteList] = useState([]);
|
||||
|
||||
// 执行任务弹窗
|
||||
const [executeModalVisible, setExecuteModalVisible] = useState(false);
|
||||
const [selectedRouteForExecute, setSelectedRouteForExecute] = useState(null);
|
||||
const [selectedRobotForExecute, setSelectedRobotForExecute] = useState(null);
|
||||
|
||||
// 获取数据
|
||||
const fetchAllData = async () => {
|
||||
if (!stationId) return;
|
||||
@@ -180,6 +186,38 @@ export default function RobotTaskPage() {
|
||||
};
|
||||
const handleTaskexcuted = (route) => {
|
||||
console.log('执行任务,路线数据:', route);
|
||||
setSelectedRouteForExecute(route);
|
||||
setSelectedRobotForExecute(null);
|
||||
setExecuteModalVisible(true);
|
||||
}
|
||||
|
||||
const handleExecuteConfirm = async () => {
|
||||
if (!selectedRobotForExecute) {
|
||||
message.error('请选择执行设备');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const params = {
|
||||
deviceId: selectedRobotForExecute.serialNumber,
|
||||
routeId: selectedRouteForExecute.id,
|
||||
siteId: stationId
|
||||
};
|
||||
|
||||
console.log('执行任务参数:', params);
|
||||
const res = await excuetRoute(params);
|
||||
|
||||
if (res.code === 200) {
|
||||
utils.message.success('任务执行成功');
|
||||
setExecuteModalVisible(false);
|
||||
fetchTaskList(); // 刷新任务列表
|
||||
} else {
|
||||
utils.message.error(res.msg || '任务执行失败');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('执行任务失败:', err);
|
||||
utils.message.error('任务执行异常');
|
||||
}
|
||||
}
|
||||
|
||||
const handleTaskCreated = () => {
|
||||
@@ -767,6 +805,44 @@ export default function RobotTaskPage() {
|
||||
stationId={stationId}
|
||||
onTaskCreated={handleTaskCreated}
|
||||
/>
|
||||
|
||||
{/* 执行任务弹窗 */}
|
||||
<Modal
|
||||
title="执行路线任务"
|
||||
open={executeModalVisible}
|
||||
onCancel={() => setExecuteModalVisible(false)}
|
||||
onOk={handleExecuteConfirm}
|
||||
okText="执行"
|
||||
cancelText="取消"
|
||||
>
|
||||
<div style={{ padding: '10px 0' }}>
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<div style={{ marginBottom: 8, fontWeight: 500 }}>路线信息</div>
|
||||
<div style={{ padding: 12, background: '#f5f7fa', borderRadius: 6 }}>
|
||||
<div><strong>路线名称:</strong>{selectedRouteForExecute?.workName || selectedRouteForExecute?.name}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div style={{ marginBottom: 8, fontWeight: 500 }}>选择执行设备</div>
|
||||
<Select
|
||||
style={{ width: '100%' }}
|
||||
placeholder="请选择执行设备"
|
||||
value={selectedRobotForExecute?.serialNumber}
|
||||
onChange={(val) => {
|
||||
const robot = devices.find(d => d.serialNumber === val);
|
||||
setSelectedRobotForExecute(robot);
|
||||
}}
|
||||
>
|
||||
{devices.map(device => (
|
||||
<Select.Option key={device.serialNumber} value={device.serialNumber}>
|
||||
{device.deviceAlias} ({device.serialNumber})
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user