From bd5dd618d0005a14b88fb0ad1d00df0ac22b5740 Mon Sep 17 00:00:00 2001 From: "mariapia.lorusso" Date: Thu, 12 Jun 2025 15:47:26 +0200 Subject: [PATCH] fix date --- src/views/pages/DashExecution.vue | 63 +++++++++---------------------- 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/src/views/pages/DashExecution.vue b/src/views/pages/DashExecution.vue index 673f763..6df9683 100644 --- a/src/views/pages/DashExecution.vue +++ b/src/views/pages/DashExecution.vue @@ -443,17 +443,6 @@ const uniqueAccounts = computed(() => { return accounts.map((acc) => ({ name: acc, id: acc })); // usa anche `id` se serve per la picklist }); -// Filter progetti per account selezionato -// const filteredProjects = computed(() => { -// if (!projectOptions.value) return [] -// let filteredList = projectOptions.value - -// if (selectedAccount.value) { -// filteredList = filteredList.filter(p => p.account === selectedAccount.value.name) -// } - -// return filteredList; -// }) const onPage = (event) => { currentPageExecutions.value = event.page + 1; @@ -533,9 +522,20 @@ const exportAggregations = () => { document.body.removeChild(link); }; -// const exportChats = () => { -// if (chatTable.value) chatTable.value.exportCSV() -// } +const formatLocalDate = (date) => { + if (!date) return null; + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, '0'); + return `${year}-${month}-${day}`; +}; + +const formatLocalDateTo = (date) => { + if (!date) return null; + const nextDay = new Date(date); + nextDay.setDate(nextDay.getDate() + 1); + return formatLocalDate(nextDay); +}; // Caricamento dati con filtri const loadData = async () => { @@ -543,8 +543,8 @@ const loadData = async () => { try { const filterParams = { // Date - dateFrom: dateRange.value?.[0] ? dateRange.value[0].toISOString().split('T')[0] : null, - dateTo: dateRange.value?.[1] ? dateRange.value[1].toISOString().split('T')[0] : null, + dateFrom: formatLocalDate(dateRange.value?.[0]), + dateTo: null ? formatLocalDateTo(dateRange.value?.[0]):formatLocalDateTo(dateRange.value?.[1]), account: selectedAccount.value || null, @@ -558,33 +558,6 @@ const loadData = async () => { }) .filter(Boolean) : [], - - // // Applicazioni - // applicationIds: selectedApplications.value.length - // ? selectedApplications.value.map(id => String(id)) - // : [], - // applicationNames: selectedApplications.value.length - // ? selectedApplications.value - // .map(id => { - // const app = appOptions.value.find(a => a.id === id) - // return app ? app.fe_name : null - // }) - // .filter(Boolean) - // : [], - - // // Utenti - // userIds: selectedUsers.value.length - // ? selectedUsers.value.map(id => String(id)) - // : [], - // userNames: selectedUsers.value.length - // ? selectedUsers.value - // .map(id => { - // const user = userOptions.value.find(u => u.id === id) - // return user ? user.username : null - // }) - // .filter(Boolean) - // : [], - // Scenari scenarioIds: selectedScenarios.value.length ? selectedScenarios.value.map((id) => String(id)) : [], scenarioNames: selectedScenarios.value.length @@ -600,8 +573,8 @@ const loadData = async () => { console.log('Filter parameters:', filterParams); const chatParams = { - dateFrom: dateRange.value?.[0] ? dateRange.value[0].toISOString().split('T')[0] : null, - dateTo: dateRange.value?.[1] ? dateRange.value[1].toISOString().split('T')[0] : null, + dateFrom: formatLocalDate(dateRange.value?.[0]), + dateTo: null ? formatLocalDateTo(dateRange.value?.[0]):formatLocalDateTo(dateRange.value?.[1]), projectIds: selectedProjects.value.length ? selectedProjects.value.map((id) => String(id)) : [], projectNames: selectedProjects.value.length ? selectedProjects.value