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

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

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

    componentWillUnmount() {
        this.props.hrmRecruitLibrary.unmountTab();
    }

    render() {
        const {
            hrmRecruitLibrary
        } = this.props, {
            mainTab,
            mainTabDatas,
            main,
            clickTab,
            buttonsAd,
            iconButtons_mainTab,
            changePanelStatus,
            searchsAd,
            handleSearch,
        } = hrmRecruitLibrary, {
            curKey,
            isPanelShow,
            conditionCount,
            form,
        } = mainTab, {
            isShowInDialog
        } = main;

        return (
            <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@5nsakv`}
                datas={isShowInDialog ? [] : mainTabDatas}
                keyParam='key'
                selectedKey={curKey}
                onChange={key => clickTab(key)}
                searchType={['base','advanced']}
                showSearchAd={isPanelShow}
                hasMask={false}
                advanceHeight={Math.ceil(conditionCount / 2)*52+20}
                buttonsAd={buttonsAd}
                buttons={isShowInDialog ? iconButtons_mainTab : [] }
                searchsBaseValue={form.getFormParams().name}
                setShowSearchAd={  b => changePanelStatus(b)}
                hideSearchAd={ () => changePanelStatus(false)}
                searchsAd= {searchsAd}
                onSearch={() => handleSearch()}
                onSearchChange={val => form.updateFields({name: val})}
            />
        )

    }
}