模拟障碍物 继续作业 连续作业 初始化
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useRef, useState, useMemo, useImperativeHandle, forwardRef, useCallback } from 'react';
|
||||
import React, { useEffect, useRef, useState, useMemo, useImperativeHandle, forwardRef, useCallback } from 'react';
|
||||
import carImg from '../assets/images/carplane.png';
|
||||
import planeImg from '../assets/images/planeicon.png';
|
||||
import cameraImg from '../assets/images/camera.png';
|
||||
@@ -16,6 +16,7 @@ import * as Cesium from 'cesium';
|
||||
|
||||
import 'cesium/Build/Cesium/Widgets/widgets.css';
|
||||
|
||||
|
||||
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, onObstacleRadiusChange, obstacleShapes = [], onObstacleRectResize, siteMapInfoId, detectReportInfo }, ref) => {
|
||||
const containerRef = useRef(null);
|
||||
const viewerRef = useRef(null);
|
||||
@@ -280,55 +281,65 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
if (lastFlightPromiseRef.current) viewer.camera.cancelFlight();
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
|
||||
function updateLiveObstacleBoxes(
|
||||
viewer,
|
||||
message,
|
||||
) {
|
||||
const viewer = viewerRef.current;
|
||||
if (!viewer || !Cesium) return;
|
||||
|
||||
console.log(message, "障碍物信息")
|
||||
return;
|
||||
const payload = message.data ?? message;
|
||||
const objects = payload.objects ?? [];
|
||||
const payload = message?.data ?? message;
|
||||
const objects = Array.isArray(payload) ? payload : (payload?.objects ?? []);
|
||||
|
||||
if (objects.length === 0) return;
|
||||
|
||||
// 记录第一个有效障碍物的位置,用于视角跳转
|
||||
let firstPos = null;
|
||||
|
||||
objects.forEach((obj, index) => {
|
||||
const lat = Number(obj.latitude);
|
||||
const lon = Number(obj.longitude);
|
||||
const sx = Number(obj.size_x);
|
||||
const sy = Number(obj.size_y);
|
||||
const sz = Number(obj.size_z);
|
||||
const lat = Number(obj.latitude ?? obj.lat);
|
||||
const lon = Number(obj.longitude ?? obj.lng ?? obj.lon);
|
||||
|
||||
if (
|
||||
!Number.isFinite(lat) ||
|
||||
!Number.isFinite(lon) ||
|
||||
!Number.isFinite(sx) ||
|
||||
!Number.isFinite(sy) ||
|
||||
!Number.isFinite(sz) ||
|
||||
sx <= 0 ||
|
||||
sy <= 0 ||
|
||||
sz <= 0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
// 根据类型设置默认尺寸和颜色
|
||||
const type = (obj.class_name ?? obj.name ?? '').toLowerCase();
|
||||
const isPerson = type.includes('person') || type.includes('行人') || type.includes('人');
|
||||
const isVehicle = type.includes('car') || type.includes('车辆') || type.includes('车') || type.includes('truck');
|
||||
const isFence = type.includes('fence') || type.includes('围挡') || type.includes('障碍');
|
||||
|
||||
const id = `live-obstacle-${obj.track_id ?? index}`;
|
||||
const sx = Number(obj.size_x ?? obj.sizeX ?? (isPerson ? 0.6 : isVehicle ? 1.8 : 1.2));
|
||||
const sy = Number(obj.size_y ?? obj.sizeY ?? (isPerson ? 0.6 : isVehicle ? 4.2 : 1.2));
|
||||
const sz = Number(obj.size_z ?? obj.sizeZ ?? (isPerson ? 1.7 : isVehicle ? 1.5 : 1.5));
|
||||
|
||||
// size_x、size_y、size_z 作为长、宽、高,单位按米处理
|
||||
const position = Cesium.Cartesian3.fromDegrees(
|
||||
lon,
|
||||
lat,
|
||||
sz / 2,
|
||||
);
|
||||
if (!Number.isFinite(lat) || !Number.isFinite(lon)) return;
|
||||
|
||||
const id = `live-obstacle-${obj.track_id ?? obj.id ?? index}`;
|
||||
const position = Cesium.Cartesian3.fromDegrees(lon, lat, sz / 2);
|
||||
|
||||
if (!firstPos) firstPos = { lon, lat };
|
||||
|
||||
const orientation = Cesium.Transforms.headingPitchRollQuaternion(
|
||||
position,
|
||||
new Cesium.HeadingPitchRoll(
|
||||
Cesium.Math.toRadians(Number(obj.angle ?? 0)),
|
||||
0,
|
||||
0,
|
||||
),
|
||||
new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(Number(obj.angle ?? obj.yaw ?? 0)), 0, 0)
|
||||
);
|
||||
|
||||
const labelText =
|
||||
`${obj.class_name ?? '障碍物'} #${obj.track_id ?? index}`;
|
||||
// 设置视觉差异
|
||||
let boxColor = Cesium.Color.RED;
|
||||
let typeEmoji = '⚠️';
|
||||
let iconImage = null; // 用于存储图标
|
||||
|
||||
if (isPerson) {
|
||||
boxColor = Cesium.Color.YELLOW;
|
||||
typeEmoji = '🚶';
|
||||
iconImage = 'https://img.icons8.com/color/96/walking--v1.png'; // 行人图标
|
||||
} else if (isVehicle) {
|
||||
boxColor = Cesium.Color.CYAN;
|
||||
typeEmoji = '🚗';
|
||||
iconImage = 'https://img.icons8.com/color/96/car--v1.png'; // 车辆图标
|
||||
}
|
||||
const labelText = `${typeEmoji} ${obj.class_name ?? '障碍物'} #${obj.track_id ?? obj.id ?? index} (${sx.toFixed(1)}x${sy.toFixed(1)}m)`;
|
||||
|
||||
let entity = viewer.entities.getById(id);
|
||||
|
||||
@@ -337,44 +348,118 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
id,
|
||||
position,
|
||||
orientation,
|
||||
// 外部包围盒,显示物理占用空间
|
||||
box: {
|
||||
dimensions: new Cesium.Cartesian3(sx, sy, sz),
|
||||
material: Cesium.Color.RED.withAlpha(0.18),
|
||||
material: boxColor.withAlpha(0.2),
|
||||
outline: true,
|
||||
outlineColor: Cesium.Color.RED,
|
||||
outlineColor: boxColor,
|
||||
outlineWidth: 1,
|
||||
},
|
||||
// 内部图标,直观显示物体类型
|
||||
billboard: iconImage ? {
|
||||
image: iconImage,
|
||||
width: isPerson ? 24 : 32,
|
||||
height: isPerson ? 24 : 32,
|
||||
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
|
||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
} : undefined,
|
||||
label: {
|
||||
text: labelText,
|
||||
font: '14px sans-serif',
|
||||
font: 'bold 14px sans-serif',
|
||||
fillColor: Cesium.Color.WHITE,
|
||||
showBackground: true,
|
||||
backgroundColor: Cesium.Color.RED.withAlpha(0.85),
|
||||
pixelOffset: new Cesium.Cartesian2(0, -20),
|
||||
backgroundColor: boxColor.withAlpha(0.85),
|
||||
pixelOffset: new Cesium.Cartesian2(0, -40),
|
||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
entity.position = position;
|
||||
entity.orientation = orientation;
|
||||
|
||||
if (entity.box) {
|
||||
entity.box.dimensions = new Cesium.Cartesian3(sx, sy, sz);
|
||||
entity.box.material = boxColor.withAlpha(0.2);
|
||||
entity.box.outlineColor = boxColor;
|
||||
}
|
||||
if (entity.billboard && iconImage) {
|
||||
entity.billboard.image = iconImage;
|
||||
}
|
||||
|
||||
if (entity.label) {
|
||||
entity.label.text = labelText;
|
||||
entity.label.backgroundColor = boxColor.withAlpha(0.85);
|
||||
}
|
||||
}
|
||||
|
||||
liveObstacleEntities.set(id, entity);
|
||||
});
|
||||
|
||||
// 自动跳转到第一个障碍物
|
||||
//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();
|
||||
}
|
||||
|
||||
// 模拟触发实时障碍物(仅用于演示)
|
||||
//useEffect(() => {
|
||||
// const viewer = viewerRef.current;
|
||||
// if (!viewer || !Cesium) return;
|
||||
|
||||
// const timer = setTimeout(() => {
|
||||
// console.log("[Mock] 触发模拟实时障碍物渲染 (人+车+围挡)");
|
||||
// const mockMsg = {
|
||||
// objects: [
|
||||
// {
|
||||
// track_id: "obs-v-001",
|
||||
// latitude: 31.2989,
|
||||
// longitude: 120.5853,
|
||||
// size_x: 1.8,
|
||||
// size_y: 4.2,
|
||||
// size_z: 1.5,
|
||||
// angle: 30,
|
||||
// class_name: "车辆"
|
||||
// },
|
||||
// {
|
||||
// track_id: "obs-p-002",
|
||||
// latitude: 31.2992,
|
||||
// longitude: 120.5856,
|
||||
// size_x: 0.6,
|
||||
// size_y: 0.6,
|
||||
// size_z: 1.7,
|
||||
// angle: 0,
|
||||
// class_name: "行人"
|
||||
// },
|
||||
// //{
|
||||
// // track_id: "obs-f-003",
|
||||
// // latitude: 31.2987,
|
||||
// // longitude: 120.5850,
|
||||
// // size_x: 3.0,
|
||||
// // size_y: 0.5,
|
||||
// // size_z: 2.0,
|
||||
// // angle: 90,
|
||||
// // class_name: "施工围挡"
|
||||
// //}
|
||||
// ]
|
||||
// };
|
||||
// updateLiveObstacleBoxes(mockMsg);
|
||||
// }, 3000);
|
||||
|
||||
// return () => clearTimeout(timer);
|
||||
//}, [stationId]);
|
||||
|
||||
|
||||
const handleDetectFn = (res) => {
|
||||
console.log(res, "监测到障碍物")
|
||||
const viewer = viewerRef.current;
|
||||
updateLiveObstacleBoxes(viewer, res);
|
||||
if (!res) return;
|
||||
updateLiveObstacleBoxes(res);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ export default function AlarmCenterPage() {
|
||||
},
|
||||
{
|
||||
title: t('alerts.reportValue'),
|
||||
dataIndex: 'time_values',
|
||||
dataIndex: 'timeValues',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
@@ -849,9 +849,9 @@ export default function AlarmCenterPage() {
|
||||
</Row>
|
||||
|
||||
{/* 告警详情抽屉 */}
|
||||
<Drawer
|
||||
title={t('alerts.alertDetail')}
|
||||
open={drawerVisible}
|
||||
<Drawer
|
||||
title={t('alerts.alertDetail')}
|
||||
open={drawerVisible}
|
||||
onClose={() => setDrawerVisible(false)}
|
||||
width={480}
|
||||
destroyOnClose
|
||||
@@ -878,9 +878,9 @@ export default function AlarmCenterPage() {
|
||||
|
||||
{/* 告警基础信息 */}
|
||||
<Descriptions column={1} bordered size="small" style={{ marginBottom: 16 }}>
|
||||
<Descriptions.Item label={t('alerts.sourceDevice')}>{currentAlarm.deviceName || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.alertType')}>{alarmTypeMap[currentAlarm.alarmType] || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.occurTime')}>{dayjs(currentAlarm.alarmTime).format('YYYY-MM-DD HH:mm:ss')}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.sourceDevice')}>{currentAlarm.deviceName || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.alertType')}>{alarmTypeMap[currentAlarm.alarmType] || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.occurTime')}>{dayjs(currentAlarm.alarmTime).format('YYYY-MM-DD HH:mm:ss')}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.handleStatus')}>
|
||||
{(() => {
|
||||
let color = 'default';
|
||||
@@ -924,32 +924,32 @@ export default function AlarmCenterPage() {
|
||||
|
||||
{/* 处理操作 */}
|
||||
<Card size="small" title={t('alerts.handleOperation')} style={{ marginBottom: 16 }}>
|
||||
<Form.Item label={t('alerts.handleStatus')} name="handleStatus" rules={[{ required: true, message: t('alerts.pleaseSelectHandleStatus') }]}>
|
||||
<Select>
|
||||
<Option value={1}>{t('constants.pending')}</Option>
|
||||
<Form.Item label={t('alerts.handleStatus')} name="handleStatus" rules={[{ required: true, message: t('alerts.pleaseSelectHandleStatus') }]}>
|
||||
<Select>
|
||||
<Option value={1}>{t('constants.pending')}</Option>
|
||||
|
||||
<Option value={2}>{t('constants.closed')}</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('alerts.handleResult')} name="handleResult" rules={[{ required: true, message: t('alerts.pleaseSelectHandleResult') }]}>
|
||||
<Select
|
||||
placeholder={t('alerts.pleaseSelectHandleResult')}
|
||||
options={alarmHandleResultOptions}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('alerts.rootCause')} name="rootCause">
|
||||
<Input.TextArea rows={2} placeholder={t('alerts.pleaseInputHandleRemark')} />
|
||||
</Form.Item>
|
||||
<Form.Item label={t('alerts.handleRemark')} name="handleRemark">
|
||||
<Input.TextArea rows={2} placeholder={t('alerts.pleaseInputHandleRemark')} />
|
||||
</Form.Item>
|
||||
<Option value={2}>{t('constants.closed')}</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('alerts.handleResult')} name="handleResult" rules={[{ required: true, message: t('alerts.pleaseSelectHandleResult') }]}>
|
||||
<Select
|
||||
placeholder={t('alerts.pleaseSelectHandleResult')}
|
||||
options={alarmHandleResultOptions}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('alerts.rootCause')} name="rootCause">
|
||||
<Input.TextArea rows={2} placeholder={t('alerts.pleaseInputHandleRemark')} />
|
||||
</Form.Item>
|
||||
<Form.Item label={t('alerts.handleRemark')} name="handleRemark">
|
||||
<Input.TextArea rows={2} placeholder={t('alerts.pleaseInputHandleRemark')} />
|
||||
</Form.Item>
|
||||
|
||||
|
||||
|
||||
</Card>
|
||||
</Card>
|
||||
|
||||
{/* 底部按钮 */}
|
||||
<Button type="primary" block htmlType="submit">{t('alerts.confirmHandle')}</Button>
|
||||
{/* 底部按钮 */}
|
||||
<Button type="primary" block htmlType="submit">{t('alerts.confirmHandle')}</Button>
|
||||
|
||||
</>
|
||||
</Form>
|
||||
@@ -958,9 +958,9 @@ export default function AlarmCenterPage() {
|
||||
</Drawer>
|
||||
|
||||
{/* ====================== 修改告警弹窗 ====================== */}
|
||||
<Modal
|
||||
title={t('alerts.modifyAlert')}
|
||||
open={editModalVisible}
|
||||
<Modal
|
||||
title={t('alerts.modifyAlert')}
|
||||
open={editModalVisible}
|
||||
onCancel={() => setEditModalVisible(false)}
|
||||
footer={null}
|
||||
width={520}
|
||||
|
||||
@@ -456,23 +456,7 @@ export default function DeviceStatusPage() {
|
||||
|
||||
|
||||
|
||||
// 开关切换回调
|
||||
|
||||
const handleChange = (checked: boolean) => {
|
||||
|
||||
setIsLoopMode(checked);
|
||||
|
||||
if (checked) {
|
||||
|
||||
console.log('当前作业方式:回字');
|
||||
|
||||
} else {
|
||||
|
||||
console.log('当前作业方式:单点');
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1016,32 +1000,33 @@ export default function DeviceStatusPage() {
|
||||
|
||||
}, [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, runningStatus]);
|
||||
// 统一在线状态判断:优先实时数据,兜底接口数据
|
||||
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,]);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ import { MowerAllView } from './mowerAllView.jsx';
|
||||
import { useWebRTCPlayer } from '../useWebRTCStream.js';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { getStationRegions } from '@/api/stationManage/index.js';
|
||||
import { Reorder } from 'motion/react';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const { RangePicker } = DatePicker;
|
||||
@@ -73,7 +74,7 @@ export default function RobotTaskPage() {
|
||||
const { modal } = App.useApp();
|
||||
const [polyPoints, setPolyPoints] = useState([]);
|
||||
const [detectReportInfo, setDeportInfo] = useState<any>(null);
|
||||
|
||||
const [selectedDeviceMap, setSelectedDeviceMap] = useState<Record<string, string>>({});
|
||||
|
||||
|
||||
|
||||
@@ -896,7 +897,10 @@ export default function RobotTaskPage() {
|
||||
utils.message.error(t('devices.fixed2ResumeTaskFixed2AbnormalFixed2'));
|
||||
}
|
||||
};
|
||||
|
||||
const handleContinueWord = (record: any, selectSn: string) => {
|
||||
console.log('当前行选中设备sn:', selectSn, record);
|
||||
// 你的原有业务逻辑
|
||||
};
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
@@ -1156,7 +1160,7 @@ export default function RobotTaskPage() {
|
||||
{
|
||||
title: t('devices.device'),
|
||||
dataIndex: 'deviceId',
|
||||
width: 320,
|
||||
width: 220,
|
||||
},
|
||||
{
|
||||
title: t('roles.status'),
|
||||
@@ -1189,6 +1193,49 @@ export default function RobotTaskPage() {
|
||||
title: t('common.createTime'),
|
||||
dataIndex: 'createTime',
|
||||
width: 170,
|
||||
}, {
|
||||
title: t('common.operation'),
|
||||
width: 170,
|
||||
|
||||
render: (_text, record) => {
|
||||
// 哪些状态显示【继续作业】:FINISH 完成 / FAILED 失败 / CANCEL 取消
|
||||
const showContinueBtn = ['FAILED', 'CANCELED'].includes(record.taskStaus);
|
||||
|
||||
if (!showContinueBtn) return null;
|
||||
const currentSn = selectedDeviceMap[record.taskId] ?? record.serialNumber;
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
||||
<Select
|
||||
placeholder={t('devices.taskSelectRobot')}
|
||||
value={currentSn}
|
||||
onChange={(val) => {
|
||||
setSelectedDeviceMap(prev => ({
|
||||
...prev,
|
||||
[record.taskId]: val
|
||||
}));
|
||||
}}
|
||||
szie="small"
|
||||
style={{ flex: 1, minWidth: 100 }}
|
||||
options={(devices || []).map(item => ({
|
||||
value: item.serialNumber,
|
||||
label: `${item.deviceAlias || item.deviceName} (${item.serialNumber})`
|
||||
}))}
|
||||
/>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
const chooseSn = selectedDeviceMap[record.taskId] ?? record.serialNumber;
|
||||
handleContinueWord(record, chooseSn);
|
||||
}}
|
||||
>
|
||||
{t('devices.continueWork')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
);
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
@@ -1256,6 +1303,21 @@ export default function RobotTaskPage() {
|
||||
return (routeList || []).filter(rt => ids.has(rt.id));
|
||||
}, [regionList, dispatchRegionIds, routeList]);
|
||||
|
||||
// 选中的路径对象列表(用于拖拽排序显示)
|
||||
const selectedRouteObjects = useMemo(() => {
|
||||
// 根据 dispatchRouteIds 的顺序返回路径对象
|
||||
return dispatchRouteIds
|
||||
.map(id => routeList.find(r => r.id === id))
|
||||
.filter(Boolean);
|
||||
}, [dispatchRouteIds, routeList]);
|
||||
|
||||
// 监听路径顺序变化并打印
|
||||
useEffect(() => {
|
||||
if (dispatchRouteIds.length > 0) {
|
||||
console.log('当前已选路径 ID 顺序:', dispatchRouteIds);
|
||||
}
|
||||
}, [dispatchRouteIds]);
|
||||
|
||||
// 定时任务:周/月选项
|
||||
const weekDays = [
|
||||
{ label: t('devices.wdSun'), value: 'SUNDAY' },
|
||||
@@ -2162,136 +2224,211 @@ export default function RobotTaskPage() {
|
||||
)}
|
||||
</div>
|
||||
{dispatchRegionIds.length > 0 && (
|
||||
<div>
|
||||
<div style={{ fontWeight: 600, marginBottom: 8 }}>{t('devices.taskSelectRoute')}</div>
|
||||
{regionAvailableRoutes.length === 0 ? (
|
||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={t('devices.noRouteInRegion')} />
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
||||
<div>
|
||||
<div style={{ fontWeight: 600, marginBottom: 8 }}>{t('devices.taskSelectRoute')}</div>
|
||||
{regionAvailableRoutes.length === 0 ? (
|
||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={t('devices.noRouteInRegion')} />
|
||||
) : (
|
||||
<div
|
||||
style={{
|
||||
width: '100%',
|
||||
boxSizing: 'border-box',
|
||||
padding: 8,
|
||||
border: '1px solid #e6edf5',
|
||||
borderRadius: 6,
|
||||
background: '#fff',
|
||||
}}
|
||||
>
|
||||
{/* 顶部提示文字 */}
|
||||
<div
|
||||
style={{
|
||||
marginBottom: 8,
|
||||
color: '#8c9bb0',
|
||||
fontSize: 11,
|
||||
lineHeight: '16px',
|
||||
}}
|
||||
>
|
||||
选择需要执行任务的路线(可多选)
|
||||
</div>
|
||||
|
||||
{/* 路线选择卡片 */}
|
||||
<div
|
||||
style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: 'repeat(4, minmax(0, 1fr))',
|
||||
gap: 8,
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
{regionAvailableRoutes.map((route, index) => {
|
||||
const checked = dispatchRouteIds.includes(route.id);
|
||||
|
||||
const regionColors = [
|
||||
'#1677ff',
|
||||
'#13b879',
|
||||
'#fa8c16',
|
||||
'#a33cff',
|
||||
];
|
||||
|
||||
const color = regionColors[index % regionColors.length];
|
||||
|
||||
return (
|
||||
<Tag.CheckableTag
|
||||
key={route.id}
|
||||
checked={checked}
|
||||
onChange={nextChecked => {
|
||||
setDispatchRouteIds(prev =>
|
||||
nextChecked
|
||||
? [...prev, route.id]
|
||||
: prev.filter(id => id !== route.id)
|
||||
);
|
||||
|
||||
if (nextChecked) {
|
||||
flyToRoute(route.id);
|
||||
}
|
||||
}}
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 5,
|
||||
width: '100%',
|
||||
minWidth: 0,
|
||||
height: 40,
|
||||
boxSizing: 'border-box',
|
||||
margin: 0,
|
||||
padding: '0 8px',
|
||||
color: '#344054',
|
||||
background: '#fff',
|
||||
border: '1px solid #dce5f2',
|
||||
borderRadius: 4,
|
||||
fontSize: 12,
|
||||
lineHeight: 'normal',
|
||||
cursor: 'pointer',
|
||||
overflow: 'hidden',
|
||||
}}
|
||||
>
|
||||
{/* 自定义复选框 */}
|
||||
<span
|
||||
style={{
|
||||
display: 'inline-flex',
|
||||
flex: '0 0 12px',
|
||||
width: 12,
|
||||
height: 12,
|
||||
boxSizing: 'border-box',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
border: `1px solid ${checked ? color : '#cbd5e1'}`,
|
||||
borderRadius: 3,
|
||||
background: checked ? color : '#fff',
|
||||
color: '#fff',
|
||||
fontSize: 10,
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
{checked ? '✓' : ''}
|
||||
</span>
|
||||
|
||||
{/* 路线定位图标 */}
|
||||
<EnvironmentFilled
|
||||
style={{
|
||||
flex: '0 0 auto',
|
||||
color,
|
||||
fontSize: 13,
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* 路线名称 */}
|
||||
<span
|
||||
style={{
|
||||
flex: 1,
|
||||
minWidth: 0,
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
color: '#344054',
|
||||
}}
|
||||
>
|
||||
{route.workName || route.name}
|
||||
</span>
|
||||
</Tag.CheckableTag>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 已选路径顺序调节 */}
|
||||
{dispatchRouteIds.length > 1 && (
|
||||
<div
|
||||
style={{
|
||||
width: '100%',
|
||||
boxSizing: 'border-box',
|
||||
padding: 8,
|
||||
border: '1px solid #e6edf5',
|
||||
borderRadius: 6,
|
||||
background: '#fff',
|
||||
padding: '12px',
|
||||
background: '#f8faff',
|
||||
border: '1px dashed #d6e4ff',
|
||||
borderRadius: 8,
|
||||
}}
|
||||
>
|
||||
{/* 顶部提示文字 */}
|
||||
<div
|
||||
style={{
|
||||
marginBottom: 8,
|
||||
color: '#8c9bb0',
|
||||
fontSize: 11,
|
||||
lineHeight: '16px',
|
||||
}}
|
||||
>
|
||||
选择需要执行任务的路线(可多选)
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 12 }}>
|
||||
<TrendingUp size={16} style={{ color: '#1677ff' }} />
|
||||
<span style={{ fontWeight: 600, fontSize: 13, color: '#1d2129' }}>调节执行顺序 (拖拽排序)</span>
|
||||
<Tooltip title="机器人将按照下方列表从上到下的顺序依次执行路径任务">
|
||||
<AlertCircle size={14} style={{ color: '#86909c', cursor: 'help' }} />
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
{/* 路线选择卡片 */}
|
||||
<div
|
||||
style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: 'repeat(4, minmax(0, 1fr))',
|
||||
gap: 8,
|
||||
width: '100%',
|
||||
}}
|
||||
<Reorder.Group
|
||||
axis="y"
|
||||
values={dispatchRouteIds}
|
||||
onReorder={setDispatchRouteIds}
|
||||
style={{ listStyle: 'none', padding: 0, margin: 0, display: 'flex', flexDirection: 'column', gap: 8 }}
|
||||
>
|
||||
{regionAvailableRoutes.map((route, index) => {
|
||||
const checked = dispatchRouteIds.includes(route.id);
|
||||
|
||||
const regionColors = [
|
||||
'#1677ff',
|
||||
'#13b879',
|
||||
'#fa8c16',
|
||||
'#a33cff',
|
||||
];
|
||||
|
||||
const color = regionColors[index % regionColors.length];
|
||||
|
||||
return (
|
||||
<Tag.CheckableTag
|
||||
key={route.id}
|
||||
checked={checked}
|
||||
onChange={nextChecked => {
|
||||
setDispatchRouteIds(prev =>
|
||||
nextChecked
|
||||
? [...prev, route.id]
|
||||
: prev.filter(id => id !== route.id)
|
||||
);
|
||||
|
||||
if (nextChecked) {
|
||||
flyToRoute(route.id);
|
||||
}
|
||||
}}
|
||||
{selectedRouteObjects.map((route, idx) => (
|
||||
<Reorder.Item
|
||||
key={route.id}
|
||||
value={route.id}
|
||||
style={{
|
||||
cursor: 'grab',
|
||||
background: '#fff',
|
||||
border: '1px solid #e6edf5',
|
||||
borderRadius: 6,
|
||||
padding: '8px 12px',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 12,
|
||||
boxShadow: '0 2px 4px rgba(0,0,0,0.02)',
|
||||
}}
|
||||
whileDrag={{
|
||||
scale: 1.02,
|
||||
boxShadow: '0 8px 16px rgba(0,0,0,0.1)',
|
||||
cursor: 'grabbing',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
width: 20,
|
||||
height: 20,
|
||||
background: '#1677ff',
|
||||
color: '#fff',
|
||||
borderRadius: '50%',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 5,
|
||||
width: '100%',
|
||||
minWidth: 0,
|
||||
height: 40,
|
||||
boxSizing: 'border-box',
|
||||
margin: 0,
|
||||
padding: '0 8px',
|
||||
color: '#344054',
|
||||
background: '#fff',
|
||||
border: '1px solid #dce5f2',
|
||||
borderRadius: 4,
|
||||
fontSize: 12,
|
||||
lineHeight: 'normal',
|
||||
cursor: 'pointer',
|
||||
overflow: 'hidden',
|
||||
justifyContent: 'center',
|
||||
fontSize: 11,
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
{/* 自定义复选框 */}
|
||||
<span
|
||||
style={{
|
||||
display: 'inline-flex',
|
||||
flex: '0 0 12px',
|
||||
width: 12,
|
||||
height: 12,
|
||||
boxSizing: 'border-box',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
border: `1px solid ${checked ? color : '#cbd5e1'}`,
|
||||
borderRadius: 3,
|
||||
background: checked ? color : '#fff',
|
||||
color: '#fff',
|
||||
fontSize: 10,
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
{checked ? '✓' : ''}
|
||||
</span>
|
||||
|
||||
{/* 路线定位图标 */}
|
||||
<EnvironmentFilled
|
||||
style={{
|
||||
flex: '0 0 auto',
|
||||
color,
|
||||
fontSize: 13,
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* 路线名称 */}
|
||||
<span
|
||||
style={{
|
||||
flex: 1,
|
||||
minWidth: 0,
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
color: '#344054',
|
||||
}}
|
||||
>
|
||||
{route.workName || route.name}
|
||||
</span>
|
||||
</Tag.CheckableTag>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{idx + 1}
|
||||
</div>
|
||||
<span style={{ flex: 1, fontSize: 13, fontWeight: 500, color: '#344054' }}>
|
||||
{route.workName || route.name}
|
||||
</span>
|
||||
<div style={{ color: '#bfbfbf' }}>
|
||||
<LayoutGrid size={14} />
|
||||
</div>
|
||||
</Reorder.Item>
|
||||
))}
|
||||
</Reorder.Group>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user