Cambiada la logica de descargas multiples/simple de OTs

This commit is contained in:
imnavajas
2025-07-14 15:15:16 +02:00
parent 38f6656842
commit 2f6e27d4ca

View File

@ -20,7 +20,7 @@ $(function () {
try {
// Create hidden iframe
Notiflix.Block.circle('.section-block',{opacity : 1});
Notiflix.Block.circle('.section-block', { opacity: 1 });
const response = await getPdf(element);
var opt = {
margin: 2,
@ -40,8 +40,16 @@ $(function () {
zip.generateAsync({ type: "blob" }).then(function (blob) {
const now = new Date();
const pad = (n) => String(n).padStart(2, '0');
const timestamp = `${now.getFullYear()}_${pad(now.getMonth() + 1)}_${pad(now.getDate())}_${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
const filename = `ordenes_trabajo_${timestamp}.zip`;
const fecha = `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}`;
const hora = `${pad(now.getHours())}${pad(now.getMinutes())}`;
let filename;
if (ordenesTrabajo.length === 1) {
const otId = ordenesTrabajo[0];
filename = `OT_${otId}_${fecha}_${hora}.zip`;
} else {
filename = `OrdenesTrabajo_${fecha}_${hora}.zip`;
}
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
@ -50,14 +58,10 @@ $(function () {
link.click();
document.body.removeChild(link);
});
}else{
} else {
alertError('Seleccione una OT para descargar').fire()
}
})
})