forked from nathalie/pedi2
Cambios para usar nuevo resource de gdc + arreglo plancha con timeout para sincornizar datos
This commit is contained in:
parent
2587c759fb
commit
fd2c1b2970
1 changed files with 20 additions and 46 deletions
|
@ -3,27 +3,18 @@
|
|||
<comunes-tabs-secciones :tabs="tabs" :tabInicial="tabActiva"></comunes-tabs-secciones>
|
||||
<div class="block" id="pedidos-seccion"
|
||||
:class="seccionActiva === 'pedidos-seccion' ? 'is-active' : 'is-hidden'">
|
||||
<div class="block pb-6" id="pedidos-tabla-y-dropdown" v-show="hayPedidos">
|
||||
<div class="block pb-6" id="pedidos-tabla-y-dropdown" v-if="hayPedidos">
|
||||
<admin-dropdown-descargar
|
||||
:gdc="gdc">
|
||||
:gdc_id="gdc.id">
|
||||
</admin-dropdown-descargar>
|
||||
<admin-tabla-pedidos
|
||||
:pedidos="pedidos" :bonosDeTransporte="bonosDeTransporte" :totalBonosBarriales="totalBonosBarriales">
|
||||
</admin-tabla-pedidos>
|
||||
:gdc="this.gdc"
|
||||
></admin-tabla-pedidos>
|
||||
</div>
|
||||
<p class="has-text-centered" v-show="!hayPedidos">
|
||||
<p class="has-text-centered" v-else>
|
||||
Todavía no hay ningún pedido para administrar.
|
||||
</p>
|
||||
</div>
|
||||
<div class="block pb-6" id="bonos-seccion"
|
||||
:class="seccionActiva === 'bonos-seccion' ? 'is-active' : 'is-hidden'">
|
||||
<admin-tabla-bonos v-show="hayAprobados"
|
||||
:pedidos="pedidos">
|
||||
</admin-tabla-bonos>
|
||||
<p class="has-text-centered" v-show="!hayAprobados">
|
||||
Todavía no hay pedidos aprobados.
|
||||
</p>
|
||||
</div>
|
||||
<div class="block pb-6" id="caracteristicas-seccion"
|
||||
:class="seccionActiva === 'caracteristicas-seccion' ? 'is-active' : 'is-hidden'">
|
||||
<admin-caracteristicas-opcionales>
|
||||
|
@ -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();
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue