aggregateTableConfigForm.jsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 { formItemLayout } = props
  28. return (
  29. <Form>
  30. <FormItem label='分析目标' {...formItemLayout}>
  31. <Select
  32. value={props.chartDesigner.aggregateTable.targetColumn}
  33. mode='multiple'
  34. labelInValue={true}
  35. onChange={(value) => {
  36. props.dispatch({ type: 'chartDesigner/setModel', name: 'aggregateTable', value: { ...props.chartDesigner.aggregateTable, targetColumn: value } });
  37. }}
  38. >
  39. {columns.map((c, i)=>{
  40. return (<Option key={i} value={c.name}>{c.label}</Option>)
  41. })}
  42. </Select>
  43. </FormItem>
  44. <FormItem label='显示总体数据' {...formItemLayout}>
  45. <CheckboxGroup
  46. value={props.chartDesigner.aggregateTable.statistics}
  47. options={statisticsOptions.map((s)=>{return s.label})}
  48. onChange={(value) => {
  49. props.dispatch({ type: 'chartDesigner/setModel', name: 'aggregateTable', value: { ...props.chartDesigner.aggregateTable, statistics: value } });
  50. }}
  51. />
  52. </FormItem>
  53. </Form>
  54. );
  55. }
  56. }
  57. function mapStateToProps({ present: { chartDesigner } }) {
  58. return { chartDesigner: chartDesigner }
  59. }
  60. export default connect(mapStateToProps)(AggregateTableConfigForm);