aggregateTableConfigForm.jsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import React from 'react';
  2. import { Form, Select, Checkbox } from 'antd';
  3. const FormItem = Form.Item;
  4. const { Option } = Select;
  5. const CheckboxGroup = Checkbox.Group;
  6. import { connect } from 'dva';
  7. import chartDesigner from '../../../models/chartDesigner';
  8. class AggregateTableConfigForm extends React.Component {
  9. render() {
  10. const props = this.props;
  11. const columns = props.chartDesigner.columns;
  12. const statisticsOptions = [
  13. { value: 'count', label: '条数', checked: true },
  14. { value: 'max', label: '最大值', checked: true },
  15. { value: 'percentage', label: '百分比', checked: true },
  16. { value: '75th', label: '75th值', checked: true },
  17. { value: 'sum', label: '总和', checked: true },
  18. { value: 'median', label: '中位数', checked: false },
  19. { value: 'avg', label: '平均数', checked: true },
  20. { value: '25th', label: '25th值', checked: true },
  21. { value: 'std', label: '标准差', checked: true },
  22. { value: 'min', label: '最小值', checked: true }
  23. ];
  24. let filterFunc = function(option) {
  25. return option.checked == true;
  26. }
  27. const { getFieldDecorator, getFieldsError, getFieldError, isFieldTouched } = this.props.form;
  28. const { formItemLayout } = props
  29. return (
  30. <Form>
  31. <FormItem label='分析目标' {...formItemLayout}>
  32. <Select
  33. value={props.chartDesigner.aggregateTable.targetColumn}
  34. mode='multiple'
  35. labelInValue={true}
  36. onChange={(value) => {
  37. props.dispatch({ type: 'chartDesigner/aggregateTable/setTargetColumn', targetColumn: value});
  38. }}
  39. >
  40. {columns.map((c, i)=>{
  41. return (<Option key={i} value={c.name}>{c.label}</Option>)
  42. })}
  43. </Select>
  44. </FormItem>
  45. <FormItem label='显示总体数据' {...formItemLayout}>
  46. <CheckboxGroup
  47. value={props.chartDesigner.aggregateTable.statistics}
  48. options={statisticsOptions.map((s)=>{return s.label})}
  49. onChange={(value) => {
  50. props.dispatch({ type: 'chartDesigner/aggregateTable/setStatistics', statistics: value});
  51. }}
  52. />
  53. </FormItem>
  54. </Form>
  55. );
  56. }
  57. }
  58. function mapStateToProps({ present: { chartDesigner } }) {
  59. return { chartDesigner: chartDesigner }
  60. }
  61. export default Form.create()(connect(mapStateToProps)(AggregateTableConfigForm));