forked from ddrilling/asb_cloud_front
Обновлено использование WellService и DrillFlowChartService
This commit is contained in:
parent
69fc308352
commit
f133728e1b
@ -363,8 +363,8 @@ const TelemetryView = memo(() => {
|
|||||||
|
|
||||||
const onStatusChanged = useCallback((value) => invokeWebApiWrapperAsync(
|
const onStatusChanged = useCallback((value) => invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const well = { ...wellData, idState: value }
|
const well = { idWell, ...wellData, idState: value }
|
||||||
await WellService.updateWell(idWell, well)
|
await WellService.updateWell(well)
|
||||||
setWellData(well)
|
setWellData(well)
|
||||||
},
|
},
|
||||||
setShowLoader,
|
setShowLoader,
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
import { useState, useEffect, memo } from 'react'
|
import { useState, useEffect, memo } from 'react'
|
||||||
|
|
||||||
import { useIdWell } from '@asb/context'
|
import { useIdWell } from '@asb/context'
|
||||||
import {
|
|
||||||
EditableTable,
|
|
||||||
makeNumericMinMax,
|
|
||||||
makeNumericStartEnd,
|
|
||||||
} from '@components/Table'
|
|
||||||
import LoaderPortal from '@components/LoaderPortal'
|
import LoaderPortal from '@components/LoaderPortal'
|
||||||
import { invokeWebApiWrapperAsync } from '@components/factory'
|
import { invokeWebApiWrapperAsync } from '@components/factory'
|
||||||
import { hasPermission, arrayOrDefault } from '@utils'
|
import { EditableTable, makeNumericMinMax, makeNumericStartEnd } from '@components/Table'
|
||||||
import { DrillFlowChartService } from '@api'
|
import { DrillFlowChartService } from '@api'
|
||||||
|
import { arrayOrDefault } from '@utils'
|
||||||
|
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
@ -41,24 +37,22 @@ export const DrillProcessFlow = memo(() => {
|
|||||||
updateFlows()
|
updateFlows()
|
||||||
}, [idWell])
|
}, [idWell])
|
||||||
|
|
||||||
const onAdd = async (flow) => {
|
const tableHandlers = useMemo(() => {
|
||||||
flow.idWell = idWell
|
const handlerProps = {
|
||||||
await DrillFlowChartService.insert(idWell, flow)
|
service: DrillFlowChartService,
|
||||||
updateFlows()
|
setLoader: setShowLoader,
|
||||||
}
|
onComplete: updateFlows,
|
||||||
|
permission: 'DrillFlowChart.edit',
|
||||||
|
}
|
||||||
|
|
||||||
const onEdit = async (flow) => {
|
const recordParser = (record) => ({ idWell, ...record })
|
||||||
if (!flow.id) return
|
|
||||||
flow.idWell = idWell
|
|
||||||
await DrillFlowChartService.edit(idWell, flow)
|
|
||||||
updateFlows()
|
|
||||||
}
|
|
||||||
|
|
||||||
const onDelete = async (flow) => {
|
return {
|
||||||
if (!flow.id) return
|
add: { ...handlerProps, action: 'insert', actionName: 'Добавление месторождения', recordParser },
|
||||||
await DrillFlowChartService.delete(idWell, flow.id)
|
edit: { ...handlerProps, action: 'update', actionName: 'Редактирование месторождения', recordParser },
|
||||||
updateFlows()
|
delete: { ...handlerProps, action: 'delete', actionName: 'Удаление месторождения', permission: 'DrillFlowChart.delete' },
|
||||||
}
|
}
|
||||||
|
}, [updateFlows, idWell])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LoaderPortal show={showLoader}>
|
<LoaderPortal show={showLoader}>
|
||||||
@ -67,10 +61,10 @@ export const DrillProcessFlow = memo(() => {
|
|||||||
size={'small'}
|
size={'small'}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={flows}
|
dataSource={flows}
|
||||||
|
onRowAdd={tableHandlers.add}
|
||||||
|
onRowEdit={tableHandlers.edit}
|
||||||
|
onRowDelete={tableHandlers.delete}
|
||||||
tableName={'well_operations_flow'}
|
tableName={'well_operations_flow'}
|
||||||
onRowAdd={hasPermission('DrillFlowChart.edit') && onAdd}
|
|
||||||
onRowEdit={hasPermission('DrillFlowChart.edit') && onEdit}
|
|
||||||
onRowDelete={hasPermission('DrillFlowChart.delete') && onDelete}
|
|
||||||
pagination={false}
|
pagination={false}
|
||||||
/>
|
/>
|
||||||
</LoaderPortal>
|
</LoaderPortal>
|
||||||
|
Loading…
Reference in New Issue
Block a user