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

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

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

    render() {
        const {
            intelogin
        } = this.props, {
            mTdatas,
            clickTab,
            mainTab,
            buttonsAd,
            changePanelStatus,
            searchsAd,
            search,
            source,
        } = intelogin, {
            key,
            isPanelShow,
            form,
        } = mainTab;

        return (
            <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@7dcryu`}
                datas={source != '' ? [] : mTdatas}
                keyParam='key'
                selectedKey={key}
                onChange={key => source == '' && clickTab(key)}
                searchType={['base','advanced']}
                showSearchAd={isPanelShow}
                advanceHeight={124}
                buttonsAd={buttonsAd}
                searchsBaseValue={form.getFormParams()[key == '0'?'name': key == '1' ? 'encryptname' : 'fullName']}
                setShowSearchAd={  b => changePanelStatus(b)}
                hideSearchAd={ () => changePanelStatus(false)}
                searchsAd= {searchsAd}
                onSearch={() => search()}
                onSearchChange={val => form.updateFields({[key == '0'?'name':key == '1' ? 'encryptname' : 'fullName']: val})}
            />
        )

    }
}