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

@inject('weacloudstore_setting_store')
@observer
export default class main extends React.Component {
  componentWillMount(){
    this.props.weacloudstore_setting_store.getSetting();
  }
  getSearchs() {
    const { weacloudstore_setting_store } = this.props;
    const { form, condition } = weacloudstore_setting_store;
    let group = [];
      form.isFormInit && mobx.toJS(condition).map(c =>{
      let items = [];
      c.items.map(field => {
        items.push({
          com:(<WeaFormItem
              label={`${field.label}`}
              labelCol={{span: `${field.labelcol}`}}
              wrapperCol={{span: `${field.fieldcol}`}}>
                <WeaSwitch fieldConfig={field} form={form}/>
              </WeaFormItem>),
          col: 1,
        })
      });
      group.push(<WeaSearchGroup needTigger={true} title={c.title}
        showGroup={true} items={items}/>)
    });
    return group;
  }
  render(){
    return <div>
      {this.getSearchs()}
    </div>
  }
}