diff --git a/src/components/Table/index.ts b/src/components/Table/index.ts
index 485493d..153ff66 100644
--- a/src/components/Table/index.ts
+++ b/src/components/Table/index.ts
@@ -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'
})
diff --git a/src/pages/Cluster/ClusterSections.jsx b/src/pages/Cluster/ClusterSections.jsx
index 43952a3..b87ecd6 100644
--- a/src/pages/Cluster/ClusterSections.jsx
+++ b/src/pages/Cluster/ClusterSections.jsx
@@ -127,82 +127,59 @@ export default function ClusterSections({ clusterData }) {
const columns = [
makeTextColumn("скв №", "caption", null, null,
- (_, item) => {item.caption ?? '-'}
+ (text, item) => {text ?? '-'}
),
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"
),
{