forked from ddrilling/asb_cloud_front
Добавлено заполение средних значений на режимах композитной скважины
This commit is contained in:
parent
121cb83d83
commit
2bfdd4385f
@ -2,12 +2,75 @@ import { memo, useCallback, useEffect, useState } from 'react'
|
|||||||
import { Button, Modal, Popconfirm } from 'antd'
|
import { Button, Modal, Popconfirm } from 'antd'
|
||||||
|
|
||||||
import { useWell } from '@asb/context'
|
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 LoaderPortal from '@components/LoaderPortal'
|
||||||
import { invokeWebApiWrapperAsync } from '@components/factory'
|
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 (
|
||||||
|
<div className={'avg-column'}>
|
||||||
|
<div className={'avg-fill'} style={{ width: `${fillW}%` }} />
|
||||||
|
<div className={'avg-value'}>
|
||||||
|
{numericRender(avg)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
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 }) => {
|
export const NewParamsTable = memo(({ selectedWellsKeys }) => {
|
||||||
const [params, setParams] = useState([])
|
const [params, setParams] = useState([])
|
||||||
|
@ -12,14 +12,9 @@ import { OperationStatService, WellCompositeService } from '@api'
|
|||||||
|
|
||||||
import WellCompositeSections from './WellCompositeSections'
|
import WellCompositeSections from './WellCompositeSections'
|
||||||
|
|
||||||
const ClusterWells = lazy(() => import('@pages/Cluster/ClusterWells'))
|
import '@styles/well_composite.less'
|
||||||
|
|
||||||
const properties = {
|
const ClusterWells = lazy(() => import('@pages/Cluster/ClusterWells'))
|
||||||
requirements: ['OperationStat.get', 'WellComposite.get'],
|
|
||||||
title: 'Композитная скважина',
|
|
||||||
route: 'composite/*',
|
|
||||||
key: 'composite',
|
|
||||||
}
|
|
||||||
|
|
||||||
const WellCompositeEditor = memo(() => {
|
const WellCompositeEditor = memo(() => {
|
||||||
const [well] = useWell()
|
const [well] = useWell()
|
||||||
@ -81,4 +76,4 @@ const WellCompositeEditor = memo(() => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
export default wrapPrivateComponent(WellCompositeEditor, properties)
|
export default wrapPrivateComponent(WellCompositeEditor, { requirements: ['OperationStat.get', 'WellComposite.get'] })
|
||||||
|
13
src/styles/well_composite.less
Normal file
13
src/styles/well_composite.less
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
.avg-column {
|
||||||
|
& .avg-fill {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
height: 100%;
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
& .avg-value {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user