import React, { Component } from 'react';
import '../content.less';
import LeftTab from './leftTab';
import TechAchievement from './techAchievement';


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("techAchievementManage");
        };
    }
    getKey(key) {
        switch (key) {
            case 'techAchievementManage':
                require.ensure([], () => {
                    const TechAchievement = require('./techAchievement').default;
                    this.setState({
                        component: TechAchievement,
                        listApiUrl: '/api/admin/achievement/orgList',
                        detailApiUrl: '/api/admin/achievement/orgDetail'
                    });
                });
                break;
            //新增空白    
            case 'myTechAchievement':
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: Module,
                    });
                });
                break;
             case 'techAchievementQuery':
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: Module,
                    });
                });
                break;
            case 'techAchievementAudit':
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: Module,
                    });
                });
                break;
            case 'techAchievementPublish':
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: Module,
                    });
                });
                break;
            //-------//    
            case 'userTechAchievement':
                require.ensure([], () => {
                    const TechAchievement = require('./techAchievement').default;
                    this.setState({
                        component: TechAchievement,
                        listApiUrl: '/api/admin/achievement/userList',
                        detailApiUrl: '/api/admin/achievement/userDetail'
                    });
                });
                break;
            case 'userAchievementOrder':
                require.ensure([], () => {
                    const AchievementOrder = require('./achievementOrder').default;
                    this.setState({
                        component: AchievementOrder,
                        listApiUrl: '/api/admin/portal/order/userAchievementOrderList',
                        detailApiUrl: '/api/admin/achievement/userDetail'
                    });
                });
                break;
            case 'orgAchievementOrder':
                require.ensure([], () => {
                    const AchievementOrder = require('./achievementOrder').default;
                    this.setState({
                        component: AchievementOrder,
                        listApiUrl: '/api/admin/portal/order/orgAchievementOrderList',
                        detailApiUrl: '/api/admin/achievement/orgDetail'
                    });
                });
                break;
        };
        window.location.hash = key;
    }
    render() {
        return (
            <div className="manage-content">
                <LeftTab handlekey={this.getKey.bind(this)} />
                <div className="content-right">
                    <this.state.component
                        data-listApiUrl={this.state.listApiUrl}
                        data-detailApiUrl={this.state.detailApiUrl} />
                </div>
            </div>
        )
    }
}

export default Content;
