import React, { Component } from 'react';
import '../content.less';
import LeftTab from '../leftTab';
import {getMenu} from '../publicMenu.jsx'

class Content extends Component {
    constructor() {
        super();
        this.state = {
            loading: false,
            component: <div></div>,
        };
    }
    componentWillMount() {
        var ids=window.location.href.indexOf('rid=');
        var idk=window.location.href.substr(ids+4);
        var rid=idk.split('#');
        let menu=getMenu(rid);
        let curry;
        if(menu[0].subMenus.length>0){
        	curry=menu[0].subMenus[0].url.split('#');
        }else{
        	curry=menu[0].url.split('#');
        };
        if (window.location.hash) {
            this.getKey(window.location.hash.substr(1));
        } else {
         this.getKey(curry[1]);
        };
    }
    getKey(key) {
        switch (key) {    
        	//我的单位客户
            case 'myOrganization':
                require.ensure([], () => {
                    const MyClient = require('./customerData/myClient').default;
                    this.setState({
                        component: <MyClient />                      
                    });
                });
                break;
           // 单位客户查询
            case 'organizationQuery':
                require.ensure([], () => {
	                const CompanyCustomer = require('./customerData/companyCustomer').default;
	                this.setState({
	                    component:<CompanyCustomer />,	                    	                  
	                });
          	    });
          	    break;
          	//我的个人客户
          	case 'myPersonal':
                require.ensure([], () => {
                    const IndividualCustomer = require('./individualCustomer/individualCustomer').default;
                    this.setState({
                        component: <IndividualCustomer />                      
                      
                    });
                });
                break; 
            //我的被拒绝客户
            case 'myReject':
                require.ensure([], () => {
                    const MyReject = require('./individualCustomer/myReject').default;
                    this.setState({
                        component: <MyReject />                      
                      
                    });
                });
                break; 
            //个人客户查询
            case 'personalQuery':
                require.ensure([], () => {
	                const QueryCustomer = require('./individualCustomer/queryCustomer').default;
	                this.setState({
	                    component:<QueryCustomer />,	                    	                  
	                });
          	    });
          	    break;
          	//专家查询
			case 'expertQuery':
                require.ensure([], () => {
	                const ExpertQuery = require('./individualCustomer/expertQuery').default;
	                this.setState({
	                    component:<ExpertQuery />,	                    	                  
	                });
          	    });
          	    break;
          	//公共客户查询
          	case 'publicQuery':
                require.ensure([], () => {
	                const Qublicquery = require('./individualCustomer/publicQuery').default;
	                this.setState({
	                    component:<Qublicquery />,	                    	                  
	                });
          	    });
          	    break;
          	//个人客户管理
          	case 'personalManage':
                require.ensure([], () => {
	                const PersonalManage = require('./customerManagement/personalManages').default;
	                this.setState({
	                    component:<PersonalManage />,	                    	                  
	                });
          	    });
          	    break;
          	//专家管理    
          	case 'expertManage':
                require.ensure([], () => {
	                const ExpertManage = require('./customerManagement/expertManage').default;
	                this.setState({
	                    component:<ExpertManage />,	                    	                  
	                });
          	    });
          	    break;
          	//专家审核
          	case 'expertAudit':
                require.ensure([], () => {
	                const ExpertReview = require('./reviewed/expertReview').default;
	                this.setState({
	                    component:<ExpertReview />,	                    	                  
	                });
          	    });
          	    break;
          	//实名认证审核
          	case 'identityAudit':
                require.ensure([], () => {
	                const IdentityAudits = require('./reviewed/identityAudits').default;
	                this.setState({
	                    component:<IdentityAudits />,	                    	                  
	                });
          	    });
          	    break;
          	//客户录入审核
          	case 'enteringAudit':
                require.ensure([], () => {
	                const EnteringAudit = require('./reviewed/enteringAudit').default;
	                this.setState({
	                    component:<EnteringAudit />,	                    	                  
	                });
          	    });
          	    break;
          	//专家发布
          	case 'expertPublish':
                require.ensure([], () => {
	                const ExpertRelease = require('./release/expertRelease').default;
	                this.setState({
	                    component:<ExpertRelease />,	                    	                  
	                });
          	    });
          	    break;
          	//专家发布新
          	case 'releaseExpert':
                require.ensure([], () => {
	                const ReleaseExpert = require('./release/releaseExpert').default;
	                this.setState({
	                    component:<ReleaseExpert />,	                    	                  
	                });
          	    });
          	    break;
          	//公共客户管理
          	case 'publicManage':
                require.ensure([], () => {
	                const PublicManages = require('./customerManagement/publicManages').default;
	                this.setState({
	                    component:<PublicManages />,	                    	                  
	                });
          	    });
          	    break;
          	//单位客户管理
          	case 'organizationManage':
                require.ensure([], () => {
	                const OrganizationManage = require('./customerManagement/organizationManages').default;
	                this.setState({
	                    component:<OrganizationManage />,	                    	                  
	                });
          	    });
          	    break;
          	//我的业务
      	    case 'myBusiness':
	            require.ensure([], () => {
	                const MyBusiness = require('./customerService/myBusiness').default;
	                this.setState({
	                    component:<MyBusiness />,	                                      
	                });
	      	    });
	      	    break;
	      	//业务管理
	      	case 'businessMange':
	            require.ensure([], () => {
	                const BusinessMange = require('./customerService/businessManges').default;
	                this.setState({
	                    component:<BusinessMange />,	                                      
	                });
	      	    });
	      	    break;
	      	//业务查询
      	    case 'businessQuery':
            require.ensure([], () => {
                const ServiceQuery = require('./customerService/serviceQuery').default;
                this.setState({
                    component:<ServiceQuery />,	                                      
                });
      	    });
      	    break;
      	    //客户拜访统计
      	    case 'visitStatistics':
            require.ensure([], () => {
                const VisitStatistics = require('./statistics/visitStatistics').default;
                this.setState({
                    component:<VisitStatistics />,	                                      
                });
      	    });
      	    break;
      	    //状态统计
      	    case 'statusStatistics':
            require.ensure([], () => {
                const StatusStatistics = require('./statistics/statusStatistics').default;
                this.setState({
                    component:<StatusStatistics />,	                                      
                });
      	    });
      	    break;
      	    //进度统计
      	    case 'followStatistics':
            require.ensure([], () => {
                const FollowStatistics = require('./statistics/followStatistics').default;
                this.setState({
                    component:<FollowStatistics />,	                                      
                });
      	    });
      	    break;
      	    default:
            require.ensure([], () => {
                const Module = require('../module').default;
                this.setState({
                    component:<Module />	    
                	});
                });  
        };
        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;
