2021-10-18 12:00:03 +05:00
|
|
|
|
import { useState, useEffect } from 'react'
|
|
|
|
|
import {
|
2021-10-18 13:27:46 +05:00
|
|
|
|
makeNumericMinMax,
|
|
|
|
|
makeNumericStartEnd
|
2021-10-18 12:00:03 +05:00
|
|
|
|
} from '../../components/Table'
|
|
|
|
|
import LoaderPortal from '../../components/LoaderPortal'
|
|
|
|
|
import { invokeWebApiWrapperAsync } from '../../components/factory'
|
2021-10-18 13:27:46 +05:00
|
|
|
|
import { EditableTable } from '../../components/Table'
|
2021-10-18 12:00:03 +05:00
|
|
|
|
import { DrillFlowChartService } from '../../services/api'
|
|
|
|
|
|
|
|
|
|
const columns = [
|
2021-10-29 16:22:56 +05:00
|
|
|
|
makeNumericStartEnd('Глубина, м', 'depth'),
|
|
|
|
|
makeNumericMinMax('Нагрузка, т', 'axialLoad'),
|
|
|
|
|
makeNumericMinMax('Давление, атм', 'pressure'),
|
|
|
|
|
makeNumericMinMax('Момент на ВСП, кН·м', 'rotorTorque'),
|
|
|
|
|
makeNumericMinMax('Обороты на ВСП, об/мин', 'rotorSpeed'),
|
|
|
|
|
makeNumericMinMax('Расход, л/с', 'flow')
|
2021-10-18 12:00:03 +05:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
export const DrillProcessFlow = ({idWell}) => {
|
|
|
|
|
const [flows, setFlows] = useState([])
|
|
|
|
|
const [showLoader, setShowLoader] = useState(false)
|
|
|
|
|
|
|
|
|
|
const updateFlows = () => invokeWebApiWrapperAsync(
|
|
|
|
|
async () => {
|
|
|
|
|
const flows = await DrillFlowChartService.get(idWell)
|
|
|
|
|
setFlows(Array.isArray(flows) ? flows : [])
|
|
|
|
|
},
|
|
|
|
|
setShowLoader,
|
|
|
|
|
'Не удалось загрузить режимно-технологическую карту скважины'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
useEffect(updateFlows, [idWell])
|
|
|
|
|
|
2021-10-18 13:24:11 +05:00
|
|
|
|
const onAdd = async (flow) => {
|
|
|
|
|
flow.idWell = idWell
|
|
|
|
|
await DrillFlowChartService.insert(idWell, flow)
|
2021-10-18 12:00:03 +05:00
|
|
|
|
updateFlows()
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-18 13:24:11 +05:00
|
|
|
|
const onEdit = async (flow) => {
|
|
|
|
|
if (!flow.id) return
|
|
|
|
|
flow.idWell = idWell
|
|
|
|
|
await DrillFlowChartService.edit(idWell, flow)
|
2021-10-18 12:00:03 +05:00
|
|
|
|
updateFlows()
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-18 13:24:11 +05:00
|
|
|
|
const onDelete = async (flow) => {
|
|
|
|
|
if (!flow.id) return
|
|
|
|
|
await DrillFlowChartService.delete(idWell, flow.id)
|
2021-10-18 12:00:03 +05:00
|
|
|
|
updateFlows()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<LoaderPortal show={showLoader}>
|
|
|
|
|
<EditableTable
|
|
|
|
|
size={'small'}
|
|
|
|
|
bordered
|
|
|
|
|
columns={columns}
|
|
|
|
|
dataSource={flows}
|
|
|
|
|
onRowAdd={onAdd}
|
|
|
|
|
onRowEdit={onEdit}
|
|
|
|
|
onRowDelete={onDelete}
|
|
|
|
|
pagination={false}
|
|
|
|
|
/>
|
|
|
|
|
</LoaderPortal>
|
|
|
|
|
)
|
|
|
|
|
}
|