| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- import { isActiveWorkOrderStatus } from './waterSupplyUiModel.js'
- export const gisPointStatusColors = {
- normal: '#2ecc71',
- alarm: '#e74c3c',
- warning: '#f1c40f',
- workOrder: '#3498db',
- offline: '#95a5a6'
- }
- export const gisPointStatusIcons = {
- normal: new URL('../assets/gis/T_MarkPoint_Green.png', import.meta.url).href,
- alarm: new URL('../assets/gis/T_MarkPoint_Red.png', import.meta.url).href,
- warning: new URL('../assets/gis/T_MarkPoint_Yellow.png', import.meta.url).href,
- workOrder: new URL('../assets/gis/T_MarkPoint_Blue.png', import.meta.url).href,
- offline: new URL('../assets/gis/T_MarkPoint_Grey.png', import.meta.url).href
- }
- /**
- * 设施状态语义:与监测设备共用同一套状态色(绿-正常、红-报警/异常、蓝-工单/检修、黄-预警/欠费)。
- * 供水设施 GIS 一张图与首页全域态势都从这里取状态,保证设施颜色只有一处定义。
- * 状态缺失或未维护时按“正常”处理,不臆造异常。
- */
- const facilityStatusMeta = {
- source: {
- 0: { key: 'normal', text: '正常' },
- 1: { key: 'alarm', text: '异常' }
- },
- plant: {
- 0: { key: 'normal', text: '正常' },
- 1: { key: 'alarm', text: '停产' }
- },
- pumpStation: {
- 0: { key: 'normal', text: '正常' },
- 1: { key: 'alarm', text: '故障停运' },
- 2: { key: 'workOrder', text: '检修中' }
- },
- // 管网保持现状:只构造管线,不落点位图标,因此不参与状态色映射
- user: {
- 0: { key: 'normal', text: '正常' },
- 1: { key: 'warning', text: '欠费' },
- 2: { key: 'alarm', text: '停用' }
- }
- }
- export function getFacilityStatusMeta(type = '', status = null) {
- return facilityStatusMeta[type]?.[String(status)] || { key: 'normal', text: '正常' }
- }
- /** 设施点位图标:按状态取图标,管网不落点位图标。 */
- export function getFacilityStatusIcon(type = '', status = null) {
- if (type === 'pipe') return null
- return getMonitoringPointIcon({ statusKey: getFacilityStatusMeta(type, status).key })
- }
- const clusterPointIcon = new URL('../assets/gis/T_MarkPoint_Colorful.png', import.meta.url).href
- export function getMapClusterIcon(points = []) {
- const icons = [...new Set((Array.isArray(points) ? points : [])
- .map(point => point?.iconUrl || getMonitoringPointIcon(point))
- .filter(Boolean))]
- return icons.length === 1 ? icons[0] : clusterPointIcon
- }
- export const gisPointStatusLabels = {
- normal: '正常',
- alarm: '报警',
- warning: '预警',
- workOrder: '关联工单',
- offline: '离线'
- }
- export const gisPointStatusTagTypes = {
- normal: 'success',
- alarm: 'danger',
- warning: 'warning',
- workOrder: 'primary',
- offline: 'info'
- }
- export function getMonitoringPointStatus(point = {}) {
- if (point.statusKey && gisPointStatusColors[point.statusKey]) return point.statusKey
- const relatedOrderNo = point.orderNo ?? point.relatedOrderNo ?? point.relatedWorkOrderNo ?? point.latestOrderNo
- const orderStatus = point.orderStatus ?? point.relatedWorkOrderStatus ?? point.latestMaintainStatus
- const orderIsKnownActive = orderStatus === undefined || orderStatus === null || orderStatus === '' || isActiveWorkOrderStatus(orderStatus)
- if (relatedOrderNo && relatedOrderNo !== '-' && orderIsKnownActive) return 'workOrder'
- if (Number(point.deviceAlarmStatus ?? point.alarmStatus) === 1) return 'alarm'
- if (Number(point.currentStatus) === 3) return 'warning'
- if (Number(point.onlineStatus) === 0) return 'offline'
- return 'normal'
- }
- export function getMonitoringPointColor(point = {}) {
- return gisPointStatusColors[getMonitoringPointStatus(point)] || gisPointStatusColors.normal
- }
- export function getMonitoringPointIcon(point = {}) {
- return gisPointStatusIcons[getMonitoringPointStatus(point)] || gisPointStatusIcons.normal
- }
- export function getMonitoringPointLabel(point = {}) {
- return gisPointStatusLabels[getMonitoringPointStatus(point)] || gisPointStatusLabels.normal
- }
- export function getMonitoringPointTagType(point = {}) {
- return gisPointStatusTagTypes[getMonitoringPointStatus(point)] || gisPointStatusTagTypes.normal
- }
|