forked from ddrilling/asb_cloud_front
hotfix ClusterSections "number.ToFixed is not a function" at columns definition
This commit is contained in:
parent
2bcdbc3738
commit
03fd9ae3b1
@ -82,11 +82,23 @@ export const makeNumericSorter = (key: string) => (a: any, b: any) => a[key] - b
|
||||
|
||||
export const makeStringSorter = (key: string) => (a: any, b: any) =>
|
||||
{
|
||||
if(a == null && b == null)
|
||||
return 1
|
||||
|
||||
if(a == null)
|
||||
return 1
|
||||
|
||||
if(b == null)
|
||||
return -1
|
||||
|
||||
let aValue = a[key]
|
||||
let bValue = b[key]
|
||||
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
if (isNaN(b.charCodeAt(i)) || (a.charCodeAt(i) > b.charCodeAt(i)))
|
||||
if (isNaN(aValue.charCodeAt(i)) || (aValue.charCodeAt(i) > bValue.charCodeAt(i)))
|
||||
return 1
|
||||
|
||||
if (a.charCodeAt(i) > b.charCodeAt(i))
|
||||
if (aValue.charCodeAt(i) > bValue.charCodeAt(i))
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
@ -106,18 +118,34 @@ export const makeGroupColumn = (title: string, children: object[]) => ({
|
||||
children: children,
|
||||
})
|
||||
|
||||
export const makeTextColumn = (title: string, dataIndex: string,
|
||||
filters: object[], sorter?: (key: string) => any, render?: any, other?: any) => ({
|
||||
export const makeTextColumn = (
|
||||
title: string,
|
||||
dataIndex: string,
|
||||
filters: object[],
|
||||
sorter?: (key: string) => any,
|
||||
render?: any,
|
||||
other?: any) => ({
|
||||
title: title,
|
||||
dataIndex: dataIndex,
|
||||
key: dataIndex,
|
||||
filters: filters,
|
||||
onFilter: filters ? makeFilterTextMatch(dataIndex) : null,
|
||||
sorter: sorter ? makeStringSorter(dataIndex) : null,
|
||||
sorter: sorter ?? makeStringSorter(dataIndex),
|
||||
render: render,
|
||||
...other
|
||||
})
|
||||
|
||||
const defaultNumericRender = (value: any, row: object) => {
|
||||
const placeholder = '-'
|
||||
if((value === null) ||
|
||||
(value === undefined) ||
|
||||
Number.isNaN(value) ||
|
||||
!Number.isFinite(value))
|
||||
return placeholder
|
||||
|
||||
return (+value).toPrecision(5)
|
||||
}
|
||||
|
||||
export const makeNumericColumn = (title: string, dataIndex: string,
|
||||
filters: object[], filterDelegate: (key: string | number) => any,
|
||||
renderDelegate: (_: any, row: object) => any, width: string) => ({
|
||||
@ -128,7 +156,7 @@ export const makeNumericColumn = (title: string, dataIndex: string,
|
||||
onFilter: filterDelegate ? filterDelegate(dataIndex) : null,
|
||||
sorter: makeNumericSorter(dataIndex),
|
||||
width: width,
|
||||
render: renderDelegate,
|
||||
render: renderDelegate??defaultNumericRender,
|
||||
align: 'right'
|
||||
})
|
||||
|
||||
|
@ -127,82 +127,59 @@ export default function ClusterSections({ clusterData }) {
|
||||
|
||||
const columns = [
|
||||
makeTextColumn("скв №", "caption", null, null,
|
||||
(_, item) => <Link to={`/well/${item.id}`}>{item.caption ?? '-'}</Link>
|
||||
(text, item) => <Link to={`/well/${item?.id}`}>{text ?? '-'}</Link>
|
||||
),
|
||||
makeTextColumn("Секция", "sectionType", filtersSectionsType, null,
|
||||
(_, item) => _ ?? '-'
|
||||
(text, item) => text ?? '-'
|
||||
),
|
||||
makeNumericColumnPlanFact(
|
||||
"Глубина",
|
||||
"sectionWellDepth",
|
||||
filtersMinMax,
|
||||
makeFilterMinMaxFunction,
|
||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
||||
? number.toFixed(2)
|
||||
: '-',
|
||||
makeFilterMinMaxFunction
|
||||
),
|
||||
makeNumericColumnPlanFact(
|
||||
"Продолжительность",
|
||||
"sectionBuildDays",
|
||||
filtersMinMax,
|
||||
makeFilterMinMaxFunction,
|
||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
||||
? number.toFixed(2)
|
||||
: '-',
|
||||
makeFilterMinMaxFunction
|
||||
),
|
||||
makeNumericColumnPlanFact(
|
||||
"МСП",
|
||||
"sectionRateOfPenetration",
|
||||
filtersMinMax,
|
||||
makeFilterMinMaxFunction,
|
||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
||||
? number.toFixed(2)
|
||||
: '-',
|
||||
makeFilterMinMaxFunction
|
||||
),
|
||||
makeNumericColumnPlanFact(
|
||||
"Рейсовая скорость",
|
||||
"sectionRouteSpeed",
|
||||
filtersMinMax,
|
||||
makeFilterMinMaxFunction,
|
||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
||||
? number.toFixed(2)
|
||||
: '-',
|
||||
makeFilterMinMaxFunction
|
||||
),
|
||||
makeNumericColumnPlanFact(
|
||||
"Спуск КНБК",
|
||||
"sectionBhaDownSpeed",
|
||||
filtersMinMax,
|
||||
makeFilterMinMaxFunction,
|
||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
||||
? number.toFixed(2)
|
||||
: '-',
|
||||
makeFilterMinMaxFunction
|
||||
),
|
||||
makeNumericColumnPlanFact(
|
||||
"Подъем КНБК",
|
||||
"sectionBhaUpSpeed",
|
||||
filtersMinMax,
|
||||
makeFilterMinMaxFunction,
|
||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
||||
? number.toFixed(2)
|
||||
: '-',
|
||||
makeFilterMinMaxFunction
|
||||
),
|
||||
makeNumericColumnPlanFact(
|
||||
"Скорость спуска ОК",
|
||||
"sectionCasingDownSpeed",
|
||||
filtersMinMax,
|
||||
makeFilterMinMaxFunction,
|
||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
||||
? number.toFixed(2)
|
||||
: '-',
|
||||
makeFilterMinMaxFunction
|
||||
),
|
||||
makeNumericColumnPlanFact(
|
||||
"НПВ, сут",
|
||||
"nonProductiveTime",
|
||||
filtersMinMax,
|
||||
makeFilterMinMaxFunction,
|
||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
||||
? number.toFixed(2)
|
||||
: '-',
|
||||
null,
|
||||
"70px"
|
||||
),
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user