baseConfigForm.jsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import React from 'react';
  2. import { Form, Select, Input, Icon, Dropdown, Menu, Row, Col, Card } from 'antd';
  3. const FormItem = Form.Item;
  4. const { Option } = Select;
  5. const { Search } = Input;
  6. import { connect } from 'dva';
  7. import chartDesigner from '../../../models/chartDesigner';
  8. import './baseConfigForm.less';
  9. class baseConfigForm extends React.Component {
  10. render() {
  11. const props = this.props;
  12. const allDataSource = props.chartDesigner.allDataSource;
  13. const { formItemLayout } = props
  14. const menu = (
  15. <Menu>
  16. <Menu.Item key="1">1st menu item</Menu.Item>
  17. <Menu.Item key="2">2nd memu item</Menu.Item>
  18. <Menu.Item key="3">3rd menu item</Menu.Item>
  19. </Menu>
  20. );
  21. return (
  22. <Form hideRequiredMark={true}>
  23. <FormItem label='数据源' {...formItemLayout}>
  24. <Select
  25. value={props.chartDesigner.baseConfig.dataSource}
  26. labelInValue={true}
  27. onChange={(value) => {
  28. props.dispatch({ type: 'chartDesigner/baseConfig/setDataSource', dataSource: value});
  29. }}
  30. >
  31. {allDataSource.map((dataSource, i)=>{
  32. return (<Option key={`dataSource-${i}`} value={dataSource.id}>{dataSource.name}</Option>)
  33. })}
  34. </Select>
  35. </FormItem>
  36. <FormItem label='可视化模式' {...formItemLayout}>
  37. <Select
  38. dropdownClassName='baseconfig-viewtype'
  39. value={props.chartDesigner.baseConfig.viewType.key}
  40. dropdownMatchSelectWidth={false}
  41. onChange={(value, item) => {
  42. props.dispatch({ type: 'chartDesigner/baseConfig/setViewType', viewType: {key: value, label: item.title}});
  43. }}
  44. >
  45. <Option value="aggregateTable" title='总体统计数据表'>
  46. <div className='viewtype-box'>
  47. <div className='viewtype-icon viewtype-icon-agg'>
  48. </div>
  49. <div className='viewtype-text'>
  50. 总体统计数据表
  51. </div>
  52. </div>
  53. </Option>
  54. <Option value="dataView" title='个体统计数据表'>
  55. <div className='viewtype-box'>
  56. <div className='viewtype-icon'>
  57. </div>
  58. <div className='viewtype-text'>
  59. 个体统计数据表
  60. </div>
  61. </div>
  62. </Option>
  63. <Option value="line" title='折线图'>
  64. <div className='viewtype-box'>
  65. <div className='viewtype-icon'>
  66. </div>
  67. <div className='viewtype-text'>
  68. 折线图
  69. </div>
  70. </div>
  71. </Option>
  72. <Option value="bar" title='柱状图'>
  73. <div className='viewtype-box'>
  74. <div className='viewtype-icon'>
  75. </div>
  76. <div className='viewtype-text'>
  77. 柱状图
  78. </div>
  79. </div>
  80. </Option>
  81. <Option value="pie" title='饼状图'>
  82. <div className='viewtype-box'>
  83. <div className='viewtype-icon'>
  84. </div>
  85. <div className='viewtype-text'>
  86. 饼状图
  87. </div>
  88. </div>
  89. </Option>
  90. <Option value="scatter" title='散点图'>
  91. <div className='viewtype-box'>
  92. <div className='viewtype-icon'>
  93. </div>
  94. <div className='viewtype-text'>
  95. 散点图
  96. </div>
  97. </div>
  98. </Option>
  99. </Select>
  100. {/* <Select
  101. value={props.chartDesigner.baseConfig.viewType}
  102. labelInValue={true}
  103. onChange={(value) => {
  104. props.dispatch({ type: 'chartDesigner/baseConfig/setViewType', viewType: value});
  105. }}
  106. >
  107. <Option value='aggregateTable'>总体统计数据表</Option>
  108. <Option value='dataView'>个体统计数据表</Option>
  109. <Option value='line'>折线图</Option>
  110. <Option value='bar'>柱状图</Option>
  111. <Option value='pie'>饼状图</Option>
  112. <Option value='scatter'>散点图</Option>
  113. </Select> */}
  114. </FormItem>
  115. </Form>
  116. );
  117. }
  118. }
  119. function mapStateToProps({ present: { chartDesigner } }) {
  120. return { chartDesigner: chartDesigner }
  121. }
  122. export default Form.create()(connect(mapStateToProps)(baseConfigForm));