import {
	observer
} from 'mobx-react';
import {
	WeaFormItem,
} from 'ecCom';
import {
	WeaSwitch
} from 'comsMobx'

@observer
export default class Form extends React.Component {
	constructor(props) {
		super(props);
	}

	customRender = (c, form) => {
		return c.items.map((item, index) => {
			const {
				label,
			} = item;

			return (
				<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@ct0xie@${index}`}
			      label={label}
			      labelCol={{span: 6}}
			      wrapperCol={{span: 18}}
			      tipPosition={'bottom'}
			      error={form.getError(item)}
			      style={{padding:'5px 0'}}
	    		>
		    	  <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@0snlh1@${index}`} fieldConfig={item} form={form} formParams={form.getFormParams()}/>
		    	</WeaFormItem>
			)
		});
	}

	render() {
		const {
			datas
		} = this.props, {
			form
		} = datas;

		return (
			<div className='content'>
				{form.render({},{},true,(c) => this.customRender(c,form))}
			</div>
		);
	}
}