import {
	inject,
	observer,
} from 'mobx-react'
import {
	WeaRightMenu,
	WeaSearchGroup,
} from 'ecCom'
import {
	Spin,
	Button,
} from 'antd'
import {
	i18n
} from '../../public/i18n';

import SpecialForm from './SpecialForm';
import TableEdit from './TableEdit';

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

	getDropMenuDatas = () => {
		const {
			hrmWorkHour
		} = this.props, {
			formInfo
		} = hrmWorkHour, {
			loading
		} = formInfo;

		const menu = [{
			key: '0',
			icon: <i className='icon-coms-Preservation' />,
			content: i18n.button.save(),
			disabled: loading,
		}];

		return menu
	}

	handleMenuClick = (key) => {
		const {
			hrmWorkHour,
		} = this.props, {
			save,
		} = hrmWorkHour;

		key == '0' && save();
	}

	getCustomComponent = () => {
		const {
			hrmWorkHour
		} = this.props, {
			openDialog,
			tableEdit
		} = hrmWorkHour, {
			selectedIndexs
		} = tableEdit;

		const buttons = [
			(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@2cd58t`} disabled={selectedIndexs.length > 0 ? false : true} onClick={() => openDialog('sub')}>{i18n.label.selectQuotingSet()}</Button>),
		];

		return buttons
	}

	render() {
		const {
			hrmWorkHour
		} = this.props, {
			formInfo
		} = hrmWorkHour, {
			loading
		} = formInfo;

		return (
			<div className='hrm-work-hour'>
				{loading  ? <div style={{textAlign: 'center', paddingTop: 200}}>
								<Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@eqzcav`} spinning={loading}></Spin>
						    </div>
						  : <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@94d30s`} datas={this.getDropMenuDatas()} onClick={ key => this.handleMenuClick(key)}>
					          	<WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@s5t0hf`} title={i18n.label.basicInfo()} children={<SpecialForm ecId={`${this && this.props && this.props.ecId || ''}_SpecialForm@8pi7eg`} />} showGroup={true} />
					          	<WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@wwgrsf`} 
					          		title={i18n.label.workTimeSet()} 
					          		children={<TableEdit ecId={`${this && this.props && this.props.ecId || ''}_TableEdit@z8flxw`} />} 
					          		showGroup={true} 
					          		customComponent={this.getCustomComponent()}
					          	/>
	          				</WeaRightMenu>
	          	}
	       	</div>
		)

	}
}