content.jsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import React, { Component } from 'react';
  2. import '../content.less';
  3. import LeftTab from './leftTab';
  4. import TechAchievement from './myClient';
  5. class Content extends Component {
  6. constructor() {
  7. super();
  8. this.state = {
  9. loading: false,
  10. component: 'div'
  11. };
  12. }
  13. componentWillMount() {
  14. if (window.location.hash) {
  15. this.getKey(window.location.hash.substr(1));
  16. } else {
  17. this.getKey("myClient");
  18. };
  19. }
  20. getKey(key) {
  21. switch (key) {
  22. case 'myClient':
  23. require.ensure([], () => {
  24. const TechAchievement = require('./myClient').default;
  25. this.setState({
  26. component: TechAchievement ,
  27. listApiUrl: '/api/admin/achievement/orgList',
  28. detailApiUrl: '/api/admin/achievement/orgDetail'
  29. });
  30. });
  31. break;
  32. case 'publicCustomer':
  33. require.ensure([], () => {
  34. const AchievementOrder = require('./publicCustomer').default;
  35. this.setState({
  36. component:AchievementOrder,
  37. listApiUrl: '/api/admin/achievement/orgList',
  38. detailApiUrl: '/api/admin/achievement/orgDetail'
  39. });
  40. });
  41. break;
  42. };
  43. window.location.hash = key;
  44. }
  45. render() {
  46. return (
  47. <div className="manage-content">
  48. <LeftTab handlekey={this.getKey.bind(this)} />
  49. <div className="content-right">
  50. <this.state.component
  51. data-listApiUrl={this.state.listApiUrl}
  52. data-detailApiUrl={this.state.detailApiUrl} />
  53. </div>
  54. </div>
  55. )
  56. }
  57. }
  58. export default Content;