Compare commits

...

3 commits

Author SHA1 Message Date
Rodrigo
1586a1190a Arreglo y ajuste a devoluciones en chismosa 2024-09-16 09:25:37 -03:00
Rodrigo
a998f76d44 Arreglo a ProductoCantidad 2024-09-16 09:25:26 -03:00
Rodrigo
b845637064 Arreglé todos los errores al inicio 2024-09-15 18:09:23 -03:00
7 changed files with 80 additions and 27 deletions

6
resources/js/app.js vendored
View file

@ -91,6 +91,7 @@ const app = new Vue({
axios.get('/api/subpedidos/' + this.pedido)
.then(response => {
this.pedido = response.data.data;
Event.$emit("pedido-actualizado");
});
} else {
axios.get('/admin/obtener_sesion')
@ -113,20 +114,21 @@ const app = new Vue({
this.$toast('Pedido actualizado exitosamente')
Event.$emit("pedido-actualizado");
});
});
});
// Actualizar monto y notas de devoluciones
Event.$on('sync-devoluciones', (total, notas) => {
if (this.pedido.aprobado) {
this.$toast('No se puede modificar un pedido ya aprobado', 2000);
return;
}
axios.post("api/subpedidos/" + this.pedido.id + "/sync_devoluciones", {
total: total,
notas: notas,
}).then((response) => {
this.pedido = response.data.data;
this.$toast('Pedido actualizado');
Event.$emit("pedido-actualizado");
});
});

View file

@ -1,10 +1,31 @@
<template>
<div v-show="this.$root.pedido.aprobado" class="notification is-warning has-text-centered">
<div v-show="aprobado" class="notification is-warning has-text-centered">
Tu pedido fue <strong>aprobado</strong>, por lo que no puede ser modificado
</div>
</template>
<script>
export default {
data() {
return {
aprobado: false,
}
},
mounted() {
Event.$on('pedido-actualizado', this.actualizarEstado);
if (this.$root.pedido != null) {
this.actualizarEstado();
}
},
methods: {
pedidoAprobado: function() {
return this.$root.pedido.aprobado;
},
actualizarEstado: function() {
this.aprobado = this.pedidoAprobado();
},
},
}
</script>
<style>

View file

