2022-11-13 17:00:24 -03:00
|
|
|
<template>
|
2022-11-13 18:01:01 -03:00
|
|
|
<div class="block">
|
|
|
|
<div class="block" v-show="!hayBonos">
|
|
|
|
<p class="has-text-centered">
|
|
|
|
Todavía no hay bonos pedidos.
|
|
|
|
</p>
|
|
|
|
</div>
|
2023-05-24 15:01:31 -03:00
|
|
|
<div class="block" v-show="hayBonos">
|
|
|
|
<table class="table is-bordered is-striped is-hoverable is-fullwidth">
|
2022-11-13 18:01:01 -03:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2023-05-24 15:01:31 -03:00
|
|
|
<th><abbr title="Núcleo">Núcleo</abbr></th>
|
|
|
|
<td v-for="(bono,i) in bonos" :key="i" class="is-1">
|
|
|
|
{{ bono.nombre }}
|
|
|
|
</td>
|
2022-11-13 18:01:01 -03:00
|
|
|
<th><abbr title="Total a Pagar">Total $</abbr></th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
2023-05-24 15:01:31 -03:00
|
|
|
<tbody>
|
|
|
|
<tr v-for="(bp, i) in bonosPorPedido" :key="i">
|
|
|
|
<td> {{ bp.nucleo }} </td>
|
2023-10-04 22:37:59 -03:00
|
|
|
<td v-for="(bono,j) in bp.bonos" :key="j" class="has-text-right">
|
2023-05-24 15:01:31 -03:00
|
|
|
{{ bono.cantidad }}
|
|
|
|
</td>
|
2023-09-10 17:07:41 -03:00
|
|
|
<td class="has-text-right"> {{ bp.total }} </td>
|
2023-05-24 15:01:31 -03:00
|
|
|
</tr>
|
|
|
|
</tbody>
|
2022-11-13 18:01:01 -03:00
|
|
|
<tfoot>
|
2023-05-24 15:01:31 -03:00
|
|
|
<tr>
|
2022-11-13 18:01:01 -03:00
|
|
|
<th></th>
|
2023-05-24 15:01:31 -03:00
|
|
|
<th :colspan="bonos.length">Total bonos</th>
|
2023-09-10 17:07:41 -03:00
|
|
|
<th class="has-text-right">$ {{ totalBonos }}</th>
|
2022-11-13 18:01:01 -03:00
|
|
|
</tr>
|
|
|
|
</tfoot>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-11-13 17:00:24 -03:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
pedidos: {
|
|
|
|
type: Array,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
2023-05-24 15:01:31 -03:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
bonos: []
|
|
|
|
}
|
|
|
|
},
|
2022-11-13 17:00:24 -03:00
|
|
|
computed: {
|
|
|
|
pedidosAprobados: function() {
|
2023-05-24 15:01:31 -03:00
|
|
|
return this.pedidos.filter(p => p.aprobado)
|
2022-11-13 17:00:24 -03:00
|
|
|
},
|
2023-05-24 15:01:31 -03:00
|
|
|
hayBonos: function() {
|
|
|
|
return this.pedidosAprobados.filter(p => p.subtotal_bonos != 0).length !== 0
|
2022-11-13 17:34:33 -03:00
|
|
|
},
|
2023-05-24 15:01:31 -03:00
|
|
|
bonosPorPedido: function() {
|
|
|
|
let bonosPorPedido = this.pedidosAprobados.map(p => p = {"nucleo":p.nombre, "bonos":p.productos.filter(x => x.bono), "total":p.subtotal_bonos});
|
|
|
|
bonosPorPedido.forEach(bp => {
|
|
|
|
bp.bonos = bp.bonos.map(b => b = {"bono":b.nombre, "cantidad":b.pivot.cantidad, "total":b.pivot.total, "id":b.id})
|
|
|
|
})
|
|
|
|
return bonosPorPedido.map(bp => this.completarBonos(bp));
|
2022-11-13 17:00:24 -03:00
|
|
|
},
|
|
|
|
totalBonos: function() {
|
2023-05-24 15:01:31 -03:00
|
|
|
let total = 0
|
|
|
|
this.bonosPorPedido.map(bp => total += parseInt(bp.total))
|
|
|
|
return total
|
2022-11-13 18:01:01 -03:00
|
|
|
},
|
2022-11-13 17:00:24 -03:00
|
|
|
},
|
|
|
|
methods: {
|
2023-05-24 15:01:31 -03:00
|
|
|
completarBonos(bonosPedido) {
|
|
|
|
this.bonos.map(b => {
|
|
|
|
if (!bonosPedido.bonos.map(x => x.id).includes(b.id))
|
|
|
|
bonosPedido.bonos.push({"bono":b.nombre, "cantidad":0, "total":0, "id":b.id})
|
|
|
|
})
|
|
|
|
bonosPedido.bonos = bonosPedido.bonos.sort((b1,b2) => b1.id - b2.id)
|
|
|
|
return bonosPedido
|
2022-11-13 17:00:24 -03:00
|
|
|
}
|
|
|
|
},
|
2023-05-24 15:01:31 -03:00
|
|
|
beforeMount() {
|
|
|
|
axios.get("../api/productos", {
|
|
|
|
params: {
|
|
|
|
categoria:'TRANSPORTE, BONOS Y FINANCIAMIENTO SORORO',
|
|
|
|
}
|
|
|
|
}).then(response => {
|
|
|
|
this.bonos = response.data.data;
|
|
|
|
});
|
|
|
|
},
|
2022-11-13 17:00:24 -03:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
2024-08-30 01:33:47 -03:00
|
|
|
</style>
|