import {
	inject,
	observer
} from 'mobx-react';
import {
	WeaTop,
	WeaRightMenu,
	WeaLocaleProvider,
	WeaLeftRightLayout
} from 'ecCom';
import {
	LeftTree,
	NoData,
} from '../../public/learn';

import ConditionGroup from './ConditionGroup';
import Year from './Year';
import Table from './Table';
const getLabel = WeaLocaleProvider.getLabel;

@inject('hrmHolidySettingNew')
@observer
class Top extends React.Component {
	constructor(props) {
		super(props);
	}

	componentDidMount () {
		this.props.hrmHolidySettingNew.getRightMenu();
	}

	getRightLayout = () => {
		const {
			noDataProps,
			dropMenuDatas,
			hasRightLayout,
		} = this.props.hrmHolidySettingNew;

		if (hasRightLayout) {
			return (
				<div style={{ height: '100%' }}>
					<ConditionGroup ecId={`${this && this.props && this.props.ecId || ''}_ConditionGroup@qrj8xa`} />
					<div className='tabPane' style={{ top: 50 }}>
						<WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@t4uag3`} datas={dropMenuDatas}>
							{this.getContent()}
						</WeaRightMenu>
					</div>
				</div>
			)
		} else {
			return <NoData ecId={`${this && this.props && this.props.ecId || ''}_NoData@0zwye2`} {...noDataProps} />
		}
	}

	getContent = () => {
		const {
			tab
		} = this.props.hrmHolidySettingNew, {
			selectedKey
		} = tab;

		if (selectedKey === '0') {
			return <Year ecId={`${this && this.props && this.props.ecId || ''}_Year@20jmlg`} />
		} else {
			return <Table ecId={`${this && this.props && this.props.ecId || ''}_Table@yp4i2x`} />
		}
	}

	render () {
		const {
			topProps,
			toploading,
			topButtons,
			dropMenuDatas,
			tree,
			treeProps,
		} = this.props.hrmHolidySettingNew;

		return (
			<WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@ot4tdi`}
				title={getLabel('505580', "节假日设置")}
				{...topProps}
				loading={toploading}
				buttons={topButtons}
				dropMenuDatas={dropMenuDatas}
			>
				<WeaLeftRightLayout ecId={`${this && this.props && this.props.ecId || ''}_WeaLeftRightLayout@agargf`}
					isNew={true}
					leftCom={<LeftTree ecId={`${this && this.props && this.props.ecId || ''}_LeftTree@pk326c`}  {...treeProps} {...tree} />}
					resize={true}
					leftWidth={320}
				>
					{this.getRightLayout()}
				</WeaLeftRightLayout>
			</WeaTop>
		);
	}

}

export default Top;