import React from 'react';
import { Menu, Icon } from 'antd';
import '../leftTab.less';
const SubMenu = Menu.SubMenu;
const MenuItemGroup = Menu.ItemGroup;


const LeftTab = React.createClass({
    getInitialState() {
        return {
            current: 'comprehensive',
            subKey: 'sub1',
            keyList: [
                { key: 'sub1', value: ['comprehensive', 'payment', 'correction', 'express', 'applyFee'] },
                { key: 'sub2', value: ['copyright'] },
                { key: 'sub3', value: ['highTechApply', 'highTechFoster'] },
                { key: 'sub4', value: ['applyManage', 'websiteManage'] }
            ]
        };
    },
    handleClick(e) {
        if (this.state.subKey !== e.keyPath[1]) {
            switch (e.keyPath[1]) {
                case 'sub1':
                    location.href = globalConfig.context + '/admin/servicesManage/patent.html#' + e.key;
                    break;
                case 'sub2':
                    location.href = globalConfig.context + '/admin/servicesManage/copyright.html#' + e.key;
                    break;
                case 'sub3':
                    location.href = globalConfig.context + '/admin/servicesManage/highTech.html#' + e.key;
                    break;
                case 'sub4':
                    location.href = globalConfig.context + '/admin/servicesManage/technology.html#' + e.key;
                    break;
            }
        };
        this.props.handlekey(e.key);
        this.setState({
            current: e.key,
        });
    },
    componentWillMount() {
        const _me = this;
        if (window.location.hash) {
            let theKey = window.location.hash.substr(1);
            this.state.keyList.map(function (item1) {
                item1.value.map(function (item2) {
                    if (theKey == item2) {
                        _me.state.subKey = item1.key
                    }
                });
            });
            this.state.current = theKey;
        };
    },
    render() {
        return (
            <Menu onClick={this.handleClick}
                selectedKeys={[this.state.current]}
                defaultOpenKeys={[this.state.subKey]}
                mode="vertical"
                className="account-left"
                mode="inline"
            >
                <SubMenu key="sub1"
                    title={<div>专利申请管理</div>}>
                    <Menu.Item key="comprehensive">
                        专利综合管理
                    </Menu.Item>
                    <Menu.Item key="payment">
                        待缴费专利管理
                    </Menu.Item>
                    <Menu.Item key="correction">
                        补正审查通知管理
                    </Menu.Item>
                    <Menu.Item key="express">
                        专利纸件收发登记
                    </Menu.Item>
                    <Menu.Item key="applyFee">
                        专利申请费用管理
                    </Menu.Item>
                </SubMenu>
                <SubMenu key="sub2" title={<span>软著申请管理</span>}>
                	<Menu.Item key="copyright">
                        软著申请管理
                    </Menu.Item>
                </SubMenu>
                <SubMenu key="sub3"
                    title={<div>高企认定管理</div>}>
                    <Menu.Item key="highTechApply">
                        高企认定申请
                    </Menu.Item>
                    <Menu.Item key="highTechFoster">
                        高企认定培育
                    </Menu.Item>
                </SubMenu>
                <SubMenu key="sub4" title={<span>科技项目申报管理</span>}>
                	<Menu.Item key="applyManage">
                        申报管理
                    </Menu.Item>
                    <Menu.Item key="websiteManage">
                        科技部门网址管理
                    </Menu.Item>
                </SubMenu>
            </Menu>
        );
    }
});

export default LeftTab;