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) =>
|
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++) {
|
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
|
return 1
|
||||||
|
|
||||||
if (a.charCodeAt(i) > b.charCodeAt(i))
|
if (aValue.charCodeAt(i) > bValue.charCodeAt(i))
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
@ -106,18 +118,34 @@ export const makeGroupColumn = (title: string, children: object[]) => ({
|
|||||||
children: children,
|
children: children,
|
||||||
})
|
})
|
||||||
|
|
||||||
export const makeTextColumn = (title: string, dataIndex: string,
|
export const makeTextColumn = (
|
||||||
filters: object[], sorter?: (key: string) => any, render?: any, other?: any) => ({
|
title: string,
|
||||||
|
dataIndex: string,
|
||||||
|
filters: object[],
|
||||||
|
sorter?: (key: string) => any,
|
||||||
|
render?: any,
|
||||||
|
other?: any) => ({
|
||||||
title: title,
|
title: title,
|
||||||
dataIndex: dataIndex,
|
dataIndex: dataIndex,
|
||||||
key: dataIndex,
|
key: dataIndex,
|
||||||
filters: filters,
|
filters: filters,
|
||||||
onFilter: filters ? makeFilterTextMatch(dataIndex) : null,
|
onFilter: filters ? makeFilterTextMatch(dataIndex) : null,
|
||||||
sorter: sorter ? makeStringSorter(dataIndex) : null,
|
sorter: sorter ?? makeStringSorter(dataIndex),
|
||||||
render: render,
|
render: render,
|
||||||
...other
|
...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,
|
export const makeNumericColumn = (title: string, dataIndex: string,
|
||||||
filters: object[], filterDelegate: (key: string | number) => any,
|
filters: object[], filterDelegate: (key: string | number) => any,
|
||||||
renderDelegate: (_: any, row: object) => any, width: string) => ({
|
renderDelegate: (_: any, row: object) => any, width: string) => ({
|
||||||
@ -128,7 +156,7 @@ export const makeNumericColumn = (title: string, dataIndex: string,
|
|||||||
onFilter: filterDelegate ? filterDelegate(dataIndex) : null,
|
onFilter: filterDelegate ? filterDelegate(dataIndex) : null,
|
||||||
sorter: makeNumericSorter(dataIndex),
|
sorter: makeNumericSorter(dataIndex),
|
||||||
width: width,
|
width: width,
|
||||||
render: renderDelegate,
|
render: renderDelegate??defaultNumericRender,
|
||||||
align: 'right'
|
align: 'right'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -127,82 +127,59 @@ export default function ClusterSections({ clusterData }) {
|
|||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
makeTextColumn("скв №", "caption", null, null,
|
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,
|
makeTextColumn("Секция", "sectionType", filtersSectionsType, null,
|
||||||
(_, item) => _ ?? '-'
|
(text, item) => text ?? '-'
|
||||||
),
|
),
|
||||||
makeNumericColumnPlanFact(
|
makeNumericColumnPlanFact(
|
||||||
"Глубина",
|
"Глубина",
|
||||||
"sectionWellDepth",
|
"sectionWellDepth",
|
||||||
filtersMinMax,
|
filtersMinMax,
|
||||||
makeFilterMinMaxFunction,
|
makeFilterMinMaxFunction
|
||||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
|
||||||
? number.toFixed(2)
|
|
||||||
: '-',
|
|
||||||
),
|
),
|
||||||
makeNumericColumnPlanFact(
|
makeNumericColumnPlanFact(
|
||||||
"Продолжительность",
|
"Продолжительность",
|
||||||
"sectionBuildDays",
|
"sectionBuildDays",
|
||||||
filtersMinMax,
|
filtersMinMax,
|
||||||
makeFilterMinMaxFunction,
|
makeFilterMinMaxFunction
|
||||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
|
||||||
? number.toFixed(2)
|
|
||||||
: '-',
|
|
||||||
),
|
),
|
||||||
makeNumericColumnPlanFact(
|
makeNumericColumnPlanFact(
|
||||||
"МСП",
|
"МСП",
|
||||||
"sectionRateOfPenetration",
|
"sectionRateOfPenetration",
|
||||||
filtersMinMax,
|
filtersMinMax,
|
||||||
makeFilterMinMaxFunction,
|
makeFilterMinMaxFunction
|
||||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
|
||||||
? number.toFixed(2)
|
|
||||||
: '-',
|
|
||||||
),
|
),
|
||||||
makeNumericColumnPlanFact(
|
makeNumericColumnPlanFact(
|
||||||
"Рейсовая скорость",
|
"Рейсовая скорость",
|
||||||
"sectionRouteSpeed",
|
"sectionRouteSpeed",
|
||||||
filtersMinMax,
|
filtersMinMax,
|
||||||
makeFilterMinMaxFunction,
|
makeFilterMinMaxFunction
|
||||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
|
||||||
? number.toFixed(2)
|
|
||||||
: '-',
|
|
||||||
),
|
),
|
||||||
makeNumericColumnPlanFact(
|
makeNumericColumnPlanFact(
|
||||||
"Спуск КНБК",
|
"Спуск КНБК",
|
||||||
"sectionBhaDownSpeed",
|
"sectionBhaDownSpeed",
|
||||||
filtersMinMax,
|
filtersMinMax,
|
||||||
makeFilterMinMaxFunction,
|
makeFilterMinMaxFunction
|
||||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
|
||||||
? number.toFixed(2)
|
|
||||||
: '-',
|
|
||||||
),
|
),
|
||||||
makeNumericColumnPlanFact(
|
makeNumericColumnPlanFact(
|
||||||
"Подъем КНБК",
|
"Подъем КНБК",
|
||||||
"sectionBhaUpSpeed",
|
"sectionBhaUpSpeed",
|
||||||
filtersMinMax,
|
filtersMinMax,
|
||||||
makeFilterMinMaxFunction,
|
makeFilterMinMaxFunction
|
||||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
|
||||||
? number.toFixed(2)
|
|
||||||
: '-',
|
|
||||||
),
|
),
|
||||||
makeNumericColumnPlanFact(
|
makeNumericColumnPlanFact(
|
||||||
"Скорость спуска ОК",
|
"Скорость спуска ОК",
|
||||||
"sectionCasingDownSpeed",
|
"sectionCasingDownSpeed",
|
||||||
filtersMinMax,
|
filtersMinMax,
|
||||||
makeFilterMinMaxFunction,
|
makeFilterMinMaxFunction
|
||||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
|
||||||
? number.toFixed(2)
|
|
||||||
: '-',
|
|
||||||
),
|
),
|
||||||
makeNumericColumnPlanFact(
|
makeNumericColumnPlanFact(
|
||||||
"НПВ, сут",
|
"НПВ, сут",
|
||||||
"nonProductiveTime",
|
"nonProductiveTime",
|
||||||
filtersMinMax,
|
filtersMinMax,
|
||||||
makeFilterMinMaxFunction,
|
makeFilterMinMaxFunction,
|
||||||
(number) => (!Number.isNaN(number) && number !== undefined)
|
null,
|
||||||
? number.toFixed(2)
|
|
||||||
: '-',
|
|
||||||
"70px"
|
"70px"
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user