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

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 ApiUrl={''}/>                      
//                  });
//              });
//              break;
//         // 单位客户查询
//          case 'organizationQuery':
//              require.ensure([], () => {
//	                const CompanyCustomer = require('./customerData/companyCustomer').default;
//	                this.setState({
//	                    component:<CompanyCustomer ApiUrl={''}/>,	                    	                  
//	                });
//        	    });
//        	    break;
          	//我的个人客户
//        	case 'myPersonal':
//              require.ensure([], () => {
//                  const IndividualCustomer = require('./individualCustomer/individualCustomer').default;
//                  this.setState({
//                      component: <IndividualCustomer ApiUrl={''}/>                      
//                    
//                  });
//              });
//              break; 
            //我的被拒绝客户
            case 'myReject':
                require.ensure([], () => {
                    const MyReject = require('./individualCustomer/myReject').default;
                    this.setState({
                        component: <MyReject ApiUrl={''}/>                      
                      
                    });
                });
                break; 
//          //个人客户查询
//          case 'personalQuery':
//              require.ensure([], () => {
//	                const QueryCustomer = require('./individualCustomer/queryCustomer').default;
//	                this.setState({
//	                    component:<QueryCustomer ApiUrl={''}/>,	                    	                  
//	                });
//        	    });
//        	    break;
          	//专家查询
			case 'expertQuery':
                require.ensure([], () => {
	                const ExpertQuery = require('./individualCustomer/expertQuery').default;
	                this.setState({
	                    component:<ExpertQuery ApiUrl={''}/>,	                    	                  
	                });
          	    });
          	    break;
          	//公共客户查询
          	case 'publicQuery':
                require.ensure([], () => {
	                const Qublicquery = require('./individualCustomer/publicQuery').default;
	                this.setState({
	                    component:<Qublicquery ApiUrl={''}/>,	                    	                  
	                });
          	    });
          	    break;
          	//个人客户管理
          	case 'personalManage':
                require.ensure([], () => {
	                const PersonalManage = require('./customerManagement/personalManages').default;
	                this.setState({
	                    component:<PersonalManage ApiUrl={''}/>,	                    	                  
	                });
          	    });
          	    break;
          	//专家管理    
          	case 'expertManage':
                require.ensure([], () => {
	                const ExpertManage = require('./customerManagement/expertManage').default;
	                this.setState({
	                    component:<ExpertManage ApiUrl={''}/>,	                    	                  
	                });
          	    });
          	    break;
          	//专家审核
          	case 'expertAudit':
                require.ensure([], () => {
	                const ExpertReview = require('./reviewed/expertReview').default;
	                this.setState({
	                    component:<ExpertReview ApiUrl={''}/>,	                    	                  
	                });
          	    });
          	    break;
          	//实名认证审核
          	case 'identityAudit':
                require.ensure([], () => {
	                const IdentityAudits = require('./reviewed/identityAudits').default;
	                this.setState({
	                    component:<IdentityAudits ApiUrl={''}/>,	                    	                  
	                });
          	    });
          	    break;
          	//客户录入审核
          	case 'enteringAudit':
                require.ensure([], () => {
	                const EnteringAudit = require('./reviewed/enteringAudit').default;
	                this.setState({
	                    component:<EnteringAudit ApiUrl={''}/>,	                    	                  
	                });
          	    });
          	    break;
          	//专家发布
          	case 'expertPublish':
                require.ensure([], () => {
	                const ExpertRelease = require('./release/expertRelease').default;
	                this.setState({
	                    component:<ExpertRelease ApiUrl={''}/>,	                    	                  
	                });
          	    });
          	    break;
          	//专家发布新
          	case 'releaseExpert':
                require.ensure([], () => {
	                const ReleaseExpert = require('./release/releaseExpert').default;
	                this.setState({
	                    component:<ReleaseExpert ApiUrl={''}/>,	                    	                  
	                });
          	    });
          	    break;
          	//公共客户管理
          	case 'publicManage':
                require.ensure([], () => {
	                const PublicManages = require('./customerManagement/publicManages').default;
	                this.setState({
	                    component:<PublicManages ApiUrl={''}/>,	                    	                  
	                });
          	    });
          	    break;
          	//单位客户管理
          	case 'organizationManage':
                require.ensure([], () => {
	                const OrganizationManage = require('./customerManagement/organizationManages').default;
	                this.setState({
	                    component:<OrganizationManage ApiUrl={''}/>,	                    	                  
	                });
          	    });
          	    break;
          	//我的业务
      	    case 'myBusiness':
	            require.ensure([], () => {
	                const MyBusiness = require('./customerService/myBusiness').default;
	                this.setState({
	                    component:<MyBusiness ApiUrl={''}/>,	                                      
	                });
	      	    });
	      	    break;
	      	//业务管理
	      	case 'businessMange':
	            require.ensure([], () => {
	                const BusinessMange = require('./customerService/businessManges').default;
	                this.setState({
	                    component:<BusinessMange ApiUrl={''}/>,	                                      
	                });
	      	    });
	      	    break;
	      	//业务查询
      	    case 'businessQuery':
            require.ensure([], () => {
                const ServiceQuery = require('./customerService/serviceQuery').default;
                this.setState({
                    component:<ServiceQuery ApiUrl={''}/>,	                                      
                });
      	    });
      	    break;
      	    //客户拜访统计
      	    case 'visitStatistics':
            require.ensure([], () => {
                const VisitStatistics = require('./statistics/visitStatistics').default;
                this.setState({
                    component:<VisitStatistics ApiUrl={''}/>,	                                      
                });
      	    });
      	    break;
      	    //状态统计
      	    case 'statusStatistics':
            require.ensure([], () => {
                const StatusStatistics = require('./statistics/statusStatistics').default;
                this.setState({
                    component:<StatusStatistics ApiUrl={''}/>,	                                      
                });
      	    });
      	    break;
      	    //进度统计
      	    case 'followStatistics':
            require.ensure([], () => {
                const FollowStatistics = require('./statistics/followStatistics').default;
                this.setState({
                    component:<FollowStatistics ApiUrl={''}/>,	                                      
                });
      	    });
      	    break;
      	    /*
      	     *报表开发 
      	     */
      	    case 'personalReport':
                require.ensure([], () => {
                    const Jurisdiction = require('./report/personalReport').default;
                    this.setState({
                        component: <Jurisdiction ApiUrl={''}/>                      
                    });
                });
                break;  
            case 'departmentReport':
                require.ensure([], () => {
                    const DepartmentReport = require('./report/departmentReport').default;
                    this.setState({
                        component: <DepartmentReport ApiUrl={''}/>                      
                    });
                });
                break;
            /*拜访记录统计*/
           //客户营销日统计
           case 'diurnalStatistics':
                require.ensure([], () => {
                    const DiurnalStatistics = require('./customerMarketing/diurnalStatistics').default;
                    this.setState({
                        component: <DiurnalStatistics ApiUrl={''}/>                      
                    });
                });
                break;  
            //客户营销时段统计
            case 'timeStatistics':
                require.ensure([], () => {
                    const TimeStatistics = require('./customerMarketing/timeStatistics').default;
                    this.setState({
                        component: <TimeStatistics ApiUrl={''}/>                      
                    });
                });
                break;
            /*意向客户*/
            //个人意向客户
           	case 'personalIntention':
                require.ensure([], () => {
                    const PersonalIntention = require('./NEW/intentionCustomer/intentionCustomer').default;
                    this.setState({
                        component: <PersonalIntention
                        			intentionState={1}
                        		    ApiUrl={'/api/admin/customer/listPrivatePersonalCustomer'}
                        		    detailApi={'/api/admin/customer/findPersonalCustomerDetail'}
                        			/>
                    });
                });
                break;
            //单位意向客户    
            case 'companyIntention':
                require.ensure([], () => {
                    const CompanyIntention = require('./NEW/intentionCustomer/intentionCustomer').default;
                    this.setState({
                        component: <CompanyIntention 
	                        		intentionState={0}
	                        		ApiUrl={'/api/admin/customer/listPrivateOrganizationCustomer'}
	                        		detailApi={'/api/admin/customer/findOrganizationCustomerDetail'}
                        		/>
                    });
                });
                break;
            //客户资料    
            case 'crm':
                require.ensure([], () => {
                    const Crm = require('./NEW/crm/crm').default;
                    this.setState({
                        component: <Crm 
	                        		intentionState={0}
	                        		ApiUrl={'/api/admin/customer/listPrivateOrganizationCustomer'}
	                        		detailApi={'/api/admin/customer/findOrganizationCustomerDetail'}
                        		/>
                    });
                });
                break;
             //客户资料    
            case 'crmCount':
                require.ensure([], () => {
                    const CrmCount = require('./NEW/crm/crmCount').default;
                    this.setState({
                        component: <CrmCount 
	                        		intentionState={0}
	                        		ApiUrl={'/api/admin/customer/listPrivateOrganizationCustomer'}
	                        		detailApi={'/api/admin/customer/findOrganizationCustomerDetail'}
                        		/>
                    });
                });
                break;
            //客户资料    
            case 'crmAll':
                require.ensure([], () => {
                    const CrmAll = require('./NEW/crm/crmAll').default;
                    this.setState({
                        component: <CrmAll 
	                        		intentionState={0}
	                        		ApiUrl={'/api/admin/customer/listPrivateOrganizationCustomer'}
	                        		detailApi={'/api/admin/customer/findOrganizationCustomerDetail'}
                        		/>
                    });
                });
                break;
            /*签单客户*/ 
            //个人签单客户
            case 'personalSign':
                require.ensure([], () => {
                    const PersonalSign = require('./NEW/signCustomer/signCustomer').default;
                    this.setState({
                        component: <PersonalSign 
                    			intentionState={1}
                    		    ApiUrl={'/api/admin/customer/listSignPersonalCustomer'}
                    		    //ApiUrl={'/api/admin/customer/listPrivatePersonalCustomer'}
                    		    detailApi={'/api/admin/customer/findPersonalCustomerDetail'}
                        />
                    });
                });
                break;
            //单位签单客户    
            case 'companySign':
                require.ensure([], () => {
                    const CompanySign =  require('./NEW/signCustomer/signCustomer').default;
                    this.setState({
                        component: <CompanySign 
                    			intentionState={0}
                        		ApiUrl={'/api/admin/customer/listSignOrganizationCustomer'}
                        		detailApi={'/api/admin/customer/findOrganizationCustomerDetail'}/>                      
                    });
                });
                break;
             //个人客户查询
            case 'personalQuery':
                require.ensure([], () => {
                    const PersonalQuery = require('./NEW/query/queryCutomer').default;
                    this.setState({
                        component: <PersonalQuery 
                			intentionState={1}
                		    ApiUrl={'/api/admin/customer/listAllPersonalCustomer'}	
                		    detailApi={'/api/admin/customer/getLockedProject'}
                        />
                    });
                });
                break;
            //单位客户查询    
            case 'organizationQuery':
                require.ensure([], () => {
                    const CompanyQuery =  require('./NEW/query/queryCutomer').default;
                    this.setState({
                        component: <CompanyQuery 
                			intentionState={0}
                    		ApiUrl={'/api/admin/customer/listAllOrganizationCustomer'}
                    		detailApi={'/api/admin/customer/getLockedProject'}
                    	/>	
                    });
                });
                break;  
             //个人公共客户
            case 'personalPublicCustomer':
                require.ensure([], () => {
                    const PersonalPublicCustomer = require('./NEW/publicCustomer/publicCustomer').default;
                    this.setState({
                        component: <PersonalPublicCustomer 
                			intentionState={1}
                		    ApiUrl={'/api/admin/customer/listPublicPersonalCustomer'}	
                        />
                    });
                });
                break;
            //单位公共客户    
            case 'organizationPublicCustomer':
                require.ensure([], () => {
                    const OrganizationPublicCustomer =  require('./NEW/publicCustomer/publicCustomer').default;
                    this.setState({
                        component: <OrganizationPublicCustomer 
                			intentionState={0}
                    		ApiUrl={'/api/admin/customer/listPublicOrganizationCustomer'}
                    	/>	
                    });
                });
                break;     
      	    default:
            require.ensure([], () => {
                const Module = require('../module').default;
                this.setState({
                    component:<Module ApiUrl={''}/>	    
                	});
                });  
           
           
                
        };
        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;
