|
@@ -9,8 +9,8 @@ import { DateService } from 'src/app/services/date.service';
|
9
|
9
|
styleUrls: ['./custom-change-date.component.less']
|
10
|
10
|
})
|
11
|
11
|
export class CustomChangeDateComponent implements OnInit {
|
12
|
|
- @Output() customChangeDateEmit = new EventEmitter();
|
13
|
|
- @Input() queryType: number;
|
|
12
|
+ // @Output() customChangeDateEmit = new EventEmitter();
|
|
13
|
+ @Input() isShowType: boolean = true;
|
14
|
14
|
constructor(
|
15
|
15
|
private dateService: DateService,
|
16
|
16
|
) { }
|
|
@@ -30,20 +30,36 @@ export class CustomChangeDateComponent implements OnInit {
|
30
|
30
|
value: "year",
|
31
|
31
|
},
|
32
|
32
|
]; //时间维度
|
33
|
|
- defRange = "1"; //默认上周
|
|
33
|
+ defRange = 6; //默认上月
|
34
|
34
|
defRanges = [
|
35
|
35
|
{
|
36
|
|
- label: "上周",
|
|
36
|
+ label: "昨日",
|
37
|
37
|
id: 1,
|
38
|
38
|
},
|
39
|
39
|
{
|
40
|
|
- label: "上月",
|
|
40
|
+ label: "本周",
|
41
|
41
|
id: 2,
|
42
|
42
|
},
|
43
|
43
|
{
|
44
|
|
- label: "上年",
|
|
44
|
+ label: "本月",
|
45
|
45
|
id: 3,
|
46
|
46
|
},
|
|
47
|
+ {
|
|
48
|
+ label: "本年",
|
|
49
|
+ id: 4,
|
|
50
|
+ },
|
|
51
|
+ {
|
|
52
|
+ label: "上周",
|
|
53
|
+ id: 5,
|
|
54
|
+ },
|
|
55
|
+ {
|
|
56
|
+ label: "上月",
|
|
57
|
+ id: 6,
|
|
58
|
+ },
|
|
59
|
+ {
|
|
60
|
+ label: "上年",
|
|
61
|
+ id: 7,
|
|
62
|
+ },
|
47
|
63
|
]; //时间默认区间
|
48
|
64
|
|
49
|
65
|
dateRange: any = []; //发起时间区间 天
|
|
@@ -52,9 +68,27 @@ export class CustomChangeDateComponent implements OnInit {
|
52
|
68
|
yearRangeStart: any; //发起时间 年 起
|
53
|
69
|
yearRangeEnd: any; //发起时间 年 止
|
54
|
70
|
|
55
|
|
- ngOnInit() {}
|
|
71
|
+ ngOnInit() {
|
|
72
|
+ this.dateType = 'day';
|
|
73
|
+ this.defRange = 6;
|
|
74
|
+ this.changeDateRange(this.defRange);
|
|
75
|
+ }
|
56
|
76
|
|
57
|
|
- // this.customChangeDateEmit.emit({queryType, hospital, duty, parent});
|
|
77
|
+ // 根据时间区间重置
|
|
78
|
+ reset(dateRange:any[]){
|
|
79
|
+ this.dateType = 'day';
|
|
80
|
+ if(
|
|
81
|
+ this.dateService.getDateType(dateRange) == 1 ||
|
|
82
|
+ this.dateService.getDateType(dateRange) == 2 ||
|
|
83
|
+ this.dateService.getDateType(dateRange) == 3 ||
|
|
84
|
+ this.dateService.getDateType(dateRange) == 5 ||
|
|
85
|
+ this.dateService.getDateType(dateRange) == 6 ||
|
|
86
|
+ this.dateService.getDateType(dateRange) == 7
|
|
87
|
+ ){
|
|
88
|
+ this.defRange = this.dateService.getDateType(dateRange);
|
|
89
|
+ }
|
|
90
|
+ this.changeDateRange(this.defRange);
|
|
91
|
+ }
|
58
|
92
|
|
59
|
93
|
// 修改时间展示维度
|
60
|
94
|
changeDateType(res) {
|
|
@@ -64,44 +98,64 @@ export class CustomChangeDateComponent implements OnInit {
|
64
|
98
|
case "day":
|
65
|
99
|
this.defRanges = [
|
66
|
100
|
{
|
67
|
|
- label: "上周",
|
|
101
|
+ label: "昨日",
|
68
|
102
|
id: 1,
|
69
|
103
|
},
|
70
|
104
|
{
|
71
|
|
- label: "上月",
|
|
105
|
+ label: "本周",
|
72
|
106
|
id: 2,
|
73
|
107
|
},
|
74
|
108
|
{
|
75
|
|
- label: "上年",
|
|
109
|
+ label: "本月",
|
76
|
110
|
id: 3,
|
77
|
111
|
},
|
|
112
|
+ {
|
|
113
|
+ label: "上周",
|
|
114
|
+ id: 5,
|
|
115
|
+ },
|
|
116
|
+ {
|
|
117
|
+ label: "上月",
|
|
118
|
+ id: 6,
|
|
119
|
+ },
|
|
120
|
+ {
|
|
121
|
+ label: "上年",
|
|
122
|
+ id: 7,
|
|
123
|
+ },
|
78
|
124
|
]; //时间默认区间
|
79
|
|
- this.defRange = "1"; //默认上周
|
80
|
|
- this.changeDateRange("1");
|
|
125
|
+ this.defRange = this.defRanges[0].id;
|
|
126
|
+ this.changeDateRange(this.defRanges[0].id);
|
81
|
127
|
break;
|
82
|
128
|
case "month":
|
83
|
129
|
this.defRanges = [
|
84
|
130
|
{
|
|
131
|
+ label: "本月",
|
|
132
|
+ id: 3,
|
|
133
|
+ },
|
|
134
|
+ {
|
85
|
135
|
label: "上月",
|
86
|
|
- id: 2,
|
|
136
|
+ id: 6,
|
87
|
137
|
},
|
88
|
138
|
{
|
89
|
139
|
label: "上年",
|
90
|
|
- id: 3,
|
|
140
|
+ id: 7,
|
91
|
141
|
},
|
92
|
142
|
]; //时间默认区间
|
93
|
|
- this.defRange = "2"; //上月
|
94
|
|
- this.changeDateRange("2");
|
|
143
|
+ this.defRange = this.defRanges[0].id;
|
|
144
|
+ this.changeDateRange(this.defRanges[0].id);
|
95
|
145
|
break;
|
96
|
146
|
case "year":
|
97
|
147
|
this.defRanges = [
|
98
|
148
|
{
|
|
149
|
+ label: "本年",
|
|
150
|
+ id: 4,
|
|
151
|
+ },
|
|
152
|
+ {
|
99
|
153
|
label: "上年",
|
100
|
|
- id: 3,
|
|
154
|
+ id: 7,
|
101
|
155
|
},
|
102
|
156
|
]; //时间默认区间
|
103
|
|
- this.defRange = "3"; //默认上周
|
104
|
|
- this.changeDateRange("3");
|
|
157
|
+ this.defRange = this.defRanges[0].id;
|
|
158
|
+ this.changeDateRange(this.defRanges[0].id);
|
105
|
159
|
break;
|
106
|
160
|
}
|
107
|
161
|
}
|
|
@@ -109,7 +163,7 @@ export class CustomChangeDateComponent implements OnInit {
|
109
|
163
|
// 禁选日期
|
110
|
164
|
disabledDate = (current: Date): boolean => {
|
111
|
165
|
// Can not select days before today and today
|
112
|
|
- return differenceInCalendarDays(current, this.today) > 0;
|
|
166
|
+ return false;
|
113
|
167
|
};
|
114
|
168
|
|
115
|
169
|
// 禁选月份开始
|
|
@@ -122,9 +176,8 @@ export class CustomChangeDateComponent implements OnInit {
|
122
|
176
|
// 禁选月份结束
|
123
|
177
|
disabledMonthEnd = (current: Date): boolean => {
|
124
|
178
|
// Can not select days before today and today
|
125
|
|
- let cur = differenceInCalendarDays(current, endOfMonth(this.today)) > 0;
|
126
|
179
|
let staEnd = differenceInCalendarDays(this.monthRangeStart, current) > 0;
|
127
|
|
- return cur || staEnd;
|
|
180
|
+ return staEnd;
|
128
|
181
|
};
|
129
|
182
|
|
130
|
183
|
// 禁选年份开始
|
|
@@ -138,17 +191,14 @@ export class CustomChangeDateComponent implements OnInit {
|
138
|
191
|
// 禁选年份结束
|
139
|
192
|
disabledYearEnd = (current: Date): boolean => {
|
140
|
193
|
// Can not select days before today and today
|
141
|
|
- let cur = differenceInCalendarDays(current, endOfYear(this.today)) > 0;
|
142
|
194
|
let staEnd = differenceInCalendarDays(this.yearRangeStart, current) > 0;
|
143
|
|
- return cur || staEnd;
|
|
195
|
+ return staEnd;
|
144
|
196
|
};
|
145
|
197
|
|
146
|
198
|
// 日期选择 日
|
147
|
199
|
startDate: string; //发起时间开始
|
148
|
200
|
endDate: string; //发起时间结束
|
149
|
|
- changeDate(result?): void {
|
150
|
|
- console.log(this.dateRange);
|
151
|
|
- console.log(result);
|
|
201
|
+ changeDate(result): void {
|
152
|
202
|
this.dateRange = result;
|
153
|
203
|
if (!this.quick) {
|
154
|
204
|
// 不是快捷选择
|
|
@@ -158,22 +208,12 @@ export class CustomChangeDateComponent implements OnInit {
|
158
|
208
|
this.startDate = this.endDate = "";
|
159
|
209
|
return;
|
160
|
210
|
}
|
161
|
|
- this.startDate =
|
162
|
|
- result[0].getFullYear() +
|
163
|
|
- "-" +
|
164
|
|
- (result[0].getMonth() + 1) +
|
165
|
|
- "-" +
|
166
|
|
- result[0].getDate();
|
167
|
|
- this.endDate =
|
168
|
|
- result[1].getFullYear() +
|
169
|
|
- "-" +
|
170
|
|
- (result[1].getMonth() + 1) +
|
171
|
|
- "-" +
|
172
|
|
- result[1].getDate();
|
|
211
|
+ this.startDate = format(startOfDay(result[0]), "yyyy-MM-dd HH:mm:ss");
|
|
212
|
+ this.endDate = format(endOfDay(result[1]), "yyyy-MM-dd HH:mm:ss");
|
173
|
213
|
}
|
174
|
214
|
|
175
|
215
|
// 月份选择
|
176
|
|
- changeMonthStart(result?) {
|
|
216
|
+ changeMonthStart(result) {
|
177
|
217
|
console.log(result);
|
178
|
218
|
this.monthRangeStart = result;
|
179
|
219
|
if (!this.quick) {
|
|
@@ -184,9 +224,9 @@ export class CustomChangeDateComponent implements OnInit {
|
184
|
224
|
this.startDate = this.endDate = "";
|
185
|
225
|
return;
|
186
|
226
|
}
|
187
|
|
- this.startDate = format(startOfMonth(result), 'yyyy-MM-dd');
|
|
227
|
+ this.startDate = format(startOfMonth(result), 'yyyy-MM-dd HH:mm:ss');
|
188
|
228
|
}
|
189
|
|
- changeMonthEnd(result?) {
|
|
229
|
+ changeMonthEnd(result) {
|
190
|
230
|
console.log(result);
|
191
|
231
|
this.monthRangeEnd = result;
|
192
|
232
|
if (!this.quick) {
|
|
@@ -197,10 +237,10 @@ export class CustomChangeDateComponent implements OnInit {
|
197
|
237
|
this.startDate = this.endDate = "";
|
198
|
238
|
return;
|
199
|
239
|
}
|
200
|
|
- this.endDate = format(endOfMonth(result), 'yyyy-MM-dd');
|
|
240
|
+ this.endDate = format(endOfMonth(result), 'yyyy-MM-dd HH:mm:ss');
|
201
|
241
|
}
|
202
|
242
|
// 年份选择
|
203
|
|
- changeYearStart(result?) {
|
|
243
|
+ changeYearStart(result) {
|
204
|
244
|
console.log(result);
|
205
|
245
|
this.yearRangeStart = result;
|
206
|
246
|
if (!this.quick) {
|
|
@@ -211,10 +251,9 @@ export class CustomChangeDateComponent implements OnInit {
|
211
|
251
|
this.startDate = this.endDate = "";
|
212
|
252
|
return;
|
213
|
253
|
}
|
214
|
|
- this.startDate = format(startOfYear(result), 'yyyy-MM-dd');
|
215
|
|
- // this.endDate = result.getFullYear() + '-01-01';
|
|
254
|
+ this.startDate = format(startOfYear(result), 'yyyy-MM-dd HH:mm:ss');
|
216
|
255
|
}
|
217
|
|
- changeYearEnd(result?) {
|
|
256
|
+ changeYearEnd(result) {
|
218
|
257
|
console.log(result);
|
219
|
258
|
this.yearRangeEnd = result;
|
220
|
259
|
if (!this.quick) {
|
|
@@ -225,7 +264,7 @@ export class CustomChangeDateComponent implements OnInit {
|
225
|
264
|
this.startDate = this.endDate = "";
|
226
|
265
|
return;
|
227
|
266
|
}
|
228
|
|
- this.endDate = format(endOfYear(result), 'yyyy-MM-dd');
|
|
267
|
+ this.endDate = format(endOfYear(result), 'yyyy-MM-dd HH:mm:ss');
|
229
|
268
|
}
|
230
|
269
|
|
231
|
270
|
// 日期选择 快速修改时间区间
|
|
@@ -235,14 +274,48 @@ export class CustomChangeDateComponent implements OnInit {
|
235
|
274
|
console.log(res);
|
236
|
275
|
this.quick = true;
|
237
|
276
|
switch (res) {
|
238
|
|
- case "1":
|
|
277
|
+ case 1:
|
|
278
|
+ // 昨日
|
|
279
|
+ let yesterdaystartdate = this.dateService.date().yesterdayStartDate;
|
|
280
|
+ let yesterdayenddate = this.dateService.date().yesterdayEndDate;
|
|
281
|
+ console.log(yesterdaystartdate, yesterdayenddate);
|
|
282
|
+ this.changeDate([yesterdaystartdate, yesterdayenddate]);
|
|
283
|
+ break;
|
|
284
|
+ case 2:
|
|
285
|
+ // 本周
|
|
286
|
+ let thisweekstartdate = this.dateService.date().thisWeekStartDate;
|
|
287
|
+ let thisweekenddate = this.dateService.date().thisWeekEndDate;
|
|
288
|
+ console.log(thisweekstartdate, thisweekenddate);
|
|
289
|
+ this.changeDate([thisweekstartdate, thisweekenddate]);
|
|
290
|
+ break;
|
|
291
|
+ case 3:
|
|
292
|
+ // 本月
|
|
293
|
+ let thismonthstartdate = this.dateService.date().thisMonthStartDate;
|
|
294
|
+ let thismonthenddate = this.dateService.date().thisMonthEndDate;
|
|
295
|
+ console.log(thismonthstartdate, thismonthenddate);
|
|
296
|
+ this.changeDate([thismonthstartdate, thismonthenddate]);
|
|
297
|
+ this.changeMonthStart(thismonthstartdate);
|
|
298
|
+ this.changeMonthEnd(thismonthenddate);
|
|
299
|
+ break;
|
|
300
|
+ case 4:
|
|
301
|
+ // 本年
|
|
302
|
+ let thisyearstartdate = this.dateService.date().thisYearStartDate;
|
|
303
|
+ let thisyearenddate = this.dateService.date().thisYearEndDate;
|
|
304
|
+ console.log(thisyearstartdate, thisyearenddate);
|
|
305
|
+ this.changeDate([thisyearstartdate, thisyearenddate]);
|
|
306
|
+ this.changeMonthStart(thisyearstartdate);
|
|
307
|
+ this.changeMonthEnd(thisyearenddate);
|
|
308
|
+ this.changeYearStart(thisyearstartdate);
|
|
309
|
+ this.changeYearEnd(thisyearenddate);
|
|
310
|
+ break;
|
|
311
|
+ case 5:
|
239
|
312
|
// 上周
|
240
|
313
|
let lastweekstartdate = this.dateService.date().lastWeekStartDate;
|
241
|
314
|
let lastweekenddate = this.dateService.date().lastWeekEndDate;
|
242
|
315
|
console.log(lastweekstartdate, lastweekenddate);
|
243
|
316
|
this.changeDate([lastweekstartdate, lastweekenddate]);
|
244
|
317
|
break;
|
245
|
|
- case "2":
|
|
318
|
+ case 6:
|
246
|
319
|
// 上月
|
247
|
320
|
let lastmonthstartdate = this.dateService.date().lastMonthStartDate;
|
248
|
321
|
let lastmonthenddate = this.dateService.date().lastMonthEndDate;
|
|
@@ -251,7 +324,7 @@ export class CustomChangeDateComponent implements OnInit {
|
251
|
324
|
this.changeMonthStart(lastmonthstartdate);
|
252
|
325
|
this.changeMonthEnd(lastmonthenddate);
|
253
|
326
|
break;
|
254
|
|
- case "3":
|
|
327
|
+ case 7:
|
255
|
328
|
// 上年
|
256
|
329
|
let lastyearstartdate = this.dateService.date().lastYearStartDate;
|
257
|
330
|
let lastyearenddate = this.dateService.date().lastYearEndDate;
|