From 14fee455a18d0093bad3c0c7c8187aeda3bea3ec Mon Sep 17 00:00:00 2001 From: xds Date: Tue, 2 Dec 2025 19:05:10 +0300 Subject: [PATCH] feat: Dynamically adjust dashboard period start and end dates based on the current day of the month. --- src/components/dashboard/DashboardView.vue | 31 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) 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)