aggregateTableConfigForm.jsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import React from 'react';
  2. import { Form, Icon, Input, Button, Select, Switch, Checkbox } from 'antd';
  3. const FormItem = Form.Item;
  4. const { Option } = Select;
  5. const CheckboxGroup = Checkbox.Group;
  6. class AggregateTableConfigForm extends React.Component {
  7. constructor(props) {
  8. super(props);
  9. this.state = {
  10. config: props.config
  11. }
  12. }
  13. componentDidMount() {
  14. }
  15. onChange(checkedList) {
  16. }
  17. render() {
  18. const { config } = this.state;
  19. const columns = [
  20. { value: 'c1', label: '列1' },
  21. { value: 'c2', label: '列2' },
  22. { value: 'c3', label: '列3' },
  23. { value: 'c4', label: '列4' },
  24. { value: 'c5', label: '列5' },
  25. ];
  26. let targetColumn = ['c3'];
  27. const statisticsOptions = [
  28. { value: 'count', label: '条数', checked: true },
  29. { value: 'max', label: '最大值', checked: true },
  30. { value: 'percentage', label: '百分比', checked: true },
  31. { value: '75th', label: '75th值', checked: true },
  32. { value: 'sum', label: '总和', checked: true },
  33. { value: 'median', label: '中位数', checked: false },
  34. { value: 'avg', label: '平均数', checked: true },
  35. { value: '25th', label: '25th值', checked: true },
  36. { value: 'std', label: '标准差', checked: true },
  37. { value: 'min', label: '最小值', checked: true }
  38. ];
  39. let filterFunc = function(option) {
  40. return option.checked == true;
  41. }
  42. const { getFieldDecorator, getFieldsError, getFieldError, isFieldTouched } = this.props.form;
  43. const formItemLayout = {
  44. labelCol: { span: 10 },
  45. wrapperCol: { span: 14 },
  46. };
  47. return (
  48. <Form layout='horizontal'>
  49. <FormItem label='分析目标' {...formItemLayout}>
  50. {getFieldDecorator('targetColumn', {
  51. rules: [{ required: true, message: '分析目标不能为空' }],
  52. initialValue : targetColumn
  53. })(
  54. <Select mode='multiple'>
  55. {columns.map((c, i)=>{
  56. return (<Option key={`c-${i}`} value={c.value}>{c.label}</Option>)
  57. })}
  58. </Select>
  59. )}
  60. </FormItem>
  61. <FormItem label='显示总体数据' {...formItemLayout}>
  62. {getFieldDecorator('statistics', {
  63. initialValue: statisticsOptions.filter(filterFunc).map((s)=>{return s.label})
  64. })(
  65. <CheckboxGroup options={statisticsOptions.map((s)=>{return s.label})} onChange={this.onChange} />
  66. )}
  67. </FormItem>
  68. </Form>
  69. );
  70. }
  71. }
  72. export default Form.create()(AggregateTableConfigForm);