From fb363882acff6e9fb94657217238d2508d2afcab Mon Sep 17 00:00:00 2001 From: mmc <1556375442@qq.com> Date: Sat, 24 Oct 2026 13:38:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9C=B0=E5=9B=BE=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E7=95=8C=E9=9D=A2=EF=BC=8C=E8=AF=A5=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5=20?= =?UTF-8?q?=E8=BF=94=E8=88=AA=E7=82=B9=EF=BC=8C=E4=B8=80=E4=B8=AA=E6=9C=BA?= =?UTF-8?q?=E5=99=A8=E5=AF=B9=E5=BA=94=E4=B8=80=E4=B8=AA=E8=BF=94=E8=88=AA?= =?UTF-8?q?=E7=82=B9=EF=BC=8C=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5=E5=9C=BA?= =?UTF-8?q?=E7=AB=99=E5=88=86=E5=8C=BA=EF=BC=8C=E5=B0=86=E5=8E=9F=E6=9C=AC?= =?UTF-8?q?=E6=9C=BA=E5=99=A8=E7=8A=B6=E6=80=81=E7=95=8C=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=20=E8=B7=AF=E5=BE=84=E8=A7=84=E5=88=92=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E7=A7=BB=E6=A4=8D=E5=88=B0=E8=AF=A5=E9=A1=B5=E9=9D=A2=EF=BC=8C?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E4=B8=8A=E6=94=AF=E6=8C=81=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=20=E8=BF=94=E8=88=AA=E7=82=B9=E5=92=8C=E5=88=86=E5=8C=BA?= =?UTF-8?q?=EF=BC=8C=E7=82=B9=E5=87=BB=E5=88=86=E5=8C=BA=E5=92=8C=E8=BF=94?= =?UTF-8?q?=E8=88=AA=E7=82=B9=EF=BC=8C=E5=9C=B0=E5=9B=BE=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=AE=9A=E4=BD=8D=E5=92=8C=E9=AB=98=E4=BA=AE=EF=BC=8C=E7=AD=89?= =?UTF-8?q?=E5=BE=85=E6=B5=8B=E8=AF=95=20=E6=9C=BA=E5=99=A8=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=95=8C=E9=9D=A2=E8=BF=94=E8=88=AA=20=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5=EF=BC=8C=E8=BF=98?= =?UTF-8?q?=E6=9C=AA=E5=AF=B9=E6=8E=A5=E5=AE=9E=E6=9C=BA=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mapEdit.ts | 31 + src/api/stationManage/index.ts | 11 + src/components/Map.jsx | 392 ++++- src/components/devices/DeviceStatusPage.tsx | 42 +- src/components/devices/MapEditorPage.tsx | 1375 +++++++++++++++++ .../devices/RobotFeatureButtons.tsx | 8 +- src/components/devices/RobotTaskPage.tsx | 355 +++-- src/locales/en/index.ts | 55 +- src/locales/zh/index.ts | 75 + src/router/routes.tsx | 7 +- 10 files changed, 2137 insertions(+), 214 deletions(-) create mode 100644 src/api/mapEdit.ts create mode 100644 src/components/devices/MapEditorPage.tsx diff --git a/src/api/mapEdit.ts b/src/api/mapEdit.ts new file mode 100644 index 0000000..cea2d22 --- /dev/null +++ b/src/api/mapEdit.ts @@ -0,0 +1,31 @@ + +import request from './request'; + +export function saveSiteMapInfo(data) { + return request({ + url: `/system/siteMapInfo/save`, + method: 'post', + data, + }); +} + +//返回休息区 + +export function backToRestPointCommand(data) { + return request({ + url: `/iot/deviceTask/backToRestPoint`, + method: 'post', + data, + }); +} + +/// 下发区域绑定任务/iot/deviceTask/createRegionDefaultTask + +export function createRegionDefaultTask(data) { + return request({ + url: `/iot/deviceTask/createRegionDefaultTask`, + method: 'post', + data, + }); +} + diff --git a/src/api/stationManage/index.ts b/src/api/stationManage/index.ts index 9f30f97..341256a 100644 --- a/src/api/stationManage/index.ts +++ b/src/api/stationManage/index.ts @@ -49,6 +49,17 @@ export function getStationRegions(params) { }); } +//根据场站获取地图配置 + +export function getSiteMapInfo(params) { + return request({ + url: '/system/siteMapInfo/selectBySiteId', + method: 'get', + params + + }); +} + //新增分区 export function saveRegion(data) { return request({ diff --git a/src/components/Map.jsx b/src/components/Map.jsx index 6815049..4f995c3 100644 --- a/src/components/Map.jsx +++ b/src/components/Map.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef, useState, useMemo, useImperativeHandle, forwardRef, useCallback } from 'react'; +import React, { useEffect, useRef, useState, useMemo, useImperativeHandle, forwardRef, useCallback, useLayoutEffect } from 'react'; import carImg from '../assets/images/carplane.png'; import inspectImg from "../assets/images/inspectCar.png" import planeImg from '../assets/images/planeicon.png'; @@ -10,6 +10,8 @@ import iotImg from '../assets/images/iot.png'; import envConfig from '../../env'; import { TracePoint, TPAction, TPMode } from '../lib/TracePoint/tracePoint'; import { useTranslation } from 'react-i18next'; +import { useSelector } from 'react-redux'; +import { getSiteMapInfo, getStationRegions } from '../api/stationManage'; const CYAN_ALARM_COLOR = new window.Cesium.Color( @@ -27,7 +29,7 @@ const CYAN_GLOW_COLOR = new window.Cesium.Color( ); window.Cesium.Ion.defaultAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJmNjk0NjI1MC0wZGYyLTQ1YzItYjJmZi0wY2M5ODEwODllYzIiLCJpZCI6Mzk3MTQxLCJpYXQiOjE3NzI1MjkwMjV9.U6qmakhDgXJVXwLFyWzSxAUOFZRrDkIsRUPP6CCdnKg"; -const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, finishPoint, drawRealTime, realtimePosition, realtimeType, pathPoints = [], devices = [], onCameraClick, focusLocation, points = [], markedPoints = [], onPathChange, from, onClearDraw, onMarkPoint, routeMode = '', polyPoints, mapLayer }, ref) => { +const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, finishPoint, drawRealTime, realtimePosition, realtimeType, pathPoints = [], devices = [], onCameraClick, focusLocation, points = [], markedPoints = [], onPathChange, from, onClearDraw, onMarkPoint, routeMode = '', polyPoints, mapLayer, activeType, overlayRefreshKey = 0, focusOverlay = null }, ref) => { const containerRef = useRef(null); const viewerRef = useRef(null); const tooltipRef = useRef(null); @@ -41,10 +43,20 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, const navLineRef = useRef(null); // 完成点实时轨迹 const markedPointsRef = useRef([]); // 标记点实体 const markedLineRef = useRef(null); // 标记点连线实体 + const lastMarkedPointsRef = useRef([]); // 上次渲染的标记点数据,用于增量更新 const onMarkPointRef = useRef(onMarkPoint); // 总是指向最新的 onMarkPoint,避免闭包滞后 const onCameraClickRef = useRef(onCameraClick); // 同样处理,避免闭包滞后 const { t } = useTranslation(); + // 场站已配置的返航点 / 分区叠加显示 + const stationId = useSelector((state) => state?.station?.stationId || state?.station?.currentStation?.id); + const [stationOverlay, setStationOverlay] = useState({ returnPoints: [], regions: [] }); + const stationOverlayIdsRef = useRef([]); + const returnPointPinUrlRef = useRef(null); + // 被点击聚焦的返航点 id / 图例高亮类型 + const [highlightReturnPointId, setHighlightReturnPointId] = useState(''); + const [legendHighlight, setLegendHighlight] = useState(''); + const realtimeEntityRef = useRef(null); const realtimeLineRef = useRef(null); @@ -679,63 +691,94 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, } }, [points]); - // 渲染标记点 + 连线(唯一系统,避免重复标记) + // 渲染标记点 + 连线(增量更新:只增删改真正变化的点) const drawMarkedPoints = (points) => { const viewer = viewerRef.current; if (!viewer) return; - // 先清空之前的标记点与连线 - markedPointsRef.current.forEach(id => { - viewer.entities.removeById(id); - }); - markedPointsRef.current = []; + const newPoints = points || []; + const prevPoints = lastMarkedPointsRef.current || []; - if (markedLineRef.current) { - try { - viewer.entities.remove(markedLineRef.current); - } catch (e) { } - markedLineRef.current = null; + const nextIds = new Set(newPoints.map((p, i) => `marked-point-${p.id ?? i}`)); + + // 1) 删除不在新列表中的旧 entity + markedPointsRef.current = markedPointsRef.current.filter(id => { + if (!nextIds.has(id)) { + viewer.entities.removeById(id); + return false; + } + return true; + }); + + // 2) 新增或更新标记点 entity + newPoints.forEach((p, i) => { + const id = `marked-point-${p.id ?? i}`; + const entity = viewer.entities.getById(id); + const position = window.Cesium.Cartesian3.fromDegrees(Number(p.lon), Number(p.lat)); + const labelText = `${i + 1}`; + + if (entity) { + // 只更新位置和 label,避免销毁重建 + entity.position = position; + if (entity.label) entity.label.text = labelText; + } else { + viewer.entities.add({ + id, + position, + point: { + color: window.Cesium.Color.GREEN, + pixelSize: 15, + disableDepthTestDistance: Number.POSITIVE_INFINITY, + }, + label: { + text: labelText, + font: '14px sans-serif', + pixelOffset: new window.Cesium.Cartesian2(0, -20), + fillColor: window.Cesium.Color.WHITE, + outlineColor: window.Cesium.Color.BLACK, + outlineWidth: 2, + style: window.Cesium.LabelStyle.FILL_AND_OUTLINE, + } + }); + markedPointsRef.current.push(id); + } + }); + + // 3) 连线:只有坐标/数量真正变化时才重建 + if (activeType !== "routeGen") { + viewer.scene.requestRender(); + return; + } + const lineChanged = newPoints.length !== prevPoints.length || + newPoints.some((p, i) => { + const pp = prevPoints[i]; + return !pp || Number(pp.lon) !== Number(p.lon) || Number(pp.lat) !== Number(p.lat); + }); + + if (lineChanged) { + if (markedLineRef.current) { + try { viewer.entities.remove(markedLineRef.current); } catch (e) { } + markedLineRef.current = null; + } + if (newPoints.length >= 2) { + const linePositions = newPoints.map(p => + window.Cesium.Cartesian3.fromDegrees(Number(p.lon), Number(p.lat)) + ); + markedLineRef.current = viewer.entities.add({ + polyline: { + positions: linePositions, + width: 4, + material: window.Cesium.Color.SKYBLUE, + clampToGround: true, + } + }); + } } - if (!points || points.length === 0) return; + lastMarkedPointsRef.current = newPoints.map(p => ({ ...p })); - // 先绘制连线:有 2 个及以上打点才连线 - if (points.length >= 2) { - const linePositions = points.map(p => - window.Cesium.Cartesian3.fromDegrees(Number(p.lon), Number(p.lat)) - ); - markedLineRef.current = viewer.entities.add({ - polyline: { - positions: linePositions, - width: 4, - material: window.Cesium.Color.SKYBLUE, - clampToGround: true, - } - }); - } - - points.forEach((p, i) => { - const id = `marked-point-${i}`; - viewer.entities.add({ - id, - position: window.Cesium.Cartesian3.fromDegrees(p.lon, p.lat), - point: { - color: window.Cesium.Color.GREEN, - pixelSize: 15, - disableDepthTestDistance: Number.POSITIVE_INFINITY, - }, - label: { - text: `${i + 1}`, - font: '14px sans-serif', - pixelOffset: new window.Cesium.Cartesian2(0, -20), - fillColor: window.Cesium.Color.WHITE, - outlineColor: window.Cesium.Color.BLACK, - outlineWidth: 2, - style: window.Cesium.LabelStyle.FILL_AND_OUTLINE, - } - }); - markedPointsRef.current.push(id); - }); + // 强制 Cesium 立即渲染(requestRenderMode=true 时必须手动触发) + viewer.scene.requestRender(); }; useEffect(() => { @@ -834,6 +877,25 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, } } + // 返航点悬浮提示:显示别名与该返航点绑定的机器 + function showReturnPointTooltip(tooltip, position, point) { + if (!tooltip) return; + tooltip.style.display = "block"; + tooltip.style.left = position.x + 12 + "px"; + tooltip.style.top = position.y + 12 + "px"; + tooltip.style.whiteSpace = "nowrap"; + + const boundDevice = devices.find(d => d?.serialNumber === point.bindDeviceId); + const deviceLabel = point.bindDeviceId + ? (boundDevice?.deviceAlias || boundDevice?.deviceName || point.bindDeviceId) + : t('devices.mapEditor.unbound'); + + tooltip.innerHTML = ` +
📍 ${point.alias || '-'}
+
🤖 ${deviceLabel}
+ `; + } + function fetchPublishedLayers() { const baseUrl = envConfig.geoserver_url; //const baseUrl = 'https://gis.caasrobot.com/geoserver'; @@ -1271,6 +1333,163 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, flyToLayer(mapLayer, envConfig.geoserver_url, 100); }, [mapLayer]); + // 拉取当前场站已配置的返航点与分区 + useEffect(() => { + if (!stationId) { + setStationOverlay({ returnPoints: [], regions: [] }); + return; + } + let cancelled = false; + getSiteMapInfo({ siteId: stationId }) + .then((res) => { + if (cancelled) return; + const pts = res?.code === 200 ? (res?.data?.restPoints || []) : []; + setStationOverlay(prev => ({ ...prev, returnPoints: Array.isArray(pts) ? pts : [] })); + }) + .catch(() => { }); + getStationRegions({ siteId: stationId }) + .then((res) => { + if (cancelled) return; + const list = res?.code === 200 ? (res?.data || res?.rows || []) : []; + setStationOverlay(prev => ({ ...prev, regions: Array.isArray(list) ? list : [] })); + }) + .catch(() => { }); + return () => { cancelled = true; }; + }, [stationId, overlayRefreshKey]); + + // 在地图上叠加显示:返航点用标志图标,分区用小框 + useEffect(() => { + const viewer = viewerRef.current; + const Cesium = window.Cesium; + if (!viewer || !Cesium) return; + + // 清理上一次叠加实体 + stationOverlayIdsRef.current.forEach(id => viewer.entities.removeById(id)); + stationOverlayIdsRef.current = []; + + // 返航点标志图标(PinBuilder 生成,失败则退化为圆点) + if (!returnPointPinUrlRef.current && Cesium.PinBuilder) { + try { + returnPointPinUrlRef.current = Cesium.PinBuilder.fromColor(Cesium.Color.fromCssColorString('#165DFF'), 36).toDataURL(); + } catch (e) { /* ignore */ } + } + (stationOverlay.returnPoints || []).forEach((pt, idx) => { + const lon = Number(pt?.position?.lng ?? pt?.lng); + const lat = Number(pt?.position?.lat ?? pt?.lat); + if (!isFinite(lon) || !isFinite(lat) || lon === 0 || lat === 0) return; + const id = `station-return-point-${idx}`; + const isHighlighted = id === highlightReturnPointId; + viewer.entities.add({ + id, + returnPointData: { + alias: pt?.alias || '', + bindDeviceId: pt?.bindDeviceId || '', + }, + position: Cesium.Cartesian3.fromDegrees(lon, lat, 0), + ...(returnPointPinUrlRef.current + ? { + billboard: { + image: returnPointPinUrlRef.current, + width: isHighlighted ? 36 : 24, + height: isHighlighted ? 48 : 32, + verticalOrigin: Cesium.VerticalOrigin.BOTTOM, + disableDepthTestDistance: Number.POSITIVE_INFINITY, + } + } + : { + point: { + pixelSize: isHighlighted ? 16 : 10, + color: Cesium.Color.fromCssColorString(isHighlighted ? '#FA8C16' : '#165DFF'), + disableDepthTestDistance: Number.POSITIVE_INFINITY, + } + }), + label: pt?.alias ? { + text: pt.alias, + font: 'bold 12px sans-serif', + fillColor: Cesium.Color.WHITE, + showBackground: true, + backgroundColor: Cesium.Color.fromCssColorString(isHighlighted ? '#FA8C16' : '#165DFF').withAlpha(0.8), + pixelOffset: new Cesium.Cartesian2(0, isHighlighted ? -48 : -34), + disableDepthTestDistance: Number.POSITIVE_INFINITY, + } : undefined, + }); + stationOverlayIdsRef.current.push(id); + }); + + // 分区:用小框(多边形)显示 + (stationOverlay.regions || []).forEach((region, idx) => { + const scope = Array.isArray(region?.scope) ? region.scope : []; + const positions = scope + .map(p => { + const lon = Number(p?.lng ?? p?.lon); + const lat = Number(p?.lat); + if (!isFinite(lon) || !isFinite(lat) || lon === 0 || lat === 0) return null; + return Cesium.Cartesian3.fromDegrees(lon, lat, 0); + }) + .filter(Boolean); + if (positions.length < 3) return; + const id = `station-region-${region?.id ?? idx}`; + viewer.entities.add({ + id, + polygon: { + hierarchy: positions, + material: Cesium.Color.fromCssColorString('#13C2C2').withAlpha(0.18), + outline: true, + outlineColor: Cesium.Color.fromCssColorString('#13C2C2').withAlpha(0.9), + height: 0, + clampToGround: true, + }, + label: region?.regionName ? { + text: region.regionName, + font: '12px sans-serif', + fillColor: Cesium.Color.WHITE, + showBackground: true, + backgroundColor: Cesium.Color.fromCssColorString('#13C2C2').withAlpha(0.8), + disableDepthTestDistance: Number.POSITIVE_INFINITY, + } : undefined, + }); + stationOverlayIdsRef.current.push(id); + }); + + viewer.scene.requestRender(); + }, [stationOverlay, highlightReturnPointId]); + + // 点击已配置列表:定位到对应返航点/分区;返航点额外高亮 + useEffect(() => { + const viewer = viewerRef.current; + const Cesium = window.Cesium; + if (!viewer || !Cesium || !focusOverlay) return; + + if (focusOverlay.type === 'returnPoint') { + const pt = (stationOverlay.returnPoints || [])[focusOverlay.index]; + const lon = Number(pt?.position?.lng ?? pt?.lng); + const lat = Number(pt?.position?.lat ?? pt?.lat); + if (!isFinite(lon) || !isFinite(lat) || lon === 0 || lat === 0) return; + setLegendHighlight('returnPoint'); + setHighlightReturnPointId(`station-return-point-${focusOverlay.index}`); + viewer.camera.flyTo({ + destination: Cesium.Cartesian3.fromDegrees(lon, lat, 500), + duration: 0.8, + }); + } else if (focusOverlay.type === 'region') { + const region = (stationOverlay.regions || []).find(r => String(r.id) === String(focusOverlay.id)); + const scope = Array.isArray(region?.scope) ? region.scope : []; + const lons = scope.map(p => Number(p?.lng ?? p?.lon)).filter(n => isFinite(n) && n !== 0); + const lats = scope.map(p => Number(p?.lat)).filter(n => isFinite(n) && n !== 0); + if (!lons.length || !lats.length) return; + setLegendHighlight('region'); + setHighlightReturnPointId(''); + viewer.camera.flyTo({ + destination: Cesium.Rectangle.fromDegrees( + Math.min(...lons), Math.min(...lats), Math.max(...lons), Math.max(...lats) + ), + duration: 0.8, + }); + } + }, [focusOverlay, stationOverlay]); + + + useEffect(() => { // 如果有 realtimePosition,不显示 focusEntity @@ -1960,10 +2179,13 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, handler.setInputAction((movement) => { const picked = viewer.scene.pick(movement.endPosition); + const pickedReturnPoint = (window.Cesium.defined(picked) && picked.id?.returnPointData) ? picked.id.returnPointData : null; const pickedRobot = (window.Cesium.defined(picked) && picked.id?.properties?.robot) ? picked.id.properties.robot.getValue() : null; - // ✅ 只有拾取到设备实体,才显示tooltip,空白区域直接隐藏 - if (pickedRobot) { + // 返航点优先显示「别名 + 绑定机器」,设备显示设备信息,空白区域隐藏 + if (pickedReturnPoint) { + showReturnPointTooltip(tooltipRef.current, movement.endPosition, pickedReturnPoint); + } else if (pickedRobot) { const { lon, lat } = getCursorLngLat(viewer, movement.endPosition); showCoordinateTooltip(tooltipRef.current, movement.endPosition, t, lon, lat, pickedRobot); } else { @@ -2000,11 +2222,11 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, } } } - console.log('点击地图,拾取到设备', robot); if (robot) { onCameraClickRef.current?.(robot); } - if (from !== "deviceStatus") + const _allowedFrom = ["mapEditor"]; + if (!_allowedFrom.includes(from)) return; const cartesian = viewer.camera.pickEllipsoid(movement.position, viewer.scene.globe.ellipsoid); if (!cartesian) return; @@ -2596,6 +2818,66 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, whiteSpace: "nowrap", }} /> + {/* 图例:返航点 / 分区 */} + {(stationOverlay.returnPoints.length > 0 || stationOverlay.regions.length > 0) && ( +
+
{t('devices.mapEditor.legend')}
+
+ + {t('devices.mapEditor.returnPoint')} +
+
+ + {t('devices.mapEditor.restArea')} +
+
+ )} ); diff --git a/src/components/devices/DeviceStatusPage.tsx b/src/components/devices/DeviceStatusPage.tsx index 105cf57..902d03a 100644 --- a/src/components/devices/DeviceStatusPage.tsx +++ b/src/components/devices/DeviceStatusPage.tsx @@ -154,6 +154,7 @@ import { useUnitFormatter } from '@/lib/units'; import { PauseOutlined, PlayCircleOutlined } from '@ant-design/icons'; import { useTranslation } from 'react-i18next'; +import { backToRestPointCommand } from '@/api/mapEdit'; @@ -1498,19 +1499,19 @@ export default function DeviceStatusPage() { // 无控制权限时:不发送消息,且只发起一次权限申请(避免手柄/方向盘高频更新刷屏) - //if (!isControlled) { + if (!isControlled) { - // //if (!hasRequestedControlRef.current && !connecting) { + //if (!hasRequestedControlRef.current && !connecting) { - // // hasRequestedControlRef.current = true; + // hasRequestedControlRef.current = true; - // // handleControlModal(); + // handleControlModal(); - // //} + //} - // return; + return; - //} + } console.log('Gamepad state updated:', state); @@ -1658,6 +1659,22 @@ export default function DeviceStatusPage() { return Number(val).toFixed(2); }; + const handleAutoBack = () => { + const payload = { + deviceId: selectedSn, + + + + orgId: currentStation?.orgId, + + siteId: stationId, + + } + backToRestPointCommand(payload).then(res => { }).catch(err => { + + console.error('返回休息点失败', err); + }) + } @@ -1920,9 +1937,9 @@ export default function DeviceStatusPage() { /** - + * 修改handleComplete:计算完成后 return路径对象;失败返回null - + */ const handleComplete = async () => { @@ -2159,7 +2176,7 @@ export default function DeviceStatusPage() { {/* 页面顶部按钮区域 */} - {!isUAV && ( + {/*{!isUAV && (
*/} - + + + + +
+ + {!isRouteGen ? ( + + + setRouteForm({ ...routeForm, name: e.target.value })} + placeholder={t('devices.mapEditor.routeNamePlaceholder')} + /> +
+
+ + setIscoverage(v)} + options={[ + { value: true, label: t('devices.coverageMode') }, + { value: false, label: t('devices.singleMode') }, + ]} + /> +
+ + {/* 路径点列表 */} +
+
+ {t('devices.mapEditor.routePoints')} + + 已选 {currentList.length} 个 + +
+ {currentList.length === 0 ? ( + + ) : ( +
+ {currentList.map((p, idx) => ( +
+ {idx + 1} + {p.name} +
+ ))} +
+ )} +
+
+ + )} + + + + + {/* 点位列表卡片(返航点 / 分区) */} + {!isRouteGen && ( + + {activeType === 'returnPoint' ? '返航点列表' : '分区列表'} + + 已选 {currentList.length} 个 + + + } + extra={ + + + + + } + variant="borderless" + styles={{ body: { padding: 12, maxHeight: 420, overflowY: 'auto' } }} + style={{ flex: 1 }} + > + {currentList.length === 0 ? ( + + ) : ( +
+ {currentList.map((p) => ( +
+ {activeType === 'returnPoint' + ? + : } + +
+ renamePoint(p.id, e.target.value)} + style={{ fontSize: 13 }} + /> + + {activeType === 'returnPoint' && ( + handleUpdateReturnPointBind(idx, v)} + style={{ width: '100%', marginTop: 4 }} + options={robots.map(r => ({ + value: r.serialNumber, + label: `${r.deviceAlias || r.deviceName}(${r.serialNumber})`, + }))} + /> + + ) : ( + <> +
+ {item.scope?.length ? `${t('devices.mapEditor.scopeCount')}: ${item.scope.length}` : ''} +
+ {item.bindRoutes?.length > 0 && ( +
+ {item.bindRoutes.map((rid: number) => { + const r = presetRoutes.find((x: any) => Number(x.id) === Number(rid)); + return r ? ( + {r.workName || r.name} + ) : ( + {rid} + ); + })} +
+ )} + + )} +
+ {activeType === 'restArea' && ( + <> +
+ ); + })} +
+ ); + })()} +
+ )} + + + + + {/* 分区保存 Modal */} + { + setRegionModalOpen(false); + setEditingRegion(null); + }} + okText={t('common.confirm')} + cancelText={t('common.cancel')} + destroyOnClose + > +
+ + + + + + + + ({ + value: Number(r.id), + label: r.workName || r.name, + }))} + /> + + + + +
+ {t('devices.mapEditor.currentScopePoints')}: {currentList.length} +
+
+
+ + ); +} + + + + + diff --git a/src/components/devices/RobotFeatureButtons.tsx b/src/components/devices/RobotFeatureButtons.tsx index 77c6607..de55a10 100644 --- a/src/components/devices/RobotFeatureButtons.tsx +++ b/src/components/devices/RobotFeatureButtons.tsx @@ -49,7 +49,8 @@ interface RobotFeatureButtonsProps { onToggle?: (feature: RobotFeature, enabled: boolean) => void; className?: string; showEmergencyStop?: boolean; - sendFindCar: () => {} + sendFindCar: () => {}; + sendAutoBack?: () => {}; } const RobotFeatureButtons: React.FC = ({ @@ -58,6 +59,7 @@ const RobotFeatureButtons: React.FC = ({ className = '', showEmergencyStop = true, sendFindCar, + sendAutoBack }) => { const { t } = useTranslation(); const { userInfo } = useSelector((state: RootState) => state.user); @@ -76,6 +78,9 @@ const RobotFeatureButtons: React.FC = ({ if (feature === 'findCar') { sendFindCar?.(); } + if (feature === 'autoback') { + sendAutoBack?.(); + } const next = !active.has(feature); const nextSet = new Set(active); if (next) nextSet.add(feature); @@ -100,6 +105,7 @@ const RobotFeatureButtons: React.FC = ({ backgroundColor: isActive ? `${f.activeColor}1a` : '#fafafa', borderColor: isActive ? f.activeColor : '#e5e7eb', boxShadow: isActive ? `0 0 12px ${f.activeColor}33` : 'none', + cursor: 'pointer', }} title={t(`devices.features.${f.key}`)} > diff --git a/src/components/devices/RobotTaskPage.tsx b/src/components/devices/RobotTaskPage.tsx index 3bb13d3..3915eda 100644 --- a/src/components/devices/RobotTaskPage.tsx +++ b/src/components/devices/RobotTaskPage.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect, useRef, useMemo } from 'react'; +import React, { useState, useEffect, useRef, useMemo } from 'react'; import { Row, Col, Card, Button, Space, Table, Tag, Typography, Progress, Badge, Tabs, Input, Switch, Divider, Tooltip, Timeline, Select, message, DatePicker, @@ -1767,22 +1767,11 @@ export default function RobotTaskPage() { {route.workName || route.name || t('devices.unnamedRoute')}
- ID: {route.id} + {t('devices.rtMode')}: {route.mode == "coverage" ? t('devices.coverageMode') : t('devices.singleMode')}
+ + - {/* 删除按钮 */} - - - ))} - - )} - - {/* 月选择 */} - {formData.repeatPlan === 'MONTH' && ( -
- {monthDays.map(day => ( - - ))} -
- )} - - {/* 按天:选择日期 */} - {formData.repeatPlan === 'DAY' && ( + {activeTab === 'scheduled' ? ( <> - - + + setFormData({ ...formData, planName: e.target.value })} + placeholder={t('devices.inputTaskName')} + /> + + + {/* 执行路线 */} +
+ + +
+ + {/* 选择设备 */} +
+ + +
+ + {/* 重复计划 */} +
+ + +
+ + {/* 周选择 */} + {formData.repeatPlan === 'WEEK' && ( +
+ {weekDays.map(day => ( + + ))} +
+ )} + + {/* 月选择 */} + {formData.repeatPlan === 'MONTH' && ( +
+ {monthDays.map(day => ( + + ))} +
+ )} + + {/* 按天:选择日期 */} + {formData.repeatPlan === 'DAY' && ( + <> + + + + )} + + {/* 时间 */} + + + + {/* 执行周期 */} + + + + ) : ( +
+ {/* 预设路径列表 */} +
+ +
+ {singleRouteList.length === 0 ? ( + + ) : ( + singleRouteList.map(route => { + const selected = returnRoute?.id === route.id; + return ( +
setReturnRoute(route)} + className={`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${selected ? 'border-blue-500 bg-blue-50' : 'border-gray-200 hover:border-blue-300'}`} + > +
+ {route.imgUrl ? ( + + ) : ( + + )} +
+
{route.workName || route.name}
+ {selected && } +
+ ); + }) + )} +
+
+ + {/* 选择机器 */} +
+ +