From 9298107d62c9ff4080d12c202b7ff34988f45989 Mon Sep 17 00:00:00 2001
From: mmc <1556375442@qq.com>
Date: Tue, 7 Jul 2026 16:25:38 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=A2=84=E8=AE=BE=E8=88=AA?=
=?UTF-8?q?=E7=BA=BF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/device.ts | 9 ++++
src/components/devices/RobotTaskPage.tsx | 56 +++++++++++++++++++++++-
2 files changed, 63 insertions(+), 2 deletions(-)
diff --git a/src/api/device.ts b/src/api/device.ts
index 7b20f4e..1463f81 100644
--- a/src/api/device.ts
+++ b/src/api/device.ts
@@ -402,6 +402,15 @@ export function getRouteByTask(params) {
})
}
+//删除预设路径
+
+export function deleteRoute(workName) {
+ return request({
+ url: 'iot/workRecord/deleteByWorkName?workName=' + workName,
+ method: 'get',
+ })
+}
+
//增加预设路径iot/workRecord/add
export function addRoute(data) {
diff --git a/src/components/devices/RobotTaskPage.tsx b/src/components/devices/RobotTaskPage.tsx
index 0b29bb9..23df8d8 100644
--- a/src/components/devices/RobotTaskPage.tsx
+++ b/src/components/devices/RobotTaskPage.tsx
@@ -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: ,
+ 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}
+ {/* 删除按钮 */}
+
+ }
+ onClick={(e) => {
+ e.stopPropagation();
+ setSelectedPathWork(route);
+ // 替换为你的删除处理函数
+ handleDeleteRoute(route);
+ }}
+ />
+