From 9973009c65de88bf06af63102b659ebd92a43f31 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Wed, 6 Oct 2021 15:31:55 +0500 Subject: [PATCH] CF2-49: Added 'Insert' and 'Delete' actions --- src/pages/Measure/MeasureTable.jsx | 31 ++++++++++++++++++++++++++---- src/pages/Measure/index.jsx | 12 +++++++++++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx index 67b712a..e1337d7 100644 --- a/src/pages/Measure/MeasureTable.jsx +++ b/src/pages/Measure/MeasureTable.jsx @@ -4,12 +4,13 @@ import moment from 'moment' import { ExclamationCircleOutlined } from '@ant-design/icons' import { View } from './View' import LoaderPortal from '../../components/LoaderPortal' +import { MeasureService } from '../../services/api' import '../../styles/index.css' import '../../styles/measure.css' const format='YYYY.MM.DD HH:mm' -export const MeasureTable = ({title, columns, values}) => { +export const MeasureTable = ({idWell, idCategory, title, columns, values, updateMeasuresDelegate}) => { var defaultDisplay = values && values.length ? values[values.length-1] : [] @@ -55,7 +56,20 @@ export const MeasureTable = ({title, columns, values}) => {

{editingActionName} данные?

- +
@@ -78,7 +92,7 @@ export const MeasureTable = ({title, columns, values}) => { : switchableColumns = createEditingColumns(columns, null) setEditingColumns(switchableColumns) - }, [isTableEditing]) + }, [isTableEditing, columns, editingActionName]) let handleSubmitMeasuresForm = async (formData) => { @@ -86,10 +100,19 @@ export const MeasureTable = ({title, columns, values}) => { // measuresForm.setFieldsValue({ // ...displayedValues // }); - measuresForm.validateFields() + const measureParams = { + idWell: idWell, + idCategory: idCategory, + timestamp: new Date().toISOString(), + data: formData + } + setShowLoader(true) + await MeasureService.insert(idWell, measureParams) + setIsTableEditing(false) + updateMeasuresDelegate() setShowLoader(false) } diff --git a/src/pages/Measure/index.jsx b/src/pages/Measure/index.jsx index a1d66a4..6f5a20c 100644 --- a/src/pages/Measure/index.jsx +++ b/src/pages/Measure/index.jsx @@ -12,6 +12,7 @@ export default function Measure({idWell}){ const [fluidValues, setFluidValues] = useState([]) const [mudValues, setMudValues] = useState([]) const [nnbValues, setNnbValues] = useState([]) + const [isMeasuresUpdating, setIsMeasuresUpdating] = useState(false) const updateCurrentValues = () => invokeWebApiWrapperAsync(async()=>{ const measures = await MeasureService.getHisory(idWell) @@ -26,24 +27,33 @@ export default function Measure({idWell}){ ,setShowLoader ,`Не удалось загрузить последние данные по скважине ${idWell}`) - useEffect(updateCurrentValues, [idWell]) + useEffect(updateCurrentValues, [idWell, isMeasuresUpdating]) return <> setIsMeasuresUpdating(true)} /> setIsMeasuresUpdating(true)} /> setIsMeasuresUpdating(true)} />