getYear(date) {
return date.getFullYear().toString();
},
getMonth(date) {
return this.formatDateNumber(date.getMonth() + 1);
},
getDay(date) {
return this.formatDateNumber(date.getDate());
},
formatDateNumber(num) {
return num >= 10 ? num.toString() : '0' + num;
},
formatDate(date) {
const newDate = new Date(date);
return this.getYear(newDate) + '-' + this.getMonth(newDate) + '-' + this.getDay(newDate);
},
// 默认查询七天
var defaultTime= [(new Date().getTime() - 3600 * 1000 * 24 * 6), new Date()]
formatDate(this.defaultTime[0]) + ' 00:00:00',
formatDate(this.defaultTime[1]) + ' 23:59:59'
// 判断不能超出七天
const startTimestamp = new Date(params.startTime).getTime();
const endTimestamp = new Date(params.endTime).getTime();
if ((endTimestamp - startTimestamp) > 7 * 24 * 60 * 60 * 1000) {
this.$message.warning('查询范围不能超过一周');
return;
}
时间默认七天并且判断时间段不能超出七天
最新推荐文章于 2024-01-29 19:34:44 发布