fix numeric formetting in tables

This commit is contained in:
Фролов 2021-10-18 11:48:07 +05:00
parent 0c1e520a62
commit 467b878e29
2 changed files with 9 additions and 9 deletions

View File

@ -13,10 +13,10 @@ export const formatDate='YYYY.MM.DD HH:mm'
export const makeNumericRender = (fixed?:number) => (value: any, row: object): ReactNode => {
const placeholder = '-'
let val = placeholder
if((value !== null) ||
(value !== undefined) ||
Number.isNaN(value) ||
!Number.isFinite(value)){
if((value !== null) &&
(value !== undefined) &&
!Number.isNaN(value) &&
Number.isFinite(value)){
val = !!fixed
? (+value).toFixed(fixed)
: (+value).toPrecision(5)

View File

@ -9,7 +9,7 @@ import {
makeColumn,
makeDateSorter,
makeNumericColumnPlanFact} from '../../components/Table'
import { calcAndUpdateStatsBySections, makeFilterMinMaxFunction, getPrecision } from './functions'
import { calcAndUpdateStatsBySections, makeFilterMinMaxFunction } from './functions'
import { invokeWebApiWrapperAsync } from '../../components/factory'
import { Tvd } from '../WellOperations/Tvd'
import WellOperationsTable from './WellOperationsTable'
@ -98,10 +98,10 @@ export default function ClusterWells({statsWells}) {
makeColumn('начало', 'factStart', { sorter: makeDateSorter('factStart'), render: getDate }),
makeColumn('окончание', 'factEnd', { sorter: makeDateSorter('factEnd'), render: getDate })
]),
makeNumericColumnPlanFact('Продолжительность', 'period', filtersMinMax, makeFilterMinMaxFunction, getPrecision),
makeNumericColumnPlanFact('МСП', 'rateOfPenetration', filtersMinMax, makeFilterMinMaxFunction, getPrecision),
makeNumericColumnPlanFact('Рейсовая скорость', 'routeSpeed', filtersMinMax, makeFilterMinMaxFunction, getPrecision),
makeNumericColumnPlanFact('НПВ, сут', 'notProductiveTime', filtersMinMax, makeFilterMinMaxFunction, getPrecision),
makeNumericColumnPlanFact('Продолжительность', 'period', filtersMinMax, makeFilterMinMaxFunction),
makeNumericColumnPlanFact('МСП', 'rateOfPenetration', filtersMinMax, makeFilterMinMaxFunction),
makeNumericColumnPlanFact('Рейсовая скорость', 'routeSpeed', filtersMinMax, makeFilterMinMaxFunction),
makeNumericColumnPlanFact('НПВ, сут', 'notProductiveTime', filtersMinMax, makeFilterMinMaxFunction),
{
title: 'TVD',
key: 'tvd',