diff --git a/resources/js/Components/Dashboard/Maps.vue b/resources/js/Components/Dashboard/Maps.vue index 951783c..8fffb6a 100644 --- a/resources/js/Components/Dashboard/Maps.vue +++ b/resources/js/Components/Dashboard/Maps.vue @@ -1,12 +1,9 @@ - diff --git a/resources/js/Components/Dashboard/MapsCopy.vue b/resources/js/Components/Dashboard/MapsCopy.vue deleted file mode 100644 index bc18343..0000000 --- a/resources/js/Components/Dashboard/MapsCopy.vue +++ /dev/null @@ -1,721 +0,0 @@ - - - diff --git a/resources/js/Pages/App/AtencionCiudadana.vue b/resources/js/Pages/App/AtencionCiudadana.vue index 529f8e4..77f38f9 100644 --- a/resources/js/Pages/App/AtencionCiudadana.vue +++ b/resources/js/Pages/App/AtencionCiudadana.vue @@ -180,15 +180,16 @@ const applyDataToComponents = (payload, includeCharts = true) => { const { porTipo, porGenero, porEdad, totalsShape } = normalizeResponse(payload); - // Actualizar totales - totals.value.day = totalsShape?.today ?? 0; - totals.value.week = totalsShape?.week ?? 0; - totals.value.month = totalsShape?.month ?? 0; + // Solo usar totales del servidor si no hay filtros activos + if (!selectedDepartment.value && !selectedType.value) { + totals.value.day = totalsShape?.today ?? 0; + totals.value.week = totalsShape?.week ?? 0; + totals.value.month = totalsShape?.month ?? 0; + } - // Procesar beneficiarios + // Procesar beneficiarios (esto también actualizará los totales filtrados) processBeneficiariesAsync(payload); - // Solo construir gráficas si se solicita (para evitar conflicto con DateRange) if (includeCharts) { buildTipoChart(porTipo); buildGeneroChart(porGenero); @@ -230,9 +231,42 @@ const processBeneficiariesAsync = async (payload) => { beneficiariesList.value = beneficiariesData; beneficiariesByType.value = groupBeneficiariesByType(beneficiariesData); expandedGroups.value = new Set(); + + updateTotalsFromFilteredData(payload); }, 0); }; +const updateTotalsFromFilteredData = (payload) => { + const dashboardAlmacenData = payload.dashboard?.data ?? payload.dashboard ?? {}; + const dashboardServicioData = payload.dashboard_servicio?.data ?? payload.dashboard_servicio ?? {}; + + // Calcular para cada período + const periods = ['hoy', 'semana']; + const totalsKeys = ['day', 'week']; + + periods.forEach((periodKey, index) => { + const beneficiariesAlmacen = dashboardAlmacenData[periodKey] || []; + const beneficiariesServicio = dashboardServicioData[periodKey] || []; + + let allBeneficiaries = [...beneficiariesAlmacen, ...beneficiariesServicio]; + + // Aplicar filtros de departamento y tipo + allBeneficiaries = filterBeneficiariesByDepartment( + allBeneficiaries, + selectedDepartment.value + ); + + allBeneficiaries = filterBeneficiariesByType( + allBeneficiaries, + selectedType.value + ); + + // Actualizar el total correspondiente + const totalKey = totalsKeys[index]; + totals.value[totalKey] = allBeneficiaries.length; + }); +}; + const clearComponentData = () => { tipoChart.value = { labels: [], datasets: [] }; generoChart.value = { labels: [], datasets: [] }; @@ -664,13 +698,6 @@ onMounted(() => { Entregados - {{ - selectedPeriod === "hoy" - ? "Hoy" - : selectedPeriod === "semana" - ? "Esta Semana" - : "Este Mes" - }} ({{ beneficiariesList.length }})