|
@@ -63,12 +63,16 @@ const isLoading = ref<boolean>(false)
|
|
|
|
|
|
// 本月日期
|
|
|
const defineMonth = () => {
|
|
|
- // 如果本周六是在一号或二号,那本周必然算是上个月,所以做一个判断
|
|
|
- const thisWeekSixDay = 6 - moment().day()
|
|
|
- if (thisWeekSixDay < 3 || thisWeekSixDay == 6) {
|
|
|
+ // 获取本月的第一天
|
|
|
+ const firstDayOfMonth = moment().startOf('month')
|
|
|
+ // 判断本月的1号是周几
|
|
|
+ const firstDayOfWeek = firstDayOfMonth.day() == 0 ? 7 : firstDayOfMonth.day()
|
|
|
+ // 如果本月的1号为周四之后,则本周为上个月的最后一周
|
|
|
+ if (firstDayOfWeek >= 4) {
|
|
|
return moment().subtract(1, 'month')
|
|
|
+ } else {
|
|
|
+ return moment()
|
|
|
}
|
|
|
- return moment()
|
|
|
}
|
|
|
const thisMonth = ref<any>(defineMonth())
|
|
|
// 本月的周日报和周划分
|