lineConfigForm.jsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import React from 'react';
  2. import { Form, Select } from 'antd';
  3. const FormItem = Form.Item;
  4. const { Option } = Select;
  5. class LineConfigForm extends React.Component {
  6. constructor(props) {
  7. super(props);
  8. this.state = {
  9. }
  10. }
  11. render() {
  12. const columns = [
  13. { value: 'c1', label: '列1' },
  14. { value: 'c2', label: '列2' },
  15. { value: 'c3', label: '列3' },
  16. { value: 'c4', label: '列4' },
  17. { value: 'c5', label: '列5' },
  18. ];
  19. let targetColumn = ['c3'];
  20. const { getFieldDecorator, getFieldsError, getFieldError, isFieldTouched } = this.props.form;
  21. const formItemLayout = {
  22. labelCol: { span: 10 },
  23. wrapperCol: { span: 14 },
  24. };
  25. return (
  26. <Form layout='horizontal'>
  27. <FormItem label='横轴' {...formItemLayout}>
  28. {getFieldDecorator('xAxis', {
  29. initialValue : targetColumn
  30. })(
  31. <Select mode='multiple'>
  32. {columns.map((c, i)=>{
  33. return (<Option key={`xaxis-${i}`} value={c.value}>{c.label}</Option>)
  34. })}
  35. </Select>
  36. )}
  37. </FormItem>
  38. <FormItem label='纵轴' {...formItemLayout}>
  39. {getFieldDecorator('yAxis', {
  40. initialValue : targetColumn
  41. })(
  42. <Select mode='multiple'>
  43. {columns.map((c, i)=>{
  44. return (<Option key={`yaxis-${i}`} value={c.value}>{c.label}</Option>)
  45. })}
  46. </Select>
  47. )}
  48. </FormItem>
  49. </Form>
  50. );
  51. }
  52. }
  53. export default Form.create()(LineConfigForm);