+
{t('devices.fixed2Fixed2DeviceSn')}
{currentEditRobot.device_sn || currentEditRobot.serialNumber}
-
+
{t('devices.fixed2DeviceType')}
{currentEditRobot.productName || t('constants.locationUnknown')}
-
-
{t('devices.fixed2Device')}*
+
+ {t('devices.fixed2Device')}*
-
{t('devices.deviceListControlDeviceFixed2')}
+
{t('devices.deviceListControlDeviceFixed2')}
)}
diff --git a/src/components/devices/DeviceStatusPage.tsx b/src/components/devices/DeviceStatusPage.tsx
index 95719ac..775a945 100644
--- a/src/components/devices/DeviceStatusPage.tsx
+++ b/src/components/devices/DeviceStatusPage.tsx
@@ -705,7 +705,8 @@ export default function DeviceStatusPage() {
return;
}
//console.log(runningStatus,controlMode, "现在的控制controlmode")
- if (controlMode == 3 && runningStatus?.control_mode == 3) {
+ if ((controlMode == 3 && runningStatus?.control_mode == 3) || runningStatus?.systemMode == 3) {
+ messageApi.warning(t('devices.onRemoteControl'));
return;
}
const data = {
@@ -716,7 +717,7 @@ export default function DeviceStatusPage() {
if (res.code == 200 && res?.data) {
messageApi.success(t('devices.controlModeSuccess'));
} else {
- messageApi.error(res.msg || t('devices.controlModeFail'));
+ messageApi.error(t('devices.controlModeFail'));
}
}).catch(err => {
messageApi.success(t('devices.controlModeFail'));
@@ -731,29 +732,44 @@ export default function DeviceStatusPage() {
...currentDroneData, // 持久化数据最后覆盖,确保优先显示
};
}, [device, uavState, currentDroneData]);
+ // 模式/权限提示节流:仅在用户真实操作(有按键或摇杆输入)时提示,2 秒内只提示一次
+ // 避免点击页面其他区域、手柄轮询中性帧、失焦复位等无输入帧误触发提示
+ const controlWarnRef = useRef(0);
const handleGamepadUpdate = useCallback((state) => {
- // 无控制权限时:不发送消息,且只发起一次权限申请(避免手柄/方向盘高频更新刷屏)
- if (!isControlled) {
- messageApi.warning("请获取控制权限");
- //if (!hasRequestedControlRef.current && !connecting) {
- // hasRequestedControlRef.current = true;
- // handleControlModal();
- //}
- //return;
- }
- console.log(realtimePosition?.controlMode, "现在的控制controlmode")
- if (
- realtimePosition?.controlMode != 3 &&
- realtimePosition?.controlMode != 0 &&
- realtimePosition?.controlMode != null
- ) {
- messageApi.warning(t('devices.noRemoteControl'));
+ const hasInput =
+ //(Array.isArray(state?.buttons) && state.buttons.some((v: any) => v == true || v == 1)) ||
+ (Array.isArray(state?.axes) && state.axes.some((v: any) => Math.abs(Number(v) || 0) > 0.05));
+ // 只有真实操作才做模式与权限校验,中性帧(无按键、轴为 0)不提示
+ if (hasInput) {
+ const now = Date.now();
+ if (now - controlWarnRef.current > 2000) {
+ let warned = false;
+ // 无控制权限时:提示(避免手柄/方向盘高频更新刷屏)
+ if (!isControlled) {
+ messageApi.warning("请获取控制权限");
+ warned = true;
+ }
+ console.log(runningStatus, "realtimePosition1111")
+ if (!(runningStatus?.control_mode == 3 || runningStatus?.systemMode == 3)) {
+ messageApi.warning(t('devices.switchControl'));
+ warned = true;
+ } else if (
+ runningStatus?.controlMode != 3 &&
+ runningStatus?.controlMode != 0 &&
+ runningStatus?.controlMode != null
+ ) {
+ messageApi.warning(t('devices.noRemoteControl'));
+ warned = true;
+ }
+ if (warned) controlWarnRef.current = now;
+ }
}
console.log('Gamepad state updated:', state);
// 记录方向盘 xy 坐标,用于倒车影像叠加层
if (state?.axes) {
setSteerXY({ x: state.axes[2] || 0, y: state.axes[1] || 0 });
}
+ // 无论是否有输入(含 false/中性帧)都必须下发,保证设备侧能收到释放/停止状态
controllerRef.current?.sendGamepad(state);
}, [isControlled, connecting]);
// 手柄已连接时拦截面板操作并提示(2 秒内只提示一次,避免高频刷屏)
@@ -1324,23 +1340,30 @@ export default function DeviceStatusPage() {
}
label={t('devices.systemMode')}
- value={
- (runningStatus?.system_mode ?? runningStatus?.systemMode) !== undefined
- ? (() => {
- const mode = runningStatus?.system_mode ?? runningStatus?.systemMode;
- switch (mode) {
- case '2':
- case 2:
- return t('devices.autoTask');
- case '3':
- case 3:
- return t('devices.remoteControl');
- default:
- return "-";
- }
- })()
- : '-'
- }
+ value={(() => {
+ const mode =
+ runningStatus?.system_mode ??
+ runningStatus?.systemMode ??
+ runningStatus?.control_mode ??
+ runningStatus?.controlMode;
+
+ switch (mode) {
+ case '2':
+ case 2:
+ return t('devices.autoTask');
+ case '3':
+ case 3:
+ return t('devices.remoteControl');
+ case '0':
+ case 0:
+ return t('devices.controlOff');
+ case '1':
+ case 1:
+ return t('devices.localCpntrol');
+ default:
+ return '-';
+ }
+ })()}
/>
} label={t('devices.forwardSpeed')} value={(runningStatus?.linear_speed ?? runningStatus?.linearSpeed) !== undefined ? Number(runningStatus?.linear_speed ?? runningStatus?.linearSpeed).toFixed(2) + ' m/s' : '-'} />
} label={t('devices.turnSpeed')} value={(runningStatus?.angular_speed ?? runningStatus?.angularSpeed) !== undefined ? Number(runningStatus?.angular_speed ?? runningStatus?.angularSpeed).toFixed(2) + ' rad/s' : '-'} />
@@ -1397,7 +1420,7 @@ export default function DeviceStatusPage() {
) : mowerView === 'front' ? (
-
+
{ console.log('[DeviceStatusPage] Feature toggled: ' + feature + ' = ' + enabled); }}
diff --git a/src/components/devices/RobotFeatureButtons.tsx b/src/components/devices/RobotFeatureButtons.tsx
index 76aea85..b088d44 100644
--- a/src/components/devices/RobotFeatureButtons.tsx
+++ b/src/components/devices/RobotFeatureButtons.tsx
@@ -1,8 +1,8 @@
-import React, { useState } from 'react';
+import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import { RootState } from '@/store';
-import { sendEmergencyStop } from './emergencyStopControl';
+import { sendEmergencyStop, subscribeEmergencyStop } from './emergencyStopControl';
import {
ShieldAlert,
Zap,
@@ -77,6 +77,9 @@ const RobotFeatureButtons: React.FC = ({
const [active, setActive] = useState>(new Set(activeFeatures));
// 临时按压闪烁标记
const [flashKey, setFlashKey] = useState(null);
+ // 急停锁存状态:与 DPad / 手柄共用同一份状态,点击后保持按下态
+ const [eStopActive, setEStopActive] = useState(false);
+ useEffect(() => subscribeEmergencyStop(setEStopActive), []);
// 一次性触发,不toggle的按钮列表
const oneShotKeys: RobotFeature[] = ['emergencyStop', 'findCar', 'autoback', 'controlMode', 'personFollow'];
@@ -138,9 +141,11 @@ const RobotFeatureButtons: React.FC = ({
`}
{list.map((f) => {
- const isOneShot = oneShotKeys.includes(f.key);
- const isActive = active.has(f.key);
- const isFlashing = flashKey === f.key;
+ const isEmergency = f.key === 'emergencyStop';
+ const isOneShot = oneShotKeys.includes(f.key) && !isEmergency;
+ // 急停走锁存状态,其余按钮沿用本地 toggle 状态
+ const isActive = isEmergency ? eStopActive : active.has(f.key);
+ const isFlashing = flashKey === f.key
const shouldGlow = f.key === 'controlMode' && controlMode != 3;
return (
diff --git a/src/components/devices/RobotTaskPage.tsx b/src/components/devices/RobotTaskPage.tsx
index 7ac0f98..44eb31a 100644
--- a/src/components/devices/RobotTaskPage.tsx
+++ b/src/components/devices/RobotTaskPage.tsx
@@ -1,186 +1,368 @@
-import React, { useState, useEffect, useMemo } from 'react';
-import { Row, Col, Card, Space, Typography, Select, Empty } from 'antd';
-import { Car, Satellite, LayoutGrid, CheckCircle2, AlertCircle, TrendingUp } from 'lucide-react';
-import { getSiteDevice, getSiteUAVList } from '../../api/device';
-import { useSelector } from 'react-redux';
-import { RootState } from '@/src/store';
-import { useTranslation } from 'react-i18next';
-import { WayLineView } from './WayLineView';
-import { TaskPlanningView } from './TaskPlanningView';
-import type { ViewStats } from './WayLineView';
-
-const { Text } = Typography;
-
-// ==================== 合并页面:任务规划 + 地图编辑 + 航线任务 ====================
-interface MachineOption {
- value: string;
- label: string;
- group: 'robot' | 'plane';
-}
-
-export default function RobotTaskPage() {
- const { t } = useTranslation();
- const { stationId, currentStation } = useSelector((state: RootState) => state.station);
-
- const [machineOptions, setMachineOptions] = useState([]);
- const [selectedMachine, setSelectedMachine] = useState(undefined);
- const [selectedGroup, setSelectedGroup] = useState<'robot' | 'plane' | undefined>(undefined);
- const [robotStats, setRobotStats] = useState({});
- const [droneStats, setDroneStats] = useState({});
- const [robotOnline, setRobotOnline] = useState({ online: 0, total: 0 });
-
- // 顶部统一机器列表:机器人 + 无人机合并
- useEffect(() => {
- if (!stationId) return;
- let ignore = false;
- const loadMachines = async () => {
- try {
- const [robotRes, planeRes] = await Promise.all([
- getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1, orgId: currentStation?.orgId }),
- getSiteUAVList(stationId),
- ]);
- if (ignore) return;
- const robots = robotRes?.code === 200 ? (robotRes.rows || []) : [];
- const planes = planeRes?.code === 200 ? (planeRes.rows || []) : [];
- const options: MachineOption[] = [
- ...robots
- .filter((r) => !!r.serialNumber)
- .map((r) => ({ value: r.serialNumber, label: r.deviceAlias || r.deviceName || r.serialNumber, group: 'robot' as const })),
- ...planes
- .filter((p) => !!p.device_sn)
- .map((p) => ({ value: p.device_sn, label: p.drone_callsign || p.device_sn, group: 'plane' as const })),
- ];
- setMachineOptions(options);
- // 初始化时默认选中机器人分组的第一个(无机器人时取第一个选项)
- const firstRobot = options.find((o) => o.group === 'robot') || options[0];
- if (firstRobot) {
- setSelectedMachine(firstRobot.value);
- setSelectedGroup(firstRobot.group);
- }
- setRobotOnline({
- online: robots.filter((r) => r.onlineStatus == 1).length,
- total: robots.length,
- });
- } catch (err) {
- console.error('获取机器列表失败', err);
- }
- };
- loadMachines();
- return () => { ignore = true; };
- }, [stationId, currentStation?.orgId]);
-
- const handleMachineChange = (value: string | undefined) => {
- setSelectedMachine(value);
- const hit = machineOptions.find((o) => o.value === value);
- setSelectedGroup(hit?.group);
- };
-
- // 分组下拉:仅有对应机器时才显示该分组
- const groupedOptions = useMemo(() => {
- const groups: { label: string; options: { value: string; label: string }[] }[] = [];
- const robots = machineOptions.filter((o) => o.group === 'robot');
- const planes = machineOptions.filter((o) => o.group === 'plane');
- if (robots.length) {
- groups.push({ label: t('devices.robot'), options: robots.map((o) => ({ value: o.value, label: o.label })) });
- }
- if (planes.length) {
- groups.push({ label: t('devices.drone'), options: planes.map((o) => ({ value: o.value, label: o.label })) });
- }
- return groups;
- }, [machineOptions]);
-
- const cardStyle = { borderRadius: 12, border: 'none', boxShadow: '0 2px 12px rgba(0,0,0,0.04)' };
-
- // 顶部统计卡:机器人任务 + 无人机航线任务数据合并
- const mergedCards = useMemo(() => {
- const planTotal = (robotStats.planTotal || 0) + (droneStats.planTotal || 0);
- const working = (robotStats.working || 0) + (droneStats.working || 0);
- const finishCount = (robotStats.finishCount || 0) + (droneStats.finishCount || 0);
- const totalCount = (robotStats.totalCount || 0) + (droneStats.totalCount || 0);
- const completionRate = totalCount ? Math.round((finishCount / totalCount) * 100) : 0;
- const onlineRate = robotOnline.total ? Math.round((robotOnline.online / robotOnline.total) * 100) : 0;
- return [
- { title: t('devices.statTodayPlan'), value: planTotal, unit: t('devices.unitPlan'), desc: t('devices.statInProgress'), icon: , color: '#165DFF' },
- { title: t('devices.statWorkingRobots'), value: working, unit: t('devices.unitRobot'), desc: t('devices.statWorking'), icon: , color: '#165DFF' },
- { title: t('devices.statTotalDistance'), value: '12.5', unit: 'km', trend: t('devices.vsYesterday', { value: '+1.2' }), trendColor: '#00B42A', icon: , color: '#722ED1' },
- { title: t('devices.statCompletionRate'), value: completionRate, unit: '%', trend: t('devices.vsYesterday', { value: '+5%' }), trendColor: '#00B42A', icon: , color: '#00B42A' },
- { title: t('devices.statAlerts'), value: '0', unit: t('devices.unitTimes'), trend: t('devices.vsYesterday', { value: '-1' }), trendColor: '#00B42A', icon: , color: '#F53F3F' },
- { title: t('devices.statOnlineRate'), value: `${onlineRate}`, unit: '%', desc: t('devices.good'), icon: , color: '#165DFF' },
- ] as { title: string; value: any; unit: string; desc?: string; trend?: string; trendColor?: string; icon: React.ReactElement; color: string }[];
- }, [robotStats, droneStats, robotOnline, t]);
-
- return (
-
-
-
- {t('devices.robotTask')}
-
-
- {t('devices.mapEditor.selectRobot')}
-
-
-
-
-
-
- {mergedCards.map((item, index) => (
-
-
-
-
- {React.cloneElement(item.icon as React.ReactElement, { size: 18 })}
-
-
-
{item.title}
-
- {item.value}
- {item.unit}
-
-
- {item.trend || item.desc}
-
-
-
-
-
- ))}
-
-
- {!selectedMachine ? (
-
-
- ) : selectedGroup === 'plane' ? (
-
- ) : (
-
- )}
-
-
- );
-}
-
+import React, { useState, useEffect, useMemo } from 'react';
+
+import { Row, Col, Card, Space, Typography, Select, Empty } from 'antd';
+
+import { Car, Satellite, LayoutGrid, CheckCircle2, AlertCircle, TrendingUp } from 'lucide-react';
+
+import { getSiteDevice, getSiteUAVList } from '../../api/device';
+
+import { useSelector } from 'react-redux';
+
+import { RootState } from '@/src/store';
+
+import { useTranslation } from 'react-i18next';
+
+import { WayLineView } from './WayLineView';
+
+import { TaskPlanningView } from './TaskPlanningView';
+
+import type { ViewStats } from './WayLineView';
+
+
+
+const { Text } = Typography;
+
+
+
+// ==================== 合并页面:任务规划 + 地图编辑 + 航线任务 ====================
+
+interface MachineOption {
+
+ value: string;
+
+ label: string;
+
+ group: 'robot' | 'plane';
+
+}
+
+
+
+export default function RobotTaskPage() {
+
+ const { t } = useTranslation();
+
+ const { stationId, currentStation } = useSelector((state: RootState) => state.station);
+
+
+
+ const [machineOptions, setMachineOptions] = useState([]);
+
+ const [selectedMachine, setSelectedMachine] = useState(undefined);
+
+ const [selectedGroup, setSelectedGroup] = useState<'robot' | 'plane' | undefined>(undefined);
+
+ const [robotStats, setRobotStats] = useState({});
+
+ const [droneStats, setDroneStats] = useState({});
+
+ const [robotOnline, setRobotOnline] = useState({ online: 0, total: 0 });
+
+
+
+ // 顶部统一机器列表:机器人 + 无人机合并
+
+ useEffect(() => {
+
+ if (!stationId) return;
+
+ let ignore = false;
+
+ const loadMachines = async () => {
+
+ try {
+
+ const [robotRes, planeRes] = await Promise.all([
+
+ getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1, orgId: currentStation?.orgId }),
+
+ getSiteUAVList(stationId),
+
+ ]);
+
+ if (ignore) return;
+
+ const robots = robotRes?.code === 200 ? (robotRes.rows || []) : [];
+
+ const planes = planeRes?.code === 200 ? (planeRes.rows || []) : [];
+
+ const options: MachineOption[] = [
+
+ ...robots
+
+ .filter((r) => !!r.serialNumber)
+
+ .map((r) => ({ value: r.serialNumber, label: r.deviceAlias || r.deviceName || r.serialNumber, group: 'robot' as const })),
+
+ ...planes
+
+ .filter((p) => !!p.device_sn)
+
+ .map((p) => ({ value: p.device_sn, label: p.drone_callsign || p.device_sn, group: 'plane' as const })),
+
+ ];
+
+ setMachineOptions(options);
+
+ // 初始化时默认选中机器人分组的第一个(无机器人时取第一个选项)
+
+ const firstRobot = options.find((o) => o.group === 'robot') || options[0];
+
+ if (firstRobot) {
+
+ setSelectedMachine(firstRobot.value);
+
+ setSelectedGroup(firstRobot.group);
+
+ }
+
+ setRobotOnline({
+
+ online: robots.filter((r) => r.onlineStatus == 1).length,
+
+ total: robots.length,
+
+ });
+
+ } catch (err) {
+
+ console.error('获取机器列表失败', err);
+
+ }
+
+ };
+
+ loadMachines();
+
+ return () => { ignore = true; };
+
+ }, [stationId, currentStation?.orgId]);
+
+
+
+ const handleMachineChange = (value: string | undefined) => {
+
+ setSelectedMachine(value);
+
+ const hit = machineOptions.find((o) => o.value === value);
+
+ setSelectedGroup(hit?.group);
+
+ };
+
+
+
+ // 分组下拉:仅有对应机器时才显示该分组
+
+ const groupedOptions = useMemo(() => {
+
+ const groups: { label: string; options: { value: string; label: string }[] }[] = [];
+
+ const robots = machineOptions.filter((o) => o.group === 'robot');
+
+ const planes = machineOptions.filter((o) => o.group === 'plane');
+
+ if (robots.length) {
+
+ groups.push({ label: t('devices.robot'), options: robots.map((o) => ({ value: o.value, label: o.label })) });
+
+ }
+
+ if (planes.length) {
+
+ groups.push({ label: t('devices.drone'), options: planes.map((o) => ({ value: o.value, label: o.label })) });
+
+ }
+
+ return groups;
+
+ }, [machineOptions]);
+
+
+
+ const cardStyle = { borderRadius: 12, border: 'none', boxShadow: '0 2px 12px rgba(0,0,0,0.04)' };
+
+
+
+ // 顶部统计卡:机器人任务 + 无人机航线任务数据合并
+
+ const mergedCards = useMemo(() => {
+
+ const planTotal = (robotStats.planTotal || 0) + (droneStats.planTotal || 0);
+
+ const working = (robotStats.working || 0) + (droneStats.working || 0);
+
+ const finishCount = (robotStats.finishCount || 0) + (droneStats.finishCount || 0);
+
+ const totalCount = (robotStats.totalCount || 0) + (droneStats.totalCount || 0);
+
+ const completionRate = totalCount ? Math.round((finishCount / totalCount) * 100) : 0;
+
+ const onlineRate = robotOnline.total ? Math.round((robotOnline.online / robotOnline.total) * 100) : 0;
+ const totalWorkArea = robotStats?.workArea ?? "0";
+
+ return [
+
+ { title: t('devices.statTodayPlan'), value: planTotal, unit: t('devices.unitPlan'), desc: t('devices.statInProgress'), icon: , color: '#165DFF' },
+
+ { title: t('devices.statWorkingRobots'), value: working, unit: t('devices.unitRobot'), desc: t('devices.statWorking'), icon: , color: '#165DFF' },
+
+ //{ title: t('devices.totalWorkArea'), value: totalWorkArea, unit: '㎡', trend: "", trendColor: '#00B42A', icon: , color: '#722ED1' },
+
+ { title: t('devices.statCompletionRate'), value: completionRate, unit: '%', trend: t('devices.vsYesterday', { value: '+5%' }), trendColor: '#00B42A', icon: , color: '#00B42A' },
+
+ { title: t('devices.statAlerts'), value: '0', unit: t('devices.unitTimes'), trend: t('devices.vsYesterday', { value: '-1' }), trendColor: '#00B42A', icon: , color: '#F53F3F' },
+
+ { title: t('devices.statOnlineRate'), value: `${onlineRate}`, unit: '%', desc: t('devices.good'), icon: , color: '#165DFF' },
+
+ ] as { title: string; value: any; unit: string; desc?: string; trend?: string; trendColor?: string; icon: React.ReactElement; color: string }[];
+
+ }, [robotStats, droneStats, robotOnline, t]);
+
+
+
+ return (
+
+
+
+
+
+
+
+ {t('devices.robotTask')}
+
+
+
+
+
+ {t('devices.mapEditor.selectRobot')}
+
+
+
+
+
+
+
+
+
+
+
+ {mergedCards.map((item, index) => (
+
+
+
+
+
+
+
+ {React.cloneElement(item.icon as React.ReactElement, { size: 18 })}
+
+
+
+
+
+
{item.title}
+
+
+
+ {item.value}
+
+ {item.unit}
+
+
+
+
+
+ {item.trend || item.desc}
+
+
+
+
+
+
+
+
+
+ ))}
+
+
+
+
+
+
+ {!selectedMachine ? (
+
+
+
+
+
+ ) : selectedGroup === 'plane' ? (
+
+
+
+ ) : (
+
+
+
+ )}
+
+
+
+
+
+ );
+
+}
+
+
+
diff --git a/src/components/devices/TaskPlanningView.tsx b/src/components/devices/TaskPlanningView.tsx
index 7fe0b6a..db131c4 100644
--- a/src/components/devices/TaskPlanningView.tsx
+++ b/src/components/devices/TaskPlanningView.tsx
@@ -3,7 +3,7 @@ import { Row, Col, Card, Button, Space, Table, Tag, Typography, Badge, Tabs, Inp
import { PlusOutlined, ImportOutlined, NodeIndexOutlined, SaveOutlined, DeleteOutlined, CloseOutlined, ReloadOutlined, ExclamationCircleOutlined, EnvironmentOutlined, EnvironmentFilled } from '@ant-design/icons';
import { Car, Navigation, MapPinned, Route, Satellite, LayoutGrid, CheckCircle2, AlertCircle, TrendingUp, Maximize2 } from 'lucide-react';
import TaskTypeRadio from '../taskRadio/taskRadio';
-import { getRobotRouteList, getSingleRouteList, saveDeviceTask, getRobotTaskList, deleteDeviceTask, getSiteDevice, excuetRoute, cancelRoute, pauseRoute, recoverRoute, getDeviceTastPool, getSiteDeviceTaskHistory, getRouteByTask, deleteRoute, getTaskPath, createConsecutiveTasks, cancelConsecutiveTask, getConsecutiveTask, modeChage } from '../../api/device';
+import { getRobotRouteList, getSingleRouteList, saveDeviceTask, getRobotTaskList, deleteDeviceTask, getSiteDevice, excuetRoute, cancelRoute, pauseRoute, recoverRoute, getDeviceTastPool, getSiteDeviceTaskHistory, getRouteByTask, deleteRoute, getTaskPath, createConsecutiveTasks, cancelConsecutiveTask, getConsecutiveTask, modeChage, getDeviceTotalData } from '../../api/device';
import dayjs from 'dayjs';
import DraggableBox from '../Draggable';
import utils from '../../lib/utils';
@@ -18,6 +18,7 @@ import { Reorder } from 'motion/react';
import { MapEditorView } from './MapEditorView';
import type { ViewStats } from './WayLineView';
import { backToRestPointCommand } from '@/api/mapEdit';
+import { sendEmergencyStop, subscribeEmergencyStop, syncEmergencyStop } from './emergencyStopControl';
const { Text, Title } = Typography;
@@ -50,6 +51,9 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
const [excuteStatus, setExcuteStatus] = useState("stop"); //"stop" "running" "pause"
// 全量设备实时状态(mapPush),实时数据统一从这里取
const [realtimeMap, setRealtimeMap] = useState({});
+ // 急停锁存状态:与 DPad / 手柄 / 设备控制页共用同一份状态
+ const [eStopActive, setEStopActive] = useState(false);
+ useEffect(() => subscribeEmergencyStop(setEStopActive), []);
const [execute, setExecute] = useState(false); // 是否执行任务
const [taskList, setTaskList] = useState([]);
const { modal } = App.useApp();
@@ -57,6 +61,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
const [detectReportInfo, setDeportInfo] = useState(null);
const [selectedDeviceMap, setSelectedDeviceMap] = useState>({});
const [consecutiveTaskList, setConsecutiveTaskList] = useState([]);
+ const [deviceStatistics, setDeviceStatistics] = useState({});
@@ -389,6 +394,8 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
};
}, [userInfo, stationId]);
+
+
// 监听任务列表和设备列表变化,自动连接正在执行中的机器人(仅在没有选择任务时)
useEffect(() => {
if (!taskPoolList || taskPoolList.length == 0) {
@@ -462,8 +469,9 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
longitude: rt?.lng,
latitude: rt?.lat,
fix_status: rt?.fixStatus,
- controlMode: rt?.controlMode ?? targetRobot?.lastRunningStatus?.controlMode,
+ controlMode: rt?.controlMode ?? rt?.control_mode ?? targetRobot?.lastRunningStatus?.controlMode,
sm: rt?.sm,
+ e: rt?.emergencyStop,
};
}, [realtimeMap, targetRobot]);
@@ -757,6 +765,10 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
});
};
+ useEffect(() => {
+ syncEmergencyStop(robotRealtimePosition?.emergencyStop);
+ }, [robotRealtimePosition?.emergencyStop]);
+
@@ -1359,16 +1371,40 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
}];
// 向合并页面汇报统计口径(与无人机任务统计合并展示)
+
useEffect(() => {
- const workingCount = taskPoolList?.filter(item => ['EXECUTING', 'PAUSE'].includes(item.taskStaus))?.length || 0;
+ if (!selectedMachineSn) return;
+
+ const params = {
+ deviceId: selectedMachineSn,
+ };
+
+ getDeviceTotalData(params).then((res) => {
+ if (res.code === 200) {
+ setDeviceStatistics(res.data || {});
+ }
+ });
+ }, [selectedMachineSn]);
+
+ useEffect(() => {
+ const workingCount = taskPoolList?.filter(item =>
+ ['EXECUTING', 'PAUSE'].includes(item.taskStaus)
+ )?.length || 0;
+
onStatsChange?.({
planTotal: taskList.length,
working: workingCount,
finishCount: successfulTaskList.length,
totalCount: taskHistoryList.length,
+ ...deviceStatistics,
});
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [taskList.length, taskPoolList, successfulTaskList.length, taskHistoryList.length]);
+ }, [
+ taskList.length,
+ taskPoolList,
+ successfulTaskList.length,
+ taskHistoryList.length,
+ deviceStatistics,
+ ]);
// ===== 分区列表 =====
useEffect(() => {
@@ -1408,6 +1444,11 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
})
}
+ // 急停:与 DPad 保持一致,调用共享锁存接口(再次点击解除)
+ const handleEmergencyStop = () => {
+ sendEmergencyStop(selectedMachineSn || targetRobot?.serialNumber || '');
+ };
+
// 选中的路径对象列表(用于拖拽排序显示)
const selectedRouteObjects = useMemo(() => {
// 根据 dispatchRouteIds 的顺序返回路径对象
@@ -1812,7 +1853,9 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
{t('devices.controlMode')}
{(() => {
- const mode = robotRealtimePosition?.controlMode || robotRealtimePosition?.control_mode;
+ const mode =
+ robotRealtimePosition?.controlMode ??
+ robotRealtimePosition?.control_mode;
const modeConfig: Record = {
'0': {
@@ -1839,11 +1882,11 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
: undefined;
return config ? (
- {config.label}
- ) : (
-
- -
+
+ {config.label}
+ ) : (
+ -
);
})()}
@@ -1938,6 +1981,27 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
{t('devices.features.autoback')}
+ { if (!eStopActive) e.currentTarget.style.background = 'rgba(255,255,255,0.3)'; }}
+ onMouseLeave={e => { e.currentTarget.style.background = eStopActive ? '#cf1322' : 'rgba(255,255,255,0.18)'; }}
+ >
+
+ {eStopActive ? t('devices.estopTriggered') : t('devices.features.emergencyStop')}
+
+
)}
diff --git a/src/components/devices/WayLinePage.tsx b/src/components/devices/WayLinePage.tsx
index 76606a8..76c3bf3 100644
--- a/src/components/devices/WayLinePage.tsx
+++ b/src/components/devices/WayLinePage.tsx
@@ -1,4 +1,4 @@
-import React, { useState, useEffect, useRef, useCallback } from 'react';
+import React, { useState, useEffect, useRef, useCallback } from 'react';
import {
Row, Col, Card, Button, Space, Table, Tag, Typography, Progress, Badge,
Tabs, Input, Switch, Divider, Tooltip, Timeline, Select, message, DatePicker,
diff --git a/src/components/devices/deviceController.js b/src/components/devices/deviceController.js
index 130f1c5..6fd9d1b 100644
--- a/src/components/devices/deviceController.js
+++ b/src/components/devices/deviceController.js
@@ -135,6 +135,7 @@ export default class DeviceController {
const key = String(it?.id ?? '');
if (!key) return;
next[key] = {
+ ...it,
id: key,
lng: String(it?.lng ?? it?.lon ?? it?.longitude),
lat: String(it?.lat ?? it?.latitude),
@@ -150,6 +151,8 @@ export default class DeviceController {
controlMode: it?.cm ?? it?.controlMode,
progress: it?.p ?? it?.progress,
workName: it?.wk ?? null,
+ sm: it?.sm ?? null,
+ emergencyStop: it?.e
};
});
@@ -161,6 +164,7 @@ export default class DeviceController {
console.log('task finish');
this.onIsFinished?.(msg);
} else {
+ console.log("device_task_change", msg.status)
this.onIsExecuting?.(true);
}
diff --git a/src/components/devices/emergencyStopControl.ts b/src/components/devices/emergencyStopControl.ts
index 3eb1af3..a30e9cc 100644
--- a/src/components/devices/emergencyStopControl.ts
+++ b/src/components/devices/emergencyStopControl.ts
@@ -1,3 +1,4 @@
+import utils from '../../lib/utils';
import { eStopChange } from '../../api/device';
// 本地锁存状态
@@ -43,9 +44,12 @@ export const sendEmergencyStop = async (deviceId: string) => {
if (res?.code == 200) {
active = newActive;
emit();
+ utils.message.success('急停状态切换成功');
console.log('[EmergencyStop] eStop=' + (active ? 1 : 0) + ' success');
} else {
+ utils.message.error('急停状态切换失败');
+
console.warn('[EmergencyStop] eStop failed:', res);
}
diff --git a/src/locales/en/index.ts b/src/locales/en/index.ts
index 964103b..edf8717 100644
--- a/src/locales/en/index.ts
+++ b/src/locales/en/index.ts
@@ -1567,6 +1567,8 @@
fixed2TaskSuspended22: 'Fixed2 Task Suspended2 已启动',
fixed2ReturnHomeFixed2CommandIssuedFixed2: 'Return Home Command Issued ',
+ switchControl: 'switchControl',
+ onRemoteControl: "onRemoteControl",
fixed2ReturnHomeFixed2CommandIssuedFixed2Failed: 'Return Home Command Issued Failed ',
commandIssuedFixed2: '回充 Command Issued Fixed2',
diff --git a/src/locales/zh/index.ts b/src/locales/zh/index.ts
index 8099709..ee996ee 100644
--- a/src/locales/zh/index.ts
+++ b/src/locales/zh/index.ts
@@ -1529,9 +1529,13 @@ const zh = {
"ultrasonicPresent": "超声波在位",
"dacPresent": "DAC在位",
"operator": "质检员",
+ onRemoteControl: "当前正处于远程控制状态",
+
"inspectionNo": "检测报告号",
"activeTime": "激活时间",
"dealer": "经销商",
+ switchControl: '请先模式切换',
+
taskConsecutive: '连续任务',
paramEnum: {
@@ -1879,6 +1883,7 @@ const zh = {
restored: '已恢复',
ignored: '已忽略',
ignore: "忽略",
+
unableToHandle: '无法处理',
manufacturerHandling: '厂家处理中',
falseAlarm: '误报',
diff --git a/src/pages/Agri.css b/src/pages/Agri.css
new file mode 100644
index 0000000..6bca1ae
--- /dev/null
+++ b/src/pages/Agri.css
@@ -0,0 +1,432 @@
+/* 农业AI算法分析页面样式(由 Agri.jsx 内联样式外联而来) */
+
+/* ===== 页面骨架 ===== */
+.agri-page {
+ padding: 8px;
+ background: #f4f7f9;
+ min-height: 100vh;
+}
+
+.agri-page-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding-bottom: 16px;
+}
+
+.agri-page-title.ant-typography {
+ margin: 0;
+ font-size: clamp(18px, 1.5vw, 24px);
+ color: #1D2129;
+}
+
+.agri-main-row.ant-row {
+ flex-wrap: wrap;
+}
+
+/* ===== 顶部统计卡片 ===== */
+.agri-stats-row.ant-row {
+ margin-bottom: 8px;
+}
+
+.agri-stat-card.ant-card {
+ height: 100%;
+}
+
+.agri-stat-card.ant-card .ant-card-body {
+ padding: 20px 16px;
+}
+
+.agri-stat-head {
+ display: flex;
+ justify-content: space-between;
+ align-items: flex-start;
+}
+
+.agri-stat-main {
+ flex: 1;
+}
+
+.agri-stat-title {
+ font-size: clamp(12px, 0.8vw, 13px);
+ color: #86909C;
+ margin-bottom: 8px;
+ white-space: nowrap;
+}
+
+.agri-stat-value {
+ font-size: clamp(20px, 1.4vw, 24px);
+ font-weight: 800;
+ color: var(--agri-stat-value-color);
+ display: flex;
+ align-items: baseline;
+ gap: 4px;
+}
+
+.agri-stat-unit {
+ font-size: 13px;
+ font-weight: 400;
+ color: #86909C;
+}
+
+.agri-stat-icon-box {
+ width: 44px;
+ height: 44px;
+ background: var(--agri-stat-icon-bg);
+ border-radius: 12px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ flex-shrink: 0;
+ box-shadow: var(--agri-stat-icon-shadow);
+}
+
+/* ===== 通用间距 ===== */
+.agri-mb-16 {
+ margin-bottom: 16px;
+}
+
+.agri-mt-16.ant-row,
+.agri-mt-16.ant-space {
+ margin-top: 16px;
+}
+
+.agri-mt-24,
+.agri-mt-24.ant-space {
+ margin-top: 24px;
+}
+
+/* ===== 检测/分割工作区 ===== */
+.agri-workspace-pane {
+ padding: 0 8px;
+}
+
+.agri-model-label.ant-typography {
+ font-size: 15px;
+}
+
+.agri-model-select.ant-select {
+ width: 100%;
+ margin-top: 8px;
+}
+
+.agri-field-label.ant-typography {
+ font-size: 13px;
+ display: block;
+ margin-bottom: 8px;
+}
+
+.agri-field-hint.ant-typography {
+ font-size: 12px;
+ display: block;
+}
+
+.agri-full-width.ant-input-number,
+.agri-full-width.ant-select {
+ width: 100%;
+}
+
+.agri-detect-dragger.ant-upload-wrapper .ant-upload-drag {
+ background: #fafafa;
+ border-radius: 8px;
+}
+
+.agri-seg-dragger.ant-upload-wrapper .ant-upload-drag {
+ background: #fafafa;
+ border-radius: 8px;
+ height: 120px;
+}
+
+.agri-upload-icon.anticon {
+ color: #1677ff;
+}
+
+.agri-seg-drag-icon.ant-upload-drag-icon {
+ font-size: 24px;
+}
+
+.agri-seg-upload-hint {
+ font-size: 12px;
+}
+
+/* ===== 结果卡片标题/提示 ===== */
+.agri-card-title.ant-typography {
+ font-size: 14px;
+}
+
+.agri-card-extra.ant-typography {
+ font-size: 11px;
+}
+
+.agri-json-hint.ant-typography {
+ font-size: 11px;
+ display: block;
+ margin-bottom: 12px;
+}
+
+.agri-note-hint.ant-typography {
+ font-size: 11px;
+ margin-bottom: 12px;
+}
+
+.agri-workspace-intro.ant-typography {
+ font-size: 11px;
+ display: block;
+ margin-bottom: 16px;
+}
+
+.agri-result-card.ant-card {
+ margin-top: 12px;
+ border-radius: 8px;
+}
+
+.agri-result-card.ant-card .ant-card-body {
+ padding: 12px;
+}
+
+.agri-preview-card.ant-card {
+ height: 480px;
+}
+
+.agri-side-card.ant-card {
+ border-radius: 8px;
+ height: 100%;
+}
+
+.agri-side-card.ant-card .ant-card-body {
+ padding: 8px;
+}
+
+.agri-workspace-card.ant-card {
+ border-radius: 8px;
+}
+
+.agri-workspace-card.ant-card .ant-card-body {
+ padding: 16px;
+}
+
+.agri-detail-card.ant-card {
+ height: 400px;
+}
+
+.agri-detail-card.ant-card .ant-card-body {
+ height: 350px;
+}
+
+/* ===== 媒体/JSON 展示区 ===== */
+.agri-media-stage {
+ height: 400px;
+ background: #001529;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ overflow: hidden;
+}
+
+.agri-result-stage {
+ height: 400px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: #fafafa;
+}
+
+.agri-json-stage {
+ height: 400px;
+ overflow-y: auto;
+ background: #fafafa;
+ padding: 8px;
+}
+
+.agri-json-pre {
+ font-size: 10px;
+ margin: 0;
+}
+
+.agri-media-fit {
+ max-width: 100%;
+ max-height: 100%;
+}
+
+/* ===== 分割结果:顶部统计块 ===== */
+.agri-stat-tile.ant-card {
+ border-radius: 8px;
+ height: 100%;
+}
+
+.agri-stat-tile.ant-card .ant-card-body {
+ padding: 12px 8px;
+}
+
+.agri-stat-tile-green.ant-card {
+ background: #E8FFEA;
+}
+
+.agri-stat-tile-blue.ant-card {
+ background: #E6F4FF;
+}
+
+.agri-stat-tile-orange.ant-card {
+ background: #FFF7E8;
+}
+
+.agri-stat-tile-purple.ant-card {
+ background: #F3E8FF;
+}
+
+.agri-stat-tile-title {
+ font-size: 15px;
+ color: #86909C;
+}
+
+.agri-stat-count-red.ant-statistic .ant-statistic-content {
+ font-size: 18px;
+ font-weight: 600;
+ color: #FF4D4F;
+}
+
+.agri-stat-count-blue.ant-statistic .ant-statistic-content {
+ font-size: 18px;
+ font-weight: 600;
+ color: #1677FF;
+}
+
+.agri-stat-count-orange.ant-statistic .ant-statistic-content {
+ font-size: 18px;
+ font-weight: 600;
+ color: #FF7D00;
+}
+
+.agri-stat-count-purple.ant-statistic .ant-statistic-content {
+ font-size: 18px;
+ font-weight: 600;
+ color: #722ED1;
+}
+
+/* ===== 分割结果:热成像图与热点 ===== */
+.agri-thermal-stage {
+ background: #001529;
+ border-radius: 8px;
+ height: 400px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ overflow: hidden;
+ position: relative;
+}
+
+/* ===== 分割结果:点位详情 ===== */
+.agri-detail-body {
+ width: 100%;
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ box-sizing: border-box;
+ padding-bottom: 8px;
+}
+
+.agri-detail-top {
+ flex: 1;
+ min-height: 0;
+ overflow-y: auto;
+ padding-right: 4px;
+ box-sizing: border-box;
+ height: 50%;
+}
+
+.agri-detail-bottom {
+ flex: 1;
+ min-height: 0;
+ overflow-y: auto;
+ padding-right: 4px;
+ box-sizing: border-box;
+}
+
+.agri-detail-row {
+ display: flex;
+ justify-content: space-between;
+ padding: 8px 0;
+ border-bottom: 1px dashed #eee;
+}
+
+.agri-detail-divider {
+ height: 1px;
+ background: #eee;
+ margin: 12px 0;
+ flex-shrink: 0;
+}
+
+.agri-panel-item {
+ display: flex;
+ justify-content: space-between;
+ padding: 8px 12px;
+ border-radius: 4px;
+ margin-bottom: 4px;
+ background: var(--agri-panel-item-bg);
+ cursor: pointer;
+ font-size: 12px;
+}
+
+.agri-panel-temp {
+ color: #ff4d4f;
+}
+
+/* ===== 算法列表 ===== */
+.agri-algo-item {
+ padding: 12px;
+ border-radius: 8px;
+ cursor: pointer;
+ margin-bottom: 8px;
+ border: 1px solid var(--agri-algo-border-color);
+ background: var(--agri-algo-bg);
+ transition: all 0.3s;
+}
+
+.agri-algo-head {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 4px;
+}
+
+.agri-algo-tag.ant-tag {
+ margin: 0;
+ font-size: 10px;
+}
+
+.agri-algo-meta {
+ font-size: 11px;
+ color: #999;
+ margin-bottom: 4px;
+}
+
+.agri-algo-desc {
+ font-size: 11px;
+ color: #999;
+}
+
+/* ===== 历史记录 ===== */
+.agri-history-item {
+ padding: 10px;
+ border-radius: 6px;
+ border: 1px solid #f0f0f0;
+ margin-bottom: 8px;
+ font-size: 12px;
+}
+
+.agri-history-head {
+ display: flex;
+ justify-content: space-between;
+ margin-bottom: 4px;
+}
+
+.agri-history-id {
+ color: #999;
+ font-size: 11px;
+ margin-bottom: 4px;
+}
+
+.agri-history-time {
+ color: #ccc;
+ font-size: 10px;
+}
diff --git a/src/pages/Agri.jsx b/src/pages/Agri.jsx
index d72a60c..f575982 100644
--- a/src/pages/Agri.jsx
+++ b/src/pages/Agri.jsx
@@ -24,6 +24,7 @@ import {
} from '../api/aiAnalysis';
import utils from '../lib/utils';
import { useTranslation } from 'react-i18next';
+import './Agri.css';
const { Title, Text } = Typography;
const { Dragger } = Upload;
diff --git a/src/pages/Alerts.css b/src/pages/Alerts.css
new file mode 100644
index 0000000..eafb8f3
--- /dev/null
+++ b/src/pages/Alerts.css
@@ -0,0 +1,38 @@
+/* 告警中心页面样式(由 Alerts.tsx 内联样式外联而来) -- test */
+
+.alerts-layout {
+ min-height: 100vh;
+ overflow: hidden;
+}
+
+.alerts-topbar {
+ display: flex;
+ padding-bottom: 4px;
+}
+
+.alerts-title-box {
+ padding: 8px 12px 0;
+}
+
+.alerts-title {
+ margin: 0;
+ font-size: clamp(14px, 1.2vw, 18px);
+}
+
+.alerts-header {
+ padding: 0;
+ border-bottom: 1px solid #f0f0f0;
+ position: sticky;
+ top: 0;
+ z-index: 10;
+ height: 40px;
+ line-height: 40px;
+}
+
+.alerts-content {
+ max-height: calc(100vh - 40px);
+ overflow-y: auto;
+ background: #f5f7fa;
+ scrollbar-width: none;
+ ms-overflow-style: none;
+}
diff --git a/src/pages/Alerts.tsx b/src/pages/Alerts.tsx
index b461dd4..ccb6193 100644
--- a/src/pages/Alerts.tsx
+++ b/src/pages/Alerts.tsx
@@ -8,6 +8,7 @@ import { getMenuList } from '../api/mune';
import AlarmOverview from '../components/alerts/AlarmOverview';
import { useTranslation } from 'react-i18next';
+import './Alerts.css';
@@ -31,13 +32,13 @@ export default function AlarmCenterPage() {
};
return (
-
-
-
-
{t('router.alerts')}
+
+
+
+ {t('router.alerts')}
-
+
{/*