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 SubForm from './SubForm';

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

	getButtons = () => {
		const {
			hrmConExWarning
		} = this.props, {
			subForm,
			save
		} = hrmConExWarning;

		const sv = (<Button type="primary" disabled={subForm.loading} onClick={() => save()}>{i18n.button.save()}</Button>);
		const mr = (<WeaMoreButton />);

		return [sv, mr];
	}

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

		return (
			<WeaDialog
	          	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 && <SubForm />}
	        </WeaDialog>
		)

	}
}