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

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

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

    render() {
        const {
            hrmRecruitLibrary
        } = this.props, {
            top,
            mainTable,
            menus,
            main,
            mainTab,
        } = hrmRecruitLibrary, {
            title,
        } = top, {
            tableStore
        } = mainTable, {　　
            buttons,
            dropMenuDatas,
        } = menus, {
            isShowInDialog
        } = main, {
            needTab
        } = mainTab;

        if (isShowInDialog) {
            return (
                <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@fwe1fp`} 
                    datas={dropMenuDatas}
                    collectParams={{favname:title,favouritetype:5}}
                >
                     {needTab &&  <MainTab ecId={`${this && this.props && this.props.ecId || ''}_MainTab@s35ovv`} />}
                    <MainTable ecId={`${this && this.props && this.props.ecId || ''}_MainTable@5qr0jb`} {...this.props}/>
                </WeaRightMenu>
            )
        } else {
            return (
                <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@qgup2r`} 
                    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@2xitcf`} 
                        datas={dropMenuDatas}
                        collectParams={{favname:title,favouritetype:5}}
                    >
                        <MainTab ecId={`${this && this.props && this.props.ecId || ''}_MainTab@gz1ljk`} />
                        <MainTable ecId={`${this && this.props && this.props.ecId || ''}_MainTable@nkdi94`} />
                    </WeaRightMenu>
                </WeaTop>
            )
        }



    }
}