Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {ChangeApplySurePage} from "../change-apply-sure/change-apply-sure";
import {CalendarComponentOptions, DayConfig} from "ion2-calendar";
import {DatePipe} from "@angular/common";
import {monthCh,weekDay} from "../../../../app/main";
import {AppService} from "../../../../service/http.service";
@IonicPage()
@Component({
selector: 'page-select-change-person',
templateUrl: 'select-change-person.html',
})
export class SelectChangePersonPage {
//日历
optionsMulti: CalendarComponentOptions;
newArr: DayConfig[] = [];
scheduleId; //换班申请中值班Id
changeInfo; //换班信息
date; //换班日期
list = [];
type;
constructor(public navCtrl: NavController, public navParams: NavParams,
public appService: AppService, public datePipe: DatePipe) {
}
ionViewDidLoad() {
this.scheduleId = this.navParams.get('scheduleId');
this.getDetail();
}
getDetail() {
const year = this.datePipe.transform(this.navParams.get('date'), 'yyyy');
const month = this.datePipe.transform(this.navParams.get('date'), 'MM');
const data = {
id: this.scheduleId
}
this.appService.ObserverHttpGetOption('/wisdomgroup/schedule/getScheduleById', data).subscribe((res) => {
this.type = res.json().type;
this.getMonth(year, month);
})
}
//选择月份
//月份改变
monChange(e) {
this.getMonth(e.newMonth.years, e.newMonth.months);
}
getMonth(year, month) {
let date = new Date();
//4.每月的周末
let d = new Date(year, month, 0).getDate();
// for (let i = 1; i < d + 1; i++) {
// date.setFullYear(year, month - 1, i);
// let day = date.getDay();
// if (day == 6 || day == 0) {
// const data = {
// date: new Date(year, month - 1, i),
// cssClass: 'dayOff1'
// };
// this.newArr.push(data);
// }
// }
const data = {
date: year + '/' + month + '/01',
type: this.type
};
this.appService.ObserverHttpGetOption('/wisdomgroup/schedule/getScheduleByMonthAndType', data)
.subscribe((res) => {
let response = res.json();
response.forEach(event => {
this.newArr.push({
date: new Date(event.dutyDate),
disable: false,
subTitle: event.name,
cssClass: event.id
})
});
this.optionsMulti = {
pickMode: 'single',
monthFormat: 'YYYY 年 MM 月 ',
weekdays: weekDay,
monthPickerFormat: monthCh,
weekStart: 0,
daysConfig: this.newArr
};
})
}
onSelect(e) {
this.changeInfo = null;
if (e.subTitle != '') {
this.changeInfo = e;
}
}
//换班
submit() {
if (!this.changeInfo) {
this.appService.popToastView('请选择换班人员', 'middle', 1500);
return false;
}
const item = {
name: this.changeInfo.subTitle,
time: this.changeInfo.time
};
this.navCtrl.push('ChangeApplySurePage', {
'changeId': this.changeInfo.cssClass,
'nowId': this.scheduleId,
'item': item,
'applyId': this.navParams.get('applyId'),
})
}
}