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

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

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

			return (
				<WeaFormItem
			      label={label}
			      labelCol={{span: 6}}
			      wrapperCol={{span: 18}}
			      tipPosition={'bottom'}
			      error={form.getError(item)}
			      underline={isEdit === '0'}
			      style={{padding:'4px 0'}}
	    		>
		    	  <WeaSwitch fieldConfig={item} form={form} formParams={form.getFormParams()}/>
		    	</WeaFormItem>
			)
		});
	}

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

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