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) : '-'