content.jsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import React from 'react';
  2. import { Layout, Collapse, Form, Select, Input, Tabs } from 'antd';
  3. const { Header, Sider, Content } = Layout;
  4. const CollapsePanel = Collapse.Panel;
  5. const { TabPane } = Tabs;
  6. const { FormItem } = Form;
  7. const { Option } = Select;
  8. import emitter from '../../eventManger/ev';
  9. import BaseConfigForm from './sections/baseConfigForm';
  10. import PreparingForm from './sections/preparingForm';
  11. import AggregateTableConfigForm from './sections/aggregateTableConfigForm';
  12. import DataViewConfigForm from './sections/dataViewConfigForm';
  13. import LineConfigForm from './sections/lineConfigForm';
  14. import TableView from './charts/table';
  15. import EchartsView from './charts/echartsView';
  16. import StyleEditor from './sections/styleEditor';
  17. import ToolBar from './sections/toolBar';
  18. import './content.less';
  19. class ChartDesignerContent extends React.Component {
  20. constructor(props) {
  21. super(props);
  22. this.state = {
  23. viewType: {
  24. name: 'aggregateTable',
  25. label: '总体统计数据表',
  26. },
  27. baseConfig: props.baseConfig,
  28. preparingConfig: props.preparingConfig,
  29. chartOption: props.chartOption,
  30. history: {}
  31. }
  32. }
  33. componentDidMount() {
  34. // 在组件装载完成后发布事件
  35. this.eventEmitter = emitter.addListener('changeViewType', (viewType)=>{
  36. this.setState({
  37. viewType
  38. });
  39. });
  40. }
  41. componentWillUnmount() {
  42. emitter.removeAllListeners('changeViewType');
  43. }
  44. render() {
  45. let { viewType, baseConfig, preparingConfig, chartOption } = this.state;
  46. let configForm, chartView;
  47. if(viewType.name == 'aggregateTable') {
  48. configForm = (<AggregateTableConfigForm />);
  49. chartView = (<TableView />);
  50. }else if(viewType.name == 'dataView') {
  51. configForm = (<DataViewConfigForm />);
  52. chartView = (<TableView />);
  53. }else if(viewType.name == 'line') {
  54. configForm = (<DataViewConfigForm />);
  55. chartView = (<EchartsView option={chartOption}/>);
  56. }else if(viewType.name == 'bar') {
  57. configForm = (<DataViewConfigForm />);
  58. chartView = (<EchartsView option={chartOption}/>);
  59. }else if(viewType.name == 'pie') {
  60. configForm = (<LineConfigForm />);
  61. chartView = (<EchartsView option={chartOption}/>);
  62. }
  63. return (
  64. <Layout>
  65. <Sider width={270} style={{ overflow: 'auto' }}>
  66. <Collapse defaultActiveKey={['0', '1']}>
  67. <CollapsePanel header='基础设置'>
  68. <BaseConfigForm config={baseConfig}/>
  69. </CollapsePanel>
  70. <CollapsePanel header='数据预处理'>
  71. <PreparingForm config={preparingConfig}/>
  72. </CollapsePanel>
  73. </Collapse>
  74. </Sider>
  75. <Content>
  76. <Layout>
  77. <Header className='content-header'>
  78. <ToolBar className='header-toolbar'/>
  79. </Header>
  80. <Content>
  81. { chartView }
  82. </Content>
  83. </Layout>
  84. </Content>
  85. <Sider width={250}>
  86. <Collapse defaultActiveKey={['0', '1']}>
  87. <CollapsePanel header={`${viewType.label}选项`}>
  88. { configForm }
  89. </CollapsePanel>
  90. <CollapsePanel header='样式'>
  91. <StyleEditor />
  92. </CollapsePanel>
  93. </Collapse>
  94. </Sider>
  95. </Layout>
  96. )
  97. }
  98. }
  99. export default ChartDesignerContent;