import React from 'react';
import { Menu, Icon } from 'antd';
import '../leftTab.less';
const SubMenu = Menu.SubMenu;
const MenuItemGroup = Menu.ItemGroup;
import {getMenu} from '../publicMenu.js'
const LeftTab = React.createClass({
getInitialState() {
return {
current: '',
subKey: '',
};
},
current(e){
let menuArr=this.state.menu;
let curr;
menuArr.map(function(item){
if(e==item.url){
curr=item.subMenus[0].url.split('#')
}
})
return curr;
},
handleClick(e) {
let menuArr=this.state.menu;
let path=e.keyPath[1];
if (this.state.subKey !== e.keyPath[1]) {
let urls= this.current(path);
location.href=globalConfig.context +urls[0]+'?rid='+this.state.idtt+'#' + e.key;
};
this.props.handlekey(e.key);
this.setState({
subKey:path,
current: e.key,
});
},
componentWillMount() {
let me_=this;
var ids=window.location.href.indexOf('rid=')
var idk=window.location.href.substr(ids+4)
var rid=idk.split('#')
var menu=getMenu(rid);
let sub;
let curr=rid[1];
for(var i=0;i
0){
sub=menu[i].url
}
})
}
let cur,subs;
if(menu[0].subMenus.length){
cur=menu[0].subMenus[0].url.split('#');
subs=menu[0].url;
}else{
cur=menu[0].url.split('#');
subs=''
};
if(sub!=undefined){
this.setState({
menu:menu,
current:rid[1],
subKey:sub,
idtt:rid[0]
});
}else{
this.setState({
menu:menu,
current:cur[1],
subKey:subs,
idtt:rid[0]
});
}
var htmlMenu=[];
for(var j=0;j{menu[j].name}}>
{
menu[j].subMenus.map(function(item){
let urls=item.url.split('#');
return {item.name}
})
}
);
}else{
let urlt=menu[j].url.split('#');
htmlMenu.push(
{menu[j].name}
)
}
};
this.setState({
htmlMenus:htmlMenu
})
const _me = this;
if (window.location.hash&&menu[0].subMenus.length) {
let theKey = window.location.hash.substr(1);
menu.map(function (item1) {
item1.subMenus.map(function (item2) {
let urls=item2.url.split('#')
if (theKey == urls[1]) {
_me.state.subKey = item1.url
};
});
});
this.state.current = theKey;
}else{
this.state.current = window.location.hash.substr(1);
};
},
render() {
return (
);
}
});
export default LeftTab;