content.jsx 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import React, { Component } from 'react';
  2. import '../content.less';
  3. import LeftTab from './leftTab';
  4. import UserList from './userList';
  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(window.showCustomer ? 'customerList' : 'userList');
  18. };
  19. }
  20. getKey (key) {
  21. switch (key) {
  22. case 'userList':
  23. require.ensure([], () => {
  24. const UserList = require('./userList').default;
  25. this.setState({
  26. component: <UserList />,
  27. });
  28. });
  29. break;
  30. case 'orgList':
  31. require.ensure([], () => {
  32. const OrgList = require('./orgList').default;
  33. this.setState({
  34. component: <OrgList />,
  35. });
  36. });
  37. break;
  38. case 'customerList':
  39. require.ensure([], () => {
  40. const CustomerList = require('./customerList').default;
  41. this.setState({
  42. component: <CustomerList />,
  43. });
  44. });
  45. break;
  46. case 'levelSet':
  47. require.ensure([], () => {
  48. const LevelSet = require('./levelSet').default;
  49. this.setState({
  50. component: <LevelSet />,
  51. });
  52. });
  53. break;
  54. case 'customerSearch':
  55. require.ensure([], () => {
  56. const CustomerSearch = require('./customerSearch').default;
  57. this.setState({
  58. component: <CustomerSearch />,
  59. });
  60. });
  61. break;
  62. case 'highTechSearch':
  63. require.ensure([], () => {
  64. const HighTechSearch = require('./highTechSearch').default;
  65. this.setState({
  66. component: <HighTechSearch />,
  67. });
  68. });
  69. break;
  70. };
  71. window.location.hash = key;
  72. }
  73. render () {
  74. return (
  75. <div className="manage-content">
  76. <LeftTab handlekey={this.getKey.bind(this)} />
  77. <div className="content-right">
  78. {this.state.component}
  79. </div>
  80. </div>
  81. )
  82. }
  83. }
  84. export default Content;