import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {AppService} from "../../../service/appHttpService";
import {SelectChangePersonPage} from "../select-change-person/select-change-person";
import {SelectRelayPersonPage} from "../select-relay-person/select-relay-person";

@IonicPage()
@Component({
  selector: 'page-duty-apply-handle',
  templateUrl: 'duty-apply-handle.html',
})
export class DutyApplyHandlePage {

    applyDetail = {
        id:'',
        scheduleId:'',
      reason:''
    };
    personDetail = {
        id:'',
        name:'',
        phoneNumber:'',
        dutyDate:''
    };
  constructor(public navCtrl: NavController, public navParams: NavParams,
              public appService: AppService) {
  }

  ionViewDidLoad() {

    this.personDetail = this.navParams.get('item');
      this.appService.ObserverHttpGetOption('/wisdomgroup/changeApply/app/apply',{'id': this.personDetail.id})
          .subscribe((res)=>{
             this.applyDetail = res.json();
          })
  }

    submit(type){
        console.log(this.applyDetail);

        switch (type){
          case '1':{  //换班
            this.navCtrl.push('SelectChangePersonPage',{
                nowId:this.applyDetail.scheduleId
            });
            break;
          }
          case '2':{  //替班
              this.navCtrl.push('SelectRelayPersonPage',{
                  id:this.applyDetail.scheduleId
              });
              break;
          }
          case '3':{
              const data= {
                  applyId: this.applyDetail.id
              }
                this.appService.ObserverHttpGet('/changeApply/app/ignore',data)
                    .subscribe((res)=>{

                    })
              break;
          }
      }
    }

}
