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

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

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

    componentWillUnmount() {
        this.props.hrmRecruitInfo.resetSubTab()
    }

    render() {
        const {
            hrmRecruitInfo
        } = this.props, {
            subTabDatas,
            clickTab,
            subTab,
            buttonsAd,
            iconButtons,
            changePanelStatus,
            searchsAd,
            handleSearch,
        } = hrmRecruitInfo, {
            curKey,
            isPanelShow,
            conditionCount,
            form,
        } = subTab;

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

    }
}