删除预设航线
This commit is contained in:
@@ -4,14 +4,16 @@ import {
|
||||
Tabs, Input, Switch, Divider, Tooltip, Timeline, Select, message, DatePicker,
|
||||
Modal, InputNumber,
|
||||
TimePicker,
|
||||
Popconfirm
|
||||
Popconfirm,
|
||||
App
|
||||
} from 'antd';
|
||||
import {
|
||||
PlusOutlined, ImportOutlined, NodeIndexOutlined,
|
||||
SaveOutlined, PlayCircleOutlined, EyeOutlined,
|
||||
DeleteOutlined,
|
||||
CloseOutlined,
|
||||
ReloadOutlined
|
||||
ReloadOutlined,
|
||||
ExclamationCircleOutlined
|
||||
} from '@ant-design/icons';
|
||||
import {
|
||||
Car, Navigation, Wind, Thermometer, Droplets, Satellite,
|
||||
@@ -32,6 +34,7 @@ import {
|
||||
getDeviceTastPool,
|
||||
getSiteDeviceTaskHistory,
|
||||
getRouteByTask,
|
||||
deleteRoute,
|
||||
} from '../../api/device';
|
||||
import dayjs from 'dayjs';
|
||||
import DraggableBox from '../Draggable';
|
||||
@@ -58,10 +61,14 @@ export default function RobotTaskPage() {
|
||||
const [execute, setExecute] = useState(false); // 是否执行任务
|
||||
const [taskList, setTaskList] = useState([]);
|
||||
const [arrivedPoint, setArrivedPoint] = useState(null);//完成点
|
||||
const { modal } = App.useApp();
|
||||
|
||||
|
||||
|
||||
// 设备数据
|
||||
const [devices, setDevices] = useState([]);
|
||||
const [deleteLoading, setDeleteLoading] = useState(false);
|
||||
|
||||
|
||||
|
||||
const [focusLocation, setFocusLocation] = useState(null);
|
||||
@@ -169,6 +176,38 @@ export default function RobotTaskPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteRoute = async (route) => {
|
||||
console.log('删除航线:', route);
|
||||
// 防重复点击拦截
|
||||
if (deleteLoading) return;
|
||||
|
||||
modal.confirm({
|
||||
title: '确认删除',
|
||||
content: `确定要删除航线「${route.workName}」吗?删除后数据无法恢复!`,
|
||||
icon: <ExclamationCircleOutlined style={{ color: '#FF7D00' }} />,
|
||||
okText: '确定删除',
|
||||
cancelText: '取消',
|
||||
okButtonProps: { danger: true, loading: deleteLoading },
|
||||
onOk: async () => {
|
||||
setDeleteLoading(true);
|
||||
try {
|
||||
const res = await deleteRoute(route.workName);
|
||||
if (res.code === 200) {
|
||||
message.success('航线删除成功');
|
||||
fetchRouteList();
|
||||
} else {
|
||||
utils.message.error(res.msg || '删除失败,请稍后重试');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('删除航线接口报错:', err);
|
||||
utils.message.error('删除失败,网络或服务异常');
|
||||
} finally {
|
||||
setDeleteLoading(false);
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
// 任务池项点击事件
|
||||
const handlePoolTaskClick = (record) => {
|
||||
setRunningPoolTask(record);
|
||||
@@ -1583,6 +1622,19 @@ export default function RobotTaskPage() {
|
||||
ID: {route.id}
|
||||
</div>
|
||||
</div>
|
||||
{/* 删除按钮 */}
|
||||
<Tooltip title="删除航线">
|
||||
<Button
|
||||
type="text"
|
||||
icon={<DeleteOutlined style={{ color: '#F53F3F', fontSize: 20 }} />}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setSelectedPathWork(route);
|
||||
// 替换为你的删除处理函数
|
||||
handleDeleteRoute(route);
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip title="创建任务">
|
||||
<Button
|
||||
type="text"
|
||||
|
||||
Reference in New Issue
Block a user