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

import DialogContent from './DialogContent';

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

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

		const sv = (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@hhkse5`} type="primary" disabled={formInfo.loading} onClick={() => save()}>{i18n.button.save()}</Button>);

		const btns = [sv, <WeaMoreButton ecId={`${this && this.props && this.props.ecId || ''}_WeaMoreButton@9gjqv0`} />];

		return btns;
	}

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

		return (
			<WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@nnzjai`}
	          	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 && <DialogContent ecId={`${this && this.props && this.props.ecId || ''}_DialogContent@pvjo4r`} />}
	        </WeaDialog>
		)

	}
}