mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
add toast to show total presupuesto
This commit is contained in:
@ -1,37 +1,37 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const alertConfirmationDelete = (title,type="primary") => {
|
export const alertConfirmationDelete = (title, type = "primary") => {
|
||||||
return Swal.fire({
|
return Swal.fire({
|
||||||
title: '¿Está seguro?',
|
title: '¿Está seguro?',
|
||||||
text: "Esta acción es irreversible.",
|
text: "Esta acción es irreversible.",
|
||||||
icon: 'warning',
|
icon: 'warning',
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonColor: '#3085d6',
|
confirmButtonColor: '#3085d6',
|
||||||
cancelButtonColor: '#d33',
|
cancelButtonColor: '#d33',
|
||||||
confirmButtonText: 'Sí',
|
confirmButtonText: 'Sí',
|
||||||
cancelButtonText: 'Cancelar',
|
cancelButtonText: 'Cancelar',
|
||||||
customClass: {
|
customClass: {
|
||||||
confirmButton: 'btn btn-danger me-1',
|
confirmButton: 'btn btn-danger me-1',
|
||||||
cancelButton: 'btn btn-label-secondary'
|
cancelButton: 'btn btn-label-secondary'
|
||||||
},
|
},
|
||||||
buttonsStyling: false
|
buttonsStyling: false
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const alertSuccessMessage = (title,type="primary") => {
|
|
||||||
return Swal.fire({
|
|
||||||
showCancelButton: false,
|
|
||||||
showConfirmButton : false,
|
|
||||||
title: title,
|
|
||||||
text: title,
|
|
||||||
icon: "success",
|
|
||||||
timer : 2000
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const alertWarningMessage = (title,message,type="primary") => {
|
export const alertSuccessMessage = (title, type = "primary") => {
|
||||||
return Swal.fire({
|
return Swal.fire({
|
||||||
|
showCancelButton: false,
|
||||||
|
showConfirmButton: false,
|
||||||
|
title: title,
|
||||||
|
text: title,
|
||||||
|
icon: "success",
|
||||||
|
timer: 2000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const alertWarningMessage = (title, message, type = "primary") => {
|
||||||
|
return Swal.fire({
|
||||||
title: title,
|
title: title,
|
||||||
text: message,
|
text: message,
|
||||||
icon: "warning",
|
icon: "warning",
|
||||||
@ -41,3 +41,26 @@ export const alertWarningMessage = (title,message,type="primary") => {
|
|||||||
buttonsStyling: false
|
buttonsStyling: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const toastPresupuestoSummary = (value, target = 'body') => {
|
||||||
|
return Swal.mixin({
|
||||||
|
toast: true,
|
||||||
|
position: 'bottom-end',
|
||||||
|
html: `
|
||||||
|
<div class="d-flex flex-column">
|
||||||
|
<div class="d-flex flex-row">
|
||||||
|
<p class="px-2 ">Total presupuesto :</p><span>${value}</span>
|
||||||
|
</div>
|
||||||
|
</div>`,
|
||||||
|
customClass: {
|
||||||
|
popup: 'bg-primary text-white',
|
||||||
|
},
|
||||||
|
background: '#a5dc86',
|
||||||
|
target: target,
|
||||||
|
allowEscapeKey: false,
|
||||||
|
showConfirmButton: false,
|
||||||
|
timer: 0,
|
||||||
|
timerProgressBar: false,
|
||||||
|
stopKeydownPropagation: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
@ -1,3 +1,5 @@
|
|||||||
|
import { toastPresupuestoSummary } from "../../../components/alerts/sweetAlert.js";
|
||||||
|
|
||||||
class Resumen {
|
class Resumen {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -7,7 +9,7 @@ class Resumen {
|
|||||||
init() {
|
init() {
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
this.toastPresupuestoTotal = null
|
||||||
$(".update-totales").on("change", function () {
|
$(".update-totales").on("change", function () {
|
||||||
self.updateTotales(true, true, true)
|
self.updateTotales(true, true, true)
|
||||||
});
|
});
|
||||||
@ -16,6 +18,7 @@ class Resumen {
|
|||||||
await self.updateTotales();
|
await self.updateTotales();
|
||||||
$(document).trigger('update-totales-completed');
|
$(document).trigger('update-totales-completed');
|
||||||
});
|
});
|
||||||
|
$("#totalDespuesDecuento").on('change',this.updateToastSummary.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
cargar(resumen) {
|
cargar(resumen) {
|
||||||
@ -44,7 +47,7 @@ class Resumen {
|
|||||||
$("#totalAntesDescuento").text(resumen.total_antes_descuento + "€" || "0€");
|
$("#totalAntesDescuento").text(resumen.total_antes_descuento + "€" || "0€");
|
||||||
$("#total_descuentoPercent").val(resumen.total_descuentoPercent || "0");
|
$("#total_descuentoPercent").val(resumen.total_descuentoPercent || "0");
|
||||||
$("#descuentoTotal").text(resumen.total_descuento + "€" || "0€");
|
$("#descuentoTotal").text(resumen.total_descuento + "€" || "0€");
|
||||||
$("#totalDespuesDecuento").text(resumen.total_presupuesto + "€" || "0€");
|
$("#totalDespuesDecuento").text(resumen.total_presupuesto + "€" || "0€").trigger("change")
|
||||||
$("#precioUnidadPresupuesto").text(resumen.total_precio_unidad + "€" || "0€");
|
$("#precioUnidadPresupuesto").text(resumen.total_precio_unidad + "€" || "0€");
|
||||||
$("#factor").text(resumen.total_factor || "0");
|
$("#factor").text(resumen.total_factor || "0");
|
||||||
$("#factor_ponderado").text(resumen.total_factor_ponderado || "0");
|
$("#factor_ponderado").text(resumen.total_factor_ponderado || "0");
|
||||||
@ -294,7 +297,7 @@ class Resumen {
|
|||||||
|
|
||||||
$('#totalAntesDescuento').text((this.addSeparatorsNF(totalAntesDescuento.toFixed(2), ".", ",", ".")) + "€")
|
$('#totalAntesDescuento').text((this.addSeparatorsNF(totalAntesDescuento.toFixed(2), ".", ",", ".")) + "€")
|
||||||
$('#descuentoTotal').text((this.addSeparatorsNF(totalDescuento.toFixed(2), ".", ",", ".")) + "€")
|
$('#descuentoTotal').text((this.addSeparatorsNF(totalDescuento.toFixed(2), ".", ",", ".")) + "€")
|
||||||
$('#totalDespuesDecuento').text((this.addSeparatorsNF(totalPresupuesto.toFixed(2), ".", ",", ".")) + "€")
|
$('#totalDespuesDecuento').text((this.addSeparatorsNF(totalPresupuesto.toFixed(2), ".", ",", ".")) + "€").trigger("change")
|
||||||
$('#precioUnidadPresupuesto').text((this.addSeparatorsNF(precioUnidad.toFixed(4), ".", ",", ".")) + "€")
|
$('#precioUnidadPresupuesto').text((this.addSeparatorsNF(precioUnidad.toFixed(4), ".", ",", ".")) + "€")
|
||||||
$('#totalAntesDescuento').attr('val', (totalAntesDescuento).toFixed(2))
|
$('#totalAntesDescuento').attr('val', (totalAntesDescuento).toFixed(2))
|
||||||
$('#descuentoTotal').attr('val', (totalDescuento).toFixed(2))
|
$('#descuentoTotal').attr('val', (totalDescuento).toFixed(2))
|
||||||
@ -307,6 +310,7 @@ class Resumen {
|
|||||||
$('#factor_ponderado').text(this.addSeparatorsNF(((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactorPonderado).toFixed(2), ".", ",", "."))
|
$('#factor_ponderado').text(this.addSeparatorsNF(((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactorPonderado).toFixed(2), ".", ",", "."))
|
||||||
$('#factor_ponderado').attr('val', ((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactorPonderado).toFixed(2))
|
$('#factor_ponderado').attr('val', ((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactorPonderado).toFixed(2))
|
||||||
|
|
||||||
|
this.updateToastSummary()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -352,6 +356,15 @@ class Resumen {
|
|||||||
roundToTwoDecimals(num) {
|
roundToTwoDecimals(num) {
|
||||||
return parseFloat(num.toFixed(2));
|
return parseFloat(num.toFixed(2));
|
||||||
}
|
}
|
||||||
|
updateToastSummary()
|
||||||
|
{
|
||||||
|
if(this.toastPresupuestoTotal){
|
||||||
|
this.toastPresupuestoTotal.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
this.toastPresupuestoTotal = toastPresupuestoSummary($("#totalDespuesDecuento").text())
|
||||||
|
this.toastPresupuestoTotal.fire();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Resumen;
|
export default Resumen;
|
||||||
Reference in New Issue
Block a user