import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {AppService} from "../../../../service/http.service";

@IonicPage()
@Component({
    selector: 'page-duty-detail',
    templateUrl: 'duty-detail.html',
})
export class DutyDetailPage {

    time;
    dutyDetail = {
        reason: '',
        id: ''
    };

    constructor(public navCtrl: NavController, public navParams: NavParams,
                public appService: AppService) {
    }

    ionViewDidLoad() {
        const id = this.navParams.get('id');
        this.time = this.navParams.get('time');
        this.appService.ObserverHttpGetOption('/wisdomgroup/changeApply/app/apply', {'id': id})
            .subscribe((res) => {
                this.dutyDetail = res.json();
            })
    }

    submitOrder() {
        const id = this.dutyDetail.id;
        this.appService.alert('确定撤销该申请?', (res) => {
            this.appService.ObserverHttpGetOption('/wisdomgroup/changeApply/app/deleteApply', {'id': id})
                .subscribe((res) => {
                    this.appService.popToastView('撤销申请成功!','middle',1500);
                    this.navCtrl.pop();
                })
        });
    }

}
