content.jsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import React, { Component } from 'react';
  2. import '../content.less';
  3. import LeftTab from './leftTab';
  4. import TechDemand from './techDemand';
  5. class Content extends Component {
  6. constructor() {
  7. super();
  8. this.state = {
  9. loading: false,
  10. component: 'div',
  11. apiUrl: 'orgList'
  12. };
  13. }
  14. componentWillMount() {
  15. if (window.location.hash) {
  16. this.getKey(window.location.hash.substr(1));
  17. } else {
  18. this.getKey("techDemandOrg");
  19. };
  20. }
  21. getKey(key) {
  22. switch (key) {
  23. case 'techDemandOrg':
  24. require.ensure([], () => {
  25. const TechDemand = require('./techDemand').default;
  26. this.setState({
  27. component: TechDemand,
  28. listApiUrl: '/api/admin/demand/orgList',
  29. detailApiUrl:'/api/admin/demand/orgDemandDetail'
  30. });
  31. });
  32. break;
  33. case 'techDemandUser':
  34. require.ensure([], () => {
  35. const TechDemand = require('./techDemand').default;
  36. this.setState({
  37. component: TechDemand,
  38. listApiUrl: '/api/admin/demand/userList',
  39. detailApiUrl:'/api/admin/demand/userDemandDetail'
  40. });
  41. });
  42. break;
  43. };
  44. window.location.hash = key;
  45. }
  46. render() {
  47. return (
  48. <div className="manage-content">
  49. <LeftTab handlekey={this.getKey.bind(this)} />
  50. <div className="content-right">
  51. <this.state.component
  52. data-listApiUrl={this.state.listApiUrl}
  53. data-detailApiUrl={this.state.detailApiUrl} />
  54. </div>
  55. </div>
  56. )
  57. }
  58. }
  59. export default Content;