mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'mod/ot_pdf_numero' into 'main'
Cambiada la logica de descargas multiples/simple de OTs See merge request jjimenez/safekat!880
This commit is contained in:
@ -20,7 +20,7 @@ $(function () {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
// Create hidden iframe
|
// Create hidden iframe
|
||||||
Notiflix.Block.circle('.section-block',{opacity : 1});
|
Notiflix.Block.circle('.section-block', { opacity: 1 });
|
||||||
const response = await getPdf(element);
|
const response = await getPdf(element);
|
||||||
var opt = {
|
var opt = {
|
||||||
margin: 2,
|
margin: 2,
|
||||||
@ -40,8 +40,16 @@ $(function () {
|
|||||||
zip.generateAsync({ type: "blob" }).then(function (blob) {
|
zip.generateAsync({ type: "blob" }).then(function (blob) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const pad = (n) => String(n).padStart(2, '0');
|
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 fecha = `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}`;
|
||||||
const filename = `ordenes_trabajo_${timestamp}.zip`;
|
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");
|
const link = document.createElement("a");
|
||||||
link.href = URL.createObjectURL(blob);
|
link.href = URL.createObjectURL(blob);
|
||||||
@ -50,14 +58,10 @@ $(function () {
|
|||||||
link.click();
|
link.click();
|
||||||
document.body.removeChild(link);
|
document.body.removeChild(link);
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
alertError('Seleccione una OT para descargar').fire()
|
alertError('Seleccione una OT para descargar').fire()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user