import React from 'react';
import {
	observer,
	inject
} from 'mobx-react';
import {
	Button
} from 'antd';
import ConfigurableForm from '../../public/ConfigurableForm';
import '../../style/test.less';

@inject('hrmTest')
@observer
export default class Test extends React.Component {
	constructor(props) {
		super(props);
	}

	componentDidMount() {
		const {
			hrmTest: store
		} = this.props;

		store.getLeaveRulesForm();
	}

	handleClick = (f, togetherKeys) => {
		const {
			form
		} = f;
		form.validateForm().then(f => {
			if (f.isValid) {} else {
				f.showErrors();
			}
		})
	}

	render() {
		const {
			hrmTest: store
		} = this.props, {
			f,
			blackList,
			togetherElements,
			prefix,
			suffix,
			linkage,
			togetherKeys
		} = store;

		const d = {
			...f,
			blackList,
			togetherElements,
			prefix,
			suffix,
			linkage,
		}
		return (
			<div className='test'> 
				<ConfigurableForm ecId={`${this && this.props && this.props.ecId || ''}_ConfigurableForm@yh9bhf`} {...d}/>
				<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@p3cvgl`} type="primary" onClick={() => this.handleClick(f,togetherKeys)}>校验</Button>
			</div>
		)
	}
}