2021-10-12 11:10:33 +05:00
|
|
|
|
import { useState, useEffect } from 'react'
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
makeColumn,
|
2021-10-12 16:48:17 +05:00
|
|
|
|
makeNumericAvgRange
|
2021-10-12 11:10:33 +05:00
|
|
|
|
} from '../../components/Table'
|
|
|
|
|
import LoaderPortal from '../../components/LoaderPortal'
|
|
|
|
|
import { invokeWebApiWrapperAsync } from '../../components/factory'
|
|
|
|
|
import { EditableTable, SelectFromDictionary } from '../../components/Table'
|
2021-10-12 15:04:02 +05:00
|
|
|
|
import { DrillParamsService } from '../../services/api'
|
2021-10-12 11:10:33 +05:00
|
|
|
|
import { dictionarySectionType, getByKeyOrReturnKey } from './dictionary'
|
|
|
|
|
|
|
|
|
|
|
2021-10-12 15:04:02 +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-12 11:10:33 +05:00
|
|
|
|
setParams(params)
|
|
|
|
|
},
|
|
|
|
|
setShowLoader,
|
|
|
|
|
'Не удалось загрузить список режимов бурения скважины'
|
|
|
|
|
)
|
|
|
|
|
|
2021-10-12 16:48:17 +05:00
|
|
|
|
useEffect(updateParams, [idWell])
|
2021-10-12 11:10:33 +05:00
|
|
|
|
|
|
|
|
|
const columns = [
|
2021-10-12 16:48:17 +05:00
|
|
|
|
makeColumn('Конструкция секции','idWellSectionType', {
|
2021-10-12 11:10:33 +05:00
|
|
|
|
editable:true,
|
|
|
|
|
input:<SelectFromDictionary dictionary={dictionarySectionType}/>,
|
|
|
|
|
width:160,
|
|
|
|
|
render:(_, record)=>getByKeyOrReturnKey(dictionarySectionType, record.idWellSectionType)
|
|
|
|
|
}),
|
2021-10-12 15:04:02 +05:00
|
|
|
|
// makeNumericStartEnd('Глубина', 'depth'),
|
|
|
|
|
makeNumericAvgRange('Нагрузка', 'axialLoad'),
|
|
|
|
|
makeNumericAvgRange('Давление', 'pressure'),
|
2021-10-12 16:48:17 +05:00
|
|
|
|
makeNumericAvgRange('Момент на ВПС', 'rotorTorque'),
|
|
|
|
|
makeNumericAvgRange('Обороты на ВПС', 'rotorSpeed'),
|
2021-10-12 15:04:02 +05:00
|
|
|
|
makeNumericAvgRange('Расход', 'flow')
|
2021-10-12 11:10:33 +05:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const onAdd = async (param) => {
|
2021-10-12 16:48:17 +05:00
|
|
|
|
param.idWell = idWell
|
|
|
|
|
await DrillParamsService.save(idWell, param)
|
|
|
|
|
updateParams()
|
2021-10-12 11:10:33 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onEdit = async (param) => {
|
|
|
|
|
if (!param.id) return
|
2021-10-12 16:48:17 +05:00
|
|
|
|
param.idWell = idWell
|
2021-10-12 16:49:33 +05:00
|
|
|
|
await DrillParamsService.edit(idWell, param)
|
2021-10-12 16:48:17 +05:00
|
|
|
|
updateParams()
|
2021-10-12 11:10:33 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onDelete = async (param) => {
|
|
|
|
|
if (!param.id) return
|
2021-10-12 15:04:02 +05:00
|
|
|
|
await DrillParamsService.delete(idWell, param.id)
|
2021-10-12 16:48:17 +05:00
|
|
|
|
updateParams()
|
2021-10-12 11:10:33 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<LoaderPortal show={showLoader}>
|
|
|
|
|
<EditableTable
|
|
|
|
|
size={'small'}
|
|
|
|
|
bordered
|
|
|
|
|
columns={columns}
|
|
|
|
|
dataSource={params}
|
2021-10-12 16:48:17 +05:00
|
|
|
|
onRowAdd={onAdd}
|
2021-10-12 11:10:33 +05:00
|
|
|
|
onRowEdit={onEdit}
|
|
|
|
|
onRowDelete={onDelete}
|
2021-10-12 16:51:25 +05:00
|
|
|
|
pagination={false}
|
2021-10-12 11:10:33 +05:00
|
|
|
|
/>
|
|
|
|
|
</LoaderPortal>
|
|
|
|
|
)
|
|
|
|
|
}
|