diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx index eb4714c..5cb1c45 100644 --- a/src/pages/Measure/MeasureTable.jsx +++ b/src/pages/Measure/MeasureTable.jsx @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react' -import { Button, Form, Timeline } from 'antd' +import { Button, Form, Input, Timeline } from 'antd' import moment from 'moment' import { ExclamationCircleOutlined } from '@ant-design/icons' import { View } from './View' @@ -44,12 +44,18 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update useEffect(() => { let switchableColumns = [] + isTableEditing && editingActionName !== 'Удалить' - ? switchableColumns = createEditingColumns(columns, () => ) + ? switchableColumns = createEditingColumns(columns, () => ) : switchableColumns = createEditingColumns(columns, null) + if(editingActionName === 'Редактировать') + measuresForm.setFieldsValue(displayedValues.data); + else if(editingActionName === 'Добавить') + measuresForm.resetFields() + setEditingColumns(switchableColumns) - }, [isTableEditing, columns, editingActionName]) + }, [isTableEditing, columns, editingActionName, displayedValues.data, measuresForm]) const buttonsConfig = [ {name:'Добавить', key:'add'}, @@ -60,14 +66,14 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update const createButtons = (config, onClickDelegate) => { return (
- {config.map(c => { + {config.map(conf => { return ( ) })} @@ -75,7 +81,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update ) } - const crudButtons = createButtons(buttonsConfig, (e)=> { + const crudButtons = createButtons(buttonsConfig, (e) => { setEditingActionName(e.target.innerText) setIsTableEditing(true) }) @@ -103,10 +109,6 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update
let handleSubmitMeasuresForm = async (formData) => { - // if(isTableEditing) - // measuresForm.setFieldsValue({ - // ...displayedValues - // }); measuresForm.validateFields() const measureParams = { @@ -162,7 +164,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update onFinish={handleSubmitMeasuresForm} > diff --git a/src/pages/Measure/View.jsx b/src/pages/Measure/View.jsx index 419caad..16a9c80 100644 --- a/src/pages/Measure/View.jsx +++ b/src/pages/Measure/View.jsx @@ -31,10 +31,7 @@ export const View = ({columns, item}) => { {column.title} @@ -42,9 +39,7 @@ export const View = ({columns, item}) => {