From fd2c1b29704fd651504194a5a080ff4d917043f3 Mon Sep 17 00:00:00 2001 From: ale Date: Tue, 18 Mar 2025 19:58:19 -0300 Subject: [PATCH] Cambios para usar nuevo resource de gdc + arreglo plancha con timeout para sincornizar datos --- resources/js/components/admin/Body.vue | 66 ++++++++------------------ 1 file changed, 20 insertions(+), 46 deletions(-) diff --git a/resources/js/components/admin/Body.vue b/resources/js/components/admin/Body.vue index 1b4b8c5..2083305 100644 --- a/resources/js/components/admin/Body.vue +++ b/resources/js/components/admin/Body.vue @@ -3,27 +3,18 @@
-
+
+ :gdc_id="gdc.id"> - + :gdc="this.gdc" + >
-

+

Todavía no hay ningún pedido para administrar.

-
- - -

- Todavía no hay pedidos aprobados. -

-
@@ -38,6 +29,7 @@ import TabsSecciones from "../comunes/TabsSecciones.vue"; import DropdownDescargar from "./DropdownDescargar.vue"; import TablaPedidos from "./TablaPedidos.vue"; import TablaBonos from "./TablaBonos.vue"; +import axios from "axios"; export default { components: { CaracteristicasOpcionales, @@ -48,12 +40,8 @@ export default { }, data() { return { - gdc: 0, - pedidos: [], - bonosDeTransporte: 0, - totalBonosBarriales: 0, + gdc: undefined, tabs: [{ id: "pedidos", nombre: "Pedidos" }, - { id: "bonos", nombre: "Bonos" }, { id: "caracteristicas", nombre: "Caracteristicas opcionales" }], tabActiva: "pedidos", seccionActiva: "pedidos-seccion", @@ -61,46 +49,32 @@ export default { }, computed: { hayPedidos: function() { - return this.pedidos.length !== 0 + return this.gdc && this.gdc.pedidos.length !== 0 }, hayAprobados: function() { - return this.pedidos.filter(p => p.aprobado).length > 0 + return this.gdc && this.gdc.pedidos.filter(p => p.aprobado).length > 0 } }, methods: { - fetchPedidos() { - axios.get("/api/grupos-de-compra/"+this.gdc+"/bonos-de-transporte", {}) - .then(response => this.bonosDeTransporte = response.data.bdt); - axios.get("/api/subpedidos/resources", { - params: { - grupo_de_compra: this.gdc - }}) - .then(response => { - this.pedidos = response.data.data - }).get; - axios.get("/api/grupos-de-compra/"+this.gdc+"/bonos-barriales", {}) - .then(response => this.totalBonosBarriales = response.data.bonos_barriales) - }, setSeccionActiva(tabId) { this.tabActiva = tabId; this.seccionActiva = tabId + "-seccion"; }, - getBonosBarriales() { - axios.get("/api/grupos-de-compra/"+this.gdc+"/bonos-barriales", {}) - .then(response => this.totalBonosBarriales = response.data.bonos_barriales) + actualizar() { + axios.get('/api/grupos-de-compra/' + this.$root.gdc) + .then(response => { + this.gdc = response.data.data; + console.log(this.gdc); + }) } }, - mounted() { + async mounted() { Event.$on('sync-aprobacion', (_) => { - this.fetchPedidos(); + this.actualizar(); }); - - axios.get("/admin/obtener_sesion").then(response => { - this.gdc = response.data.gdc; - this.fetchPedidos(); - this.bonosBarriales = this.getBonosBarriales() - }); - } + await new Promise(r => setTimeout(r, 1000)); + this.actualizar(); + }, }