2021-10-12 11:10:33 +05:00
|
|
|
|
import { useState, useEffect } from 'react'
|
|
|
|
|
|
2021-12-27 15:18:20 +05:00
|
|
|
|
import { DrillParamsService } from '../../services/api'
|
2021-10-12 11:10:33 +05:00
|
|
|
|
import LoaderPortal from '../../components/LoaderPortal'
|
|
|
|
|
import { invokeWebApiWrapperAsync } from '../../components/factory'
|
|
|
|
|
import { EditableTable, SelectFromDictionary } from '../../components/Table'
|
2021-12-27 15:18:20 +05:00
|
|
|
|
import { makeActionHandler, makeColumn, makeNumericAvgRange } from '../../components/Table'
|
|
|
|
|
|
2021-10-12 11:10:33 +05:00
|
|
|
|
import { dictionarySectionType, getByKeyOrReturnKey } from './dictionary'
|
|
|
|
|
|
2021-10-15 16:02:35 +05:00
|
|
|
|
export const columns = [
|
|
|
|
|
makeColumn('Конструкция секции','idWellSectionType', {
|
2021-12-27 15:18:20 +05:00
|
|
|
|
editable: true,
|
|
|
|
|
input: <SelectFromDictionary dictionary={dictionarySectionType}/>,
|
|
|
|
|
width: 160,
|
|
|
|
|
render: (_, record) => getByKeyOrReturnKey(dictionarySectionType, record.idWellSectionType)
|
2021-10-15 16:02:35 +05:00
|
|
|
|
}),
|
2021-12-27 15:18:20 +05:00
|
|
|
|
makeNumericAvgRange('Нагрузка, т', 'axialLoad', 1),
|
|
|
|
|
makeNumericAvgRange('Давление, атм', 'pressure', 1),
|
|
|
|
|
makeNumericAvgRange('Момент на ВСП, кН·м', 'rotorTorque', 1),
|
|
|
|
|
makeNumericAvgRange('Обороты на ВСП, об/мин', 'rotorSpeed', 1),
|
|
|
|
|
makeNumericAvgRange('Расход, л/с', 'flow', 1)
|
2021-10-15 16:02:35 +05:00
|
|
|
|
]
|
2021-10-12 11:10:33 +05:00
|
|
|
|
|
2021-12-27 15:18:20 +05:00
|
|
|
|
export const WellDrillParams = ({ idWell }) => {
|
2021-10-12 11:10:33 +05:00
|
|
|
|
const [params, setParams] = useState([])
|
|
|
|
|
const [showLoader, setShowLoader] = useState(false)
|
|
|
|
|
|
2021-10-12 16:48:17 +05:00
|
|
|
|
const updateParams = () => invokeWebApiWrapperAsync(
|
2021-10-12 11:10:33 +05:00
|
|
|
|
async () => {
|
2021-10-12 16:48:17 +05:00
|
|
|
|
const params = await DrillParamsService.getAll(idWell)
|
2021-10-18 11:49:53 +05:00
|
|
|
|
setParams(Array.isArray(params) ? params : [])
|
2021-10-12 11:10:33 +05:00
|
|
|
|
},
|
|
|
|
|
setShowLoader,
|
|
|
|
|
'Не удалось загрузить список режимов бурения скважины'
|
|
|
|
|
)
|
|
|
|
|
|
2021-10-12 16:48:17 +05:00
|
|
|
|
useEffect(updateParams, [idWell])
|
2021-10-12 11:10:33 +05:00
|
|
|
|
|
2021-12-27 15:18:20 +05:00
|
|
|
|
const handlerProps = {
|
|
|
|
|
service: DrillParamsService,
|
|
|
|
|
setLoader: setShowLoader,
|
|
|
|
|
errorMsg: `Не удалось выполнить операцию`,
|
|
|
|
|
onComplete: updateParams,
|
|
|
|
|
idWell
|
2021-10-12 11:10:33 +05:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-27 15:18:20 +05:00
|
|
|
|
const recordParser = (record) => ({ ...record, idWell })
|
2021-10-12 11:10:33 +05:00
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<LoaderPortal show={showLoader}>
|
|
|
|
|
<EditableTable
|
|
|
|
|
size={'small'}
|
|
|
|
|
bordered
|
|
|
|
|
columns={columns}
|
|
|
|
|
dataSource={params}
|
2021-12-27 15:18:20 +05:00
|
|
|
|
onRowAdd={makeActionHandler('insert', handlerProps, recordParser)}
|
|
|
|
|
onRowEdit={makeActionHandler('update', handlerProps, recordParser)}
|
|
|
|
|
onRowDelete={makeActionHandler('delete', handlerProps, recordParser)}
|
2021-10-12 16:51:25 +05:00
|
|
|
|
pagination={false}
|
2021-10-12 11:10:33 +05:00
|
|
|
|
/>
|
|
|
|
|
</LoaderPortal>
|
|
|
|
|
)
|
|
|
|
|
}
|