baseConfigForm.jsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 '../../../models/chartDesigner'
  8. import '../../../models/dataSource'
  9. import CHART_TYPE from './chartType.json'
  10. import './baseConfigForm.less'
  11. class baseConfigForm extends React.Component {
  12. render() {
  13. const props = this.props;
  14. const allDataSource = props.dataSource.list;
  15. const { formItemLayout } = props
  16. return (
  17. <Form hideRequiredMark={true}>
  18. <FormItem label='数据源' {...formItemLayout}>
  19. <Select
  20. value={props.chartDesigner.baseConfig.dataSource}
  21. labelInValue={true}
  22. onChange={(value) => {
  23. props.dispatch({ type: 'chartDesigner/setModel', name: 'baseConfig', value: {
  24. ...props.chartDesigner.baseConfig, dataSource: value } });
  25. }}
  26. >
  27. {allDataSource.map((dataSource, i)=>{
  28. return (<Option key={`dataSource-${i}`} value={dataSource.code}>{dataSource.name}</Option>)
  29. })}
  30. </Select>
  31. </FormItem>
  32. <FormItem label='可视化模式' {...formItemLayout}>
  33. <Select
  34. dropdownClassName='baseconfig-viewtype'
  35. value={props.chartDesigner.baseConfig.viewType.key}
  36. dropdownMatchSelectWidth={false}
  37. onChange={(value, item) => {
  38. props.dispatch({ type: 'chartDesigner/setModel', name: 'baseConfig', value: { ...props.chartDesigner.baseConfig, viewType: { key: value, label: item.title } } });
  39. }}
  40. >
  41. {
  42. CHART_TYPE.map( c => (
  43. <Option key={c.type} value={c.type} title={c.label}>
  44. <div className='viewtype-box'>
  45. <div className='viewtype-icon'>
  46. </div>
  47. <div className='viewtype-text'>
  48. {c.label}
  49. </div>
  50. </div>
  51. </Option>
  52. ))
  53. }
  54. </Select>
  55. </FormItem>
  56. </Form>
  57. );
  58. }
  59. }
  60. function mapStateToProps({ present: { chartDesigner, dataSource } }) {
  61. return { chartDesigner, dataSource }
  62. }
  63. export default Form.create()(connect(mapStateToProps)(baseConfigForm));