- catalogo

- corretto logica del RefreshToken che non richiedeva il nuovo token, quindi scadeva tutte le volte, richiedendo sempre l'accesso !
This commit is contained in:
Surya Paolo
2025-01-07 17:17:08 +01:00
parent ce86dd51a8
commit 3734762a8b
72 changed files with 2112 additions and 3592650 deletions

View File

@@ -66,7 +66,6 @@ export default defineComponent({
const filter = ref(<IFilterCatalogo>{
author: '',
sort: 1,
publisher: '',
type: '',
ageGroup: ''
@@ -158,7 +157,14 @@ export default defineComponent({
}
})
watch(() => filter.value.sort, (newval, oldval) => {
watch(() => filter.value.sort_field, (newval, oldval) => {
calcArrProducts()
if (tools.scrollTop() > 300) {
tools.scrollToTopValue(300)
}
})
watch(() => filter.value.sort_dir, (newval, oldval) => {
calcArrProducts()
if (tools.scrollTop() > 300) {
@@ -203,7 +209,9 @@ export default defineComponent({
}
function calcArrProducts() {
console.log('calcArrProducts')
// console.log('calcArrProducts')
let arrargomstr: any = []
// eventuali titoli specifici estratti dall'array di Prodotti Selezionati
//const searchtext = getSearchText()
@@ -219,12 +227,19 @@ export default defineComponent({
let boolfiltroVuotoProductTypes = (filtroProductTypes.length === 0 || (filtroProductTypes.length === 1 && (filtroProductTypes[0] === 0)))
let boolfiltroVuotoExcludeProductTypes = filtroExcludeProductTypes.length === 0
let filtroPublishers = optcatalogo.value.Editore || []
let filtroPublishers = optcatalogo.value.editore || []
let boolfiltroVuotoEditore = (filtroPublishers.length === 0)
//console.log('filtroVersione', filtroProductTypes)
let catstr = cat.value || ''
let catstr = ''
if (optcatalogo.value.argomenti) {
// ha la priorità questo scelto sul catalogo
arrargomstr = optcatalogo.value.argomenti
} else {
catstr = cat.value || ''
}
let gasselstr = ''
if (cosa.value === shared_consts.PROD.GAS) {
@@ -240,6 +255,12 @@ export default defineComponent({
if (product && product.productInfo) {
let lowerName = (product.productInfo.name || '').toLowerCase();
let hasCategoria = !catstr || (catstr && (product.productInfo.idCatProds || []).includes(catstr));
let hasArgomentiCat = true
if (arrargomstr && arrargomstr.length > 0) {
hasArgomentiCat = (product.productInfo.idCatProds || []).some(idCat => arrargomstr.includes(idCat))
hasCategoria = true
}
let hasAuthor = !filtroAuthor || (filtroAuthor && (product.productInfo.idAuthors || []).includes(filtroAuthor));
let hasProductTypes = true
@@ -253,7 +274,7 @@ export default defineComponent({
hasProductTypes = !optcatalogo.value.productTypes || (optcatalogo.value.productTypes && (product.productInfo.productTypes || []).some((item: any) => optcatalogo.value.productTypes!.includes(item)))
}
if (optcatalogo.value && !boolfiltroVuotoEditore) {
hasPublished = !optcatalogo.value.Editore || (optcatalogo.value.Editore && optcatalogo.value.Editore.includes(product.productInfo.idPublisher!))
hasPublished = !optcatalogo.value.editore || (optcatalogo.value.editore && optcatalogo.value.editore.includes(product.productInfo.idPublisher!))
}
if (optcatalogo.value && !boolfiltroVuotoExcludeProductTypes) {
@@ -273,7 +294,7 @@ export default defineComponent({
// Check if all words in lowerSearchText are present in lowerName
let allWordsPresent = lowerSearchText.split(/\s+/).every(word => new RegExp(`\\b${word}\\b`, 'i').test(lowerName));
return (codeMatch.test(product.productInfo.code || '') || allWordsPresent) && hasCategoria && hasAuthor && productgassel && hasProductTypes && hasPublished && !hasExcludeProductTypes;
return (codeMatch.test(product.productInfo.code || '') || allWordsPresent) && hasCategoria && hasArgomentiCat && hasAuthor && productgassel && hasProductTypes && hasPublished && !hasExcludeProductTypes;
} else {
console.error('product or product.productInfo is null');
return false;
@@ -281,7 +302,7 @@ export default defineComponent({
});
}
arrprod = getProductsSorted(arrprod, filter.value.sort);
arrprod = getProductsSorted(arrprod, filter.value.sort_field, filter.value.sort_dir);
arrProducts.value = arrprod
@@ -346,6 +367,8 @@ export default defineComponent({
const searchtext = scheda.arrProdottiSpeciali
let arrargomstr: any = []
let arrprod = productStore.getProducts(cosa.value) || [];
let filtroAuthor = filter.value.author || '';
@@ -359,7 +382,14 @@ export default defineComponent({
//console.log('filtroVersione', filtroProductTypes)
let catstr = cat.value || ''
let catstr = ''
if (optcatalogo.value.argomenti) {
// ha la priorità questo scelto sul catalogo
arrargomstr = optcatalogo.value.argomenti
} else {
catstr = cat.value || ''
}
let gasselstr = ''
if (cosa.value === shared_consts.PROD.GAS) {
@@ -376,6 +406,12 @@ export default defineComponent({
let lowerCode = (product.productInfo.code || '').toLowerCase();
let hasCategoria = !catstr || (catstr && (product.productInfo.idCatProds || []).includes(catstr));
let hasArgomentiCat = true
if (arrargomstr && arrargomstr.length > 0) {
hasArgomentiCat = (product.productInfo.idCatProds || []).some(idCat => arrargomstr.includes(idCat))
hasCategoria = true
}
let hasAuthor = !filtroAuthor || (filtroAuthor && (product.productInfo.idAuthors || []).includes(filtroAuthor));
// Check if ANY search term matches the product name or code
@@ -408,47 +444,49 @@ export default defineComponent({
hasExcludeProductTypes = !scheda.excludeproductTypes || (scheda.excludeproductTypes && (product.productInfo.productTypes || []).every((item: any) => scheda.excludeproductTypes!.includes(item)))
}
return searchMatch && hasCategoria && hasAuthor && hasProductTypes && hasPublished && !hasExcludeProductTypes;
return searchMatch && hasCategoria && hasArgomentiCat && hasAuthor && hasProductTypes && hasPublished && !hasExcludeProductTypes;
} else {
console.error('product or product.productInfo is null');
return false;
}
})
arrprod = getProductsSorted(arrprod, scheda?.sort!);
arrprod = getProductsSorted(arrprod, scheda?.sort_field!, scheda?.sort_dir!);
return arrprod
}
function getProductsSorted(arrprod: IProduct[], sort: number) {
// console.log('getProductsSorted', sort)
if (sort === costanti.SORT_PUBDATE) {
function getProductsSorted(arrprod: IProduct[], sort_field: string, sort_dir: number): IProduct[] {
if (sort_field) {
// 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];
arrprod = arrprod.sort((a: IProduct, b: IProduct) => {
return b.productInfo.date_pub_ts - a.productInfo.date_pub_ts
})
} else if (sort === costanti.SORT_BESTSELLER) {
if (valA === undefined || valB === undefined) {
return 0; // Gestisce il caso in cui il campo non esiste
}
arrprod = arrprod.sort((a: IProduct, b: IProduct) => {
return b.productInfo.vLast6M! - a.productInfo.vLast6M!
})
arrprod = arrprod.map((product, index) => {
return {
...product,
indiceRanking: index + 1
};
})
console.log('arr', arrprod)
} else if (sort === costanti.SORT_DEFAULT) {
if (typeof valA === 'number' && typeof valB === 'number') {
return sort_dir === 1 ? valA - valB : valB - valA;
} else {
// Per stringhe o altri tipi
const compA = valA.toString().toLowerCase();
const compB = valB.toString().toLowerCase();
return sort_dir === 1
? compA.localeCompare(compB)
: compB.localeCompare(compA);
}
});
return sortedArr.map((product, index) => ({
...product,
indiceRanking: index + 1
}));
}
return arrprod
return arrprod;
}
function addNextProductToTheView(arrproductfiltrati: IProduct[], indprod: number) {
@@ -518,8 +556,8 @@ export default defineComponent({
arrProdFiltrati = getProductsFilteredByScheda(recscheda.scheda)
indprod = 0
} else {
if (recscheda.scheda?.sort! > 0) {
arrProdFiltrati = getProductsSorted(arrGeneraleProdotti, recscheda.scheda.sort!);
if (recscheda.scheda?.sort_field!) {
arrProdFiltrati = getProductsSorted(arrGeneraleProdotti, recscheda.scheda.sort_field!, recscheda.scheda.sort_dir!);
indprod = 0
} else {
indprod = indprodGenerale
@@ -577,7 +615,7 @@ export default defineComponent({
}
}
console.log('Fine...')
// console.log('Fine...')
}
function getNextProd() {
@@ -610,7 +648,7 @@ export default defineComponent({
}*/
async function mounted() {
console.log('mounted Catalogo')
// console.log('mounted Catalogo')
loadpage.value = false
await productStore.loadProducts()

View File

@@ -87,7 +87,7 @@
<!--<q-select
v-model="filter.publisher"
:options="publishers"
label="Editore"
label="editore"
placeholder="Tutti"
dense
/>
@@ -159,9 +159,9 @@
<div class="row justify-center q-mx-auto">
<q-select
v-model="filter.sort"
v-model="filter.sort_field"
dense
:options="shared_consts.ORDINAMENTO_CATALOGHI"
:options="shared_consts.ORDINAMENTO_CATALOGHI_PUBBLICO"
label="Ordinamento"
placeholder=""
emit-value
@@ -169,6 +169,17 @@
filled
rounded
></q-select>
<q-select
v-model="filter.sort_dir"
dense
:options="shared_consts.ORDINAMENTO_DIREZIONE"
label="Direzione"
placeholder=""
emit-value
map-options
filled
rounded
></q-select>
</div>
<div class="text-center q-py-sm prod_trov">
@@ -479,17 +490,22 @@
2. Eseguire "IMPORTA DESCRIZIONI E LINK DA SITO GRUPPOMACRO (XML)" - importa_descrizioni_e_link.xml
3. Visualizza <a
3. Visualizza
<a
href="http://vps-88271abb.vps.ovh.net/apimacro/public/view-articles-fatturati"
target="_blank"
>Ranking</a> -
<a
href="http://vps-88271abb.vps.ovh.net/apimacro/public/view-articles-sales"
target="_blank"
>Ranking</a
> e controlla se tutto ok
>(Ranking Ordini)</a>
e controlla se tutto ok
4. Esporta il file del Ranking ed importarlo con "IMPORTA RANKING DA JSON"
<a
href="http://vps-88271abb.vps.ovh.net/apimacro/public/export-articles-sales-json"
target="_blank"
>Esporta Ranking</a
>(Esporta Ranking Venduti e Fatturati)</a
>
5. Scarica Catalogo (<a
@@ -516,12 +532,6 @@
>Struttura Campi GM</a
>
<a
href="http://vps-88271abb.vps.ovh.net/apimacro/public/view-articles-sales"
target="_blank"
>Visualizza Descrizioni</a
>
<a
href="https://www.fioredellavita.it/wp-admin/admin.php?page=webappick-manage-feeds"
target="_blank"