import {
	WeaFormItem
} from 'ecCom'

import {
	WeaSwitch
} from 'comsMobx'

export default class Info extends React.Component {
	constructor(props) {
		super(props);
	}

	getForm() {
		const {
			form,
			condition,
			isFormInit,
			wholeFormStyle,
			onFormChange,
		} = this.props;

		let arr = [];
		isFormInit && condition.map(c => {
			c.items.map((field, index) => {
				arr.push(<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@u04oar@${index}`}
                            label={`${field.label}`}
                            labelCol={{span: `${field.labelcol}`}}
                            error={form.getError(field)}
                            tipPosition="bottom"
                            wrapperCol={{span: `${field.fieldcol}`}}
                            style={{padding:'5px 0'}}
                        >
                                <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@mwpetk@${index}`} fieldConfig={field} form={form} formParams={form.getFormParams()} onChange={cb => onFormChange ? onFormChange(cb) : {}  }/>
                        </WeaFormItem>)
			})
		});

		return <div style={wholeFormStyle} className='hrm-date-picker'>{arr}</div>
	}

	render() {
		const {
			loading
		} = this.props;

		return (!loading && this.getForm())
	}
}