content.jsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import React, { Component } from 'react';
  2. import '../content.less';
  3. import LeftTab from './leftTab';
  4. import TechAchievement from './myClient';
  5. import PublicCustomer from './publicCustomer';
  6. import CompanyCustomer from './companyCustomer';
  7. import Teamcustomer from './teamCustomer';
  8. class Content extends Component {
  9. constructor() {
  10. super();
  11. this.state = {
  12. loading: false,
  13. component: 'div'
  14. };
  15. }
  16. componentWillMount() {
  17. if (window.location.hash) {
  18. this.getKey(window.location.hash.substr(1));
  19. } else {
  20. this.getKey("myClient");
  21. };
  22. }
  23. getKey(key) {
  24. switch (key) {
  25. case 'myClient':
  26. require.ensure([], () => {
  27. const TechAchievement = require('./myClient').default;
  28. this.setState({
  29. component: TechAchievement ,
  30. detailApiUrl: '/api/admin/customer/findCustomerUserDetails'
  31. });
  32. });
  33. break;
  34. case 'publicCustomer':
  35. require.ensure([], () => {
  36. const publicCustomer = require('./publicCustomer').default;
  37. this.setState({
  38. component:publicCustomer,
  39. detailApiUrl: '/api/admin/customer/orgDetail'
  40. });
  41. });
  42. break;
  43. case 'companyCustomer':
  44. require.ensure([], () => {
  45. const companyCustomer = require('./companyCustomer').default;
  46. this.setState({
  47. component:companyCustomer,
  48. detailApiUrl: '/api/admin/customer/listCompanyCustomer'
  49. });
  50. });
  51. break;
  52. case 'teamCustomer':
  53. require.ensure([], () => {
  54. const teamCustomer = require('./teamCustomer').default;
  55. this.setState({
  56. component:teamCustomer,
  57. detailApiUrl: '/api/admin/customer/listTeamCustomer'
  58. });
  59. });
  60. break;
  61. };
  62. window.location.hash = key;
  63. }
  64. render() {
  65. return (
  66. <div className="manage-content">
  67. <LeftTab handlekey={this.getKey.bind(this)} />
  68. <div className="content-right">
  69. <this.state.component
  70. data-listApiUrl={this.state.listApiUrl}
  71. data-detailApiUrl={this.state.detailApiUrl} />
  72. </div>
  73. </div>
  74. )
  75. }
  76. }
  77. export default Content;