diff --git a/features/workbench/components/feature-insight-panel.tsx b/features/workbench/components/feature-insight-panel.tsx index 2a1b4f8..4a132be 100644 --- a/features/workbench/components/feature-insight-panel.tsx +++ b/features/workbench/components/feature-insight-panel.tsx @@ -9,8 +9,10 @@ import { SCADA_ICON_PATHS } from "../map/scada"; import type { DetailFeature } from "../types"; import { formatFeaturePropertyValue, + getFeatureInsightMetrics, getLocalizedFeatureProperties } from "../utils/feature-properties"; +import { FeaturePropertyList } from "./feature-property-list"; type FeatureInsightPanelProps = { feature: DetailFeature | null; @@ -32,50 +34,7 @@ export function FeatureInsightPanel({ feature, onClose }: FeatureInsightPanelPro return []; } - switch (feature.layer) { - case "conduits": - return [ - ["管径", formatFeaturePropertyValue("diameter", feature.properties.diameter)], - ["长度", formatFeaturePropertyValue("length", feature.properties.length)], - ["粗糙系数", formatFeaturePropertyValue("roughness", feature.properties.roughness)], - ["状态", formatFeaturePropertyValue("status", feature.properties.status)] - ]; - case "junctions": - return [ - ["最大深度", formatFeaturePropertyValue("max_depth", feature.properties.max_depth)], - ["井底高程", formatFeaturePropertyValue("invert_elevation", feature.properties.invert_elevation)], - ["对象类型", "检查井"], - ["状态", "在线"] - ]; - case "orifices": - return [ - ["孔口类型", formatFeaturePropertyValue("orifice_type", feature.properties.orifice_type)], - ["断面形状", formatFeaturePropertyValue("shape", feature.properties.shape)], - ["流量系数", formatFeaturePropertyValue("discharge_coeff", feature.properties.discharge_coeff)], - ["闸门", formatFeaturePropertyValue("gated", feature.properties.gated)] - ]; - case "pumps": - return [ - ["状态", formatFeaturePropertyValue("status", feature.properties.status)], - ["泵曲线", formatFeaturePropertyValue("pump_curve", feature.properties.pump_curve)], - ["启动水深", formatFeaturePropertyValue("startup_depth", feature.properties.startup_depth)], - ["停泵水深", formatFeaturePropertyValue("shutoff_depth", feature.properties.shutoff_depth)] - ]; - case "outfalls": - return [ - ["排放类型", formatFeaturePropertyValue("outfall_type", feature.properties.outfall_type)], - ["井底高程", formatFeaturePropertyValue("invert_elevation", feature.properties.invert_elevation)], - ["阶段数据", formatFeaturePropertyValue("stage_data", feature.properties.stage_data)], - ["状态", "在线"] - ]; - case "scada": - return [ - ["设备类型", formatFeaturePropertyValue("kind", feature.properties.kind)], - ["运行状态", formatFeaturePropertyValue("active", feature.properties.active)], - ["关联检查井", formatFeaturePropertyValue("junction_id", feature.properties.junction_id)], - ["同步时间", formatFeaturePropertyValue("synced_at", feature.properties.synced_at)] - ]; - } + return getFeatureInsightMetrics(feature.layer, feature.properties); }, [feature]); const propertyEntries = useMemo(() => { @@ -83,14 +42,13 @@ export function FeatureInsightPanel({ feature, onClose }: FeatureInsightPanelPro return []; } - const properties = feature.layer === "scada" && feature.properties.scada_id === undefined - ? { scada_id: feature.id, ...feature.properties } - : feature.properties; - return getLocalizedFeatureProperties(properties); + return feature.layer === "scada" + ? [] + : getLocalizedFeatureProperties(feature.properties); }, [feature]); const scadaQueryUuid = feature?.layer === "scada" - ? getCopyablePropertyValue(feature.properties.scada_id ?? feature.id) + ? getCopyablePropertyValue(feature.properties.sensor_id ?? feature.id) : null; const handleCopyScadaUuid = async () => { @@ -148,11 +106,23 @@ export function FeatureInsightPanel({ feature, onClose }: FeatureInsightPanelPro
{label}
-{value}
+{value}
{formatFeaturePropertyValue("name", feature.properties.name)}
-{formatFeaturePropertyValue("external_id", feature.properties.external_id)}
+{formatFeaturePropertyValue("sensor_name", feature.properties.sensor_name)}
+{formatFeaturePropertyValue("sensor_id", feature.properties.sensor_id ?? feature.id)}
编号 UUID
+传感器 ID
{scadaQueryUuid}
-SCADA 时序查询 asset_ids
+SCADA 时序查询 sensor_id
当前点位由管网节点空间均匀采样生成,仅用于空间展示,不代表设备真实安装坐标。图层暂未提供实时测值或历史曲线。
+设备类型为综合监测点,数据源为 geo_scadas_mat。
) : null} @@ -199,20 +169,14 @@ export function FeatureInsightPanel({ feature, onClose }: FeatureInsightPanelPro -暂无可展示属性
diff --git a/features/workbench/components/feature-property-list.tsx b/features/workbench/components/feature-property-list.tsx new file mode 100644 index 0000000..fcc2843 --- /dev/null +++ b/features/workbench/components/feature-property-list.tsx @@ -0,0 +1,51 @@ +import { cn } from "@/lib/utils"; +import type { LocalizedFeatureProperty } from "../utils/feature-properties"; + +type FeaturePropertyListProps = { + entries: LocalizedFeatureProperty[]; + variant?: "insight" | "popover"; +}; + +export function FeaturePropertyList({ + entries, + variant = "insight" +}: FeaturePropertyListProps) { + if (entries.length === 0) { + return暂无可展示属性
; + } + + return ( +