feat(scada): align map asset fields

This commit is contained in:
2026-07-15 18:30:12 +08:00
parent 16ecb69d00
commit 055335e404
11 changed files with 153 additions and 71 deletions
+5 -3
View File
@@ -3,10 +3,12 @@ import type { DetailFeature } from "../types";
import { formatValue } from "../utils/format-value";
import { SOURCE_LAYERS, type WaterNetworkSourceId } from "./sources";
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
export function getFeatureId(feature: MapGeoJSONFeature) {
const layer = getWaterNetworkSourceId(feature);
const raw = layer === "scada"
? feature.id ?? feature.properties?.id ?? feature.properties?.point_id ?? feature.properties?.point_external_id
? feature.properties?.scada_id ?? (typeof feature.id === "string" && UUID_PATTERN.test(feature.id) ? feature.id : undefined)
: feature.id ?? feature.properties?.id;
return raw === undefined || raw === null ? "" : String(raw);
@@ -70,8 +72,8 @@ function getFeaturePresentation(
};
case "scada":
return {
title: String(properties.point_name || `SCADA 测点 ${displayId}`),
subtitle: `${formatValue(properties.device_type_name)} · 设备 ${formatValue(properties.device_external_id)}`
title: String(properties.name || `SCADA 测点 ${displayId}`),
subtitle: `${formatValue(properties.kind)} · 设备 ${formatValue(properties.external_id)}`
};
}
}