12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- import React, { Component } from 'react';
- import '../content.less';
- import LeftTab from './leftTab';
- import UserList from './userList';
- class Content extends Component {
- constructor() {
- super();
- this.state = {
- loading: false,
- component: <div />,
- };
- }
- componentWillMount () {
- if (window.location.hash) {
- this.getKey(window.location.hash.substr(1));
- } else {
- this.getKey(window.showCustomer ? 'customerList' : 'userList');
- };
- }
- getKey (key) {
- switch (key) {
- case 'userList':
- require.ensure([], () => {
- const UserList = require('./userList').default;
- this.setState({
- component: <UserList />,
- });
- });
- break;
- case 'orgList':
- require.ensure([], () => {
- const OrgList = require('./orgList').default;
- this.setState({
- component: <OrgList />,
- });
- });
- break;
- case 'customerList':
- require.ensure([], () => {
- const CustomerList = require('./customerList').default;
- this.setState({
- component: <CustomerList />,
- });
- });
- break;
- case 'levelSet':
- require.ensure([], () => {
- const LevelSet = require('./levelSet').default;
- this.setState({
- component: <LevelSet />,
- });
- });
- break;
- case 'customerSearch':
- require.ensure([], () => {
- const CustomerSearch = require('./customerSearch').default;
- this.setState({
- component: <CustomerSearch />,
- });
- });
- break;
- case 'highTechSearch':
- require.ensure([], () => {
- const HighTechSearch = require('./highTechSearch').default;
- this.setState({
- component: <HighTechSearch />,
- });
- });
- break;
- };
- window.location.hash = key;
- }
- render () {
- return (
- <div className="manage-content">
- <LeftTab handlekey={this.getKey.bind(this)} />
- <div className="content-right">
- {this.state.component}
- </div>
- </div>
- )
- }
- }
- export default Content;
|