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: 'myClient', 
            subKey: 'sub1', 
            keyList: [
                { key: 'sub1', value: ['myClient', 'publicCustomer','companyCustomer'] },
                { key: 'sub2', value: ['individualCustomer', 'publicCustomer','queryCustomer'] },
                { key: 'sub3', value: ['myBusiness', 'serviceQuery'] },               
            ]
        };
    },
     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="myClient">
		                    我的单位客户
		                </Menu.Item>               
		                <Menu.Item key="publicCustomer">
		                    公共单位客户
		                </Menu.Item>		               
		                <Menu.Item key="companyCustomer">
		                    单位客户查询
		                </Menu.Item>		           
		        </SubMenu> 
		        <SubMenu key="sub2" title={<span>个人客户</span>}>	            	
		                <Menu.Item key="individualCustomer">
		                    我的个人客户
		                </Menu.Item>               
		                <Menu.Item key="publicindividualCustomer">
		                    公共个人客户
		                </Menu.Item>		               
		                <Menu.Item key="queryCustomer">
		                    个人客户查询
		                </Menu.Item>		           
		        </SubMenu>
		        <SubMenu key="sub3" title={<span>客户业务</span>}>		            
		                <Menu.Item key="myBusiness">
		                    我的业务
		                </Menu.Item>               
		                <Menu.Item key="serviceQuery">
		                    业务查询
		                </Menu.Item>	               		           
		        </SubMenu>   
            </Menu>
        );
    },
});

export default LeftTab;