preparingForm.jsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import React from 'react';
  2. import { Form, Icon, Input, Button, Select, Switch } from 'antd';
  3. const FormItem = Form.Item;
  4. const { Option } = Select;
  5. class PreparingForm extends React.Component {
  6. constructor(props) {
  7. super(props);
  8. this.state = {
  9. config: props.config
  10. }
  11. }
  12. componentDidMount() {
  13. // To disabled submit button at the beginning.
  14. this.props.form.validateFields();
  15. }
  16. render() {
  17. const { config } = this.state;
  18. const { groupBy } = config;
  19. const { getFieldDecorator, getFieldsError, getFieldError, isFieldTouched } = this.props.form;
  20. const formItemLayout = {
  21. labelCol: { span: 10 },
  22. wrapperCol: { span: 14 },
  23. };
  24. const columns = [
  25. { value: 'c1', label: '列1' },
  26. { value: 'c2', label: '列2' },
  27. { value: 'c3', label: '列3' },
  28. { value: 'c4', label: '列4' },
  29. { value: 'c5', label: '列5' },
  30. { value: 'c6', label: '列6' },
  31. { value: 'c7', label: '列7' },
  32. { value: 'c8', label: '列8' },
  33. { value: 'c9', label: '列9' },
  34. { value: 'c10', label: '列10' },
  35. { value: 'c11', label: '列11' },
  36. { value: 'c12', label: '列12' },
  37. { value: 'c13', label: '列13' }
  38. ];
  39. return (
  40. <Form layout='horizontal'>
  41. <FormItem label='分组' {...formItemLayout}>
  42. {getFieldDecorator('groupBy', {
  43. initialValue : groupBy
  44. })(
  45. <Select mode="multiple">
  46. {columns.map((c, i)=>{
  47. return (<Option key={`column-${i}`} value={c.value}>{c.label}</Option>)
  48. })}
  49. </Select>
  50. )}
  51. </FormItem>
  52. {/* <FormItem label='分段' {...formItemLayout}>
  53. {getFieldDecorator('bucketization', {
  54. initialValue : bucketization
  55. })(
  56. <Select mode="multiple">
  57. {bucketizations.map((b, i)=>{
  58. return (<Option key={`bucketization-${i}`} value={b.value}>{b.label}</Option>)
  59. })}
  60. </Select>
  61. )}
  62. </FormItem> */}
  63. </Form>
  64. );
  65. }
  66. }
  67. export default Form.create()(PreparingForm);