content.jsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. //项目派单
  33. // case "projectAssignment":
  34. // require.ensure([], () => {
  35. // const ProjectAssignment = require("./project/projectAssignment")
  36. // .default;
  37. // this.setState({
  38. // component: <ProjectAssignment ApiUrl={""} />,
  39. // });
  40. // });
  41. // break;
  42. // //项目查询
  43. case "personnelAll":
  44. require.ensure([], () => {
  45. const PersonnelAll = require("./personnel/personnelAll").default;
  46. this.setState({
  47. component: <PersonnelAll ApiUrl={""} />,
  48. });
  49. });
  50. break;
  51. default:
  52. require.ensure([], () => {
  53. const Module = require("../module").default;
  54. this.setState({
  55. component: <Module ApiUrl={""} />,
  56. });
  57. });
  58. }
  59. window.location.hash = key;
  60. }
  61. render() {
  62. return (
  63. <div className="manage-content">
  64. <LeftTab handlekey={this.getKey.bind(this)} />
  65. <div className="content-right">{this.state.component}</div>
  66. </div>
  67. );
  68. }
  69. }
  70. export default Content;