gis-bi/core/core-frontend/src/utils/viewUtils.ts

36 lines
1.1 KiB
Java
Raw Normal View History

2025-02-27 14:44:08 +08:00
import { getRange } from '@/utils/timeUitils'
import { union } from 'lodash-es'
export function viewFieldTimeTrans(viewDataInfo, params) {
if (viewDataInfo && params && params.dimensionList) {
const fields = viewDataInfo.fields
? viewDataInfo.fields
: viewDataInfo.left?.fields || viewDataInfo.right?.fields
? union(viewDataInfo.left?.fields, viewDataInfo.right?.fields)
: []
const idNameMap = fields.reduce((pre, next) => {
2025-06-25 10:20:27 +08:00
pre[next['id']] = next['gisbiName']
2025-02-27 14:44:08 +08:00
return pre
}, {})
const nameTypeMap = fields.reduce((pre, next) => {
2025-06-25 10:20:27 +08:00
pre[next['gisbiName']] = next['deType']
2025-02-27 14:44:08 +08:00
return pre
}, {})
const nameDateStyleMap = fields.reduce((pre, next) => {
2025-06-25 10:20:27 +08:00
pre[next['gisbiName']] = next['dateStyle']
2025-02-27 14:44:08 +08:00
return pre
}, {})
params.dimensionList.forEach(dimension => {
2025-06-25 10:20:27 +08:00
const gisbiName = idNameMap[dimension.id]
2025-02-27 14:44:08 +08:00
// deType === 1 表示是时间类型
2025-06-25 10:20:27 +08:00
if (nameTypeMap[gisbiName] === 1) {
dimension['timeValue'] = getRange(dimension.value, nameDateStyleMap[gisbiName])
2025-02-27 14:44:08 +08:00
}
})
}
}