content.jsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import React, { Component } from 'react';
  2. import '../content.less';
  3. import './content.less';
  4. import LeftTab from '../leftTab';
  5. import { getMenu } from '../publicMenu.js'
  6. class Content extends Component {
  7. constructor() {
  8. super();
  9. this.state = {
  10. loading: false,
  11. component: <div></div>,
  12. };
  13. }
  14. componentWillMount() {
  15. var ids = window.location.href.indexOf('rid=');
  16. var idk = window.location.href.substr(ids + 4);
  17. var rid = idk.split('#');
  18. let menu = getMenu(rid);
  19. let curry;
  20. if (menu[0].subMenus.length > 0) {
  21. curry = menu[0].subMenus[0].url.split('#');
  22. } else {
  23. curry = menu[0].url.split('#');
  24. };
  25. if (window.location.hash) {
  26. this.getKey(window.location.hash.substr(1));
  27. } else {
  28. this.getKey(curry[1]);
  29. };
  30. }
  31. getKey(key) {
  32. switch (key) {
  33. //法务催收中
  34. case "collectioningn":
  35. require.ensure([], () => {
  36. const Collectioningn = require("./collectioning")
  37. .default;
  38. this.setState({
  39. component: <Collectioningn />,
  40. });
  41. });
  42. break;
  43. //订单新增空白
  44. default:
  45. require.ensure([], () => {
  46. const Module = require("../module").default;
  47. this.setState({
  48. component: <Module />,
  49. });
  50. });
  51. };
  52. window.location.hash = key;
  53. }
  54. render() {
  55. return (
  56. <div className="manage-content">
  57. <LeftTab handlekey={this.getKey.bind(this)} />
  58. <div className="content-right">
  59. {this.state.component}
  60. </div>
  61. </div>
  62. )
  63. }
  64. }
  65. export default Content;