diff --git a/src/components/dashboard/DashboardView.vue b/src/components/dashboard/DashboardView.vue index a1f3b08..f5e78b5 100644 --- a/src/components/dashboard/DashboardView.vue +++ b/src/components/dashboard/DashboardView.vue @@ -49,18 +49,45 @@ const nextMonth = () => { }; const currentStartDate = computed(() => { + const currentDay = currentBaseDate.value.date(); + + // Если текущая дата от 1 до 9, период начинается с 10-го числа предыдущего месяца + if (currentDay >= 1 && currentDay <= 9) { + return currentBaseDate.value.subtract(1, 'month').date(10).toDate(); + } + + // Если текущая дата от 10 до конца месяца, период начинается с 10-го числа текущего месяца return currentBaseDate.value.date(10).toDate(); }); const currentEndDate = computed(() => { + const currentDay = currentBaseDate.value.date(); + + // Если текущая дата от 1 до 9, период заканчивается 9-го числа текущего месяца + if (currentDay >= 1 && currentDay <= 9) { + return currentBaseDate.value.date(9).toDate(); + } + + // Если текущая дата от 10 до конца месяца, период заканчивается 9-го числа следующего месяца return currentBaseDate.value.add(1, 'month').date(9).toDate(); }); const fetchDashboardData = async () => { if (!spaceStore.selectedSpaceId) return; - const startDate = currentBaseDate.value.date(10).toDate(); - const endDate = currentBaseDate.value.add(1, 'month').date(9).toDate(); + const currentDay = currentBaseDate.value.date(); + let startDate: Date; + let endDate: Date; + + // Если текущая дата от 1 до 9, период: с 10-го предыдущего месяца до 9-го текущего месяца + if (currentDay >= 1 && currentDay <= 9) { + startDate = currentBaseDate.value.subtract(1, 'month').date(10).toDate(); + endDate = currentBaseDate.value.date(9).toDate(); + } else { + // Если текущая дата от 10 до конца месяца, период: с 10-го текущего месяца до 9-го следующего месяца + startDate = currentBaseDate.value.date(10).toDate(); + endDate = currentBaseDate.value.add(1, 'month').date(9).toDate(); + } try { dashboardData.value = await dashboardService.fetchDashboardData(spaceStore.selectedSpaceId, startDate, endDate)