This commit is contained in:
parent
982fb201ea
commit
5ffd0000cb
|
|
@ -431,15 +431,14 @@ export default {
|
|||
// 默认日期范围
|
||||
getDefaultDateRange() {
|
||||
const today = new Date()
|
||||
const lastMonth = new Date()
|
||||
|
||||
// 设置为前一个月
|
||||
// 获取上个月的同一天
|
||||
const lastMonth = new Date(today)
|
||||
lastMonth.setMonth(today.getMonth() - 1)
|
||||
|
||||
// 处理跨年情况
|
||||
if (today.getMonth() === 0) {
|
||||
lastMonth.setFullYear(today.getFullYear() - 1)
|
||||
lastMonth.setMonth(11)
|
||||
// 处理日期溢出问题
|
||||
if (lastMonth.getDate() !== today.getDate()) {
|
||||
lastMonth.setDate(0) // 设置为上个月的最后一天
|
||||
}
|
||||
|
||||
const formatDate = date => {
|
||||
|
|
@ -449,7 +448,6 @@ export default {
|
|||
return `${y}-${m}-${d}`
|
||||
}
|
||||
|
||||
// 返回从前一个月到今天的日期范围
|
||||
return [formatDate(lastMonth), formatDate(today)]
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -224,15 +224,14 @@ export default {
|
|||
// 默认日期范围
|
||||
getDefaultDateRange() {
|
||||
const today = new Date()
|
||||
const lastMonth = new Date()
|
||||
|
||||
// 设置为前一个月
|
||||
// 获取上个月的同一天
|
||||
const lastMonth = new Date(today)
|
||||
lastMonth.setMonth(today.getMonth() - 1)
|
||||
|
||||
// 处理跨年情况
|
||||
if (today.getMonth() === 0) {
|
||||
lastMonth.setFullYear(today.getFullYear() - 1)
|
||||
lastMonth.setMonth(11)
|
||||
// 处理日期溢出问题
|
||||
if (lastMonth.getDate() !== today.getDate()) {
|
||||
lastMonth.setDate(0) // 设置为上个月的最后一天
|
||||
}
|
||||
|
||||
const formatDate = date => {
|
||||
|
|
@ -242,7 +241,6 @@ export default {
|
|||
return `${y}-${m}-${d}`
|
||||
}
|
||||
|
||||
// 返回从前一个月到今天的日期范围
|
||||
return [formatDate(lastMonth), formatDate(today)]
|
||||
},
|
||||
// 导出数据
|
||||
|
|
|
|||
Loading…
Reference in New Issue