import { observable, action } from 'mobx';
import {WeaForm} from 'comsMobx';
import * as API from '../apis/edulevel';
import * as Util from '../util/index';
import {WeaTableNew} from 'comsMobx'
const {TableStore} = WeaTableNew;

export class HrmEduLevel {
  title = "学历设置";
  @observable verified = false;
  @observable hasRight = false;
  @observable form = new WeaForm();
  @observable table = new TableStore();
  @observable condition=[];
  @observable showSearchAd=false;
  @observable searchParamsAd={};

  @action
  getHasRight(params = {}) {
    API.getHasRight(params).then((data) => {
      this.hasRight = data.hasRight;
      if(data.hasRight){
        this.getSearchCondition();
        this.getSearchList();
      }
      this.verified = true;
    });
  }

  getSearchCondition(params = {}) {
    API.getSearchCondition(params).then((data) => {
        this.condition = data.conditions;
        this.form.initFormFields(data.conditions);
    });
  }

  doSearch(){
    const formParams = this.form.getFormParams();
    this.getSearchList(formParams);
  }
  getSearchList(params = {}) {
    API.getSearchList(params).then((data) => {
        this.table.getDatas(data.sessionkey);
    });
  }

  setShowSearchAd(bool) {
    this.showSearchAd = bool;
  }

  getFormParams() {
    return this.form.getFormParams();
  }
}