preparingForm.jsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React from 'react';
  2. import { Form, Select } from 'antd';
  3. const FormItem = Form.Item;
  4. const { Option } = Select;
  5. import { connect } from 'dva';
  6. import chartDesigner from '../../../models/chartDesigner';
  7. class PreparingForm extends React.Component {
  8. render() {
  9. const props = this.props;
  10. const columns = props.chartDesigner.columns;
  11. const { formItemLayout } = props
  12. return (
  13. <Form layout='horizontal'>
  14. <FormItem label='分组' {...formItemLayout}>
  15. <Select
  16. mode="multiple"
  17. labelInValue={true}
  18. placeholder='请选择...'
  19. onChange={(value) => {
  20. props.dispatch({ type: 'chartDesigner/setModel', name: 'preparing', value: { ...props.chartDesigner.preparing, groupBy: value } });
  21. }}
  22. value={props.chartDesigner.preparing.groupBy}
  23. >
  24. {columns.map((c, i)=>{
  25. return (<Option key={i} value={c.name}>{c.label}</Option>)
  26. })}
  27. </Select>
  28. </FormItem>
  29. </Form>
  30. );
  31. }
  32. };
  33. function mapStateToProps({ present: { chartDesigner } }) {
  34. return { chartDesigner: chartDesigner }
  35. }
  36. export default connect(mapStateToProps)(PreparingForm);