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: 'star',
            subKey: 'sub1',
            keyList: [
                { key: 'sub1', value: ['star', 'lecture'] },
                { key: 'sub2', value: ['flash', 'localPolicy', 'nationalPolicy', 'contact'] },
                { key: 'sub10', value: ['banner'] }
            ]
        };
    },
    handleClick(e) {
        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={<span>大咖说</span>}>
                    <Menu.Item key="star">
                        科技明星
                    </Menu.Item>
                    <Menu.Item key="lecture">
                        科技讲堂
                    </Menu.Item>
                </SubMenu>
                <SubMenu key="sub1" title={<span>策源地</span>}>
                    <Menu.Item key="flash">
                        科技快讯
                    </Menu.Item>
                    <Menu.Item key="nationalPolicy">
                        国家政策
                    </Menu.Item>
                    <Menu.Item key="localPolicy">
                        地方政策
                    </Menu.Item>
                    <Menu.Item key="contact">
                        政府往来
                    </Menu.Item>
                </SubMenu>
                <SubMenu key="sub10" title={<span>广告图</span>}>
                    <Menu.Item key="banner">
                        广告图管理
                    </Menu.Item>
                </SubMenu>
            </Menu>
        );
    }
});

export default LeftTab;