From 2f6e27d4ca1d6613d7ec0f6290e2e054d574003a Mon Sep 17 00:00:00 2001 From: imnavajas Date: Mon, 14 Jul 2025 15:15:16 +0200 Subject: [PATCH] Cambiada la logica de descargas multiples/simple de OTs --- .../js/safekat/pages/produccion/index.js | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/httpdocs/assets/js/safekat/pages/produccion/index.js b/httpdocs/assets/js/safekat/pages/produccion/index.js index 96c7b795..fbd32d28 100644 --- a/httpdocs/assets/js/safekat/pages/produccion/index.js +++ b/httpdocs/assets/js/safekat/pages/produccion/index.js @@ -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() } - - - - }) })