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

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

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

    componentWillUnmount() {
        this.props.hrmRecruitPlan.handleTabUnmount();
    }

    render() {
        const {
            hrmRecruitPlan
        } = this.props, {
            mainTabDatas = [],
            clickTab,
            mainTab,
            buttonsAd,
            changePanelStatus,
            searchsAd,
            handleSearch,
        } = hrmRecruitPlan, {
            curKey,
            isPanelShow,
            conditionCount,
            form,
        } = mainTab;

        return (
            <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@ikmfgn`}
                datas={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}
                searchsBaseValue={form.getFormParams().topic}
                setShowSearchAd={  b => changePanelStatus(b)}
                hideSearchAd={ () => changePanelStatus(false)}
                searchsAd= {searchsAd}
                onSearch={() => handleSearch()}
                onSearchChange={val => form.updateFields({topic: val})}
            />
        )

    }
}