content.jsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import React, { Component } from 'react';
  2. import "../content.less";
  3. import LeftTab from '../leftTab';
  4. import {getMenu} from '../publicMenu.js'
  5. class Content extends Component {
  6. constructor() {
  7. super();
  8. this.state = {
  9. loading: false,
  10. component: <div></div>,
  11. };
  12. }
  13. componentWillMount() {
  14. var ids=window.location.href.indexOf('rid=');
  15. var idk=window.location.href.substr(ids+4);
  16. var rid=idk.split('#');
  17. let menu=getMenu(rid);
  18. let curry;
  19. if(menu[0].subMenus.length>0){
  20. curry=menu[0].subMenus[0].url.split('#');
  21. }else{
  22. curry=menu[0].url.split('#');
  23. };
  24. if (window.location.hash) {
  25. this.getKey(window.location.hash.substr(1));
  26. } else {
  27. this.getKey(curry[1]);
  28. };
  29. }
  30. getKey(key) {
  31. switch (key) {
  32. case "order": //派单管理
  33. require.ensure([], () => {
  34. let Module = require("./order/index").default;
  35. this.setState({
  36. component: <Module />,
  37. });
  38. });
  39. break;
  40. case "personnelAll":
  41. require.ensure([], () => {
  42. const PersonnelAll = require("./personnel/personnelAll").default;
  43. this.setState({
  44. component: <PersonnelAll ApiUrl={""} />,
  45. });
  46. });
  47. break;
  48. //催款列表
  49. case "pressList":
  50. require.ensure([], () => {
  51. const PressList = require("../order/orderNew/pressList").default;
  52. this.setState({
  53. component: <PressList />,
  54. });
  55. });
  56. break;
  57. case "bonusList":
  58. require.ensure([], () => {
  59. const BonusList = require("./personnel/bonusList").default;
  60. this.setState({
  61. component: <BonusList ApiUrl={""} />,
  62. });
  63. });
  64. break;
  65. default:
  66. require.ensure([], () => {
  67. let Module = require("../module").default;
  68. this.setState({
  69. component: <Module />,
  70. });
  71. });
  72. };
  73. window.location.hash = key;
  74. }
  75. render() {
  76. return (
  77. <div className="manage-content">
  78. <LeftTab handlekey={this.getKey.bind(this)} />
  79. <div className="content-right">
  80. {this.state.component}
  81. </div>
  82. </div>
  83. )
  84. }
  85. }
  86. export default Content;