Skip to content
duty-apply.ts 1.94 KiB
Newer Older
wangqinghua's avatar
wangqinghua committed
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
wangqinghua's avatar
wangqinghua committed
import {AppService} from "../../../../service/http.service";
wangqinghua's avatar
wangqinghua committed
import {HomeService} from "../../home.service";
import {DatePipe} from "@angular/common";
wangqinghua's avatar
wangqinghua committed

@IonicPage()
@Component({
wangqinghua's avatar
wangqinghua committed
    selector: 'page-duty-apply',
    templateUrl: 'duty-apply.html',
wangqinghua's avatar
wangqinghua committed
})
export class DutyApplyPage {

wangqinghua's avatar
wangqinghua committed
    reason = '';  //申请原因

    old = {
        date: null,
        type: null,
        id: ''
    };

    change = {
        date: null,
        personName: ''
wangqinghua's avatar
wangqinghua committed
    };
wangqinghua's avatar
wangqinghua committed

    constructor(public navCtrl: NavController, public navParams: NavParams, private datePipe: DatePipe,
                public appService: AppService, private homeSer: HomeService) {
    }

    ionViewDidLoad() {
        this.old.id = this.navParams.get('id');
        this.old.date = this.navParams.get('date');
        this.old.type = this.navParams.get('type');
        this.change.date = this.datePipe.transform(this.old.date, "yyyy-MM-dd");
        console.log(this.change.date)
    }

    //查询值班
    getScheduleInfo() {
        const data = {
            date: this.datePipe.transform(this.change.date, "yyyy/MM/dd"),
            type: this.old.type   //0 白班  1 夜班
        };
        this.homeSer.getScheduleInfo(data).subscribe(
            (res) => {
                this.change.personName = res.name;
            }
        )
    }

    submit() {
        const reason = this.reason + "备注:换班人--" + this.change.personName;
        const data = {
            scheduleId: this.old.id,
            reason: reason
        };
        this.appService.alert('确定提交该申请?', res => {
            this.appService.ObserverHttpPost('/wisdomgroup/changeApply/app/apply', data)
                .subscribe((res) => {
                    this.appService.popToastView('提交该申请成功!', 'middle', 1000);
                    this.navCtrl.pop();
                })
        });
    }
wangqinghua's avatar
wangqinghua committed

}