CF2-49: Added values to table inputs while 'Measures' table update

This commit is contained in:
KharchenkoVV 2021-10-07 10:48:26 +05:00
parent c6bdb27857
commit d562b910ca
3 changed files with 20 additions and 19 deletions

View File

@ -1,5 +1,5 @@
import { useState, useEffect } from 'react' import { useState, useEffect } from 'react'
import { Button, Form, Timeline } from 'antd' import { Button, Form, Input, Timeline } from 'antd'
import moment from 'moment' import moment from 'moment'
import { ExclamationCircleOutlined } from '@ant-design/icons' import { ExclamationCircleOutlined } from '@ant-design/icons'
import { View } from './View' import { View } from './View'
@ -44,12 +44,18 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update
useEffect(() => { useEffect(() => {
let switchableColumns = [] let switchableColumns = []
isTableEditing && editingActionName !== 'Удалить' isTableEditing && editingActionName !== 'Удалить'
? switchableColumns = createEditingColumns(columns, () => <input className='w-100'></input>) ? switchableColumns = createEditingColumns(columns, () => <Input className='w-100' />)
: switchableColumns = createEditingColumns(columns, null) : switchableColumns = createEditingColumns(columns, null)
if(editingActionName === 'Редактировать')
measuresForm.setFieldsValue(displayedValues.data);
else if(editingActionName === 'Добавить')
measuresForm.resetFields()
setEditingColumns(switchableColumns) setEditingColumns(switchableColumns)
}, [isTableEditing, columns, editingActionName]) }, [isTableEditing, columns, editingActionName, displayedValues.data, measuresForm])
const buttonsConfig = [ const buttonsConfig = [
{name:'Добавить', key:'add'}, {name:'Добавить', key:'add'},
@ -60,14 +66,14 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update
const createButtons = (config, onClickDelegate) => { const createButtons = (config, onClickDelegate) => {
return ( return (
<div className='w-300px mt-12px'> <div className='w-300px mt-12px'>
{config.map(c => { {config.map(conf => {
return ( return (
<Button <Button
key={c.key} key={conf.key}
className='w-100' className='w-100'
onClick={onClickDelegate} onClick={onClickDelegate}
> >
{c.name} {conf.name}
</Button> </Button>
) )
})} })}
@ -103,10 +109,6 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update
</div> </div>
let handleSubmitMeasuresForm = async (formData) => { let handleSubmitMeasuresForm = async (formData) => {
// if(isTableEditing)
// measuresForm.setFieldsValue({
// ...displayedValues
// });
measuresForm.validateFields() measuresForm.validateFields()
const measureParams = { const measureParams = {
@ -162,7 +164,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update
onFinish={handleSubmitMeasuresForm} onFinish={handleSubmitMeasuresForm}
> >
<View <View
item={displayedValues?.data ?? []} item={displayedValues.data}
columns={editingColumns} columns={editingColumns}
/> />
</Form> </Form>

View File

@ -31,10 +31,7 @@ export const View = ({columns, item}) => {
<GridItem <GridItem
row={row} row={row}
col={colb*2 + 1} col={colb*2 + 1}
style={{background:'#00000005', style={{border:'1px solid lightgrey'}}
//width: '300px',
border:'1px solid black'
}}
> >
{column.title} {column.title}
</GridItem> </GridItem>
@ -42,9 +39,7 @@ export const View = ({columns, item}) => {
<GridItem <GridItem
row={row} row={row}
col={colb*2 + 2} col={colb*2 + 2}
style={{background:'#00000005', style={{border:'1px solid lightgrey',
//width: '150px',
border:'1px solid black',
justifyContent:'right', justifyContent:'right',
marginRight:'16px', marginRight:'16px',
fontWeight:'bold', fontWeight:'bold',

View File

@ -1,3 +1,7 @@
input {
font-weight:bold;
}
.w-300px { .w-300px {
width: 300px; width: 300px;
} }