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

export class HrmUnderling {
  @observable title = "";
  @observable id = "";
  @observable lastname = "";
  @observable table = new TableStore();
  @observable showAllLevel = false;

  @action
  getSearchList = (params = {}) => {
    if(typeof(params) == 'string')
      params = {};
    params.id = this.id;
    params.lastname = this.lastname;
    params.showAllLevel = this.showAllLevel;
    API.getSearchList(params).then((data) => {
        this.table.getDatas(data.sessionkey,1);
        this.title = data.lastname+i18n.label.subordinated();
    });
  }

  changeShowAllLevel = () => {
    this.showAllLevel = !this.showAllLevel;
    this.getSearchList();
  }
}