1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import React from 'react';
import { Form, Modal, message } from 'antd';
import CFormItem from './CreateFormItem';
let UForm = React.createClass({
getInitialState: function() {
return {
};
},
render: function() {
const self = this;
const UType = this.props.UType;
const updateItem = this.props.updateItem;
// 详情见antd form 文档
const { getFieldProps } = this.props.form;
const formItemLayout = {
labelCol: { span: 6 },
wrapperCol: { span: 18 },
};
return UType ?
<div className="f-update">
<Modal title="更新对象" visible={this.props.isShow} onOk={this.handleUpdate} onCancel={this.hideModal}>
<Form horizontal form={this.props.form}>
{
UType.map(function(item){
item.defaultValue = updateItem[item.name]||'';
//return self.dealConfigUType(item, defaultValue);
return <CFormItem key={item.name} getFieldProps={getFieldProps} formItemLayout={formItemLayout} item={item}/>
})
}
</Form>
</Modal>
</div>:
<div></div>
},
handleUpdate: function(){
this.props.submit(this.props.form.getFieldsValue());
},
handleReset: function() {
this.props.form.resetFields();
},
hideModal: function() {
this.props.hideForm();
this.handleReset();
}
});
UForm = Form.create()(UForm);
export default UForm;