import {
	inject,
	observer,
} from 'mobx-react'
import {
	WeaDialog,
	WeaMoreButton,
} from 'ecCom'
import {
	Button,
} from 'antd'
import {
	i18n
} from '../../public/i18n';

import FormInfo from './FormInfo';

@inject('hrmEmployDemand')
@observer
export default class MainDialog extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			width: 750,
			height: 400,
		}
	}

	getButtons = () => {
		const {
			hrmEmployDemand
		} = this.props, {
			formInfo,
			save,
		} = hrmEmployDemand;

		const btns = [
			(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@81iknc`} type="primary" disabled={formInfo.loading} onClick={() => save()}>{i18n.button.save()}</Button>),
			(<WeaMoreButton ecId={`${this && this.props && this.props.ecId || ''}_WeaMoreButton@i1y7n5`} />)
		];

		return btns;
	}


	render() {
		const {
			hrmEmployDemand
		} = this.props, {
			closeDialog,
			mainDialog,
		} = hrmEmployDemand, {
			title,
			visible,
		} = mainDialog, {
			width,
			height,
		} = this.state;

		return (
			<WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@irk3xh`}
	          	title={title}
	          	icon="icon-coms-hrm"
	          	iconBgcolor="#217346"
	          	visible={visible}
	          	closable={true}
	          	hasScroll={true}
	          	onCancel={() => closeDialog()}
	          	buttons={this.getButtons()}
	          	style={{width: width, height: height}}
	          	onChangeHeight={(h) => this.setState({height: h})}
	        >
	          	{visible && <FormInfo ecId={`${this && this.props && this.props.ecId || ''}_FormInfo@wayrpr`} />}
	        </WeaDialog>
		)

	}
}