diff --git a/src/api/device.ts b/src/api/device.ts index 5fed4d8..598c32e 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -499,6 +499,50 @@ export function createRegionDefaultTask(params) { }) } +//下发连续任务 + +export function createConsecutiveTasks(data) { + return request({ + url: '/iot/deviceTask/createConsecutiveTask', + method: 'post', + data, + }) +} + +//取消连续任务/iot/deviceTask/cancelConsecutiveTask + +export function cancelConsecutiveTask(data) { + return request({ + url: '/iot/deviceTask/cancelConsecutiveTask ', + method: 'post', + data, + }) +} + + +//连续任务记录 + +export function getConsecutiveTask(data) { + return request({ + url: '/iot/deviceTask/getConsecutiveTask', + method: 'post', + data, + }) +} + +///iot/host/modeChage 切换控制模式 + +export function modeChage(params) { + return request({ + url: '/iot/host/modeChage', + method: 'get', + params, + }) +} + + + + diff --git a/src/components/Map.jsx b/src/components/Map.jsx index e79b5f1..b5377a5 100644 --- a/src/components/Map.jsx +++ b/src/components/Map.jsx @@ -394,17 +394,17 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, }); // 自动跳转到第一个障碍物 - //if (firstPos) { - // flyToView(viewer, 100, { - // destination: Cesium.Cartesian3.fromDegrees(firstPos.lon, firstPos.lat, 60), - // orientation: { - // heading: Cesium.Math.toRadians(0), - // pitch: Cesium.Math.toRadians(-40), - // roll: 0 - // }, - // duration: 2.0 - // }, 'live-obstacle-jump'); - //} + if (firstPos) { + flyToView(viewer, 100, { + destination: Cesium.Cartesian3.fromDegrees(firstPos.lon, firstPos.lat, 60), + orientation: { + heading: Cesium.Math.toRadians(0), + pitch: Cesium.Math.toRadians(-40), + roll: 0 + }, + duration: 2.0 + }, 'live-obstacle-jump'); + } viewer.scene.requestRender(); } diff --git a/src/components/devices/DPadControl.tsx b/src/components/devices/DPadControl.tsx index e0682d6..a4c6621 100644 --- a/src/components/devices/DPadControl.tsx +++ b/src/components/devices/DPadControl.tsx @@ -39,6 +39,14 @@ const KEY_MAP: Record = { A: 'left', D: 'right', }; +const KEY_LABELS: Record = { + up: 'W/↑', + down: 'S/↓', + left: 'A/←', + right: 'D/→', + center: 'SPACE' +}; + const DIRECTIONS = ['up', 'down', 'left', 'right']; @@ -340,7 +348,7 @@ const DPadControl: React.FC = ({ type="button" aria-label={ariaLabel} disabled={disabled} - className={`${btnBase} ${pressed[key] ? btnActive : btnIdle + className={`${btnBase} relative ${pressed[key] ? btnActive : btnIdle } ${disabled ? 'opacity-40 cursor-not-allowed' : 'cursor-pointer' @@ -371,6 +379,9 @@ const DPadControl: React.FC = ({ onContextMenu={(e) => e.preventDefault()} > {icon} + + {KEY_LABELS[key]} + ); @@ -379,7 +390,7 @@ const DPadControl: React.FC = ({ type="button" aria-label={t('devices.emergencyStop')} disabled={disabled} - className={`${btnBase} ${pressed.center + className={`${btnBase} relative ${pressed.center ? 'border-red-500 bg-red-500/40 text-white shadow-[0_0_16px_rgba(239,68,68,0.6)]' : 'border-red-500/70 bg-red-500/10 text-red-400 hover:bg-red-500/20' } ${disabled @@ -389,6 +400,9 @@ const DPadControl: React.FC = ({ onClick={startEmergency} > + + {KEY_LABELS.center} + ); diff --git a/src/components/devices/DeviceStatusPage.tsx b/src/components/devices/DeviceStatusPage.tsx index ab0ed77..eea692d 100644 --- a/src/components/devices/DeviceStatusPage.tsx +++ b/src/components/devices/DeviceStatusPage.tsx @@ -1,250 +1,120 @@ import React, { - useState, - useEffect, - useMemo, - useRef, - useCallback, - } from 'react'; - - - import { - Row, - Col, - Card, - Tag, - Typography, - Space, - Empty, - Descriptions, - Badge, - Progress, - Button, - Select, - message, - Modal, - Switch, - } from 'antd'; - - - import { - DashboardOutlined, - GlobalOutlined, - VideoCameraOutlined, - ControlOutlined, - CameraOutlined, - ThunderboltOutlined, - EnvironmentOutlined, - DeleteOutlined, - SafetyOutlined, - LockOutlined, - UnlockOutlined, - LoadingOutlined, - PoweroffOutlined, - ArrowUpOutlined, - ArrowDownOutlined, - PlusOutlined, - MinusOutlined, - } from '@ant-design/icons'; - - - import { - getsinglePlan, - getsinglePlanTrack, - getFlightTaskDetail, - getUAVState, - getSiteDevice, - getSiteUAVList, - addRoute, - + modeChage, } from '../../api/device.ts'; - import { useLocation } from 'react-router-dom'; - - - import XboxController from './XboxController'; - import RobotFeatureButtons from './RobotFeatureButtons'; - import DPadControl from './DPadControl'; - import ReverseCameraOverlay from './ReverseCameraOverlay'; - import DroneVideoPlayer from './DroneVideoPlayer'; - import CesiumMap from '../Map.jsx'; - import { useSelector } from 'react-redux'; - import { RootState } from '@/src/store/index.ts'; - import { useWebRTCPlayer } from '../useWebRTCStream.tsx'; - import VideoPlayer from '../VideoPlayer.tsx'; import SteerButton from './SteerButton'; - import AgrtcRoomRobot from '../AgrtcRoomRobot'; - import DeviceController from './DeviceController'; - import { DatePicker } from 'antd'; - import dayjs from 'dayjs'; - import { MowerAllView } from './MowerAllView'; - import { useMqtt } from '@/hooks/useMqtt'; - import envConfig from '../../../env'; - import { dataUrlToFile } from '@/lib/utils.ts'; - import { useUnitFormatter } from '@/lib/units'; - import { PauseOutlined, PlayCircleOutlined } from '@ant-design/icons'; - import { useTranslation } from 'react-i18next'; import { backToRestPointCommand } from '@/api/mapEdit'; - - - import CarReverseGuideLine from './CarReverseGuideLine'; - import mowerImg from '../../assets/images/mower.png'; - import { sendEmergencyStop } from './emergencyStopControl'; - const { RangePicker } = DatePicker; - - - const { Text } = Typography; - - - const ConsoleBadge = ({ online, text, color }: any) => ( - - - {text} - - ); - - - const ConsoleRow = ({ icon, label, value }: any) => ( -
- - {icon} - {label} - - {value} -
- ); - - - // 暗色控制台面板(参考图样式:细边框、小圆角、蓝色竖条标题、右侧状态 badge) - const ConsolePanel = ({ title, extra, badge, children, style, bodyStyle }: any) => ( -
-
- - - {title} - - {extra}{badge} -
-
{children}
-
- ); - - - - - // 方向盘功能按钮(暗色小方块,样式参考参考图) - // SteerButton:支持长按持续发送(与 DPadControl 方向键行为一致) //const SteerButton = ({ icon, label, color, onPressStart, onPressEnd }: any) => { // const [pressed, setPressed] = useState(false); // const holdingRef = useRef(false); // const intervalRef = useRef(null); // const emitEndedRef = useRef(false); - // const stopHold = useCallback(() => { // if (intervalRef.current !== null) { window.clearInterval(intervalRef.current); intervalRef.current = null; } // if (!holdingRef.current) return; @@ -253,7 +123,6 @@ const ConsolePanel = ({ title, extra, badge, children, style, bodyStyle }: any) // setPressed(false); // onPressEnd?.(); // }, [onPressEnd]); - // const startHold = useCallback(() => { // if (holdingRef.current) return; // holdingRef.current = true; @@ -267,12 +136,10 @@ const ConsolePanel = ({ title, extra, badge, children, style, bodyStyle }: any) // onPressStart?.(); // }, 100); // }, [onPressStart]); - // useEffect(() => () => { // if (intervalRef.current !== null) window.clearInterval(intervalRef.current); // if (holdingRef.current) stopHold(); // }, [stopHold]); - // return ( // // ); //}; - - - - - export default function DeviceStatusPage() { - const { t } = useTranslation(); - const { userInfo } = useSelector((state: RootState) => state.user); - const { stationId, currentStation } = useSelector((state: RootState) => state.station); - const { formatTemperature } = useUnitFormatter(); - const [persistentDroneData, setPersistentDroneData] = useState(null); // 持久化无人机数据 - const [persistentHostData, setPersistentHostData] = useState(null); // 持久化机场数据 - const [devices, setDevices] = useState([]); - const [planedevices, setPlaneDevices] = useState([]); - const [devicesAll, setDevicesAll] = useState([]); - const [arrivedPoint, setArrivedPoint] = useState(null);//完成点 - const [isLoopMode, setIsLoopMode] = useState(true); - const controllerRef = useRef(null); - const isFirstConnect = useRef(true); const [detectReportInfo, setDeportInfo] = useState(null); - // 标记本次会话是否已经发起过控制权限申请,避免手柄/方向盘高频更新时重复申请 - const hasRequestedControlRef = useRef(false); - const [messageApi, contextHolder] = message.useMessage(); - - - // 视频播放开关 - const [isVideoPlaying, setIsVideoPlaying] = useState(false); - - - const toggleVideoPlay = useCallback(() => { - setIsVideoPlaying(prev => !prev); - }, []); - - - - - - - const [isControlled, setIsControlled] = useState(false); - const [hasControlRight, setHasControlRight] = useState(false); - const [connecting, setConnecting] = useState(false); - const [wsStatus, setWsStatus] = useState('disconnected'); - const [wsDeviceInfo, setWsDeviceInfo] = useState({}); - const [locationInfo, setLocationInfo] = useState({}); - - - - - // 👇 加上这两个 - const [queryTimeRange, setQueryTimeRange] = useState([]); // 时间范围 - const [startTimestamp, setStartTimestamp] = useState(''); // 开始时间戳 - const [endTimestamp, setEndTimestamp] = useState(''); // 结束时间戳 - - - const [isModalOpen, setIsModalOpen] = useState(false); - const [modalContent, setModalContent] = useState({ - title: '', - content: '', - }); - - - const [mowerView, setMowerView] = useState('front'); - const [steerXY, setSteerXY] = useState({ x: 0, y: 0 }); - const [isGamepadConnected, setIsGamepadConnected] = useState(false); - const [uavState, setUavState] = useState(null); - const [points, setPoints] = useState([]); - const [clearNavLine, setClearNavLine] = useState(0); - const [clearPlanLine, setClearPlanLine] = useState(0); - const timerRef = useRef(null); - // 打点相关状态 - const [markedPoints, setMarkedPoints] = useState([]); // 标记的点 - const [completeFlag, setCompleteFlag] = useState(false); // 是否完成路径规划 - const [savePath, setSavePath] = useState(null); // 保存的路径数据 - const [isSaveModalVisible, setIsSaveModalVisible] = useState(false); // 保存模态框可见性 - const [plotName, setPlotName] = useState(''); // 地块名称 - const [isSaving, setIsSaving] = useState(false); // 是否正在保存 - const mapRef = useRef(null); - const clearDrawRef = useRef<(() => void) | null>(null); // 地图 ref - - - const location = useLocation(); - const queryParams = new URLSearchParams(location.search); - const urlSn = queryParams.get('sn'); // 拿到路由上的sn - - - - - - - - - - - // 获取数据 - const fetchAllData = async () => { - if (!stationId) return; - - - try { - // 1. 同时发请求 - const [deviceRes, planeRes] = await Promise.all([ - getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1, orgId: currentStation?.orgId }), - getSiteUAVList(stationId), - ]); - - - // 2. 处理普通设备 - const devData = deviceRes?.code === 200 ? (deviceRes.rows || []) : []; - - - // 3. 处理无人机 + 自动补全地图需要的字段(关键改动) - let planeData = planeRes?.code === 200 ? (planeRes?.rows || []) : []; - - - planeData = planeData.map(item => ({ - ...item, - type: 'plane', - lastRunningStatus: { - longitude: item.longitude || 0, - latitude: item.latitude || 0, - }, - deviceAlias: item.drone_callsign || item.device_sn - || t('constants.uav'), - - - })); - - - setDevices(devData); - setPlaneDevices(planeData); - - - // 合并所有设备 - const all = [...devData, ...planeData]; - setDevicesAll(all); - - - } catch (err) { - console.error('数据请求失败', err); - } - }; - - - const handleFinishEdPoint = (point) => { - setArrivedPoint(point); - } - - - - - useEffect(() => { - fetchAllData(); - }, [userInfo, stationId]); - - - // 当前选中的设备SN - const [selectedSn, setSelectedSn] = useState(''); - - - - - - - // 当设备列表加载后,如果没有选中的设备,默认选中第一个 - useEffect(() => { - if (devicesAll?.length > 0) { - // 优先从url参数匹配设备 - if (urlSn) { - const target = devicesAll.find(d => - (d.device_sn || d.serialNumber) === urlSn - ); - if (target) { - setSelectedSn(urlSn); - setIsVideoPlaying(false); - - - return; - } - } - // url无sn / 没匹配到对应设备:默认选中第一个 - const firstDevice = devicesAll[0]; - setSelectedSn(firstDevice.device_sn || firstDevice.serialNumber); - setIsVideoPlaying(false); - - - } - }, [devicesAll, urlSn]); - - - - - // 获取当前选中的无人机设备 - const device = useMemo(() => { - const sn = selectedSn; - - - if (!sn) return null; - - - return devicesAll?.find( - (d) => (d.device_sn || d.serialNumber) == sn, - ); - }, [devicesAll, selectedSn]); - - - const isUAV = useMemo(() => { - // 设备有 drone_callsign 或 gateway_sn 则是无人机 - return !!(device?.drone_callsign || device?.gateway_sn); - }, [device]); - - - // 设备选择变化时,调用回调并更新内部状态 - const handleDeviceSelectChange = (val) => { - setSelectedSn(val); - // 切换设备时清空之前的标记点等 - setMarkedPoints([]); - setCompleteFlag(false); - setSavePath(null); - }; - - - // 当MQTT数据更新时,更新持久化数据(只在有新数据时更新) - const handleMqttMessage = useCallback((topic, message) => { - - - try { - const parsedMessage = JSON.parse(message); - - - if (parsedMessage.data && parsedMessage.data.host) { - const { host } = parsedMessage.data; - - - // 判断是无人机数据还是机场数据:无人机数据有 battery 字段 - const isDroneData = host.battery !== undefined; - - - if (isDroneData) { - // 处理无人机数据 - setPersistentDroneData(prevData => { - const newData = { ...prevData }; - - - - - // 无人机特有字段 - if (host.battery?.capacity_percent !== undefined) { - newData.capacity_percent = host.battery.capacity_percent; - } - if (host.attitude_head !== undefined) { - newData.heading = host.attitude_head; - } - if (host.horizontal_speed !== undefined) { - newData.horizontal_speed = host.horizontal_speed; - } - if (host.vertical_speed !== undefined) { - newData.vertical_speed = host.vertical_speed; - } - if (host.total_flight_time !== undefined) { - newData.total_flight_time = host.total_flight_time; - } - if (host.total_flight_sorties !== undefined) { - newData.total_flight_sorties = host.total_flight_sorties; - } - if (host.mode_code !== undefined) { - newData.mode_code = host.mode_code; - } - - - // 通用字段 - if (host.height !== undefined) { - newData.height = host.height; - } - if (host.wind_speed !== undefined) { - newData.wind_speed = host.wind_speed; - } - if (host.position_state !== undefined) { - newData.position_state = host.position_state; - } - if (host.longitude !== undefined) { - newData.longitude = host.longitude; - } - if (host.latitude !== undefined) { - newData.latitude = host.latitude; - } - - - return newData; - }); - } else { - // 处理机场数据 - setPersistentHostData(prevData => { - const newData = { ...prevData }; - - - // 机场特有字段 - if (host.drone_charge_state?.capacity_percent !== undefined) { - newData.capacity_percent = host.drone_charge_state.capacity_percent; - } - if (host.air_conditioner?.air_conditioner_state !== undefined) { - newData.air_conditioner_state = host.air_conditioner.air_conditioner_state; - } - if (host.air_conditioner_state !== undefined) { - newData.air_conditioner_state = host.air_conditioner_state; - } - - - // 通用字段 - if (host.environment_temperature !== undefined) { - newData.environment_temperature = host.environment_temperature; - } - if (host.wind_speed !== undefined) { - newData.wind_speed = host.wind_speed; - } - if (host.rainfall !== undefined) { - newData.rainfall = host.rainfall === 0 ? 'no_rain' : 'rain'; - } - if (host.humidity !== undefined) { - newData.humidity = host.humidity; - } - if (host.drone_in_dock !== undefined) { - newData.drone_in_dock = host.drone_in_dock; - } - if (host.cover_state !== undefined) { - newData.cover_state = host.cover_state; - } - if (host.temperature !== undefined) { - newData.temperature = host.temperature; - } - if (host.home_distance !== undefined) { - newData.home_distance = host.home_distance; - } - - - return newData; - }); - } - } - } catch (err) { - console.error('DeviceStatusPage MQTT 消息解析失败:', err); - } - }, []); - - - // 根据选中设备动态构建MQTT主题 - const mqttTopics = useMemo(() => { - if (!isUAV || !device) { - return []; - } - const topics = []; - if (device.device_sn) { - topics.push(`thing/product/${device.device_sn}/osd`); - } - if (device.gateway_sn && device.gateway_sn !== device.device_sn) { - topics.push(`thing/product/${device.gateway_sn}/osd`); - } - return topics; - }, [isUAV, device]); - - - // 订阅MQTT消息 - useMqtt({ - url: envConfig.mqtt_url, - topic: mqttTopics, - onMessage: handleMqttMessage, - enabled: mqttTopics.length > 0, - }); - - - // 合并无人机和机场数据 - const currentDroneData = React.useMemo(() => { - return { ...persistentHostData, ...persistentDroneData }; - }, [persistentDroneData, persistentHostData]); - - - // 实时位置数据(用于地图) - - - - - - - - - const runningStatus = useMemo(() => { - // 判断对象是否为空 - if ((!wsDeviceInfo || Object.keys(wsDeviceInfo).length === 0) && (!locationInfo || Object.keys(locationInfo).length === 0) && !isUAV) { - return {}; - } - if (isUAV) { - return { - ...wsDeviceInfo, - }; - } - const base = device?.lastRunningStatus || {}; - - - return isUAV - ? base - : { - ...base, - ...device?.locationMessage, - ...wsDeviceInfo, - ...locationInfo - }; - }, [device, wsDeviceInfo, isUAV, locationInfo]); - // 统一在线状态判断:优先实时数据,兜底接口数据 const isDeviceOnline = useMemo(() => { // 1. 优先检查实时数据源(WebSocket 推送的 wsDeviceInfo / locationInfo) const hasWsData = wsDeviceInfo && Object.keys(wsDeviceInfo).length > 0; const hasLocData = locationInfo && Object.keys(locationInfo).length > 0; - if (hasWsData || hasLocData) { return true; } - - //// 2. 检查 runningStatus 里是否有有效经纬度或实时状态字段 //const runningLon = runningStatus?.longitude; //const runningLat = runningStatus?.latitude; //const hasValidCoords = runningLon !== undefined && runningLon !== null && runningLon !== 0 // && runningLat !== undefined && runningLat !== null && runningLat !== 0; - //const hasFeStatus = runningStatus?.feStatus !== 3; //const hasStatusField = runningStatus?.status !== 0; - //if (hasValidCoords || hasFeStatus || hasStatusField) { // return true; //} - // 3. 兜底用接口返回的 onlineStatus return device?.onlineStatus == 1; }, [device, wsDeviceInfo, locationInfo,]); - - - const { video: robotVideo, error, ready } = useWebRTCPlayer( - (!isUAV && isVideoPlaying && !device?.hasHost) ? (device?.serialNumber || '') : '', - (!isUAV && isVideoPlaying) - ? `webrtc://1.95.137.212/live/livestream/${device?.serialNumber}` - : '' - ); - - - //const { video: robotVideo, error, ready } = useWebRTCPlayer( - // !isUAV ? device?.serialNumber : '', - // `webrtc://1.95.137.212/live/livestream/${device?.serialNumber}`, - //); - const getVal = (val) => val === "no_rain" ? t('devices.rainNo') : (val || '-'); - const fixStatusMap: Record = { - 'no_fix': t('devices.noFix'), - 'single': t('devices.single'), - 'dgnss': t('devices.dgnss'), - 'ins': t('devices.ins'), - 'rtk_fixed': t('devices.rtkFixed'), - 'rtk_float': t('devices.rtkFloat'), - 'single_no_heading': t('devices.singleNoHeading'), - 'dgnss_no_heading': t('devices.dgnssNoHeading'), - 'rtk_fixed_no_heading': t('devices.rtkFixedNoHeading'), - 'rtk_float_no_heading': t('devices.rtkFloatNoHeading'), - } - - - - - - - const realtimePosition = React.useMemo(() => { - // 1. 无人机:优先用 MQTT 实时数据 - if (isUAV) { - if (currentDroneData?.longitude && currentDroneData?.latitude) { - return { - lon: currentDroneData.longitude, - lat: currentDroneData.latitude, - heading: currentDroneData.heading || 0, - }; - } - // 无人机没有实时数据时,用 lastRunningStatus 兜底 - const baseLon = device?.lastRunningStatus?.longitude || device?.longitude; - const baseLat = device?.lastRunningStatus?.latitude || device?.latitude; - if (baseLon && baseLat) { - return { - lon: Number(baseLon), - lat: Number(baseLat), - heading: device?.lastRunningStatus?.heading || 0, - }; - } - return null; - } - - - // 2. 机器人:优先从 wsDeviceInfo / runningStatus / locationInfo 取实时经纬度 - let robotLon = runningStatus?.longitude || wsDeviceInfo?.longitude || locationInfo?.longitude; - let robotLat = runningStatus?.latitude || wsDeviceInfo?.latitude || locationInfo?.latitude; - - - // 3. 没有实时经纬度时,从 lastRunningStatus 兜底 - if ((!robotLon || !robotLat) && (device?.lastRunningStatus || device?.locationMessage)) { - robotLon = robotLon || device?.lastRunningStatus?.longitude || device?.locationMessage?.longitude; - robotLat = robotLat || device?.lastRunningStatus?.latitude || device?.locationMessage?.latitude; - } - // 4. 最终兜底:设备静态经纬度 - if ((!robotLon || !robotLat) && device) { - robotLon = robotLon || device.longitude; - robotLat = robotLat || device.latitude; - } - - - if (robotLon && robotLat) { - return { - lon: robotLon, - lat: robotLat, - heading: runningStatus?.yaw || wsDeviceInfo?.yaw || locationInfo?.yaw || device?.lastRunningStatus?.heading || 0, - }; - } - - - return null; - }, [isUAV, currentDroneData, runningStatus, wsDeviceInfo, locationInfo, device]); - - - // 寻车:地图定位到当前设备位置 - const handleFindCar = () => { - if (!realtimePosition) { - messageApi.warning(t('devices.locationUnknown')); - return; - } - mapRef.current?.flyToPosition?.(realtimePosition, { height: 300 }); - }; const handleDetectionReport = (res) => { setDeportInfo(res); console.log("获取障碍物信息", res) - } - - - useEffect(() => { - const controller = new DeviceController(userInfo, messageApi); - - - controller.onDeviceInfoUpdate = setWsDeviceInfo; - controller.onLocationInfoUpdate = setLocationInfo; - controller.onControlStatusChange = setIsControlled; - controller.onHasControlRightChange = setHasControlRight; - controller.onRequestControlStatusChange = setConnecting; - controller.onWsStatusChange = setWsStatus; - controller.handleArrivedPoint = handleFinishEdPoint; - controller.onDetectionReport = handleDetectionReport; - - - - - - controller.onPermissionRequest = (content) => { - setModalContent(content); - setIsModalOpen(true); - }; - - - controller.init(); - - - controllerRef.current = controller; - - - return () => { - controller?.destroy(); - controllerRef.current?.destroy(); - - - controllerRef.current = null; - - - }; - }, []); - - - useEffect(() => { - if (!device || !controllerRef.current || !device?.serialNumber || isUAV) { - return; - } - setWsDeviceInfo({}); - setLocationInfo({}); - - - if (isFirstConnect.current) { - - - isFirstConnect.current = false; - controllerRef.current.connectDevice(device); - } else { - - - controllerRef.current.switchDevice(device); - } - - - }, [device?.serialNumber]); - - - // 定时获取无人机状态 - useEffect(() => { - const fetchUavState = async () => { - if (isUAV && device?.gateway_sn && device?.device_sn) { - try { - const res = await getUAVState({ - sn: device.gateway_sn, - droneSn: device.device_sn - }); - if (res.code === 200) { - setUavState(res.data); - } - } catch (err) { - console.error('获取无人机状态失败', err); - } - } else { - setUavState(null); - } - }; - - - fetchUavState(); - }, [isUAV, device]); - - - // 获取执行中任务的轨迹 - useEffect(() => { - const fetchExecutingTaskTrack = async () => { - if (isUAV && device?.gateway_sn) { - try { - const todayStart = dayjs().startOf('day').unix(); - const todayEnd = dayjs().endOf('day').unix(); - const sns = [device.gateway_sn]; - - - const res = await getsinglePlan({ sns, beginAt: todayStart, endAt: todayEnd }); - if (res?.code === 200 && res.data) { - let combinedList = []; - Object.values(res.data).forEach((item: any) => { - if (item.list) combinedList = combinedList.concat(item.list); - }); - - - // 筛选出执行中的任务 - const executingTask = combinedList.find(t => - ['executing', 'running', 'restored'].includes(t.status) - ); - - - if (executingTask) { - const trackRes = await getsinglePlanTrack(executingTask); - if (trackRes.code === 0 && trackRes.data.track?.points?.length) { - const trackPoints = trackRes.data.track.points.map(item => ({ - lon: item.longitude || item.lon, - lat: item.latitude || item.lat - })); - setPoints(trackPoints); - } else { - setPoints([]); - } - } else { - setPoints([]); - } - } else { - setPoints([]); - } - } catch (err) { - console.error('获取执行中任务轨迹失败', err); - setPoints([]); - } - } else { - setPoints([]); - } - }; - - - fetchExecutingTaskTrack(); - }, [isUAV, device]); - - - const mapDevices = useMemo(() => { - if (!device) return null; - - - // 优先使用持久化MQTT数据,其次使用uavState - const lng = currentDroneData?.longitude ?? uavState?.longitude ?? runningStatus?.longitude ?? device.longitude; - const lat = currentDroneData?.latitude ?? uavState?.latitude ?? runningStatus?.latitude ?? device.latitude; - - - return { - ...device, - lastRunningStatus: { - ...device.lastRunningStatus, - longitude: lng, - latitude: lat, - }, - longitude: lng, - latitude: lat, - name: device?.deviceAlias || device?.callsign || device?.deviceName || t('devices.device'), - type: isUAV - ? 'drone' - : device?.productName?.includes(t('constants.mower')) - ? 'mower' - : 'robot', - }; - }, [device, isUAV, runningStatus, uavState, currentDroneData]); - - const realtimeDevice = useMemo(() => { - - if (!device) return null; - - return { - - ...device, - - ...uavState, - - ...currentDroneData, // 持久化数据最后覆盖,确保优先显示 - - }; - - }, [device, uavState, currentDroneData]); - - - - const handleGamepadUpdate = useCallback((state) => { - - // 无控制权限时:不发送消息,且只发起一次权限申请(避免手柄/方向盘高频更新刷屏) - - if (!isControlled) { - - //if (!hasRequestedControlRef.current && !connecting) { - - // hasRequestedControlRef.current = true; - - // handleControlModal(); - - //} - + const handleControlMode = () => { + if (!selectedSn) { + messageApi.error(t('devices.selectDevice')); + return; + } + console.log(runningStatus, "现在的控制controlmode") + if (runningStatus?.control_mode == 3) { + return; + } + const data = { + controlMode: 3, + deviceId: selectedSn + } + modeChage(data).then(res => { + if (res.code == 200) { + messageApi.success(t('devices.controlModeSuccess')); + } else { + messageApi.error(res.msg || t('devices.controlModeFail')); + } + }).catch(err => { + messageApi.success(t('devices.controlModeFail')); + } + ) + } + const realtimeDevice = useMemo(() => { + if (!device) return null; + return { + ...device, + ...uavState, + ...currentDroneData, // 持久化数据最后覆盖,确保优先显示 + }; + }, [device, uavState, currentDroneData]); + const handleGamepadUpdate = useCallback((state) => { + // 无控制权限时:不发送消息,且只发起一次权限申请(避免手柄/方向盘高频更新刷屏) + if (!isControlled) { + //if (!hasRequestedControlRef.current && !connecting) { + // hasRequestedControlRef.current = true; + // handleControlModal(); + //} return; - } console.log(realtimePosition?.controlMode, "现在的控制controlmode") if (realtimePosition?.controlMode && (realtimePosition?.controlMode != 3 || realtimePosition?.control_mode != 3)) { - messageApi.warning(t('devices.noRemoteControl')); - return; - } - console.log('Gamepad state updated:', state); - // 记录方向盘 xy 坐标,用于倒车影像叠加层 - if (state?.axes) { - setSteerXY({ x: state.axes[2] || 0, y: state.axes[1] || 0 }); - } - controllerRef.current?.sendGamepad(state); - }, [isControlled, connecting]); - - - // 手柄已连接时拦截面板操作并提示(2 秒内只提示一次,避免高频刷屏) - const gamepadWarnRef = useRef(0); - const blockIfGamepadConnected = useCallback(() => { - // 没连接手柄 或 还没获取控制权限 → 不拦截(没控制权限本来就发不出消息) if (!isGamepadConnected || !isControlled) return false; - const now = Date.now(); - if (now - gamepadWarnRef.current > 2000) { - gamepadWarnRef.current = now; - messageApi.warning(t('devices.disconnectGamepadFirst')); - } - return true; - }, [isGamepadConnected, isControlled, t, messageApi]); - - - // 方向盘功能按钮:复用与手柄一致的遥控帧(指定位按下后短暂释放) // 方向盘按键按下/释放帧(长按模式:onDown 每 100ms 调用一次;短按模式:sendSteerButton 一次性发送后 300ms 自动释放) const sendSteerFrame = useCallback( (index: number, pressed: boolean) => { if (blockIfGamepadConnected()) return; - const buttons = new Array(17).fill(false); - buttons[index] = pressed; - handleGamepadUpdate({ buttons, axes: [0, 0, 0, 0], @@ -1602,1006 +765,442 @@ export default function DeviceStatusPage() { }, [handleGamepadUpdate, blockIfGamepadConnected], ); - const sendSteerButton = useCallback((index: number) => { sendSteerFrame(index, true); window.setTimeout(() => sendSteerFrame(index, false), 300); }, [sendSteerFrame]); - - - const handleControlModal = useCallback(() => { - console.log('请求控制权限'); - controllerRef.current?.requestControl(); - }, []); - - - // 获得控制权限后,重置"已申请"标记,以便后续失去权限时可再次提示 - useEffect(() => { - if (isControlled) { - hasRequestedControlRef.current = false; - } - }, [isControlled]); - - - const handleOk = () => { - controllerRef.current?.sendPermissionRequest( - true, - 'switchResult', - ); - setIsControlled(false); - - - setIsModalOpen(false); - }; - - - const handleCancel = () => { - - - controllerRef.current?.sendPermissionRequest( - false, - 'switchResult', - ); - setIsControlled(true); - - - setIsModalOpen(false); - }; - - - const fix2 = (val) => { - if (val === null || val === undefined || isNaN(val)) { - return '-'; - } - - - 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); }) } - - - // 打点功能 - const handleMarkPoint = () => { - if (!realtimePosition) { - message.warning(t('devices.locationFail')); - return; - } - const newPoint = { - lon: Number(realtimePosition.lon), - lat: Number(realtimePosition.lat), - }; - setMarkedPoints([...markedPoints, newPoint]); - messageApi.success(t('devices.pointMarked', { count: markedPoints.length + 1 })); - }; - - - // Map click to add marked point - const handleMapMarkPoint = (point) => { - setMarkedPoints([...markedPoints, { lon: Number(point.lon), lat: Number(point.lat) }]); - messageApi.success(t('devices.pointMarked', { count: markedPoints.length + 1 })); - }; - - - // 撤回上一个打点 - const handleUndoMark = () => { - if (markedPoints.length === 0) { - message.info(t('devices.noPointsToUndo')); - return; - } - const newPoints = markedPoints.slice(0, -1); - setMarkedPoints(newPoints); - messageApi.success(t('devices.pointUndone', { count: newPoints.length })); - }; - - - // 清空标记点 - const handleClearPoints = () => { - setMarkedPoints([]); - setCompleteFlag(false); - setSavePath(null); - clearDrawRef.current?.(); - }; - - - const getPathPoints = (coords) => { - console.log("getPathPoints", coords) - //setPathPoints(coords); - if (!coords || coords.length === 0) return; - const newWps = coords.map((p, i) => ({ - id: i + 1, - lon: p.lon.toFixed(6), - lat: p.lat.toFixed(6), - })); - console.log("newWps", newWps) - //setWaypoints(newWps); - }; - - - - - // 完成功能 - 调用路径规划接口 - const handleSave = async () => { - if (!plotName.trim()) { - messageApi.warning(t('devices.inputPlotName')); - return; - } - - - setIsSaving(true); - try { - // ✅重点:接收handleComplete返回的path数据,不再读组件savePath state - const pathResult = await handleComplete(); - if (!pathResult) { - messageApi.warning(t('devices.saveFail')); - - - // 路径规划失败/校验不通过直接终止 - return; - } - - - // 1. 获取地图截图 - let screenshotDataUrl = null; - if (mapRef.current) { - screenshotDataUrl = await mapRef.current.captureScreenshot(); - } - - - // 2. 创建 FormData - const formData = new FormData(); - - - // 3. 添加文件 - if (screenshotDataUrl) { - // 将 dataUrl 转换为 Blob - const file = dataUrlToFile(screenshotDataUrl, "screenshot.jpg"); - console.log("blob", file) - - - if (file instanceof File) { - formData.append('file', file); - } - } - - - // 4. 添加 workRecord,直接使用函数返回的 pathResult,不读取state savePath - const workRecord = { - workName: plotName, - siteId: stationId, - orgId: currentStation?.orgId, - jsonData: pathResult, // 直接用返回值,彻底规避state异步延迟 - mode: isLoopMode ? "coverage" : "single_point",//"区域还是单点" - }; - console.log("workRecord", workRecord) - formData.append( - "workRecord", - new Blob([JSON.stringify(workRecord)], { - type: "application/json" - }) - ); - - - // 5. 调用保存接口 - const res = await addRoute(formData); - - - if (res.code === 200) { - messageApi.success(t('common.saveSuccess')); - setIsSaveModalVisible(false); - // 重置状态 - setMarkedPoints([]); - setCompleteFlag(false); - setSavePath(null); - } else { - messageApi.error(res.msg || t('common.saveFail')); - } - } catch (error) { - console.error('保存失败:', error); - messageApi.error(t('common.saveFail')); - } finally { - setIsSaving(false); - } - }; - - - - - /** - * 修改handleComplete:计算完成后 return路径对象;失败返回null - */ - const handleComplete = async () => { - //如果是闭环模式 - if (isLoopMode) { - if (markedPoints.length < 3) { - messageApi.warning(t('devices.minThreePoints')); - return null; //校验失败返回null - } - - - try { - // 准备路径规划请求参数 - let positionPoints = [...markedPoints]; - - - // =========新增:保证闭环,第一个点和最后一个点一致========= - const firstPt = positionPoints[0]; - const lastPt = positionPoints[positionPoints.length - 1]; - // 判断经纬度是否相等,不相等就把首点追加到末尾 - if (!(firstPt.lat === lastPt.lat && firstPt.lon === lastPt.lon)) { - positionPoints.push({ ...firstPt }); - } - - - const requestParams = { - outer: { - position: positionPoints.map(point => ({ - lat: point.lat, - lng: point.lon, - })), - }, - }; - - - const path = requestParams?.outer?.position - setPoints(path); - - - const resultObj = { - path: path, - outer: requestParams?.outer?.position?.map(p => { - return { - lng: p.lon, - lat: p.lat - } - }), - }; - - - setSavePath(resultObj); - setCompleteFlag(true); - messageApi.success(t('devices.pathPlanDone')); - return resultObj; // ✅返回计算好的数据给上层调用 - } catch (error) { - console.error('路径规划失败:', error); - messageApi.error(t('devices.pathPlanFailRetry')); - return null; - } - } else { - // 单点模式 - const positionPoints = [...markedPoints].map(item => { - return { - lng: item.lon, - lat: item.lat - } - }); - - - setPoints(positionPoints); - - - const resultObj = { - path: positionPoints, - outer: [], - }; - setSavePath(resultObj); - setCompleteFlag(true); - - - return resultObj; // ✅返回 - } - }; - - - // 打开保存模态框 - const handleOpenSaveModal = () => { - //if (!completeFlag) { - // messageApi.warning(t('devices.completePathFirst')); - // return; - //} - setPlotName(''); - setIsSaveModalVisible(true); - }; - - - - - - - const realtimeType = useMemo(() => { - return isUAV ? 'plane' : 'car'; - }, [isUAV]); - - - - - if (!device) { - return ( - - ); - } - - - - - - - - - return ( -
- -
- 机器人控制 -
- - - - -
- {contextHolder} - - - - -
- {t('devices.selectDevice')}: - - - setPlotName(e.target.value)} - placeholder={t('devices.inputPlotName')} - style={{ - width: '100%', - padding: '8px 12px', - border: '1px solid #d9d9d9', - borderRadius: 4, - fontSize: 14, - }} - /> -
- {isSaving && ( -
-
-
{t('devices.saving')}
-
- )} - - - -
- +
- ); - } - diff --git a/src/components/devices/MapEditorPage.tsx b/src/components/devices/MapEditorPage.tsx index 969914e..a564acf 100644 --- a/src/components/devices/MapEditorPage.tsx +++ b/src/components/devices/MapEditorPage.tsx @@ -1362,7 +1362,11 @@ export default function MapEditorPage() { options={[ { value: 'MOWING_TASK', label: t('devices.mapEditor.typeMowing') }, { value: 'INSPECTION_TASK', label: t('devices.mapEditor.typeInspection') }, + //{ value: 'BACK_TO_REST_POINT', label: t('devices.mapEditor.typeBackToRest') }, + { value: 'OTHER', label: t('devices.mapEditor.typeOther') }, + // BACK_TO_REST_POINT("BACK_TO_REST_POINT", "返航任务"), + ]} /> diff --git a/src/components/devices/RobotFeatureButtons.tsx b/src/components/devices/RobotFeatureButtons.tsx index 98952e5..9ca2188 100644 --- a/src/components/devices/RobotFeatureButtons.tsx +++ b/src/components/devices/RobotFeatureButtons.tsx @@ -18,7 +18,8 @@ export type RobotFeature = | 'lowBatteryReturn' | 'tiltProtection' | 'findCar' - | 'autoback'; + | 'autoback' + | 'controlMode'; export interface FeatureConfig { key: RobotFeature; @@ -27,8 +28,10 @@ export interface FeatureConfig { inactiveColor: string; } -// 功能方块:方块样式展示,不再包含急停(急停已移至方向盘中键) +// 功能方块 const FEATURES: FeatureConfig[] = [ + { key: 'controlMode', icon: , activeColor: '#0dab2d', inactiveColor: '#94a3b8' }, + { key: 'obstacleAvoidance', icon: , activeColor: '#3b82f6', inactiveColor: '#94a3b8' }, { key: 'lowBatteryReturn', icon: , activeColor: '#f59e0b', inactiveColor: '#94a3b8' }, { key: 'tiltProtection', icon: , activeColor: '#10b981', inactiveColor: '#94a3b8' }, @@ -36,7 +39,7 @@ const FEATURES: FeatureConfig[] = [ { key: 'findCar', icon: , activeColor: '#ef4444', inactiveColor: '#94a3b8' }, ]; -// 急停方块(仅在 showEmergencyStop 时展示,兼容其他页面) +// 急停方块 const EMERGENCY: FeatureConfig = { key: 'emergencyStop', icon: , @@ -49,8 +52,10 @@ interface RobotFeatureButtonsProps { onToggle?: (feature: RobotFeature, enabled: boolean) => void; className?: string; showEmergencyStop?: boolean; - sendFindCar: () => {}; - sendAutoBack?: () => {}; + sendFindCar?: () => void; + sendAutoBack?: () => void; + sendControlMode?: () => void; + controlMode?: number | string; } const RobotFeatureButtons: React.FC = ({ @@ -59,28 +64,48 @@ const RobotFeatureButtons: React.FC = ({ className = '', showEmergencyStop = true, sendFindCar, - sendAutoBack + sendAutoBack, + sendControlMode, + controlMode }) => { const { t } = useTranslation(); const { userInfo } = useSelector((state: RootState) => state.user); const [active, setActive] = useState>(new Set(activeFeatures)); + // 临时按压闪烁标记 + const [flashKey, setFlashKey] = useState(null); + + // 一次性触发,不toggle的按钮列表 + const oneShotKeys: RobotFeature[] = ['emergencyStop', 'findCar', 'autoback', 'controlMode']; const list = showEmergencyStop ? [EMERGENCY, ...FEATURES] : FEATURES; const handleClick = (feature: RobotFeature) => { - // 急停:点击时直接下发 button7(绕过控制权限校验) - if (feature === 'emergencyStop') { - sendEmergencyStop(userInfo); - onToggle?.(feature, true); + // 触发按压反馈 + setFlashKey(feature); + setTimeout(() => { + setFlashKey(null); + }, 200); + + // 一次性按钮:只发指令,不切换active状态 + if (oneShotKeys.includes(feature)) { + if (feature === 'emergencyStop') { + sendEmergencyStop(userInfo); + onToggle?.(feature, true); + return; + } + if (feature === 'findCar') { + sendFindCar?.(); + } + if (feature === 'autoback') { + sendAutoBack?.(); + } + if (feature === 'controlMode') { + sendControlMode?.(); + } return; } - // 寻车:下发指令的同时,与其他功能一样切换选中状态(toggle 效果) - if (feature === 'findCar') { - sendFindCar?.(); - } - if (feature === 'autoback') { - sendAutoBack?.(); - } + + // 开关类:保留toggle const next = !active.has(feature); const nextSet = new Set(active); if (next) nextSet.add(feature); @@ -91,26 +116,56 @@ const RobotFeatureButtons: React.FC = ({ return (
+ {list.map((f) => { + const isOneShot = oneShotKeys.includes(f.key); const isActive = 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 c11141a..4fbbff3 100644 --- a/src/components/devices/RobotTaskPage.tsx +++ b/src/components/devices/RobotTaskPage.tsx @@ -42,6 +42,10 @@ import { deleteRoute, getTaskPath, createRegionDefaultTask, + createConsecutiveTasks, + cancelConsecutiveTask, + getConsecutiveTask, + modeChage } from '../../api/device'; import dayjs from 'dayjs'; import DraggableBox from '../Draggable'; @@ -75,6 +79,7 @@ export default function RobotTaskPage() { const [polyPoints, setPolyPoints] = useState([]); const [detectReportInfo, setDeportInfo] = useState(null); const [selectedDeviceMap, setSelectedDeviceMap] = useState>({}); + const [consecutiveTaskList, setConsecutiveTaskList] = useState([]); @@ -93,6 +98,7 @@ export default function RobotTaskPage() { const [routeSearch, setRouteSearch] = useState(''); const [routeList, setRouteList] = useState([]); + const [consecutiveLoading, setConsecutiveLoading] = useState(false); // 执行任务弹窗 const [executeModalVisible, setExecuteModalVisible] = useState(false); @@ -130,6 +136,56 @@ export default function RobotTaskPage() { robot: null, dateRange: null, }); + + const [consecutiveFilterForm, setConsecutiveFilterForm] = useState({ + taskStatus: null, + deviceId: null, + dateRange: null, + }); + // 获取连续任务列表 + const fetchConsecutiveTaskList = async () => { + if (!stationId) return; + setConsecutiveLoading(true); + + try { + const params = { siteId: stationId }; + if (consecutiveFilterForm.taskStatus) params.taskStatus = consecutiveFilterForm.taskStatus; + if (consecutiveFilterForm.deviceId) params.deviceId = consecutiveFilterForm.deviceId; + if (consecutiveFilterForm.dateRange && consecutiveFilterForm.dateRange.length === 2) { + params.startTime = consecutiveFilterForm.dateRange[0].format("YYYY-MM-DD HH:mm:ss"); + params.endTime = consecutiveFilterForm.dateRange[1].format("YYYY-MM-DD HH:mm:ss"); + } + const res = await getConsecutiveTask(params); + if (res.code == 200) { + setConsecutiveTaskList(res.rows || res.data || []); + setConsecutiveLoading(false); + } + } catch (err) { console.error("获取连续任务失败:", err); } finally { + setConsecutiveLoading(false); + + } + }; + + useEffect(() => { + if (stationId) fetchConsecutiveTaskList(); + }, [consecutiveFilterForm, stationId]); + + // 取消连续任务 + const handleCancelConsecutiveTask = async (record) => { + try { + const ids = [record.id, record.taskId].filter(Boolean); + const res = await cancelConsecutiveTask({ deviceIds: ids }); + if (res.code === 200) { + utils.message.success(t("common.operationSuccess")); + fetchConsecutiveTaskList(); + } else { + utils.message.error(res.msg || t("common.operationFailed")); + } + } catch (err) { + console.error("取消连续任务失败:", err); + utils.message.error(t("common.operationFailed")); + } + }; // 取消任务模式 normal普通取消 force强制取消 const [cancelMode, setCancelMode] = useState<'normal' | 'force'>('normal'); @@ -751,6 +807,7 @@ export default function RobotTaskPage() { fetchTaskList(); fetchTaskPoolList(); fetchTaskHistoryList(); + fetchConsecutiveTaskList(); } @@ -835,6 +892,7 @@ export default function RobotTaskPage() { utils.message.success(t('devices.fixed2TaskSuspended2Fixed2CancelledFixed2')); fetchTaskPoolList(); fetchTaskHistoryList(); + fetchConsecutiveTaskList(); setExecute(false); //if (controllerRef.current) { // controllerRef.current.destroy?.(); @@ -906,6 +964,8 @@ export default function RobotTaskPage() { useEffect(() => { if (stationId) { fetchRouteList(); + fetchConsecutiveTaskList(); + } }, [stationId]); @@ -921,6 +981,7 @@ export default function RobotTaskPage() { useEffect(() => { if (stationId) { fetchTaskPoolList(); + } }, [poolFilterForm, stationId]); @@ -1055,6 +1116,10 @@ export default function RobotTaskPage() { dataIndex: 'deviceId', width: 180, }, + { + title: t('devices.workName'), + dataIndex: 'workName', + }, { title: t('devices.taskId'), dataIndex: 'id', @@ -1162,6 +1227,16 @@ export default function RobotTaskPage() { dataIndex: 'deviceId', width: 220, }, + { + title: t('devices.workName'), + dataIndex: 'workName', + width: 220, + }, + { + title: t('devices.taskId'), + dataIndex: 'id', + width: 220, + }, { title: t('roles.status'), dataIndex: 'taskStausTranslate', @@ -1202,7 +1277,24 @@ export default function RobotTaskPage() { const showContinueBtn = ['FAILED', 'CANCELED'].includes(record.taskStaus); if (!showContinueBtn) return null; - const currentSn = selectedDeviceMap[record.taskId] ?? record.serialNumber; + + // 每行独立的 key,避免不同行共用同一个 key 导致互相关联 + const rowKey = String(record.taskId ?? record.id); + // 默认选中当前行任务的设备(deviceId 即设备 SN) + const rowDeviceSn = record.deviceId ?? record.serialNumber; + const currentSn = selectedDeviceMap[rowKey] ?? rowDeviceSn; + + const robotOptions = (devices || []).map(item => ({ + value: item.serialNumber, + label: `${item.deviceAlias || item.deviceName} (${item.serialNumber})` + })); + // 历史任务所属设备可能已不在当前设备列表中,补充一条选项保证默认值可显示 + if (rowDeviceSn && !robotOptions.some(opt => opt.value === rowDeviceSn)) { + robotOptions.unshift({ + value: rowDeviceSn, + label: record.deviceAlias || record.deviceName || rowDeviceSn + }); + } return (
@@ -1212,21 +1304,18 @@ export default function RobotTaskPage() { onChange={(val) => { setSelectedDeviceMap(prev => ({ ...prev, - [record.taskId]: val + [rowKey]: val })); }} - szie="small" + size="small" style={{ flex: 1, minWidth: 100 }} - options={(devices || []).map(item => ({ - value: item.serialNumber, - label: `${item.deviceAlias || item.deviceName} (${item.serialNumber})` - }))} + options={robotOptions} />