From 93e6d2171d9a7774280adde3e71212b02aef0bf0 Mon Sep 17 00:00:00 2001 From: goodmice Date: Thu, 13 Oct 2022 16:45:30 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D1=89=D0=B8=D0=B9=20=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=B4=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BA=D0=BE=D0=BE?= =?UTF-8?q?=D1=80=D0=B4=D0=B8=D0=BD=D0=B0=D1=82=20=D0=B2=D1=8B=D0=BD=D0=B5?= =?UTF-8?q?=D1=81=D0=B5=D0=BD=20=D0=B2=20=D1=83=D1=82=D0=B8=D0=BB=D0=B8?= =?UTF-8?q?=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/AdminPanel/ClusterController.jsx | 8 +++----- src/pages/AdminPanel/DepositController.jsx | 8 +++----- src/pages/AdminPanel/WellController/index.jsx | 8 +++----- src/utils/functions/numbers.tsx | 2 ++ 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/pages/AdminPanel/ClusterController.jsx b/src/pages/AdminPanel/ClusterController.jsx index aad1987..f494c79 100755 --- a/src/pages/AdminPanel/ClusterController.jsx +++ b/src/pages/AdminPanel/ClusterController.jsx @@ -11,11 +11,9 @@ import { } from '@components/Table' import { invokeWebApiWrapperAsync } from '@components/factory' import { AdminClusterService, AdminDepositService } from '@api' -import { arrayOrDefault, wrapPrivateComponent } from '@utils' +import { arrayOrDefault, coordsFormat, wrapPrivateComponent } from '@utils' import { min1 } from '@utils/validationRules' -import { coordsFixed } from './DepositController' - const ClusterController = memo(() => { const [deposits, setDeposits] = useState([]) const [clusters, setClusters] = useState([]) @@ -41,8 +39,8 @@ const ClusterController = memo(() => { sorter: makeStringSorter('caption'), formItemRules: min1, }), - makeColumn('Широта', 'latitude', { width: 150, editable: true, render: coordsFixed }), - makeColumn('Долгота', 'longitude', { width: 150, editable: true, render: coordsFixed }), + makeColumn('Широта', 'latitude', { width: 150, editable: true, render: coordsFormat }), + makeColumn('Долгота', 'longitude', { width: 150, editable: true, render: coordsFormat }), makeTimezoneColumn('Зона', 'timezone', null, true, { width: 150 }), ], [deposits]) diff --git a/src/pages/AdminPanel/DepositController.jsx b/src/pages/AdminPanel/DepositController.jsx index 09d7bf9..3c17df4 100755 --- a/src/pages/AdminPanel/DepositController.jsx +++ b/src/pages/AdminPanel/DepositController.jsx @@ -3,16 +3,14 @@ import { Input } from 'antd' import { invokeWebApiWrapperAsync } from '@components/factory' import { EditableTable, makeColumn, defaultPagination, makeTimezoneColumn } from '@components/Table' -import { arrayOrDefault, wrapPrivateComponent } from '@utils' +import { arrayOrDefault, coordsFormat, wrapPrivateComponent } from '@utils' import { min1 } from '@utils/validationRules' import { AdminDepositService } from '@api' -export const coordsFixed = (coords) => coords && isFinite(coords) ? (+coords).toPrecision(10) : '-' - const depositColumns = [ makeColumn('Название', 'caption', { width: 200, editable: true, formItemRules: min1 }), - makeColumn('Широта', 'latitude', { width: 150, editable: true, render: coordsFixed }), - makeColumn('Долгота', 'longitude', { width: 150, editable: true, render: coordsFixed }), + makeColumn('Широта', 'latitude', { width: 150, editable: true, render: coordsFormat }), + makeColumn('Долгота', 'longitude', { width: 150, editable: true, render: coordsFormat }), makeTimezoneColumn('Зона', 'timezone', null, true, { width: 150 }), ] diff --git a/src/pages/AdminPanel/WellController/index.jsx b/src/pages/AdminPanel/WellController/index.jsx index 4dddbc6..d7b06a2 100755 --- a/src/pages/AdminPanel/WellController/index.jsx +++ b/src/pages/AdminPanel/WellController/index.jsx @@ -21,9 +21,7 @@ import { import { invokeWebApiWrapperAsync } from '@components/factory' import { TelemetryView, CompanyView } from '@components/views' import TelemetrySelect from '@components/selectors/TelemetrySelect' -import { arrayOrDefault, wrapPrivateComponent } from '@utils' - -import { coordsFixed } from '../DepositController' +import { arrayOrDefault, coordsFormat, wrapPrivateComponent } from '@utils' const wellTypes = [ { value: 1, label: 'Наклонно-направленная' }, @@ -98,8 +96,8 @@ const WellController = memo(() => { editable: true, sorter: makeNumericSorter('idWellType'), }), - makeColumn('Широта', 'latitude', { width: 150, editable: true, render: coordsFixed }), - makeColumn('Долгота', 'longitude', { width: 150, editable: true, render: coordsFixed }), + makeColumn('Широта', 'latitude', { width: 150, editable: true, render: coordsFormat }), + makeColumn('Долгота', 'longitude', { width: 150, editable: true, render: coordsFormat }), makeColumn('Телеметрия', 'telemetry', { editable: true, render: (telemetry) => , diff --git a/src/utils/functions/numbers.tsx b/src/utils/functions/numbers.tsx index 4de2a13..0a686f1 100644 --- a/src/utils/functions/numbers.tsx +++ b/src/utils/functions/numbers.tsx @@ -59,3 +59,5 @@ export const makeDisplayValue = ({ if (Number.isFinite(f)) return f.toFixed(fixed) return typeof inf === 'function' ? inf(f) : inf } + +export const coordsFormat = (coords?: string) => (typeof coords === 'string') && isFinite(Number(coords)) ? Number(coords).toPrecision(10) : '-'