- Aggiungere un campo "Vagliato dall'Editore" e aggiungere anche il campo "chi" e delle Note
This commit is contained in:
@@ -20,6 +20,10 @@ import { CProductTable } from '@src/components/CProductTable'
|
||||
import { CSearchProduct } from '@src/components/CSearchProduct'
|
||||
import { CContainerCatalogoCard } from '@src/components/CContainerCatalogoCard'
|
||||
import { CSelectUserActive } from '@src/components/CSelectUserActive'
|
||||
|
||||
import html2pdf from 'html2pdf.js'
|
||||
|
||||
|
||||
import type {
|
||||
IOptCatalogo, IDimensioni, IFilterCatalogo,
|
||||
IMyScheda, IProdView, IProduct, ISchedaSingola, ISearchList, ICatalog, IImg,
|
||||
@@ -96,6 +100,17 @@ export default defineComponent({
|
||||
|
||||
const optcatalogo = ref(<IOptCatalogo>{ ...props.modelValue });
|
||||
|
||||
const getPdfFilename = () => {
|
||||
let myfilename = (optcatalogo.value.pdf_filename ?? 'catalogo_completo')
|
||||
|
||||
const catalog = getCatalogoByMyPage.value
|
||||
if (catalog) {
|
||||
myfilename = productStore.getPathByPage(catalog.idPageAssigned)
|
||||
}
|
||||
|
||||
return myfilename
|
||||
}
|
||||
|
||||
function updateCatalogoPadre() {
|
||||
console.log('catalogo.ts PADRE')
|
||||
emit('update:modelValue', optcatalogo.value);
|
||||
@@ -461,6 +476,25 @@ export default defineComponent({
|
||||
return argomenti
|
||||
}
|
||||
|
||||
function getidTipoFormatoDaFiltrare(def_idTipoFormato?: number[]) {
|
||||
let idTipoFormato: number[] = []
|
||||
|
||||
// Cerca se nella lista cataloghi c'è la Collana di questa Pagina !
|
||||
const trovatocatalogo = getCatalogoByMyPage.value
|
||||
|
||||
if (trovatocatalogo) {
|
||||
idTipoFormato = trovatocatalogo.idTipoFormato! || []
|
||||
} else {
|
||||
if (def_idTipoFormato && def_idTipoFormato.length > 0) {
|
||||
idTipoFormato = def_idTipoFormato
|
||||
} else {
|
||||
idTipoFormato = []
|
||||
}
|
||||
}
|
||||
|
||||
return idTipoFormato
|
||||
}
|
||||
|
||||
function getEditoreDaFiltrare(def_editori?: string[]) {
|
||||
let editore: string[] = []
|
||||
|
||||
@@ -546,7 +580,7 @@ export default defineComponent({
|
||||
|
||||
if (!(optrigenera.value.visibilitaDisp === costanti.DISP.TUTTI ||
|
||||
(optrigenera.value.visibilitaDisp === costanti.DISP.ESAURITI && productStore.isEsaurito(product)) ||
|
||||
(optrigenera.value.visibilitaDisp === costanti.DISP.DISPONIBILI && productStore.isDisponibile(product)))) {
|
||||
(optrigenera.value.visibilitaDisp === costanti.DISP.DISPONIBILI && (productStore.isDisponibile(product) || productStore.isPrevendita(product))))) {
|
||||
return false;
|
||||
}
|
||||
if (!(optrigenera.value.stato === costanti.STATO.TUTTI ||
|
||||
@@ -675,7 +709,7 @@ export default defineComponent({
|
||||
const filtroProductTypes = optcatalogo.value.productTypes || [0];
|
||||
const filtroExcludeProductTypes = optcatalogo.value.excludeproductTypes || [0];
|
||||
const filtroidTipologie = optcatalogo.value.idTipologie || [];
|
||||
const filtroidTipoFormato = optcatalogo.value.idTipoFormato || [];
|
||||
const filtroidTipoFormato = getidTipoFormatoDaFiltrare(optcatalogo.value.idTipoFormato);
|
||||
const editore = getEditoreDaFiltrare(optcatalogo.value.editore);
|
||||
const filtroPublishers = editore || [];
|
||||
const idCollane = getIdCollaneDaFiltrare(optcatalogo.value.idCollane);
|
||||
@@ -741,12 +775,31 @@ export default defineComponent({
|
||||
generatearrProdToViewSorted(!generalista, salva, !optcatalogo.value.showListaArgomenti);
|
||||
loaddata();
|
||||
|
||||
if (generalista) {
|
||||
const catalog = getCatalogoByMyPage.value
|
||||
if (catalog) {
|
||||
catalog.data_lista_generata = tools.getDateNow()
|
||||
catalog.username_lista_generata = userStore.my.username
|
||||
await saveCatalog()
|
||||
}
|
||||
}
|
||||
|
||||
console.log('***** FINE calcArrPROD')
|
||||
|
||||
generatinglist.value = false
|
||||
rigeneraLibri.value = false
|
||||
}
|
||||
|
||||
async function saveCatalog() {
|
||||
const catalog = getCatalogoByMyPage.value
|
||||
const mydata = {
|
||||
table: 'catalogs',
|
||||
data: catalog
|
||||
}
|
||||
|
||||
await globalStore.saveTable(mydata)
|
||||
}
|
||||
|
||||
function generaListaLibri() {
|
||||
// chiedi prima "Sei sicuro di rigenerare il catalogo?"
|
||||
let risposta_si = false
|
||||
@@ -815,7 +868,7 @@ export default defineComponent({
|
||||
const filtroProductTypes = scheda.productTypes || [0];
|
||||
const filtroExcludeProductTypes = scheda.excludeproductTypes || [0];
|
||||
const filtroidTipologie = scheda.idTipologie || [];
|
||||
const filtroidTipoFormato = scheda.idTipoFormato || [];
|
||||
const filtroidTipoFormato = getidTipoFormatoDaFiltrare(scheda.idTipoFormato);
|
||||
const editore = getEditoreDaFiltrare(scheda.editore);
|
||||
const filtroPublishers = editore || [];
|
||||
const idCollane = getIdCollaneDaFiltrare(scheda.idCollane);
|
||||
@@ -1500,6 +1553,130 @@ export default defineComponent({
|
||||
addnewProd.value = true
|
||||
}
|
||||
|
||||
function toggleDebug() {
|
||||
optcatalogo.value.indebug = !optcatalogo.value.indebug
|
||||
}
|
||||
|
||||
const preparePDF = async () => {
|
||||
optcatalogo.value.generazionePDFInCorso = true
|
||||
optcatalogo.value.areadistampa!.scale = optcatalogo.value.areadistampa!.scale_printable
|
||||
}
|
||||
|
||||
const terminaPDF = async () => {
|
||||
optcatalogo.value.generazionePDFInCorso = false
|
||||
optcatalogo.value.areadistampa!.scale = 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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 += '_' + formatwidth + '_' + formatheight + '_' + unit + '_scale_' + scale
|
||||
|
||||
myfile += '.pdf'
|
||||
|
||||
|
||||
const element = document.getElementById('pdf-content')
|
||||
const opt = {
|
||||
margin: [
|
||||
optcatalogo.value.printable ? (parseFloat(optcatalogo.value.areadistampa!.margini?.top) || defaultMargin) : defaultMargin,
|
||||
optcatalogo.value.printable ? (parseFloat(optcatalogo.value.areadistampa!.margini?.left) || defaultMargin) : defaultMargin,
|
||||
optcatalogo.value.printable ? (parseFloat(optcatalogo.value.areadistampa!.margini?.bottom) || defaultMargin) : defaultMargin,
|
||||
optcatalogo.value.printable ? (parseFloat(optcatalogo.value.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.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]
|
||||
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
@@ -1571,6 +1748,9 @@ export default defineComponent({
|
||||
getCatalogoByMyPage,
|
||||
getReferentiCatalogo,
|
||||
reSortList,
|
||||
preparePDF, terminaPDF, toggleDebug,
|
||||
generatePDF,
|
||||
getPdfFilename,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -141,6 +141,7 @@
|
||||
<q-btn
|
||||
v-if="!showListaArgomenti"
|
||||
rounded
|
||||
icon="fas fa-redo"
|
||||
label="Rigenera Lista"
|
||||
color="primary"
|
||||
@click="rigeneraLibri = true"
|
||||
@@ -220,6 +221,31 @@
|
||||
>
|
||||
</q-spinner-tail>
|
||||
</q-inner-loading>
|
||||
<div>
|
||||
<q-btn
|
||||
v-if="optcatalogo.pdf && !optcatalogo.generazionePDFInCorso"
|
||||
:label="`Prepara PDF`"
|
||||
@click="preparePDF"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-if="optcatalogo.generazionePDFInCorso"
|
||||
:label="`Termina Generazione`"
|
||||
@click="terminaPDF"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-if="optcatalogo.pdf && optcatalogo.generazionePDFInCorso"
|
||||
:label="`Genera PDF ` + getPdfFilename()"
|
||||
@click="generatePDF()"
|
||||
color="positive"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
label="Debug"
|
||||
@click="toggleDebug()"
|
||||
:push="optcatalogo.indebug"
|
||||
:color="optcatalogo.indebug ? `positive` : 'primary'"
|
||||
></q-btn>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row justify-center q-mx-auto bg-blue-1">
|
||||
<div class="text-center">
|
||||
@@ -760,7 +786,6 @@
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
|
||||
<!--<div ref="pdfContent" class="pdf-content">-->
|
||||
</div>
|
||||
</q-page>
|
||||
<CMyDialog
|
||||
@@ -868,6 +893,14 @@
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-actions align="center">
|
||||
<q-btn
|
||||
rounded
|
||||
label="Rigenera"
|
||||
color="primary"
|
||||
icon="fas fa-redo"
|
||||
@click="generaListaLibri()"
|
||||
class="float-right"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
rounded
|
||||
label="Chiudi"
|
||||
@@ -875,13 +908,6 @@
|
||||
class="float-right"
|
||||
@click="rigeneraLibri = false"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
rounded
|
||||
label="Rigenera"
|
||||
color="primary"
|
||||
@click="generaListaLibri()"
|
||||
class="float-right"
|
||||
></q-btn>
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</CMyDialog>
|
||||
|
||||
Reference in New Issue
Block a user