2022-06-08 20:32:50 -03:00
|
|
|
<template>
|
2022-06-28 19:16:07 -03:00
|
|
|
<div class="container is-max-widescreen is-max-desktop animate__animated" :class="animation" v-show="!init">
|
2022-11-12 21:16:35 -03:00
|
|
|
<pedidos-admin-dropdown-descargar v-show="hayPedidos"
|
|
|
|
:gdc="gdc">
|
|
|
|
</pedidos-admin-dropdown-descargar>
|
|
|
|
<pedidos-admin-tabla-pedidos v-show="hayPedidos"
|
|
|
|
:pedidos="pedidos">
|
|
|
|
</pedidos-admin-tabla-pedidos>
|
|
|
|
<p class="has-text-centered" v-show="!hayPedidos">
|
2022-06-08 20:32:50 -03:00
|
|
|
Todavía no hay ningún pedido para administrar.
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-11-12 20:20:13 -03:00
|
|
|
import PedidosAdminDropdownDescargar from "./PedidosAdminDropdownDescargar.vue";
|
2022-11-12 21:16:35 -03:00
|
|
|
import PedidosAdminTablaPedidos from "./PedidosAdminTablaPedidos.vue";
|
2022-06-08 20:32:50 -03:00
|
|
|
export default {
|
2022-11-12 20:20:13 -03:00
|
|
|
name: "PedidosAdminBody",
|
|
|
|
components: {
|
2022-11-12 21:16:35 -03:00
|
|
|
PedidosAdminDropdownDescargar,
|
|
|
|
PedidosAdminTablaPedidos
|
2022-11-12 20:20:13 -03:00
|
|
|
},
|
2022-06-08 20:32:50 -03:00
|
|
|
data() {
|
|
|
|
return {
|
2022-10-21 19:17:52 -03:00
|
|
|
gdc: 0,
|
2022-11-12 21:16:35 -03:00
|
|
|
pedidos: []
|
2022-06-08 20:32:50 -03:00
|
|
|
}
|
|
|
|
},
|
2022-11-08 15:55:49 -03:00
|
|
|
computed: {
|
2022-11-12 21:16:35 -03:00
|
|
|
hayPedidos: function() {
|
|
|
|
return this.pedidos.length !== 0
|
|
|
|
},
|
2022-11-08 15:55:49 -03:00
|
|
|
hayAprobados: function() {
|
2022-11-12 21:16:35 -03:00
|
|
|
return this.pedidos.filter(p => p.aprobado).length > 0
|
2022-11-08 15:55:49 -03:00
|
|
|
}
|
|
|
|
},
|
2022-06-08 20:32:50 -03:00
|
|
|
beforeCreate() {
|
|
|
|
axios.get("/admin/obtener_sesion").then(response => {
|
|
|
|
this.gdc = response.data.gdc;
|
2022-11-12 21:16:35 -03:00
|
|
|
this.fetchPedidos();
|
2022-06-08 20:32:50 -03:00
|
|
|
});
|
|
|
|
},
|
|
|
|
methods: {
|
2022-11-12 21:16:35 -03:00
|
|
|
fetchPedidos() {
|
2022-06-09 10:34:28 -03:00
|
|
|
axios.get("/api/subpedidos/resources", {
|
2022-11-12 21:16:35 -03:00
|
|
|
params: {
|
|
|
|
grupo_de_compra: this.gdc
|
|
|
|
}})
|
|
|
|
.then(response => {
|
|
|
|
this.pedidos = response.data.data
|
|
|
|
});
|
2022-06-08 23:33:33 -03:00
|
|
|
},
|
|
|
|
totalAprobados() {
|
|
|
|
let suma = 0;
|
2022-11-12 21:16:35 -03:00
|
|
|
let aprobados = this.pedidos.filter(p => p.aprobado);
|
2022-06-08 23:33:33 -03:00
|
|
|
for (let i = 0; i < aprobados.length; i++) {
|
2022-06-09 20:09:18 -03:00
|
|
|
suma += parseFloat(aprobados[i].total.replace(/,/g, ''));
|
2022-06-08 23:33:33 -03:00
|
|
|
}
|
|
|
|
return suma;
|
2022-06-08 20:32:50 -03:00
|
|
|
}
|
2022-06-08 22:19:44 -03:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
Event.$on('sync-aprobacion', (_) => {
|
2022-11-12 21:16:35 -03:00
|
|
|
this.fetchPedidos();
|
2022-06-08 22:19:44 -03:00
|
|
|
})
|
2022-06-08 20:32:50 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2022-10-21 19:17:52 -03:00
|
|
|
<style>
|
2022-06-08 20:32:50 -03:00
|
|
|
|
|
|
|
</style>
|