- Creazione PDF Temporanei (Generati)
- Assegnazione di questi su PDF OnLine e PDF per Stampa
This commit is contained in:
@@ -102,16 +102,28 @@
|
||||
}}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="myrec.pdf_generato"
|
||||
v-if="myrec.pdf_online"
|
||||
class="text-caption text-h7 text-blue q-pb-xs"
|
||||
>
|
||||
<q-icon name="fas fa-book" /> -
|
||||
<q-icon name="fas fa-book" />
|
||||
<a
|
||||
:href="myrec.pdf_generato"
|
||||
:href="myrec.pdf_online"
|
||||
target="_blank"
|
||||
>PDF Generato</a
|
||||
>PDF OnLine</a
|
||||
>
|
||||
(Data: {{ tools.getstrDate(myrec.data_generato) }})
|
||||
aggiornato al ({{ tools.getstrDate(myrec.data_online) }})
|
||||
</div>
|
||||
<div
|
||||
v-if="!tools.isUtente() && myrec.pdf_online_stampa && dettagli"
|
||||
class="text-caption text-h7 text-blue q-pb-xs"
|
||||
>
|
||||
<q-icon name="fas fa-print" />
|
||||
<a
|
||||
:href="myrec.pdf_online_stampa"
|
||||
target="_blank"
|
||||
>PDF per Stampa</a
|
||||
>
|
||||
aggiornato al ({{ tools.getstrDate(myrec.data_online_stampa) }})
|
||||
</div>
|
||||
<div
|
||||
v-if="!tools.isUtente() && dettagli"
|
||||
@@ -123,24 +135,10 @@
|
||||
{{ myrec.username_lista_generata }}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="myrec.pdf_online"
|
||||
class="text-caption text-h7 text-blue q-pb-xs"
|
||||
>
|
||||
<q-icon name="fas fa-book" /> -
|
||||
<a
|
||||
:href="myrec.pdf_online"
|
||||
target="_blank"
|
||||
>PDF ONLINE</a
|
||||
>
|
||||
(Data: {{ tools.getstrDate(myrec.data_online) }})
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="text-overline text-orange-9">{{collanestr}}</div>-->
|
||||
</q-card-section>
|
||||
|
||||
|
||||
|
||||
<q-card-actions
|
||||
v-if="!tools.isUtente() && dettagli"
|
||||
align="center"
|
||||
@@ -277,6 +275,12 @@
|
||||
:color="myrec.pdf_online ? 'green' : 'red'"
|
||||
:copy="true"
|
||||
/>
|
||||
<CLabel
|
||||
:value="myrec.pdf_generato_stampa || 'ancora non è stato generato'"
|
||||
label="PDF per Stampa"
|
||||
:color="myrec.pdf_generato_stampa ? 'green' : 'red'"
|
||||
:copy="true"
|
||||
/>
|
||||
</div>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
||||
@@ -2528,6 +2528,15 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
return false;
|
||||
});
|
||||
},
|
||||
async execOnlinePDF(paramquery: any) {
|
||||
return Api.SendReq('/admin/online-pdf', 'POST', paramquery)
|
||||
.then((res) => {
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
async convertPdf(
|
||||
pdfFile: any,
|
||||
|
||||
@@ -1727,12 +1727,32 @@ export default defineComponent({
|
||||
optcatalogo.value.indebug = !optcatalogo.value.indebug;
|
||||
}
|
||||
|
||||
const preparePDF = async () => {
|
||||
optcatalogo.value.generazionePDFInCorso = true;
|
||||
optcatalogo.value.areadistampa!.scale = optcatalogo.value.areadistampa!.scale_printable;
|
||||
const preparePDF = () => {
|
||||
$q.dialog({
|
||||
message: 'Generare il PDF ?',
|
||||
ok: {
|
||||
label: t('dialog.yes'),
|
||||
push: true,
|
||||
},
|
||||
cancel: {
|
||||
label: t('dialog.cancel'),
|
||||
},
|
||||
title: 'Generazione PDF',
|
||||
}).onOk(async () => {
|
||||
optcatalogo.value.generazionePDFInCorso = true;
|
||||
optcatalogo.value.areadistampa!.scale = optcatalogo.value.areadistampa!.scale_printable;
|
||||
|
||||
setTimeout(() => {
|
||||
optcatalogo.value.generazionePDFInCorso = true;
|
||||
|
||||
setTimeout(() => {
|
||||
generatePDF();
|
||||
}, 500);
|
||||
}, 500);
|
||||
});
|
||||
};
|
||||
|
||||
const terminaPDF = async () => {
|
||||
const terminaPDF = () => {
|
||||
optcatalogo.value.generazionePDFInCorso = false;
|
||||
optcatalogo.value.areadistampa!.scale = 1;
|
||||
};
|
||||
@@ -1831,103 +1851,143 @@ export default defineComponent({
|
||||
const generatePDF = async () => {
|
||||
await nextTick();
|
||||
|
||||
$q.dialog({
|
||||
message: 'Generare il PDF ?',
|
||||
ok: {
|
||||
label: t('dialog.yes'),
|
||||
push: true,
|
||||
},
|
||||
cancel: {
|
||||
label: t('dialog.cancel'),
|
||||
},
|
||||
title: 'Generazione PDF',
|
||||
}).onOk(async () => {
|
||||
$q.loading.show({
|
||||
message: 'Caricamento immagini e generazione PDF in corso...',
|
||||
});
|
||||
|
||||
try {
|
||||
let defaultMargin = 0.1;
|
||||
if (optcatalogo.value.printable) {
|
||||
defaultMargin = 0;
|
||||
} else {
|
||||
defaultMargin = 0;
|
||||
}
|
||||
const unit = optcatalogo.value.areadistampa!.unit;
|
||||
|
||||
let myformat = { ...optcatalogo.value.areadistampa!.format };
|
||||
|
||||
const scale = tools.getScale(optcatalogo.value);
|
||||
|
||||
const scalecanvas = optcatalogo.value.areadistampa!.scalecanvas;
|
||||
|
||||
if (tools.isObject(myformat) && scale > 0) {
|
||||
} else {
|
||||
myformat = [210, 297];
|
||||
}
|
||||
|
||||
const formatwidth = myformat[0] * scale;
|
||||
const formatheight = myformat[1] * scale;
|
||||
|
||||
let myfile = getPdfFilename();
|
||||
|
||||
// myfile += '_' + tools.getDateYYYYMMDD_Today();
|
||||
|
||||
myfile += '.pdf';
|
||||
|
||||
let file_out = myfile;
|
||||
|
||||
const element = document.getElementById('pdf-content');
|
||||
const opt = {
|
||||
margin: [defaultMargin, defaultMargin, defaultMargin, defaultMargin],
|
||||
filename: myfile,
|
||||
image: {
|
||||
type: 'jpeg',
|
||||
quality: 0.98,
|
||||
},
|
||||
html2canvas: {
|
||||
scale: scalecanvas,
|
||||
useCORS: true,
|
||||
letterRendering: true,
|
||||
},
|
||||
jsPDF: {
|
||||
unit: unit,
|
||||
format: [formatwidth, formatheight],
|
||||
orientation: optcatalogo.value.areadistampa!.orientation,
|
||||
compress: optcatalogo.value.areadistampa!.compress,
|
||||
},
|
||||
enableLinks: true,
|
||||
pagebreak: { mode: 'avoid-all', before: '.card-page' },
|
||||
};
|
||||
|
||||
console.log('opt di stampa', opt);
|
||||
// a4: [595.28, 841.89]
|
||||
|
||||
if (true) {
|
||||
await generateLargePDF(opt, '.pdf-section', false, 'upload/cataloghi/', file_out);
|
||||
} else {
|
||||
await html2pdf().set(opt).from(element).save();
|
||||
}
|
||||
|
||||
optcatalogo.value.generazionePDFInCorso = false;
|
||||
optcatalogo.value.areadistampa!.scale = 1;
|
||||
|
||||
$q.loading.hide();
|
||||
$q.notify({
|
||||
color: 'positive',
|
||||
message: 'PDF generato con successo!',
|
||||
icon: 'check',
|
||||
});
|
||||
} catch (error) {
|
||||
$q.loading.hide();
|
||||
$q.notify({
|
||||
color: 'negative',
|
||||
message: 'Errore nella generazione del PDF',
|
||||
icon: 'error',
|
||||
});
|
||||
console.error('Errore nella generazione del PDF:', error);
|
||||
}
|
||||
$q.loading.show({
|
||||
message: 'Caricamento immagini e generazione PDF in corso...',
|
||||
});
|
||||
|
||||
try {
|
||||
let defaultMargin = 0.1;
|
||||
if (optcatalogo.value.printable) {
|
||||
defaultMargin = 0;
|
||||
} else {
|
||||
defaultMargin = 0;
|
||||
}
|
||||
const unit = optcatalogo.value.areadistampa!.unit;
|
||||
|
||||
let myformat = { ...optcatalogo.value.areadistampa!.format };
|
||||
|
||||
const scale = tools.getScale(optcatalogo.value);
|
||||
|
||||
const scalecanvas = optcatalogo.value.areadistampa!.scalecanvas;
|
||||
|
||||
if (tools.isObject(myformat) && scale > 0) {
|
||||
} else {
|
||||
myformat = [210, 297];
|
||||
}
|
||||
|
||||
const formatwidth = myformat[0] * scale;
|
||||
const formatheight = myformat[1] * scale;
|
||||
|
||||
let myfile = getPdfFilename();
|
||||
|
||||
// myfile += '_' + tools.getDateYYYYMMDD_Today();
|
||||
|
||||
myfile += '.pdf';
|
||||
|
||||
let file_out = myfile;
|
||||
|
||||
const element = document.getElementById('pdf-content');
|
||||
const opt = {
|
||||
margin: [defaultMargin, defaultMargin, defaultMargin, defaultMargin],
|
||||
filename: myfile,
|
||||
image: {
|
||||
type: 'jpeg',
|
||||
quality: 0.98,
|
||||
},
|
||||
html2canvas: {
|
||||
scale: scalecanvas,
|
||||
useCORS: true,
|
||||
letterRendering: true,
|
||||
},
|
||||
jsPDF: {
|
||||
unit: unit,
|
||||
format: [formatwidth, formatheight],
|
||||
orientation: optcatalogo.value.areadistampa!.orientation,
|
||||
compress: optcatalogo.value.areadistampa!.compress,
|
||||
},
|
||||
enableLinks: true,
|
||||
pagebreak: { mode: 'avoid-all', before: '.card-page' },
|
||||
};
|
||||
|
||||
console.log('opt di stampa', opt);
|
||||
// a4: [595.28, 841.89]
|
||||
|
||||
if (true) {
|
||||
await generateLargePDF(opt, '.pdf-section', false, 'upload/cataloghi/', file_out);
|
||||
} else {
|
||||
await html2pdf().set(opt).from(element).save();
|
||||
}
|
||||
|
||||
optcatalogo.value.generazionePDFInCorso = false;
|
||||
optcatalogo.value.areadistampa!.scale = 1;
|
||||
|
||||
$q.loading.hide();
|
||||
$q.notify({
|
||||
color: 'positive',
|
||||
message: 'PDF generato con successo!',
|
||||
icon: 'check',
|
||||
});
|
||||
} catch (error) {
|
||||
$q.loading.hide();
|
||||
$q.notify({
|
||||
color: 'negative',
|
||||
message: 'Errore nella generazione del PDF',
|
||||
icon: 'error',
|
||||
});
|
||||
console.error('Errore nella generazione del PDF:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const pubblicaPDF = async () => {
|
||||
const catalog = getCatalogoByMyPage.value;
|
||||
|
||||
const ris = await globalStore.execOnlinePDF({ id_catalog: catalog._id, stampa: false });
|
||||
|
||||
if (ris) {
|
||||
if (ris.catalog?.pdf_online) {
|
||||
catalog.pdf_online = ris.catalog.pdf_online;
|
||||
catalog.data_online = ris.catalog.data_online;
|
||||
}
|
||||
$q.notify({
|
||||
color: 'positive',
|
||||
message: 'PDF inviato ONLINE!',
|
||||
icon: 'check',
|
||||
});
|
||||
} else {
|
||||
$q.loading.hide();
|
||||
$q.notify({
|
||||
color: 'negative',
|
||||
message: "Errore nell'invio del PDF OnLine",
|
||||
icon: 'error',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const pubblicaPDFStampa = async () => {
|
||||
const catalog = getCatalogoByMyPage.value;
|
||||
|
||||
const ris = await globalStore.execOnlinePDF({ id_catalog: catalog._id, stampa: true });
|
||||
|
||||
if (ris) {
|
||||
if (ris.catalog.pdf_online_stampa) {
|
||||
catalog.pdf_online_stampa = ris.catalog.pdf_online_stampa;
|
||||
catalog.data_online_stampa = ris.catalog.data_online_stampa;
|
||||
}
|
||||
$q.notify({
|
||||
color: 'positive',
|
||||
message: 'PDF STAMPA inviato ONLINE!',
|
||||
icon: 'check',
|
||||
});
|
||||
} else {
|
||||
$q.loading.hide();
|
||||
$q.notify({
|
||||
color: 'negative',
|
||||
message: "Errore nell'invio del PDF STAMPA OnLine",
|
||||
icon: 'error',
|
||||
});
|
||||
}
|
||||
|
||||
// await saveCatalog();
|
||||
};
|
||||
|
||||
onMounted(mounted);
|
||||
@@ -2007,6 +2067,8 @@ export default defineComponent({
|
||||
getPdfFilename,
|
||||
filtroStrApplicato,
|
||||
getCollane,
|
||||
pubblicaPDF,
|
||||
pubblicaPDFStampa,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -407,11 +407,13 @@
|
||||
</q-toolbar>
|
||||
</q-tab-panel>
|
||||
<q-tab-panel name="genera">
|
||||
<div v-if="!tools.isUtente()" class="row justify-center">
|
||||
|
||||
<div
|
||||
v-if="!tools.isUtente()"
|
||||
class="row justify-center"
|
||||
>
|
||||
<q-btn
|
||||
v-if="optcatalogo.pdf && !optcatalogo.generazionePDFInCorso"
|
||||
:label="`Prepara PDF`"
|
||||
:label="`1) PREPARA PDF`"
|
||||
@click="preparePDF"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
@@ -421,34 +423,99 @@
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-if="optcatalogo.pdf && optcatalogo.generazionePDFInCorso"
|
||||
:label="`Genera PDF ` + getPdfFilename()"
|
||||
:label="`2) Genera PDF ` + getPdfFilename()"
|
||||
@click="generatePDF()"
|
||||
color="positive"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-if="tools.isAdmin() && false"
|
||||
label="Debug"
|
||||
@click="toggleDebug()"
|
||||
:push="optcatalogo.indebug"
|
||||
:color="optcatalogo.indebug ? `positive` : 'primary'"
|
||||
></q-btn>
|
||||
</div>
|
||||
<div v-if="getCatalogoByMyPage.pdf_generato" class="column justify-center q-ma-sm q-pa-sm">
|
||||
<div >
|
||||
PDF:
|
||||
<a :href="tools.getHost() + getCatalogoByMyPage.pdf_generato" target="_blank" v-if="getCatalogoByMyPage.pdf_generato" class="text-bold">
|
||||
{{tools.getHost() + getCatalogoByMyPage.pdf_generato}}
|
||||
</a>
|
||||
<span v-else>-</span>
|
||||
<br>(Generato il {{ tools.getstrDateTime(getCatalogoByMyPage.data_generato)}})
|
||||
<div
|
||||
v-if="getCatalogoByMyPage.pdf_generato"
|
||||
class="bg-green-1 q-ma-sm q-pa-sm"
|
||||
>
|
||||
<div class="bg-blue-1 text-red text-bold text-h6 q-ma-sm q-pa-sm">
|
||||
<strong>PDF generati Temporanei</strong>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
PDF Stampa:
|
||||
<a :href="tools.getHost() + getCatalogoByMyPage.pdf_generato_stampa" target="_blank" v-if="getCatalogoByMyPage.pdf_generato_stampa" class="text-bold">
|
||||
{{tools.getHost() + getCatalogoByMyPage.pdf_generato_stampa}}
|
||||
<div v-if="getCatalogoByMyPage.data_generato !== getCatalogoByMyPage.data_online">
|
||||
PDF Generato:
|
||||
<a
|
||||
:href="tools.getHost() + getCatalogoByMyPage.pdf_generato"
|
||||
target="_blank"
|
||||
v-if="getCatalogoByMyPage.pdf_generato"
|
||||
class="text-bold"
|
||||
>
|
||||
{{ tools.getHost() + getCatalogoByMyPage.pdf_generato }}
|
||||
</a>
|
||||
<span v-else>-</span>
|
||||
<br>(Generato il {{ tools.getstrDateTime(getCatalogoByMyPage.data_generato_stampa) }})
|
||||
<br />(del {{ tools.getstrDateTime(getCatalogoByMyPage.data_generato) }})
|
||||
<br />
|
||||
<q-btn
|
||||
v-if="getCatalogoByMyPage.data_generato !== getCatalogoByMyPage.data_online"
|
||||
rounded
|
||||
label="Pubblica PDF OnLine"
|
||||
color="positive"
|
||||
@click="pubblicaPDF()"
|
||||
></q-btn>
|
||||
</div>
|
||||
<br />
|
||||
<div v-if="getCatalogoByMyPage.data_generato_stampa !== getCatalogoByMyPage.data_online_stampa">
|
||||
PDF Generato Stampa:
|
||||
<a
|
||||
:href="tools.getHost() + getCatalogoByMyPage.pdf_generato_stampa"
|
||||
target="_blank"
|
||||
v-if="getCatalogoByMyPage.pdf_generato_stampa"
|
||||
class="text-bold"
|
||||
>
|
||||
{{ tools.getHost() + getCatalogoByMyPage.pdf_generato_stampa }}
|
||||
</a>
|
||||
<span v-else>-</span>
|
||||
<br />(del {{ tools.getstrDateTime(getCatalogoByMyPage.data_generato_stampa) }})
|
||||
<br />
|
||||
<q-btn
|
||||
v-if="getCatalogoByMyPage.data_generato_stampa !== getCatalogoByMyPage.data_online_stampa"
|
||||
rounded
|
||||
label="Pubblica PDF Stampa"
|
||||
color="positive"
|
||||
@click="pubblicaPDFStampa()"
|
||||
></q-btn>
|
||||
</div>
|
||||
<div class="bg-green-1">
|
||||
<div class="bg-blue-1 text-green text-bold text-h6 q-ma-sm q-pa-sm">
|
||||
<strong>PDF Pubblicati OnLine</strong>
|
||||
</div>
|
||||
<div>
|
||||
PDF OnLine:
|
||||
<a
|
||||
:href="tools.getHost() + getCatalogoByMyPage.pdf_online"
|
||||
target="_blank"
|
||||
v-if="getCatalogoByMyPage.pdf_online"
|
||||
class="text-bold"
|
||||
>
|
||||
{{ tools.getHost() + getCatalogoByMyPage.pdf_online }}
|
||||
</a>
|
||||
<span v-else>-</span>
|
||||
<br />(del {{ tools.getstrDateTime(getCatalogoByMyPage.data_online) }})
|
||||
</div>
|
||||
<br />
|
||||
<div>
|
||||
PDF OnLine Stampa:
|
||||
<a
|
||||
:href="tools.getHost() + getCatalogoByMyPage.pdf_online_stampa"
|
||||
target="_blank"
|
||||
v-if="getCatalogoByMyPage.pdf_online_stampa"
|
||||
class="text-bold"
|
||||
>
|
||||
{{ tools.getHost() + getCatalogoByMyPage.pdf_online_stampa }}
|
||||
</a>
|
||||
<span v-else>-</span>
|
||||
<br />(del {{ tools.getstrDateTime(getCatalogoByMyPage.data_online_stampa) }})
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</q-tab-panel>
|
||||
|
||||
Reference in New Issue
Block a user