From 2bfdd4385ffe73e23c4a5590a39530e82e8410b6 Mon Sep 17 00:00:00 2001 From: goodmice Date: Mon, 24 Oct 2022 09:35:31 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=B7=D0=B0=D0=BF=D0=BE=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D1=81=D1=80=D0=B5=D0=B4=D0=BD=D0=B8=D1=85=20=D0=B7?= =?UTF-8?q?=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B6=D0=B8=D0=BC=D0=B0=D1=85=20=D0=BA=D0=BE=D0=BC?= =?UTF-8?q?=D0=BF=D0=BE=D0=B7=D0=B8=D1=82=D0=BD=D0=BE=D0=B9=20=D1=81=D0=BA?= =?UTF-8?q?=D0=B2=D0=B0=D0=B6=D0=B8=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WellCompositeEditor/NewParamsTable.jsx | 69 ++++++++++++++++++- .../Analytics/WellCompositeEditor/index.jsx | 11 +-- src/styles/well_composite.less | 13 ++++ 3 files changed, 82 insertions(+), 11 deletions(-) create mode 100644 src/styles/well_composite.less diff --git a/src/pages/Well/Analytics/WellCompositeEditor/NewParamsTable.jsx b/src/pages/Well/Analytics/WellCompositeEditor/NewParamsTable.jsx index 6e9d6ef..9c3d812 100644 --- a/src/pages/Well/Analytics/WellCompositeEditor/NewParamsTable.jsx +++ b/src/pages/Well/Analytics/WellCompositeEditor/NewParamsTable.jsx @@ -2,12 +2,75 @@ import { memo, useCallback, useEffect, useState } from 'react' import { Button, Modal, Popconfirm } from 'antd' import { useWell } from '@asb/context' -import { Table } from '@components/Table' +import { makeColumn, makeGroupColumn, makeNumericRender, makeSelectColumn, Table } from '@components/Table' import LoaderPortal from '@components/LoaderPortal' import { invokeWebApiWrapperAsync } from '@components/factory' -import { DrillParamsService } from '@api' +import { DrillParamsService, WellOperationService } from '@api' -import { getColumns } from '@pages/Well/WellOperations/WellDrillParams' +const getDeepValue = (data, key) => { + if (!key || key.trim() === '') return null + const keys = key.split('.') + let out = data + while (keys.length > 0) { + if (!(keys[0] in out)) return null + out = out[keys[0]] + keys.splice(0, 1) + } + return out +} + +const makeNumericSorter = (keys) => (a, b) => getDeepValue(a, keys) - getDeepValue(b, keys) + +const numericRender = makeNumericRender(1) +const makeNumericColumn = (title, dataIndex, render, other) => makeColumn(title, dataIndex, { + sorter: makeNumericSorter(dataIndex), + render: (_, record, index) => { + const func = render ?? ((value) => <>{value}) + const item = getDeepValue(record, dataIndex) + return func(item, record, index) + }, + align: 'right', + ...other, +}) + +const makeAvgRender = (dataIndex) => (avg, record) => { + const max = record[dataIndex]?.max + const fillW = (max - avg) / max * 100 + return ( +
+
+
+ {numericRender(avg)} +
+
+ ) +} + +const makeNumericAvgRange = (title, dataIndex, defaultRender = false) => makeGroupColumn(title, [ + makeNumericColumn('мин', `${dataIndex}.min`), + makeNumericColumn('сред', `${dataIndex}.avg`, defaultRender ? undefined : makeAvgRender(dataIndex)), + makeNumericColumn('макс', `${dataIndex}.max`), +]) + +export const getColumns = async (idWell) => { + let sectionTypes = await WellOperationService.getSectionTypes(idWell) + sectionTypes = Object.entries(sectionTypes).map(([id, value]) => ({ + label: value, + value: id, + })) + + return [ + makeSelectColumn('Конструкция секции','idWellSectionType', sectionTypes, null, { + width: 160, + sorter: makeNumericSorter('idWellSectionType'), + }), + makeNumericAvgRange('Нагрузка, т', 'axialLoad'), + makeNumericAvgRange('Давление, атм', 'pressure'), + makeNumericAvgRange('Момент на ВСП, кН·м', 'rotorTorque', true), + makeNumericAvgRange('Обороты на ВСП, об/мин', 'rotorSpeed'), + makeNumericAvgRange('Расход, л/с', 'flow'), + ] +} export const NewParamsTable = memo(({ selectedWellsKeys }) => { const [params, setParams] = useState([]) diff --git a/src/pages/Well/Analytics/WellCompositeEditor/index.jsx b/src/pages/Well/Analytics/WellCompositeEditor/index.jsx index c2341e1..b2ab94b 100644 --- a/src/pages/Well/Analytics/WellCompositeEditor/index.jsx +++ b/src/pages/Well/Analytics/WellCompositeEditor/index.jsx @@ -12,14 +12,9 @@ import { OperationStatService, WellCompositeService } from '@api' import WellCompositeSections from './WellCompositeSections' -const ClusterWells = lazy(() => import('@pages/Cluster/ClusterWells')) +import '@styles/well_composite.less' -const properties = { - requirements: ['OperationStat.get', 'WellComposite.get'], - title: 'Композитная скважина', - route: 'composite/*', - key: 'composite', -} +const ClusterWells = lazy(() => import('@pages/Cluster/ClusterWells')) const WellCompositeEditor = memo(() => { const [well] = useWell() @@ -81,4 +76,4 @@ const WellCompositeEditor = memo(() => { ) }) -export default wrapPrivateComponent(WellCompositeEditor, properties) +export default wrapPrivateComponent(WellCompositeEditor, { requirements: ['OperationStat.get', 'WellComposite.get'] }) diff --git a/src/styles/well_composite.less b/src/styles/well_composite.less new file mode 100644 index 0000000..ea64fc8 --- /dev/null +++ b/src/styles/well_composite.less @@ -0,0 +1,13 @@ +.avg-column { + & .avg-fill { + position: absolute; + right: 0; + top: 0; + height: 100%; + background-color: red; + } + + & .avg-value { + position: relative; + } +}