|
|
@ -13,7 +13,7 @@ export const findStatusInfo = ( |
|
|
dict: (typeof STATUS_DICT)[keyof typeof STATUS_DICT], |
|
|
dict: (typeof STATUS_DICT)[keyof typeof STATUS_DICT], |
|
|
value: string |
|
|
value: string |
|
|
) => { |
|
|
) => { |
|
|
return dict.find((item) => item.value === value) |
|
|
|
|
|
|
|
|
return dict?.find((item) => item.value === value) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -39,22 +39,22 @@ export const getHighestPriorityStatus = (markerData: { |
|
|
const statuses: string[] = [] |
|
|
const statuses: string[] = [] |
|
|
|
|
|
|
|
|
// 收集非正常状态
|
|
|
// 收集非正常状态
|
|
|
if (markerData.gasStatus !== 0) { |
|
|
|
|
|
|
|
|
if (markerData.gasStatus === 1) { |
|
|
const gasStatusStr = getStatusMapping('gasStatus', String(markerData.gasStatus)) |
|
|
const gasStatusStr = getStatusMapping('gasStatus', String(markerData.gasStatus)) |
|
|
gasStatusStr && statuses.push(gasStatusStr) |
|
|
gasStatusStr && statuses.push(gasStatusStr) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (markerData.batteryStatus !== 0) { |
|
|
|
|
|
|
|
|
if (markerData.batteryStatus === 1) { |
|
|
const batteryStatusStr = getStatusMapping('batteryStatus', String(markerData.batteryStatus)) |
|
|
const batteryStatusStr = getStatusMapping('batteryStatus', String(markerData.batteryStatus)) |
|
|
statuses.push(batteryStatusStr) |
|
|
statuses.push(batteryStatusStr) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (markerData.fenceStatus !== 0) { |
|
|
|
|
|
|
|
|
if (markerData.fenceStatus === 1) { |
|
|
const fenceStatusStr = getStatusMapping('fenceStatus', String(markerData.fenceStatus)) |
|
|
const fenceStatusStr = getStatusMapping('fenceStatus', String(markerData.fenceStatus)) |
|
|
fenceStatusStr && statuses.push(fenceStatusStr) |
|
|
fenceStatusStr && statuses.push(fenceStatusStr) |
|
|
} |
|
|
} |
|
|
// 检查各种状态
|
|
|
// 检查各种状态
|
|
|
const onlineStatus = String(markerData.onlineStatus) === '0' ? 'offline' : null |
|
|
|
|
|
|
|
|
const onlineStatus = String(markerData.onlineStatus) !== '1' ? 'offline' : null |
|
|
if (onlineStatus) { |
|
|
if (onlineStatus) { |
|
|
statuses.push(onlineStatus) |
|
|
statuses.push(onlineStatus) |
|
|
} |
|
|
} |
|
|
@ -75,6 +75,8 @@ export const getHighestPriorityStatus = (markerData: { |
|
|
export const getStatusColor = (status: string | keyof typeof STATUS_PRIORITY): string => { |
|
|
export const getStatusColor = (status: string | keyof typeof STATUS_PRIORITY): string => { |
|
|
if (status === 'normal') return '#67c23a' |
|
|
if (status === 'normal') return '#67c23a' |
|
|
if (status === 'offline') return STATUS_DICT.onlineStatus[0].cssClass |
|
|
if (status === 'offline') return STATUS_DICT.onlineStatus[0].cssClass |
|
|
|
|
|
// 安全校验,确保状态字符串格式正确
|
|
|
|
|
|
if (!status.includes('_')) return '' |
|
|
|
|
|
|
|
|
const [type, value] = status.split('_') as [keyof typeof STATUS_DICT, string] |
|
|
const [type, value] = status.split('_') as [keyof typeof STATUS_DICT, string] |
|
|
const info = findStatusInfo(STATUS_DICT[type], value) |
|
|
const info = findStatusInfo(STATUS_DICT[type], value) |
|
|
@ -87,6 +89,8 @@ export const getStatusColor = (status: string | keyof typeof STATUS_PRIORITY): s |
|
|
export const getStatusLabel = (status: string | keyof typeof STATUS_PRIORITY): string => { |
|
|
export const getStatusLabel = (status: string | keyof typeof STATUS_PRIORITY): string => { |
|
|
if (status === 'normal') return '正常' |
|
|
if (status === 'normal') return '正常' |
|
|
if (status === 'offline') return STATUS_DICT.onlineStatus[0].label |
|
|
if (status === 'offline') return STATUS_DICT.onlineStatus[0].label |
|
|
|
|
|
// 安全校验,确保状态字符串格式正确
|
|
|
|
|
|
if (!status.includes('_')) return '' |
|
|
|
|
|
|
|
|
const [type, value] = status.split('_') as [keyof typeof STATUS_DICT, string] |
|
|
const [type, value] = status.split('_') as [keyof typeof STATUS_DICT, string] |
|
|
const info = findStatusInfo(STATUS_DICT[type], value) |
|
|
const info = findStatusInfo(STATUS_DICT[type], value) |
|
|
|