Cataloghi...

This commit is contained in:
Surya Paolo
2025-02-05 12:13:36 +01:00
parent 979f90f980
commit 2533da3692
20 changed files with 171 additions and 105 deletions

View File

@@ -14,10 +14,11 @@ import { CProductCard } from '@src/components/CProductCard'
import { CMySelect } from '@src/components/CMySelect'
import { CContainerCatalogoCard } from '@src/components/CContainerCatalogoCard'
import { CSelectUserActive } from '@src/components/CSelectUserActive'
import { IOptCatalogo, IDimensioni, IFilterCatalogo, IMyScheda, IProdView, IProduct, ISchedaSingola, ISearchList } from 'model'
import { IOptCatalogo, IDimensioni, IFilterCatalogo, IMyScheda, IProdView, IProduct, ISchedaSingola, ISearchList, ICatalog } from 'model'
import { fieldsTable } from '@store/Modules/fieldsTable'
import { useCatalogStore } from '@src/store/CatalogStore'
export default defineComponent({
name: 'Catalogo',
@@ -208,6 +209,23 @@ export default defineComponent({
return lista && lista.value && lista.value.hasOwnProperty('name') ? lista.value.name : ''
}
function getIdCollaneDaFiltrare() {
let idCollane: number[] = []
const catalogStore = useCatalogStore()
// Cerca se nella lista cataloghi c'è la Collana di questa Pagina !
let trovato = catalogStore.catalogs?.find((catalog: ICatalog) => catalog.idPageAssigned)
if (trovato) {
} else {
idCollane = optcatalogo.value.idCollane! || []
}
return idCollane
}
function calcArrProducts() {
// console.log('calcArrProducts')
@@ -228,7 +246,10 @@ export default defineComponent({
let boolfiltroVuotoExcludeProductTypes = filtroExcludeProductTypes.length === 0
let filtroPublishers = optcatalogo.value.editore || []
let filtroCollane = getIdCollaneDaFiltrare()
let boolfiltroVuotoEditore = (filtroPublishers.length === 0)
let boolfiltroVuotoCollane = (filtroCollane.length === 0)
//console.log('filtroVersione', filtroProductTypes)
@@ -247,7 +268,7 @@ export default defineComponent({
}
let lowerSearchText = (searchtext || '').toLowerCase().trim();
lowerSearchText = lowerSearchText.replace(/[-@:=]/g, '');
if ((!lowerSearchText || (lowerSearchText && lowerSearchText.length < 2)) && !catstr && boolfiltroVuotoProductTypes && boolfiltroVuotoExcludeProductTypes && boolfiltroVuotoEditore && !filtroAuthor && (!gasselstr && (cosa.value !== shared_consts.PROD.GAS))) {
if ((!lowerSearchText || (lowerSearchText && lowerSearchText.length < 2)) && !catstr && boolfiltroVuotoProductTypes && boolfiltroVuotoExcludeProductTypes && boolfiltroVuotoCollane && boolfiltroVuotoEditore && boolfiltroVuotoCollana && !filtroAuthor && (!gasselstr && (cosa.value !== shared_consts.PROD.GAS))) {
} else {
@@ -265,6 +286,7 @@ export default defineComponent({
let hasProductTypes = true
let hasPublished = true
let hasCollana = true
let hasExcludeProductTypes = false
//++AddCATALOGO_FIELDS
@@ -276,6 +298,9 @@ export default defineComponent({
if (optcatalogo.value && !boolfiltroVuotoEditore) {
hasPublished = !optcatalogo.value.editore || (optcatalogo.value.editore && optcatalogo.value.editore.includes(product.productInfo.idPublisher!))
}
if (optcatalogo.value && !boolfiltroVuotoCollane) {
hasCollana = !optcatalogo.value.idCollane || (optcatalogo.value.idCollane && optcatalogo.value.idCollane.includes(product.productInfo.idCollana!))
}
if (optcatalogo.value && !boolfiltroVuotoExcludeProductTypes) {
// check if productInfo.productTypes array exclude some item in optcatalogo.value.ProductTypes array
@@ -294,7 +319,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 && hasArgomentiCat && hasAuthor && productgassel && hasProductTypes && hasPublished && !hasExcludeProductTypes;
return (codeMatch.test(product.productInfo.code || '') || allWordsPresent) && hasCategoria && hasCollana && hasArgomentiCat && hasAuthor && productgassel && hasProductTypes && hasPublished && !hasExcludeProductTypes;
} else {
console.error('product or product.productInfo is null');
return false;
@@ -378,7 +403,9 @@ export default defineComponent({
let boolfiltroVuotoExcludeProductTypes = filtroExcludeProductTypes.length === 0
let filtroPublishers = scheda.editore || []
let filtroCollane = getIdCollaneDaFiltrare()
let boolfiltroVuotoEditore = (filtroPublishers.length === 0)
let boolfiltroVuotoCollane = (filtroCollane.length === 0)
//console.log('filtroVersione', filtroProductTypes)
@@ -429,6 +456,7 @@ export default defineComponent({
let hasProductTypes = true
let hasPublished = true
let hasCollane = true
let hasExcludeProductTypes = false
if (!boolfiltroVuotoProductTypes) {
@@ -439,12 +467,16 @@ export default defineComponent({
hasPublished = !scheda.editore || (scheda.editore && scheda.editore.includes(product.productInfo.idPublisher!))
}
if (optcatalogo.value && !boolfiltroVuotoCollane) {
hasCollane = !optcatalogo.value.idCollane || (optcatalogo.value.idCollane && optcatalogo.value.idCollane.includes(product.productInfo.idCollana!))
}
if (!boolfiltroVuotoExcludeProductTypes) {
// check if productInfo.productTypes array exclude some item in scheda.ProductTypes array
hasExcludeProductTypes = !scheda.excludeproductTypes || (scheda.excludeproductTypes && (product.productInfo.productTypes || []).every((item: any) => scheda.excludeproductTypes!.includes(item)))
}
return searchMatch && hasCategoria && hasArgomentiCat && hasAuthor && hasProductTypes && hasPublished && !hasExcludeProductTypes;
return searchMatch && hasCategoria && hasArgomentiCat && hasAuthor && hasProductTypes && hasPublished && hasCollane && !hasExcludeProductTypes;
} else {
console.error('product or product.productInfo is null');
return false;

View File

@@ -250,7 +250,7 @@
type="a"
size="md"
rounded
:label="$t('reg.website')"
:label="$t('reg.website') + ' ' + tools.getMainUrl(getLinkWebSite())"
:href="getLinkWebSite()"
target="__blank"
></q-btn>