- Aggiungere un campo "Vagliato dall'Editore" e aggiungere anche il campo "chi" e delle Note

This commit is contained in:
Surya Paolo
2025-05-02 19:11:29 +02:00
parent 8a20186e59
commit 70f1e5cbf1
24 changed files with 745 additions and 207 deletions

View File

@@ -40,9 +40,6 @@ import { costanti } from '@costanti'
import objectId from '@src/js/objectId'
import { useProducts } from '@src/store/Products'
import html2pdf from 'html2pdf.js'
export default defineComponent({
name: 'CMyEditElem',
components: {
@@ -740,135 +737,11 @@ export default defineComponent({
}
}
function toggleDebug() {
myel.value.catalogo!.indebug = !myel.value.catalogo!.indebug
}
const preparePDF = async () => {
myel.value.catalogo!.generazionePDFInCorso = true
myel.value.catalogo!.areadistampa!.scale = myel.value.catalogo!.areadistampa!.scale_printable
}
const terminaPDF = async () => {
myel.value.catalogo!.generazionePDFInCorso = false
myel.value.catalogo!.areadistampa!.scale = 1
}
const generatePDF = async (optcatalogo: IOptCatalogo) => {
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.printable) {
defaultMargin = 0
} else {
defaultMargin = 0
}
const unit = optcatalogo.areadistampa!.unit
let myformat = { ...optcatalogo.areadistampa!.format }
const scale = tools.getScale(optcatalogo)
const scalecanvas = optcatalogo.areadistampa!.scalecanvas
if (tools.isObject(myformat) && scale > 0) {
} else {
myformat = [210, 297]
}
const formatwidth = (myformat[0] * scale)
const formatheight = (myformat[1] * scale)
let myfile = (optcatalogo.pdf_filename ?? 'catalogo_completo')
myfile += '_' + formatwidth + '_' + formatheight + '_' + unit + '_scale_' + scale
myfile += '.pdf'
const element = document.getElementById('pdf-content')
const opt = {
margin: [
optcatalogo.printable ? (parseFloat(optcatalogo.areadistampa!.margini?.top) || defaultMargin) : defaultMargin,
optcatalogo.printable ? (parseFloat(optcatalogo.areadistampa!.margini?.left) || defaultMargin) : defaultMargin,
optcatalogo.printable ? (parseFloat(optcatalogo.areadistampa!.margini?.bottom) || defaultMargin) : defaultMargin,
optcatalogo.printable ? (parseFloat(optcatalogo.areadistampa!.margini?.right) || 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.areadistampa!.orientation,
compress: optcatalogo.areadistampa!.compress,
},
enableLinks: true,
pagebreak: { mode: 'avoid-all', before: '.card-page' }
}
console.log('opt di stampa', opt)
// a4: [595.28, 841.89]
await html2pdf().set(opt).from(element).save()
optcatalogo.generazionePDFInCorso = false
optcatalogo.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)
}
})
}
onMounted(mounted)
return {
preparePDF, terminaPDF, generatePDF,
toggleDebug,
tools,
shared_consts,
getArrDisciplines,