@ -5,36 +5,36 @@
<thead>
<tr>
<th>Producto</th>
<th><abbr title="Cantidad">C</abbr></th>
<th>Cantidad</th>
<th><abbr title="Precio Total">$</abbr></th>
</tr>
</thead>
<tfoot>
<tr>
<th><abbr title="Bonos de Transporte">B. Transporte</abbr></th>
<th class="has-text-right">{{ cantidadBonosDeTransporte() }}</th>
<th class="has-text-right">{{ totalBonosDeTransporte() }}</th>
<th class="has-text-right">{{ cantidad_bonos_transporte }}</th>
<th class="has-text-right">{{ total_bonos_transporte }}</th>
</tr>
<tr v-if="this.$root.devoluciones">
<th><p>Devoluciones</p></th>
<td>
<p :title="notasDevoluciones()">...</p>
<button @click.capture="modificarDevoluciones()" class="button is-warning">
<abbr :title="notas_devoluciones">{{ notas_devoluciones_abbr }}</abbr>
<button @click.capture="modificarDevoluciones()" class="button is-warning is-small">
<span class="icon">
<i class="fas fa-edit"></i>
</span>
</button>
</td>
<th class="has-text-right">-{{ devoluciones() }}</th>
<th class="has-text-right">-{{ devoluciones }}</th>
</tr>
<tr>
<th>Total total</th>
<th></th>
<th class="has-text-right">{{ total() }}</th>
<th class="has-text-right">{{ total }}</th>
</tr>
</tfoot>
<tbody>
<producto-row v-for="producto in productos()" :producto="producto" :key="producto.id"></producto-row>
<producto-row v-for="producto in productos" :producto="producto" :key="producto.id"></producto-row>
</tbody>
</table>
<p class="has-text-centered" v-show="!mostrar_tabla">
@ -49,6 +49,13 @@
data() {
return {
mostrar_tabla: false,
cantidad_bonos_transporte: 0,
total_bonos_transporte: 0,
devoluciones: 0,
notas_devoluciones: "",
notas_devoluciones_abbr: "",
total: 0,
productos: [],
}
},
mounted() {
@ -58,12 +65,16 @@
methods: {
pedidoActualizado: function() {
this.mostrar_tabla = this.$root.productos.length > 0;
},
total: function() {
return this.$limpiarInt(this.$root.devoluciones ? this.$root.pedido.total_menos_devoluciones : this.$root.pedido.total)
},
productos: function() {
return this.$root.productos
this.cantidad_bonos_transporte = this.cantidadBonosDeTransporte();
this.total_bonos_transporte = this.totalBonosDeTransporte();
this.devoluciones = this.$root.pedido.devoluciones_total;
this.notas_devoluciones = this.$root.pedido.devoluciones_notas;
this.notas_devoluciones_abbr = this.notas_devoluciones.substring(0, 15);
if (this.notas_devoluciones.length > 15) {
this.notas_devoluciones_abbr += "...";
}
this.total = this.$limpiarInt(this.$root.devoluciones ? this.$root.pedido.total_menos_devoluciones : this.$root.pedido.total);
this.productos = this.$root.productos
},
modificarDevoluciones: function() {
Event.$emit("modificar-devoluciones");
@ -74,12 +85,6 @@
totalBonosDeTransporte: function() {
return this.$limpiarInt(this.$root.pedido.subtotal_bonos_de_transporte)
},
devoluciones: function() {
return this.$root.pedido.devoluciones_total;
},
notasDevoluciones: function() {
return this.$root.pedido.devoluciones_notas;
},
},
}
</script>

View file

@ -5,7 +5,7 @@
<span class="icon is-small mr-1">
<img src="/assets/chismosa.png">
</span>
<span v-text="'$' + this.$limpiarInt($root.devoluciones ? $root.pedido.total_menos_devoluciones : $root.pedido.total)"></span>
<span v-text="'$' + total"></span>
</a>
</div>
</div>
@ -25,14 +25,21 @@ export default {
},
data() {
return {
activa: false
activa: false,
total: 0,
}
},
mounted() {
Event.$on('pedido-actualizado', this.actualizar);
},
methods: {
toggle() {
this.activa = !this.activa;
Event.$emit("toggle-chismosa", this.activa);
},
actualizar() {
this.total = this.$limpiarInt(this.$root.devoluciones ? this.$root.pedido.total_menos_devoluciones : this.$root.pedido.total);
},
},
}
</script>

View file

@ -38,6 +38,10 @@
}
},
mounted() {
if (this.producto.pivot !== undefined) {
this.cantidad = this.producto.pivot.cantidad;
this.enChismosa = this.cantidad;
}
Event.$on('sync-subpedido', (cantidad,productoId) => {
if (this.producto.id === productoId)
this.sincronizar(cantidad);
@ -59,7 +63,11 @@
},
sincronizar(cantidad) {
this.cantidad = cantidad;
this.producto.cantidad = cantidad;
if (this.producto.pivot != null) {
this.producto.pivot.cantidad = cantidad;
} else {
this.producto.cantidad = cantidad;
}
this.enChismosa = cantidad;
},
hayCambios() {

View file

@ -1,6 +1,11 @@
<script>
import ProductoCantidad from './Producto/ProductoCantidad.vue';
export default {
name: "ProductoCard",
components: {
ProductoCantidad,
},
props: {
producto: Object
},

View file

@ -9,7 +9,12 @@
</template>
producto
<script>
export default {
import ProductoCantidad from './Producto/ProductoCantidad.vue';
export default {
components: {
ProductoCantidad,
},
props: {
producto: Object
},