import {
    inject,
    observer
} from 'mobx-react'
import {
    WeaTop,
    WeaRightMenu
} from 'ecCom'

import MainTab from './MainTab';
import MainTable from './MainTable';
@inject('hrmRecruitPlan') //todo
@observer
export default class Top extends React.Component {
    constructor(props) {
        super(props);
    }

    componentDidMount() {
        this.props.hrmRecruitPlan.getMenus();
    }

    render() {
        const {
            hrmRecruitPlan
        } = this.props, {
            top,
            mainTable,
            menus,
            main,
        } = hrmRecruitPlan, {
            title,
        } = top, {
            tableStore
        } = mainTable, {　　
            buttons,
            dropMenuDatas,
        } = menus, {
            isSingle
        } = main;

        if (isSingle) {
            return (
                <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@08xwon`} 
                    datas={dropMenuDatas}
                    collectParams={{favname:title,favouritetype:5}}
                >
                    <MainTab ecId={`${this && this.props && this.props.ecId || ''}_MainTab@swqk0q`} />
                    <MainTable ecId={`${this && this.props && this.props.ecId || ''}_MainTable@2klnqc`} />
                </WeaRightMenu>
            )
        } else {
            return (
                <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@p67bpi`} 
                    title={title}
                    icon={<i className='icon-coms-hrm'/>}
                    iconBgcolor='#217346'
                    loading={tableStore.loading}
                    buttons={buttons}
                    showDropIcon={true}
                    dropMenuDatas={dropMenuDatas}
                >
                    <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@plq4j4`} 
                        datas={dropMenuDatas}
                        collectParams={{favname:title,favouritetype:5}}
                    >
                        <MainTab ecId={`${this && this.props && this.props.ecId || ''}_MainTab@pqwtmr`} />
                        <MainTable ecId={`${this && this.props && this.props.ecId || ''}_MainTable@pdt0vm`} />
                    </WeaRightMenu>
                </WeaTop>
            )
        }
    }

}