- Cataloghi: pagine, schede, formato
This commit is contained in:
@@ -190,7 +190,7 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function calcArrProducts() {
|
||||
console.log('calcArrProducts')
|
||||
// console.log('calcArrProducts')
|
||||
|
||||
// eventuali titoli specifici estratti dall'array di Prodotti Selezionati
|
||||
//const searchtext = getSearchText()
|
||||
@@ -412,16 +412,16 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
function getProdBySchedaRigaCol(recscheda: ISchedaSingola, riga: number, col: number) {
|
||||
function getProdBySchedaRigaCol(recscheda: ISchedaSingola, pagina: number, riga: number, col: number) {
|
||||
try {
|
||||
return recscheda.arrProdToShow![riga][col]
|
||||
return recscheda.arrProdToShow![pagina][riga][col]
|
||||
} catch (e) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function generatearrProdToViewSorted() {
|
||||
console.log('generatearrProdToViewSorted')
|
||||
// console.log('generatearrProdToViewSorted')
|
||||
|
||||
// Svuota
|
||||
arrProdToView.value = []
|
||||
@@ -438,31 +438,38 @@ export default defineComponent({
|
||||
let indadded = 0
|
||||
recscheda.arrProdToShow = []
|
||||
|
||||
for (let giro = 0; giro < schedePerPagina; giro++) {
|
||||
// Aggiunge il prossimo prodotto che non è stato ancora inserito
|
||||
const result = addNextProductToTheView(arrProdFiltrati, indprod);
|
||||
if (result.end) {
|
||||
break; // Esci dal ciclo se non ci sono più prodotti disponibili
|
||||
} else {
|
||||
if (result.indprod)
|
||||
indprod = result.indprod // Aggiorna indprod per il prossimo giro
|
||||
if (result.myrec) {
|
||||
for (let pagina = 0; pagina < 100; pagina++) {
|
||||
indadded = 0
|
||||
if (!recscheda.arrProdToShow[pagina]) {
|
||||
recscheda.arrProdToShow[pagina] = [];
|
||||
}
|
||||
|
||||
let riga = Math.floor(indadded / schedePerCol)
|
||||
let col = indadded % schedePerCol
|
||||
for (let giro = 0; giro < schedePerPagina; giro++) {
|
||||
// Aggiunge il prossimo prodotto che non è stato ancora inserito
|
||||
const result = addNextProductToTheView(arrProdFiltrati, indprod);
|
||||
if (result.end) {
|
||||
break; // Esci dal ciclo se non ci sono più prodotti disponibili
|
||||
} else {
|
||||
if (result.indprod)
|
||||
indprod = result.indprod // Aggiorna indprod per il prossimo giro
|
||||
if (result.myrec) {
|
||||
|
||||
if (!recscheda.arrProdToShow[riga]) {
|
||||
recscheda.arrProdToShow[riga] = [];
|
||||
let riga = Math.floor(indadded / schedePerCol)
|
||||
let col = indadded % schedePerCol
|
||||
|
||||
if (!recscheda.arrProdToShow[pagina][riga]) {
|
||||
recscheda.arrProdToShow[pagina][riga] = [];
|
||||
}
|
||||
|
||||
recscheda.arrProdToShow[pagina][riga][col] = result.myrec
|
||||
|
||||
indadded++
|
||||
}
|
||||
|
||||
recscheda.arrProdToShow[riga][col] = result.myrec
|
||||
|
||||
indadded++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('*** arrProdToShow', recscheda.arrProdToShow)
|
||||
// console.log('*** arrProdToShow', recscheda.arrProdToShow)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -635,7 +642,7 @@ export default defineComponent({
|
||||
const element = document.getElementById('pdf-content')
|
||||
const opt = {
|
||||
margin: [0.1, 0.1, 0.1, 0.1],
|
||||
filename: 'catalogo_completo.pdf',
|
||||
filename: (props.optcatalogo.pdf_filename ?? 'catalogo_completo') + '.pdf',
|
||||
image: {
|
||||
type: 'jpeg',
|
||||
quality: 0.98
|
||||
@@ -687,11 +694,11 @@ export default defineComponent({
|
||||
const page = []
|
||||
|
||||
// Crea le righe per questa pagina
|
||||
for (let rowStart = 0; rowStart < schedePerCol; rowStart++) {
|
||||
for (let rowStart = 0; rowStart < schedePerRiga; rowStart++) {
|
||||
const row = []
|
||||
|
||||
// Riempi ogni riga con il numero corretto di prodotti
|
||||
for (let col = 0; col < schedePerRiga; col++) {
|
||||
for (let col = 0; col < schedePerCol; col++) {
|
||||
const productIndex = pageStart + (rowStart * schedePerRiga) + col
|
||||
row.push(indiceprodotto)
|
||||
indiceprodotto++
|
||||
@@ -711,53 +718,89 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function generateStyleCatalogo(optcatalogo: ICatalogo) {
|
||||
const fileimg = (optcatalogo.printable
|
||||
? optcatalogo.backgroundimage_printable
|
||||
: optcatalogo.backgroundimage)
|
||||
|
||||
const marginBottom = optcatalogo.dimensioni.pagina.margini!.bottom || ''
|
||||
|
||||
const backgroundImage = fileimg ? `url(${costanti.DIR_UPLOAD +
|
||||
costanti.DIR_CATALOGO + fileimg})` : ''
|
||||
|
||||
const backgroundSize = `${optcatalogo.printable
|
||||
? optcatalogo.backgroundSize_printable
|
||||
: optcatalogo.backgroundSize}`;
|
||||
|
||||
const width = optcatalogo.dimensioni.pagina.size?.width
|
||||
|
||||
return {
|
||||
backgroundImage,
|
||||
backgroundSize,
|
||||
marginBottom,
|
||||
'--width': width
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function generateStylePageScheda(optcatalogo: ICatalogo, scheda: IMyScheda) {
|
||||
const marginTop = `${scheda.dimensioni.pagina.margini!.top}`
|
||||
const marginTop = scheda.dimensioni?.pagina?.margini?.top ? scheda.dimensioni?.pagina?.margini?.top : (optcatalogo.dimensioni_def?.pagina?.margini?.top ?? '')
|
||||
const marginBottom = scheda.dimensioni?.pagina?.margini?.bottom ? scheda.dimensioni?.pagina?.margini?.bottom : (optcatalogo.dimensioni_def?.pagina?.margini?.bottom ?? '')
|
||||
const marginLeft = scheda.dimensioni?.pagina?.margini?.left ? scheda.dimensioni?.pagina?.margini?.left : (optcatalogo.dimensioni_def?.pagina?.margini?.left ?? '')
|
||||
const marginRight = scheda.dimensioni?.pagina?.margini?.right ? scheda.dimensioni?.pagina?.margini?.right : (optcatalogo.dimensioni_def?.pagina?.margini?.right ?? '')
|
||||
|
||||
const marginBottom = scheda.dimensioni.pagina.margini!.bottom
|
||||
const paddingTop = scheda.dimensioni?.pagina?.padding?.top ? scheda.dimensioni?.pagina?.padding?.top : (optcatalogo.dimensioni_def?.pagina?.padding?.top ?? '')
|
||||
const paddingBottom = scheda.dimensioni?.pagina?.padding?.bottom ? scheda.dimensioni?.pagina?.padding?.bottom : (optcatalogo.dimensioni_def?.pagina?.padding?.bottom ?? '')
|
||||
const paddingLeft = scheda.dimensioni?.pagina?.padding?.left ? scheda.dimensioni?.pagina?.padding?.left : (optcatalogo.dimensioni_def?.pagina?.padding?.left ?? '')
|
||||
const paddingRight = scheda.dimensioni?.pagina?.padding?.right ? scheda.dimensioni?.pagina?.padding?.right : (optcatalogo.dimensioni_def?.pagina?.padding?.right ?? '')
|
||||
|
||||
const fileimg = (optcatalogo.printable
|
||||
? scheda.bgimg_printable
|
||||
: scheda.bgimg)
|
||||
// Esiste un immagine di sfondo specifica della singola pagina ?
|
||||
let fileimg = scheda.dimensioni?.pagina?.imgsfondo?.imagefile
|
||||
let backgroundSize = scheda.dimensioni?.pagina?.imgsfondo?.fit
|
||||
if (fileimg) {
|
||||
fileimg = fileimg ? `url(${costanti.DIR_UPLOAD + costanti.DIR_SCHEDA + fileimg})` : ''
|
||||
}
|
||||
|
||||
const backgroundImage = fileimg ? `url(${costanti.DIR_UPLOAD +
|
||||
costanti.DIR_SCHEDA + fileimg})` : ''
|
||||
if (!fileimg) {
|
||||
// Esiste un immagine di sfondo uguali per tutte le pagine ?
|
||||
fileimg = optcatalogo.imgsfondo_def?.imagefile
|
||||
backgroundSize = optcatalogo.imgsfondo_def?.fit
|
||||
fileimg = fileimg ? `url(${costanti.DIR_UPLOAD + costanti.DIR_CATALOGO + fileimg})` : ''
|
||||
}
|
||||
|
||||
const backgroundSize = `${optcatalogo.printable
|
||||
? scheda.bgSize_printable
|
||||
: scheda.bgSize}`;
|
||||
let backgroundImage = fileimg ?? ''
|
||||
|
||||
const width = scheda.dimensioni.pagina.size?.width
|
||||
const width = scheda.dimensioni?.pagina?.size?.width ? scheda.dimensioni?.pagina?.size?.width : (optcatalogo.dimensioni_def?.pagina?.size?.width ?? '')
|
||||
const height = scheda.dimensioni?.pagina?.size?.height ? scheda.dimensioni?.pagina?.size?.height : (optcatalogo.dimensioni_def?.pagina?.size?.height ?? '')
|
||||
|
||||
return {
|
||||
marginBottom,
|
||||
marginTop,
|
||||
marginLeft,
|
||||
marginRight,
|
||||
paddingBottom,
|
||||
paddingTop,
|
||||
paddingLeft,
|
||||
paddingRight,
|
||||
backgroundImage,
|
||||
backgroundSize,
|
||||
'--width': width
|
||||
'--width': width,
|
||||
'--height': height,
|
||||
...(width ? { width: `${width} !important;` } : {}),
|
||||
...(height ? { height: `${height} !important;` } : {}) // Aggiungi l'altezza solo se è valorizzata
|
||||
};
|
||||
}
|
||||
|
||||
function getWidthPagina(optcatalogo: ICatalogo, scheda: IMyScheda) {
|
||||
return scheda.dimensioni?.pagina?.size?.width ? scheda.dimensioni?.pagina?.size?.width : (optcatalogo.dimensioni_def?.pagina?.size?.width ?? '')
|
||||
}
|
||||
function getHeightPagina(optcatalogo: ICatalogo, scheda: IMyScheda) {
|
||||
return scheda.dimensioni?.pagina?.size?.height ? scheda.dimensioni?.pagina?.size?.height : (optcatalogo.dimensioni_def?.pagina?.size?.height ?? '')
|
||||
}
|
||||
|
||||
function getStyleRow(recscheda: ISchedaSingola) {
|
||||
const placeContent = 'center';
|
||||
|
||||
const width = recscheda.scheda?.dimensioni?.scheda_prodotto?.size?.width ?? '100px';
|
||||
const height = recscheda.scheda?.dimensioni?.scheda_prodotto?.size?.height;
|
||||
|
||||
const marginTop = recscheda.scheda?.dimensioni?.scheda_prodotto?.margini?.top ?? '0px';
|
||||
const marginBottom = recscheda.scheda?.dimensioni?.scheda_prodotto?.margini?.bottom ?? '0px';
|
||||
const marginLeft = recscheda.scheda?.dimensioni?.scheda_prodotto?.margini?.left ?? '0px';
|
||||
const marginRight = recscheda.scheda?.dimensioni?.scheda_prodotto?.margini?.right ?? '0px';
|
||||
|
||||
const paddingTop = recscheda.scheda?.dimensioni?.scheda_prodotto?.padding?.top ?? '0px';
|
||||
const paddingBottom = recscheda.scheda?.dimensioni?.scheda_prodotto?.padding?.bottom ?? '0px';
|
||||
const paddingLeft = recscheda.scheda?.dimensioni?.scheda_prodotto?.padding?.left ?? '0px';
|
||||
const paddingRight = recscheda.scheda?.dimensioni?.scheda_prodotto?.padding?.right ?? '0px';
|
||||
|
||||
return {
|
||||
placeContent,
|
||||
flex: `0 1 ${width} !important;`,
|
||||
margin: `${marginTop} ${marginRight} ${marginBottom} ${marginLeft}`,
|
||||
padding: `${paddingTop} ${paddingRight} ${paddingBottom} ${paddingLeft}`,
|
||||
...(height ? { height: `${height} !important;` } : {}) // Aggiungi l'altezza solo se è valorizzata
|
||||
};
|
||||
}
|
||||
|
||||
@@ -805,6 +848,9 @@ export default defineComponent({
|
||||
getProdBySchedaRigaCol,
|
||||
generateStylePageScheda,
|
||||
generateStyleCatalogo,
|
||||
getStyleRow,
|
||||
getWidthPagina,
|
||||
getHeightPagina,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user