优化 map中实时车悬浮的提醒框子,优化已完成任务提醒哪个设备 优化页面 设备类型显示 和 在线状态显示 预设路线分组显示 优化路径规划中的问题

This commit is contained in:
mmc
2026-11-10 17:03:52 +08:00
parent 6401327522
commit ce9f52fc52
10 changed files with 575 additions and 327 deletions

View File

@@ -2,7 +2,8 @@ import React, { useState, useEffect, useMemo, useRef } from 'react';
import {
Row, Col, Card, Typography, Space, Table, Tag, Progress, Badge,
List, Avatar, Button, Statistic, Timeline, Empty, message,
Select
Select,
Tooltip
} from 'antd';
import {
LayoutGrid, PlayCircle, CheckCircle, AlertCircle,
@@ -111,6 +112,13 @@ const TaskMonitorPage: React.FC = () => {
return undefined;
};
// 判断设备是否在线:feStatus 优先(0 离线 / 1 工作中 / 2 空闲),status 兜底(1 工作中 / 2 空闲 / 3 离线)
const isDeviceOnline = (device: any): boolean => {
const rt = pickRealtimeRecord(realtimeMap, device) || {};
const status = String(rt.feStatus ?? rt.status ?? device?.feStatus ?? device?.status ?? '');
return status === '1' || status === '2';
};
// 供 WebSocket 回调始终调用最新的 fetchData
const fetchDataRef = useRef<() => any>(() => { });
@@ -245,7 +253,6 @@ const TaskMonitorPage: React.FC = () => {
console.log(realtimeMap, "realtimeMap")
// 告警车辆数量以实时数据里的 hasAlarm 为准
const alarmDevices = devices.filter(d => !!pickRealtimeRecord(realtimeMap, d)?.hasAlarm);
console.log(alarmDevices, "alarmDevices")
const alarm = alarmDevices.length;
// 与 DeviceStatusPage 一致:有实时数据即在线,兜底接口 onlineStatus
const alarmOnline = alarmDevices.filter(d => pickRealtimeRecord(realtimeMap, d) || d?.onlineStatus == 1).length;
@@ -486,7 +493,9 @@ const TaskMonitorPage: React.FC = () => {
</div>
<div className="vehicle-map-popup__body">
<div className="vehicle-map-popup__row"><span>当前状态</span><strong className={selectedRealtime.status === '1' ? 'is-running' : ''}>{selectedRealtime.status === '1' ? '进行中' : selectedRealtime.status === '2' ? '待命' : '离线'}</strong></div>
<div className="vehicle-map-popup__row"><span>剩余电量</span><strong className={(selectedBattery ?? 85) < 20 ? 'is-low-battery' : ''}>{selectedBattery ?? 85}%</strong></div>
{isDeviceOnline(selectedDevice) && (
<div className="vehicle-map-popup__row"><span>剩余电量</span><strong className={(selectedBattery ?? 85) < 20 ? 'is-low-battery' : ''}>{selectedBattery ?? 85}%</strong></div>
)}
<div className="vehicle-map-popup__row"><span>当前任务</span><strong>{selectedRealtime.workName || "无"}</strong></div>
{/*<div className="vehicle-map-popup__row"><span>设备类型</span><strong>{selectedDevice.deviceTypeName || selectedDevice.deviceType || '车辆'}</strong></div>*/}
<div className="vehicle-map-popup__row"><span>任务进度</span><strong>{selectedRealtime.progress ?? 0}%</strong></div>
@@ -523,6 +532,7 @@ const TaskMonitorPage: React.FC = () => {
renderItem={(item: any) => {
const rt = realtimeMap[item.serialNumber] || {};
const battery = getDeviceBattery(item);
const online = isDeviceOnline(item);
return (
<List.Item
@@ -550,17 +560,41 @@ const TaskMonitorPage: React.FC = () => {
>
<div style={{ display: 'flex', gap: 12, width: '100%' }}>
<Avatar shape="square" size={44} icon={item.deviceType === 'UAV' ? <RocketOutlined /> : <RobotOutlined />} style={{ background: '#f0f7ff', color: '#1890ff' }} />
<div style={{ flex: 1 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 4 }}>
<span style={{ fontWeight: 600, fontSize: 14, color: '#262626' }}>{item.deviceAlias || item.deviceName}</span>
<div style={{ flex: 1, minWidth: 0 }}>
<div
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
marginBottom: 4,
minWidth: 0,
}}
>
<Tooltip title={item.deviceAlias || item.deviceName}>
<span
style={{
fontWeight: 600,
fontSize: 14,
color: '#262626',
display: 'inline-block',
maxWidth: '60%',
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
verticalAlign: 'middle',
}}
>
{item.deviceAlias || item.deviceName}
</span>
</Tooltip>
<Tag
color={rt.status === '1' ? 'blue' : rt.status === '2' ? 'green' : 'default'}
style={{ margin: 0, borderRadius: 4 }}
style={{ margin: 0, borderRadius: 4, flexShrink: 0 }}
>
{rt.status == '1' ? '进行中' : rt.status == '2' ? '待命' : '离线'}
</Tag>
</div>
<div
style={{
display: 'flex',
@@ -572,25 +606,48 @@ const TaskMonitorPage: React.FC = () => {
minWidth: 0,
}}
>
<span>任务: {rt.workName || '无'}</span>
<span
style={{
color: (battery ?? 85) < 20 ? '#ff4d4f' : '#faad14',
display: 'inline-flex',
alignItems: 'center',
gap: 2,
whiteSpace: 'nowrap',
flexShrink: 0,
lineHeight: 1,
}}
>
<Zap size={10} style={{ flexShrink: 0 }} />
{battery ?? 85}%
</span>
{/* 任务名称增加溢出省略 */}
<Tooltip title={rt.workName || '无'}>
<span
style={{
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
flex: 1,
minWidth: 0,
}}
>
任务: {rt.workName || '无'}
</span>
</Tooltip>
{online && (
<span
style={{
color: (battery ?? 85) < 20 ? '#ff4d4f' : '#faad14',
display: 'inline-flex',
alignItems: 'center',
gap: 2,
whiteSpace: 'nowrap',
flexShrink: 0,
lineHeight: 1,
}}
>
<Zap size={10} style={{ flexShrink: 0 }} />
{battery ?? 85}%
</span>
)}
</div>
<Progress percent={rt.progress || 0} size="small" showInfo={false} strokeColor="#52c41a" style={{ marginTop: 6 }} />
{/* Progress 关键:minWidth:0,禁止撑出去 */}
<Progress
percent={rt.progress || 0}
size="small"
showInfo={false}
strokeColor="#52c41a"
style={{ marginTop: 6, width: '100%', minWidth: 0 }}
/>
</div>
</div>
</List.Item>
);
@@ -677,9 +734,10 @@ const TaskMonitorPage: React.FC = () => {
animation: vehiclePopupIn 180ms ease-out;
}
.vehicle-map-popup__header { display:flex; align-items:center; justify-content:space-between; gap:8px; padding: 12px 14px; border-bottom:1px solid #e6f4ff; background:linear-gradient(100deg,#f0f9ff,#fff); }
.vehicle-map-popup__identity { display:flex; align-items:center; gap:10px; min-width:0; }
.vehicle-map-popup__identity { display:flex; align-items:center; gap:10px; min-width:0; flex:1; }
.vehicle-map-popup__identity > div { min-width:0; flex:1; }
.vehicle-map-popup__title { color:#087bd0; font-size:16px; font-weight:700; overflow-wrap:anywhere; }
.vehicle-map-popup__serial { color:#8a9daf; font-size:11px; margin-top:2px; }
.vehicle-map-popup__serial { color:#8a9daf; font-size:11px; margin-top:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; }
.vehicle-map-popup__body { padding: 8px 14px 12px; }
.vehicle-map-popup__row { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:8px 0; border-bottom:1px dashed #e6f4ff; font-size:13px; }
.vehicle-map-popup__row:last-child { border-bottom:0; }