Browse Source

弹窗状态提前处理

master
xh 1 day ago
parent
commit
ca8736c2fb
  1. 5
      web/src/views/HandDevice/Home/components/services/popup.service.ts
  2. 11
      web/src/views/HandDevice/Home/components/services/trajectory.service.ts

5
web/src/views/HandDevice/Home/components/services/popup.service.ts

@ -39,11 +39,10 @@ export class PopupService {
* *
*/ */
handleSingleMarkerPopup(markerData: MarkerData): string { handleSingleMarkerPopup(markerData: MarkerData): string {
const statusStr = markerData.statusStr || 'normal'
return ` return `
<div style="font-weight: bold; margin-bottom: 4px;">${markerData.name}</div> <div style="font-weight: bold; margin-bottom: 4px;">${markerData.name}</div>
<div style="color: ${getStatusColor(statusStr)};">
状态: ${getStatusLabel(statusStr)}
<div style="color: ${markerData.statusColor};">
状态: ${markerData.statusLabel}
</div> </div>
<div>在线状态: ${getLabelWithTypeValue('onlineStatus', markerData.onlineStatus)}</div> <div>在线状态: ${getLabelWithTypeValue('onlineStatus', markerData.onlineStatus)}</div>

11
web/src/views/HandDevice/Home/components/services/trajectory.service.ts

@ -66,16 +66,16 @@ export class TrajectoryService {
if (pointData) { if (pointData) {
// 将点数据构造为MarkerData格式以使用现有的状态计算函数 // 将点数据构造为MarkerData格式以使用现有的状态计算函数
const markerData = {
id: -1,
coordinates: [0, 0] as [number, number],
name: '',
const markerStatusData = {
// id: -1,
// coordinates: [0, 0] as [number, number],
// name: '',
gasStatus: pointData.gasStatus || '0', gasStatus: pointData.gasStatus || '0',
batteryStatus: pointData.batteryStatus || '0', batteryStatus: pointData.batteryStatus || '0',
fenceStatus: pointData.fenceStatus || '0', fenceStatus: pointData.fenceStatus || '0',
onlineStatus: pointData.onlineStatus || '1' onlineStatus: pointData.onlineStatus || '1'
} }
const status = getHighestPriorityStatus(markerData)
const status = getHighestPriorityStatus(markerStatusData)
color = getStatusColor(status) color = getStatusColor(status)
} }
@ -230,6 +230,7 @@ export class TrajectoryService {
let closestPoint: TrajectoryPoint | null = null let closestPoint: TrajectoryPoint | null = null
let minDiff = Infinity let minDiff = Infinity
//TODO: 这里可以优化:按秒级取最近点,而不是遍历所有点
trajectory.points.forEach((point) => { trajectory.points.forEach((point) => {
if (point.timestamp <= timestamp) { if (point.timestamp <= timestamp) {
const diff = Math.abs(point.timestamp - timestamp) const diff = Math.abs(point.timestamp - timestamp)

Loading…
Cancel
Save