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

import Group from './Group';

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

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

		const sv = (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@ybchfm`} type="primary" disabled={formInfo.loading} onClick={() => save()}>{i18n.button.save()}</Button>);
		const mr = (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@oulmv5`} disabled>{i18n.button.more()}</Button>);
		const btns = [sv, mr];

		return btns;
	}

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

		return (
			<WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@s192jz`}
	          	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 && <Group ecId={`${this && this.props && this.props.ecId || ''}_Group@22v9qc`} />}
	        </WeaDialog>
		)

	}
}