- Cataloghi aggiornamento...

This commit is contained in:
Surya Paolo
2025-02-11 18:58:06 +01:00
parent 3d0e307e42
commit 0ad4dcff75
23 changed files with 272 additions and 99 deletions

View File

@@ -64,7 +64,7 @@ export default defineComponent({
// Utile anche per sincronizzare con le modifiche ricevute da props
watch(() => props.modelValue, (newVal) => {
optcatalogo.value = { ...newVal };
}, { deep: true });
}, { deep: false });
/*watch(optcatalogo, (newValue) => {
emit('update:modelValue', newValue);
@@ -125,7 +125,7 @@ export default defineComponent({
if (recscheda.scheda!.isPagIntro) {
const catalogStore = useCatalogStore()
const catalog = catalogStore.catalogs?.find((catalog: ICatalog) => catalog.idPageAssigned === props.idPage)
const catalog = getCatalogoByMyPage.value
if (catalog && catalog.descr_introduttiva) {
// Cerca se la descrizione introduttiva è stata impostata
testo = catalog.descr_introduttiva
@@ -313,6 +313,21 @@ export default defineComponent({
return idCollane
}
function getArgomentiDaFiltrare(def_argomenti?: string[]) {
let argomenti: string[] = []
// Cerca se nella lista cataloghi c'è la Collana di questa Pagina !
let trovatocatalogo = getCatalogoByMyPage.value
if (trovatocatalogo) {
argomenti = trovatocatalogo.argomenti! || []
} else {
argomenti = def_argomenti || []
}
return argomenti
}
function getEditoreDaFiltrare(def_editori?: string[]) {
let editore: string[] = []
@@ -361,29 +376,35 @@ export default defineComponent({
if (optcatalogo.value.argomenti) {
// ha la priorità questo scelto sul catalogo
arrargomstr = optcatalogo.value.argomenti
arrargomstr = getArgomentiDaFiltrare(optcatalogo.value.argomenti!)
} else {
catstr = cat.value || ''
}
let filtroArgomenti = arrargomstr || []
let boolfiltroVuotoArgomenti = (filtroArgomenti.length === 0)
let gasselstr = ''
if (cosa.value === shared_consts.PROD.GAS) {
gasselstr = idGasSel.value || '';
}
let lowerSearchText = (searchtext || '').toLowerCase().trim();
lowerSearchText = lowerSearchText.replace(/[-@:=]/g, '');
if ((!lowerSearchText || (lowerSearchText && lowerSearchText.length < 2)) && !catstr && boolfiltroVuotoProductTypes && boolfiltroVuotoExcludeProductTypes && boolfiltroVuotoCollane && boolfiltroVuotoEditore && boolfiltroVuotoCollana && !filtroAuthor && (!gasselstr && (cosa.value !== shared_consts.PROD.GAS))) {
if ((!lowerSearchText || (lowerSearchText && lowerSearchText.length < 2)) && !catstr && boolfiltroVuotoArgomenti && boolfiltroVuotoProductTypes && boolfiltroVuotoExcludeProductTypes && boolfiltroVuotoCollane && boolfiltroVuotoEditore && boolfiltroVuotoCollana && !filtroAuthor && (!gasselstr && (cosa.value !== shared_consts.PROD.GAS))) {
} else {
arrprod = arrprod.filter((product: IProduct) => {
if (product && product.productInfo) {
let lowerName = (product.productInfo.name || '').toLowerCase();
let hasCategoria = !catstr || (catstr && (product.productInfo.idCatProds || []).includes(catstr));
let hasCategoria = false
let hasArgomentiCat = true
if (arrargomstr && arrargomstr.length > 0) {
hasArgomentiCat = (product.productInfo.idCatProds || []).some(idCat => arrargomstr.includes(idCat))
hasCategoria = true
} else {
hasCategoria = (!catstr || (catstr && (product.productInfo.idCatProds || []).includes(catstr))) ? true : false
}
let hasAuthor = !filtroAuthor || (filtroAuthor && (product.productInfo.idAuthors || []).includes(filtroAuthor));
@@ -463,7 +484,6 @@ export default defineComponent({
if (myschedatocopy) {
myschedatocopy.scheda._id = origScheda.scheda?._id
myschedatocopy.scheda.isTemplate = false
myschedatocopy.scheda.isPagIntro = false
myschedatocopy.scheda.name = precname
myschedatocopy.scheda.linkIdTemplate = linkIdTemplate
@@ -491,6 +511,7 @@ export default defineComponent({
}
}
console.log(' FINE - populateDataWithlinkIdTemplate')
}
@@ -522,7 +543,7 @@ export default defineComponent({
if (optcatalogo.value.argomenti) {
// ha la priorità questo scelto sul catalogo
arrargomstr = optcatalogo.value.argomenti
arrargomstr = getArgomentiDaFiltrare(optcatalogo.value.argomenti!)
} else {
catstr = cat.value || ''
}
@@ -541,11 +562,13 @@ export default defineComponent({
let lowerName = (product.productInfo.name || '').toLowerCase();
let lowerCode = (product.productInfo.code || '').toLowerCase();
let hasCategoria = !catstr || (catstr && (product.productInfo.idCatProds || []).includes(catstr));
let hasCategoria = false
let hasArgomentiCat = true
if (arrargomstr && arrargomstr.length > 0) {
hasArgomentiCat = (product.productInfo.idCatProds || []).some(idCat => arrargomstr.includes(idCat))
hasCategoria = true
} else {
hasCategoria = (!catstr || (catstr && (product.productInfo.idCatProds || []).includes(catstr))) ? true : false
}
let hasAuthor = !filtroAuthor || (filtroAuthor && (product.productInfo.idAuthors || []).includes(filtroAuthor));
@@ -673,7 +696,7 @@ export default defineComponent({
}
function generatearrProdToViewSorted() {
// console.log('generatearrProdToViewSorted', arrProducts.value)
console.log('generatearrProdToViewSorted...')
try {
@@ -686,6 +709,8 @@ export default defineComponent({
let indprod = 0
let indprodGenerale = 0
let indtotale = 0
for (const recscheda of optcatalogo.value.arrSchede!) {
if (recscheda && recscheda.scheda) {
let schedePerRiga = recscheda.scheda.numschede_perRiga || 1
@@ -739,16 +764,28 @@ export default defineComponent({
recscheda.arrProdToShow[pagina][riga][col] = result.myrec
indadded++
indtotale++
// console.log('indadded', indadded)
if (optcatalogo.value.maxnumlibri! > 0) {
if (indtotale > optcatalogo.value.maxnumlibri!)
return
} else {
if (indtotale > 200)
return
}
}
}
}
if (recscheda.numPagineMax! > 0) {
if (pagina + 1 >= recscheda.numPagineMax!)
break; // fine pagine
}
}
// console.log('*** arrProdToShow', recscheda.arrProdToShow)
@@ -757,6 +794,8 @@ export default defineComponent({
// console.log('Fine Generazione')
}
console.log(' FINE - generatearrProdToViewSorted !')
} catch (e) {
console.error('Err', e)
}