content.jsx 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. import React from 'react';
  2. import '../content.less';
  3. import { Spin } from 'antd';
  4. import LeftTab from './leftTab.jsx';
  5. const Content = React.createClass({
  6. getInitialState() {
  7. return {
  8. loading: false,
  9. leftKey: (window.userData.type == 1) ? 'contract' : 'evaluate',
  10. component: null,
  11. userType: '0',
  12. params: {}
  13. };
  14. },
  15. handlekey(key) {
  16. let paramsStr = key.split('?');
  17. if (paramsStr[1]) {
  18. let params = {};
  19. paramsStr[1].split('&').forEach((it) => {
  20. let arr = it.split('=');
  21. if (arr[0]) {
  22. params[arr[0]] = arr[1] || '';
  23. }
  24. });
  25. this.state.params = params;
  26. } else {
  27. this.state.params = {};
  28. }
  29. switch (paramsStr[0]) {
  30. case 'contract':
  31. require.ensure([], () => {
  32. const Contract = require('./contract/contract').default;
  33. this.setState({
  34. component: Contract,
  35. leftKey: 'contract'
  36. });
  37. });
  38. break;
  39. case 'patent':
  40. require.ensure([], () => {
  41. const Patent = require('./patent').default;
  42. this.setState({
  43. component: Patent,
  44. leftKey: 'patent'
  45. });
  46. });
  47. break;
  48. case 'cognizance':
  49. require.ensure([], () => {
  50. const Cognizance = require('./cognizance').default;
  51. this.setState({
  52. component: Cognizance,
  53. leftKey: 'cognizance'
  54. });
  55. });
  56. break;
  57. case 'copyright':
  58. require.ensure([], () => {
  59. const Copyright = require('./copyright/copyright').default;
  60. this.setState({
  61. component: Copyright,
  62. leftKey: 'copyright'
  63. });
  64. });
  65. break;
  66. case 'technology':
  67. require.ensure([], () => {
  68. const Technology = require('./technology').default;
  69. this.setState({
  70. component: Technology,
  71. leftKey: 'technology'
  72. });
  73. });
  74. break;
  75. case 'companyDetail':
  76. require.ensure([], () => {
  77. const CompanyDetail = require('./companyDetail').default;
  78. this.setState({
  79. component: CompanyDetail,
  80. leftKey: 'companyDetail'
  81. });
  82. });
  83. break;
  84. case 'orgTechCenter':
  85. require.ensure([], () => {
  86. const OrgTechCenter = require('./orgTechCenter').default;
  87. this.setState({
  88. component: OrgTechCenter,
  89. leftKey: 'orgTechCenter'
  90. });
  91. });
  92. break;
  93. case 'activity':
  94. require.ensure([], () => {
  95. const Activity = require('./activity').default;
  96. this.setState({
  97. component: Activity,
  98. leftKey: 'activity'
  99. });
  100. });
  101. break;
  102. case 'activityCostList':
  103. require.ensure([], () => {
  104. const ActivityCostList = require('./activityCostList').default;
  105. this.setState({
  106. component: ActivityCostList,
  107. leftKey: 'activityCostList'
  108. });
  109. });
  110. break;
  111. case 'techProduct':
  112. require.ensure([], () => {
  113. const TechProduct = require('./techProduct').default;
  114. this.setState({
  115. component: TechProduct,
  116. leftKey: 'techProduct'
  117. });
  118. });
  119. break;
  120. case 'intellectual':
  121. require.ensure([], () => {
  122. const Intellectual = require('./intellectual').default;
  123. this.setState({
  124. component: Intellectual,
  125. leftKey: 'intellectual'
  126. });
  127. });
  128. break;
  129. case 'achievement':
  130. require.ensure([], () => {
  131. const Achievement = require('./achievement').default;
  132. this.setState({
  133. component: Achievement,
  134. leftKey: 'achievement'
  135. });
  136. });
  137. break;
  138. case 'ratepay':
  139. require.ensure([], () => {
  140. const Ratepay = require('./ratepay').default;
  141. this.setState({
  142. component: Ratepay,
  143. leftKey: 'ratepay'
  144. });
  145. });
  146. break;
  147. case 'finance':
  148. require.ensure([], () => {
  149. const Finance = require('./finance').default;
  150. this.setState({
  151. component: Finance,
  152. leftKey: 'finance'
  153. });
  154. });
  155. break;
  156. case 'honorList':
  157. require.ensure([], () => {
  158. const HonorList = require('./honorList').default;
  159. this.setState({
  160. component: HonorList,
  161. leftKey: 'honorList'
  162. });
  163. });
  164. break;
  165. case 'standard':
  166. require.ensure([], () => {
  167. const Standard = require('./standard').default;
  168. this.setState({
  169. component: Standard,
  170. leftKey: 'standard'
  171. });
  172. });
  173. break;
  174. case 'annualReport':
  175. require.ensure([], () => {
  176. const AnnualReport = require('./annualReport').default;
  177. this.setState({
  178. component: AnnualReport,
  179. leftKey: 'annualReport'
  180. });
  181. });
  182. break;
  183. case 'evaluate':
  184. require.ensure([], () => {
  185. const Evaluate = require('./evaluate').default;
  186. this.setState({
  187. component: Evaluate,
  188. leftKey: 'evaluate'
  189. });
  190. });
  191. break;
  192. case 'createEvaluate':
  193. require.ensure([], () => {
  194. const CreateEvaluate = require('./evaluate/create').default;
  195. this.setState({
  196. component: CreateEvaluate,
  197. leftKey: 'evaluate'
  198. });
  199. });
  200. break;
  201. };
  202. window.location.hash = key;
  203. },
  204. componentWillMount() {
  205. if (window.location.hash) {
  206. this.handlekey(window.location.hash.substr(1));
  207. } else {
  208. this.handlekey(this.state.leftKey);
  209. }
  210. },
  211. render() {
  212. let component;
  213. if (this.state.component) {
  214. component = <this.state.component handlekey={this.handlekey} {...this.state.params} />;
  215. } else {
  216. component = <div className="loading-container">
  217. <Spin />
  218. </div>
  219. }
  220. return (
  221. <div className="acc-content">
  222. <LeftTab handlekey={this.handlekey} />
  223. <div className="content-right">
  224. {component}
  225. </div>
  226. </div>
  227. )
  228. }
  229. });
  230. export default Content;