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

@inject('hrmTrainArrange')
@observer
export default class SubDialog extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			width: 700,
			height: 160,
		}
	}

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

		let buttons = [
			(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@x9rscu`} type="primary" disabled={loading} onClick={() => save('sub')}>{i18n.button.save()}</Button>),
			(<WeaMoreButton ecId={`${this && this.props && this.props.ecId || ''}_WeaMoreButton@n5z5au`} />)
		];

		return buttons;
	}

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

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

	}
}