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

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

    getForm() {
        const {
            hrmEngineGroup
        } = this.props, {
            neCondition,
            neForm,
        } = hrmEngineGroup, {
            isFormInit
        } = neForm;

        let arr = [];
        isFormInit && neCondition.map(c => {
            c.items.map((field, index) => {
                arr.push(<div style={{marginTop:5}}>
                            <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@u8p89t@${index}`}
                                label={`${field.label}`}
                                labelCol={{span: 6}}
                                error={neForm.getError(field)}
                                tipPosition="bottom"
                                wrapperCol={{span: 18}}
                            >
                                {<WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@mzpwn9@${index}`} fieldConfig={field} form={neForm} formParams={neForm.getFormParams()} />}
                            </WeaFormItem>
                        </div>)
            })
        })
        return <div style={{width:'84%',marginLeft:'8%',paddingTop:20}}>{arr}</div>
    }

    render() {
        return this.getForm();
    }
}