{"size": 1741, "ext": "js", "max_stars_repo_path": "src/routes/Doorplate/DoorplateStatistic/DoorplateStatistic.js", "max_stars_repo_name": "bingotao/JXToponymy", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/routes/Doorplate/DoorplateStatistic/DoorplateStatistic.js", "max_issues_repo_name": "bingotao/JXToponymy", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/routes/Doorplate/DoorplateStatistic/DoorplateStatistic.js", "max_forks_repo_name": "bingotao/JXToponymy", "max_forks_repo_forks_event_min_datetime": "2020-01-03T02:58:09.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-03T02:58:09.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 23.527027027, "max_line_length": 63, "alphanum_fraction": 0.5427914991}
import React, { Component } from 'react';

import st from './DoorplateStatistic.less';

import PersonStatistic from './PersonStatistic.js';
import AreaStatistic from './AreaStatistic.js';
import CountStatisitic from './CountStatisitic.js';
import Authorized from '../../../utils/Authorized4';

class DoorplateStatistic extends Component {
  state = {
    current: 'CountStatistic',
  };

  getContent() {
    let { current } = this.state;
    switch (current) {
      case 'PersonStatistic':
        return (
          <Authorized>
            <PersonStatistic />
          </Authorized>
        );
      case 'CountStatistic':
        return (
          <Authorized>
            <CountStatisitic />
          </Authorized>
        );
      case 'AreaStatistic':
        return (
          <Authorized>
            <AreaStatistic />
          </Authorized>
        );
      default:
        return <div>未找到相应组件</div>;
    }
  }

  componentDidMount() {
    let that = this;
    $(this.navs)
      .find('div')
      .on('click', function() {
        let ac = 'active';
        let $this = $(this);
        $this
          .addClass(ac)
          .siblings()
          .removeClass(ac);

        that.setState({ current: $this.data('target') });
      });
  }

  render() {
    return (
      <div className={st.DoorplateStatistic}>
        <div ref={e => (this.navs = e)} className={st.navs}>
          <div className="active" data-target="CountStatistic">
            业务量统计
          </div>
          <div data-target="PersonStatistic">详单统计</div>
          <div data-target="AreaStatistic">门牌统计</div>
        </div>
        <div className={st.content}>{this.getContent()}</div>
      </div>
    );
  }
}

export default DoorplateStatistic;
