Дата удалена из текущих значений

This commit is contained in:
Александр Сироткин 2022-11-21 08:49:21 +05:00
parent fc91cfc6ff
commit 871e71e777

View File

@ -1,7 +1,6 @@
import { isValidElement, memo, useEffect, useMemo, useState } from 'react' import { isValidElement, memo, useEffect, useMemo, useState } from 'react'
import { CaretUpOutlined, CaretDownOutlined, CaretRightOutlined } from '@ant-design/icons' import { CaretUpOutlined, CaretDownOutlined, CaretRightOutlined } from '@ant-design/icons'
import { Tooltip, Typography } from 'antd' import { Tooltip } from 'antd'
import moment from 'moment'
import { formatDate, isRawDate } from '@utils' import { formatDate, isRawDate } from '@utils'
@ -10,10 +9,10 @@ import '@styles/components/data_summary.less'
export const parseValue = (value, formatter) => { export const parseValue = (value, formatter) => {
if (!value || String(value).trim().length <= 0) return '---' if (!value || String(value).trim().length <= 0) return '---'
if (typeof formatter === 'function') return formatter(value) if (typeof formatter === 'function') return formatter(value)
if (isRawDate(value)) return formatDate(value)
const v = +value const v = +value
if (Number.isFinite(v)) if (Number.isFinite(v))
return Number.isInteger(formatter) ? v.toFixed(formatter) : v.toPrecision(4) return Number.isInteger(formatter) ? v.toFixed(formatter) : v.toPrecision(4)
if (isRawDate(value)) return formatDate(value)
return value return value
} }
@ -42,19 +41,6 @@ export const DashboardDisplay = memo(({ label, title, unit, iconRenderer, value,
) )
}) })
const getTimeFormat = (value) => {
const date = moment(value)
return (
<Tooltip title={`Время последних данных: ${date.format('DD.MM.YYYY HH:mm:ss')}`}>
{date.isSame(new Date(), 'day') || (
<Typography.Text disabled style={{ fontSize: '12px', marginRight: '5px' }}>{date.format('DD.MM.YYYY')}</Typography.Text>
)}
{date.format('HH:mm:ss')}
</Tooltip>
)
}
const iconRenderer = (value, prev) => { const iconRenderer = (value, prev) => {
if (!Number.isFinite(+value)) return null if (!Number.isFinite(+value)) return null
if (prev?.prevDate + 1000 >= Date.now()) return prev if (prev?.prevDate + 1000 >= Date.now()) return prev
@ -90,7 +76,6 @@ const params = [
{ label: 'Забой', unit: 'м', accessorName: 'wellDepth', iconRenderer, format: 2 }, { label: 'Забой', unit: 'м', accessorName: 'wellDepth', iconRenderer, format: 2 },
{ label: 'Расход', unit: 'м³/ч', accessorName: 'flow', iconRenderer }, { label: 'Расход', unit: 'м³/ч', accessorName: 'flow', iconRenderer },
{ label: 'Расход х.х.', unit: 'м³/ч', accessorName: 'flowIdle', iconRenderer }, { label: 'Расход х.х.', unit: 'м³/ч', accessorName: 'flowIdle', iconRenderer },
{ label: 'Время', accessorName: 'date', format: getTimeFormat },
{ label: 'MSE', unit: '%', accessorName: 'mse', format: 2 }, { label: 'MSE', unit: '%', accessorName: 'mse', format: 2 },
] ]