Skip to content
duty.ts 3.36 KiB
Newer Older
wangqinghua's avatar
wangqinghua committed
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {CalendarComponentOptions} from "ion2-calendar";
import {DutyApplyPage} from "../duty-apply/duty-apply";
import {DutyDetailPage} from "../duty-detail/duty-detail";
import {DutySignUpPage} from "../duty-sign-up/duty-sign-up";
import { DayConfig } from "ion2-calendar";
import {AppService} from "../../../../service/http.service";
import {monthCh,weekDay} from "../../../../app/main";

declare var Swiper;
@IonicPage()
@Component({
  selector: 'page-duty',
  templateUrl: 'duty.html',
})
export class DutyPage {

    menuList = [
        {name:'值班安排'},
        {name:'我的值班'},
    ];
    swiperIndex;
    changeType = 1;
    dayObj = {
            name:''
        };
    nightObj = {
        name:''
    };
    nowDuty = [];
    historyDuty;
    options: CalendarComponentOptions = {
        from: new Date(2000, 0, 1),
        monthFormat: 'YYYY 年 MM 月 ',
        weekdays: weekDay,
        monthPickerFormat:monthCh,
        pickMode: 'single',
        color:'danger'
    };
  constructor(public navCtrl: NavController, public navParams: NavParams,
              public appService: AppService) {
  }

  ionViewDidEnter() {

      const date = new Date().toLocaleDateString();
      this.getDuty(date);
      this.myDuty();

    this.selectPageMenu(0);
    this.getSchedule()
  }

    selectPageMenu(index) {

        this.swiperIndex = index;
        //切换页面
        // this.contentSlides.slideTo(index);
    }

    getSchedule(){

    }

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

    onChange(e){
        const date = new Date(e).toLocaleDateString();
        this.getDuty(date);
    }

    getDuty(date){
        //0 白班  1 夜班
        const data = {
            date:date,
            type:0
        };
        this.appService.ObserverHttpGetOption('/wisdomgroup/schedule/getScheduleInfo',data)
            .subscribe((res)=>{
                this.dayObj = res.json();
            });

        const data1 = {
            date:date,
            type:1
        };
        this.appService.ObserverHttpGetOption('/wisdomgroup/schedule/getScheduleInfo',data1)
            .subscribe((res)=>{
                this.nightObj = res.json();
            });
    }


    //我的值班
    myDuty(){
        const data = {
            type:0
        };
        this.appService.ObserverHttpGetOption('/wisdomgroup/schedule/app/getMySchedule',data)
            .subscribe((res)=>{
               this.nowDuty = res.json();
            });
        const data1 = {
            type:1
        };
        this.appService.ObserverHttpGetOption('/wisdomgroup/schedule/app/getMySchedule',data1)
            .subscribe((res)=>{
                this.historyDuty = res;
            });
    }

    //提交申请
    dutyApply(item){
        let nowTime = new Date().getTime();
        if(nowTime > item.dutyDate){
            this.appService.popToastView('该条值班已过期','middle',1500);
            return false;
        }
      this.navCtrl.push('DutyApplyPage',{
          id:item.id,
          date:item.dutyDate
      })
    }

    //申请详情
    dutyDetail(item){
        this.navCtrl.push('DutyDetailPage',{
            "id":item.applyId,
            'time':item.dutyDate
        })
    }

    //值班签到
    sigUp(){
        this.navCtrl.push('DutySignUpPage');
    }

}