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

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

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

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

    render() {
        const {
            hrmRecruitPlan
        } = this.props, {
            subTabDatas,
            clickTab,
            subTab,
            buttonsAd,
            buttonsTab,
            changePanelStatus,
            searchsAd,
            handleSearch,
            setSearchsBaseValue,
        } = hrmRecruitPlan, {
            curKey,
            isPanelShow,
            conditionCount,
            baseValue,
        } = subTab;

        return (
            <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@f6pzrl`}
                datas={subTabDatas}
                keyParam='key'
                selectedKey={curKey}
                onChange={key => clickTab(key)}

                searchType={curKey=='2'?['base','advanced']:[]}
                showSearchAd={isPanelShow}
                hasMask={false}
                advanceHeight={Math.ceil(conditionCount / 2)*52+20}
                buttonsAd={buttonsAd}
                buttons={curKey=='2'?buttonsTab:(curKey=='1') ?buttonsTab.slice(1) : []}
                searchsBaseValue={baseValue}
                setShowSearchAd={  b => changePanelStatus(b)}
                hideSearchAd={ () => changePanelStatus(false)}
                searchsAd= {searchsAd}
                onSearch={() => handleSearch()}
                onSearchChange={val => setSearchsBaseValue(val)}
            />
        )

    }
}