- aggiornamento cataloghi.
possibilità di estrapolare i dati da GM direttamente - migrazione delle tabelle di GM in locale - corretto l'ordinamento del Catalogo
This commit is contained in:
@@ -678,13 +678,8 @@ export default defineComponent({
|
||||
|
||||
// Crea una copia dell'array per non modificare l'originale
|
||||
const sortedArr = [...arrprod].sort((a: IProduct, b: IProduct) => {
|
||||
const valA = a.productInfo?.[sort_field];
|
||||
const valB = b.productInfo?.[sort_field];
|
||||
|
||||
// Gestisce il caso in cui il campo non esiste
|
||||
if (valA === undefined || valB === undefined) {
|
||||
return 0;
|
||||
}
|
||||
const valA = a.productInfo?.[sort_field] ?? (typeof a.productInfo?.[sort_field] === 'number' ? 0 : '');
|
||||
const valB = b.productInfo?.[sort_field] ?? (typeof b.productInfo?.[sort_field] === 'number' ? 0 : '');
|
||||
|
||||
// Ordinamento per data
|
||||
if (valA instanceof Date && valB instanceof Date) {
|
||||
@@ -704,7 +699,7 @@ export default defineComponent({
|
||||
: compB.localeCompare(compA);
|
||||
});
|
||||
|
||||
// logga i primi 3 elementi, mostrando il nome del prodotto (productInfo.name e la data di pibblicazione : productinfo.date_pub
|
||||
// logga i primi N elementi, mostrando il nome del prodotto (productInfo.name e la data di pibblicazione : productinfo.date_pub
|
||||
if (sortedArr.length > 0) {
|
||||
console.log('Primi 15 elementi ordinati: ***** ');
|
||||
sortedArr.slice(0, 15).forEach((product, index) => {
|
||||
@@ -717,10 +712,7 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
|
||||
// Aggiunge l'indice di ranking ai prodotti
|
||||
return sortedArr.map((product, index) => ({
|
||||
...product,
|
||||
}))
|
||||
return sortedArr
|
||||
}
|
||||
|
||||
return arrprod;
|
||||
@@ -728,35 +720,24 @@ export default defineComponent({
|
||||
|
||||
function addNextProductToTheView(arrproductfiltrati: IProduct[], indprod: number) {
|
||||
try {
|
||||
|
||||
let rectrovato = null;
|
||||
while (true) {
|
||||
if (indprod >= arrproductfiltrati.length) {
|
||||
return { end: true }
|
||||
}
|
||||
|
||||
rectrovato = arrProdToView.value.find(
|
||||
while (indprod < arrproductfiltrati.length) {
|
||||
const rectrovato = arrProdToView.value.find(
|
||||
(prodview: IProdView) => prodview.id === arrproductfiltrati[indprod]._id
|
||||
);
|
||||
|
||||
if (rectrovato) {
|
||||
indprod++
|
||||
continue; // Era stato già aggiunto, quindi prova col prossimo
|
||||
} else {
|
||||
// Non è stato ancora aggiunto, quindi prendo questo e lo aggiungo alla lista !
|
||||
|
||||
const myrec = arrproductfiltrati[indprod]
|
||||
|
||||
arrProdToView.value.push({ id: myrec._id, showed: false });
|
||||
return { myrec, added: true, indprod }
|
||||
if (!rectrovato) {
|
||||
const myrec = arrproductfiltrati[indprod];
|
||||
arrProdToView.value.push({ id: myrec._id });
|
||||
return { myrec, added: true, indprod: indprod + 1 };
|
||||
}
|
||||
|
||||
indprod++;
|
||||
}
|
||||
|
||||
|
||||
return { end: true };
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return { rec: null, indprod }; // Assicurati di gestire correttamente l'errore
|
||||
return { rec: null, indprod };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -822,8 +803,9 @@ export default defineComponent({
|
||||
let indadded = 0
|
||||
recscheda.arrProdToShow = []
|
||||
|
||||
for (let pagina = 0; pagina < 60; pagina++) {
|
||||
for (let pagina = 0; pagina < 600; pagina++) {
|
||||
indadded = 0
|
||||
let lastresultend = false
|
||||
if (!recscheda.arrProdToShow[pagina]) {
|
||||
recscheda.arrProdToShow[pagina] = [];
|
||||
}
|
||||
@@ -832,6 +814,7 @@ export default defineComponent({
|
||||
// Aggiunge il prossimo prodotto che non è stato ancora inserito
|
||||
const result = addNextProductToTheView(arrProdFiltrati, indprod);
|
||||
if (result.end) {
|
||||
lastresultend = true
|
||||
break; // Esci dal ciclo se non ci sono più prodotti disponibili
|
||||
} else {
|
||||
if (result.indprod)
|
||||
@@ -856,14 +839,17 @@ export default defineComponent({
|
||||
if (indtotale > optcatalogo.value.maxnumlibri!)
|
||||
return
|
||||
|
||||
} else {
|
||||
if (indtotale > 200)
|
||||
return
|
||||
//} else {
|
||||
// if (indtotale > 5000)
|
||||
// return
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (lastresultend)
|
||||
break; // Esci dal ciclo se non ci sono più prodotti disponibili
|
||||
|
||||
|
||||
if (recscheda.numPagineMax! > 0) {
|
||||
@@ -916,18 +902,6 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
function getNextProd() {
|
||||
const nextRecord = arrProdToView.value.find((rec: any) => !rec.showed)
|
||||
|
||||
// Se un tale record esiste, impostalo su mostrato
|
||||
if (nextRecord) {
|
||||
nextRecord.showed = true
|
||||
return arrProducts.value.find((recprod: IProduct) => recprod._id === nextRecord.id)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
/*function getProducts() {
|
||||
let arrprod = productStore.getProducts(cosa.value)
|
||||
@@ -1328,7 +1302,6 @@ export default defineComponent({
|
||||
pdfContent,
|
||||
tabcatalogo,
|
||||
groupedPages,
|
||||
getNextProd,
|
||||
getProdBySchedaRigaCol,
|
||||
generateStylePageScheda,
|
||||
generateStyleCatalogo,
|
||||
|
||||
Reference in New Issue
Block a user