告警记录保存位置快照
This commit is contained in:
@@ -336,6 +336,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
.alarm-row-vertical {
|
||||
align-items: flex-start;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.alarm-label {
|
||||
font-size: 28px;
|
||||
color: #666666;
|
||||
@@ -349,6 +354,28 @@
|
||||
color: #1A1A1A;
|
||||
}
|
||||
|
||||
.alarm-location-value {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.alarm-location-main {
|
||||
display: block;
|
||||
font-size: 28px;
|
||||
line-height: 1.5;
|
||||
word-break: break-all;
|
||||
color: #1A1A1A;
|
||||
}
|
||||
|
||||
.alarm-location-hint {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
font-size: 22px;
|
||||
line-height: 1.5;
|
||||
color: #9CA3AF;
|
||||
}
|
||||
|
||||
.alarm-empty {
|
||||
padding: 24px;
|
||||
}
|
||||
@@ -434,6 +461,22 @@
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.alarm-history-location,
|
||||
.alarm-history-location-hint {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
font-size: 24px;
|
||||
line-height: 1.5;
|
||||
color: #4B5563;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.alarm-history-location-hint {
|
||||
margin-top: 4px;
|
||||
font-size: 22px;
|
||||
color: #9CA3AF;
|
||||
}
|
||||
|
||||
.alarm-history-empty {
|
||||
padding: 8px 0 4px;
|
||||
}
|
||||
|
||||
@@ -78,6 +78,32 @@ function getAlarmChildLabel(alarm: DeviceAlarmItem | null, fallbackChildName?: s
|
||||
return '未关联儿童'
|
||||
}
|
||||
|
||||
function formatAlarmCoordinates(alarm: DeviceAlarmItem | null): string {
|
||||
if (!alarm || alarm.lat === null || alarm.lat === undefined || alarm.lng === null || alarm.lng === undefined) {
|
||||
return ''
|
||||
}
|
||||
return `${Number(alarm.lat).toFixed(6)}, ${Number(alarm.lng).toFixed(6)}`
|
||||
}
|
||||
|
||||
function getAlarmLocationLabel(alarm: DeviceAlarmItem | null): string {
|
||||
const address = String(alarm?.address || '').trim()
|
||||
if (address) return address
|
||||
|
||||
const coordinates = formatAlarmCoordinates(alarm)
|
||||
if (coordinates) return coordinates
|
||||
|
||||
return '暂无告警位置'
|
||||
}
|
||||
|
||||
function getAlarmLocationHint(alarm: DeviceAlarmItem | null): string {
|
||||
if (!alarm?.location_updated_at) return '设备还没有可关联的位置上报'
|
||||
const prefix = `位置更新于 ${formatAlarmTime(alarm.location_updated_at)}`
|
||||
if (alarm.location_stale) return `${prefix},可能不是告警发生时的位置`
|
||||
if (!String(alarm.address || '').trim() && alarm.address_resolve_status === 0) return `${prefix},地址解析中`
|
||||
if (!String(alarm.address || '').trim() && alarm.address_resolve_status === 2) return `${prefix},地址解析失败`
|
||||
return prefix
|
||||
}
|
||||
|
||||
export default function Device() {
|
||||
const systemBanner = useSystemBanner()
|
||||
const [binding, setBinding] = useState<Binding | null>(null)
|
||||
@@ -425,6 +451,13 @@ export default function Device() {
|
||||
<Text className='alarm-label'>上报类型</Text>
|
||||
<Text className='alarm-value'>{getAlarmTypeLabel(latestAlarm.source_msg_id)}</Text>
|
||||
</View>
|
||||
<View className='alarm-row alarm-row-vertical'>
|
||||
<Text className='alarm-label'>告警位置</Text>
|
||||
<View className='alarm-location-value'>
|
||||
<Text className='alarm-location-main'>{getAlarmLocationLabel(latestAlarm)}</Text>
|
||||
<Text className='alarm-location-hint'>{getAlarmLocationHint(latestAlarm)}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className='alarm-history'>
|
||||
@@ -446,6 +479,10 @@ export default function Device() {
|
||||
</Text>
|
||||
<Text className='alarm-history-device'>{alarm.device_id}</Text>
|
||||
</View>
|
||||
<Text className='alarm-history-location'>{getAlarmLocationLabel(alarm)}</Text>
|
||||
{alarm.location_stale ? (
|
||||
<Text className='alarm-history-location-hint'>位置可能不是告警发生时的位置</Text>
|
||||
) : null}
|
||||
</View>
|
||||
))
|
||||
) : (
|
||||
|
||||
@@ -45,6 +45,14 @@ export interface DeviceAlarmItem {
|
||||
child_id?: number | null
|
||||
child_name?: string | null
|
||||
source_msg_id: string
|
||||
coord_type?: string | null
|
||||
lat?: number | null
|
||||
lng?: number | null
|
||||
location_updated_at?: string | null
|
||||
location_stale?: boolean
|
||||
address?: string | null
|
||||
address_resolved_at?: string | null
|
||||
address_resolve_status?: number | null
|
||||
created_at: string
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user