import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {AppService} from "../../../service/appHttpService";
import {ChangeApplySurePage} from "../change-apply-sure/change-apply-sure";

/**
 * Generated class for the SelectRelayPersonPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-select-relay-person',
  templateUrl: 'select-relay-person.html',
})
export class SelectRelayPersonPage {

    id;
    list;
    changeType = 0;
  constructor(public navCtrl: NavController, public navParams: NavParams,
              public appService: AppService) {
  }

  ionViewDidLoad() {
      this.id = this.navParams.get('id');
      console.log('nowId:'+this.id);
    this.getPerson();
  }

  getPerson(){
      const data = {
          date:'2018/10/01',
          gender:this.changeType,
          id:''
      };
      this.appService.ObserverHttpGetOption('/wisdomgroup/dutyPerson/getPersonListOutOfMine',data)
          .subscribe((res)=>{
              this.list = res.json();
          })
  }

  //替班
  selectPerson(item){
      this.navCtrl.push('ChangeApplySurePage',{
          'personId':item.id,
          'nowId':this.id
      })
  }

    change(type){
        this.changeType = type;
        this.getPerson();
    }

}
