如图: 是一个form表单,在顶部输入数据点击新增,怎么把数据插入到下面的表格中,并显示。
页面代码:
编辑跳转表单的代码:
showEditForm=(text) =>{
const data_save = this.props.signal.data_save.data
const data_form = []
for (let j=0; j
for (let i=0; i
if(data_save[j].variety == text.variety){
this.setState({
okText: '保存',
modalVisible:true,
isCreate:false,
formTitle: '编辑交易信号'+' '+text.variety,
currentEditId:text.variety,
data_form:
data_form.valueOf(
data_form.push({
time:data_save[j].signal[i][0],
signal:data_save[j].signal[i][1]
})
),
})
/*console.log("data_form", data_form)*/
this.form.setFieldsValue({
...data_form
});
}
}
}
}
表单代码:
import React from 'react'
import PropTypes from 'prop-types'
import { Table, Form, Card, Tooltip, Input, InputNumber, Radio, Modal,Select, Icon, Button, TimePicker } from 'antd';
import currencies from '../../common/currencies.js';
const FormItem = Form.Item
const format = 'HH:mm';
const AddSignal =(props) => {
console.log("form",props)
this.state ={
data: props.data,
loading: false,
}
console.log("state", this.state)
const handleSubmit = (e) => {
e.preventDefault();
form.validateFields((err, values) =>{
if(!err) {
this.state.data.valueOf(this.state.data.push(values))
console.log('form1', values, this.state.data)
}
})
}
const {visible, onCancel, onCreateOrSave, form, title, okText, initValues} = props;
const { getFieldDecorator } = form;
const clumn = [
{
title: '时间',
dataIndex: 'time',
width: 100,
editable: true,
},
{
title: '信号',
dataIndex: 'signal',
width: 120,
editable: true,
},
{
title: '操作',
dataIndex: 'action',
width: 30,
render: (text, record, index) => (
),
}]
return (
visible={visible}
title={title}
okText={okText}
onCancel={onCancel}
onOk={onCreateOrSave}>
{getFieldDecorator('time',{})(
/**/
)}
{getFieldDecorator('signal',{})(
[开始]
[结束交易]
[集合]
)}
新增
)
}
export default Form.create()(AddSignal)