2025-03-01 14:14:43 +01:00
|
|
|
import type { PropType } from 'vue';
|
|
|
|
|
import { defineComponent, onMounted, ref, watch, computed, onBeforeUnmount, nextTick } from 'vue'
|
|
|
|
|
import { tools } from '@tools'
|
2024-01-30 14:00:48 +01:00
|
|
|
import { useUserStore } from '@store/UserStore'
|
|
|
|
|
import { useRouter } from 'vue-router'
|
|
|
|
|
import { useGlobalStore } from '@store/globalStore'
|
|
|
|
|
import { useProducts } from '@store/Products'
|
2025-03-01 14:14:43 +01:00
|
|
|
import { useI18n } from 'vue-i18n'
|
2024-01-30 14:00:48 +01:00
|
|
|
import { toolsext } from '@store/Modules/toolsext'
|
|
|
|
|
import { useQuasar } from 'quasar'
|
|
|
|
|
import { costanti } from '@costanti'
|
|
|
|
|
|
2025-03-01 14:14:43 +01:00
|
|
|
import { shared_consts } from '@src/common/shared_vuejs'
|
2024-01-30 14:00:48 +01:00
|
|
|
import { CProductCard } from '@src/components/CProductCard'
|
2025-02-12 18:32:10 +01:00
|
|
|
|
2024-05-09 23:36:58 +02:00
|
|
|
import { CMySelect } from '@src/components/CMySelect'
|
2025-03-31 23:55:53 +02:00
|
|
|
import { CProductTable } from '@src/components/CProductTable'
|
2024-06-20 17:22:46 +02:00
|
|
|
import { CContainerCatalogoCard } from '@src/components/CContainerCatalogoCard'
|
2024-01-30 14:00:48 +01:00
|
|
|
import { CSelectUserActive } from '@src/components/CSelectUserActive'
|
2025-03-01 14:14:43 +01:00
|
|
|
import type {
|
2025-02-12 18:32:10 +01:00
|
|
|
IOptCatalogo, IDimensioni, IFilterCatalogo,
|
2025-03-31 23:55:53 +02:00
|
|
|
IMyScheda, IProdView, IProduct, ISchedaSingola, ISearchList, ICatalog, IImg,
|
|
|
|
|
IText
|
2025-03-01 14:14:43 +01:00
|
|
|
} from 'model';
|
|
|
|
|
import {
|
|
|
|
|
IMyPage,
|
|
|
|
|
|
2025-02-12 18:32:10 +01:00
|
|
|
} from 'model'
|
2024-05-09 23:36:58 +02:00
|
|
|
|
2024-07-31 15:02:30 +02:00
|
|
|
|
2024-05-09 23:36:58 +02:00
|
|
|
import { fieldsTable } from '@store/Modules/fieldsTable'
|
2025-02-05 12:13:36 +01:00
|
|
|
import { useCatalogStore } from '@src/store/CatalogStore'
|
2025-03-31 23:55:53 +02:00
|
|
|
import { Catalogo } from '.';
|
2024-01-30 14:00:48 +01:00
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
name: 'Catalogo',
|
2025-03-31 23:55:53 +02:00
|
|
|
components: { CContainerCatalogoCard, CProductCard, CSelectUserActive, CMySelect, CProductTable },
|
2024-12-09 12:32:19 +01:00
|
|
|
emits: ['update:modelValue', 'updateCatalogo'],
|
2024-07-03 13:22:57 +02:00
|
|
|
props: {
|
2024-12-09 12:32:19 +01:00
|
|
|
modelValue: {
|
2025-02-03 17:18:33 +01:00
|
|
|
type: Object as PropType<IOptCatalogo>,
|
2024-12-09 12:32:19 +01:00
|
|
|
required: true,
|
2024-06-20 17:22:46 +02:00
|
|
|
},
|
2025-02-10 22:48:53 +01:00
|
|
|
idPage: {
|
|
|
|
|
type: String,
|
|
|
|
|
required: false,
|
|
|
|
|
default: '',
|
|
|
|
|
},
|
2024-06-20 17:22:46 +02:00
|
|
|
},
|
2024-12-09 12:32:19 +01:00
|
|
|
setup(props, { emit }) {
|
2024-01-30 14:00:48 +01:00
|
|
|
const userStore = useUserStore()
|
|
|
|
|
const globalStore = useGlobalStore()
|
|
|
|
|
const productStore = useProducts()
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
const $q = useQuasar()
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
|
|
|
const search = ref('')
|
2024-05-09 23:36:58 +02:00
|
|
|
const optauthors = ref(<any>[])
|
2024-05-08 16:07:42 +02:00
|
|
|
|
2024-07-31 15:02:30 +02:00
|
|
|
const pdfContent = ref(null);
|
|
|
|
|
|
2025-02-03 17:18:33 +01:00
|
|
|
const optcatalogo = ref(<IOptCatalogo>{ ...props.modelValue });
|
2024-12-09 12:32:19 +01:00
|
|
|
|
|
|
|
|
function updateCatalogoPadre() {
|
|
|
|
|
console.log('catalogo.ts PADRE')
|
|
|
|
|
emit('update:modelValue', optcatalogo.value);
|
|
|
|
|
//emit('updateCatalogo', optcatalogo.value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Metodo per aggiornare optcatalogo
|
2025-02-03 17:18:33 +01:00
|
|
|
const updateOptCatalogo = <K extends keyof IOptCatalogo>(key: K, value: IOptCatalogo[K]) => {
|
2024-12-09 12:32:19 +01:00
|
|
|
optcatalogo.value[key] = value;
|
|
|
|
|
updateCatalogoPadre()
|
|
|
|
|
}
|
|
|
|
|
// Utile anche per sincronizzare con le modifiche ricevute da props
|
|
|
|
|
watch(() => props.modelValue, (newVal) => {
|
|
|
|
|
optcatalogo.value = { ...newVal };
|
2025-02-11 18:58:06 +01:00
|
|
|
}, { deep: false });
|
2024-12-09 12:32:19 +01:00
|
|
|
|
|
|
|
|
/*watch(optcatalogo, (newValue) => {
|
|
|
|
|
emit('update:modelValue', newValue);
|
|
|
|
|
}, { deep: true });*/
|
2024-07-31 15:02:30 +02:00
|
|
|
|
2024-10-31 23:23:06 +01:00
|
|
|
const filter = ref(<IFilterCatalogo>{
|
2024-05-04 14:49:09 +02:00
|
|
|
author: '',
|
|
|
|
|
publisher: '',
|
|
|
|
|
type: '',
|
|
|
|
|
ageGroup: ''
|
|
|
|
|
})
|
2024-01-30 14:00:48 +01:00
|
|
|
|
|
|
|
|
const cosa = ref(0)
|
|
|
|
|
const cat = ref('')
|
2024-05-04 14:49:09 +02:00
|
|
|
const idGasSel = ref('')
|
2024-01-30 14:00:48 +01:00
|
|
|
const loadpage = ref(false)
|
|
|
|
|
const refreshpage = ref(false)
|
2024-05-04 14:49:09 +02:00
|
|
|
const show_hide = ref(false)
|
2024-01-30 14:00:48 +01:00
|
|
|
|
2024-05-09 23:36:58 +02:00
|
|
|
const mycolumns = ref([])
|
|
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
const catalogStore = useCatalogStore()
|
|
|
|
|
|
2024-06-20 17:22:46 +02:00
|
|
|
const tabvisu = ref('categorie')
|
2025-03-31 23:55:53 +02:00
|
|
|
const tabcatalogo = ref()
|
2024-06-20 17:22:46 +02:00
|
|
|
|
2024-05-09 23:36:58 +02:00
|
|
|
const searchList = ref([] as ISearchList[])
|
|
|
|
|
|
2024-10-31 23:23:06 +01:00
|
|
|
const arrProducts = ref<IProduct[]>([])
|
|
|
|
|
const arrProdToView = ref<IProdView[]>([])
|
2024-01-30 14:00:48 +01:00
|
|
|
|
2024-05-04 14:49:09 +02:00
|
|
|
const numRecLoaded = ref(0)
|
|
|
|
|
|
2024-01-30 14:00:48 +01:00
|
|
|
// Create a ref for the component to fix
|
|
|
|
|
const componentToFixRef = ref(<any>null);
|
|
|
|
|
|
|
|
|
|
const isFixed = ref(false);
|
|
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
watch(() => tabcatalogo.value, () => {
|
|
|
|
|
tools.setCookie('TAB_CAT', tabcatalogo.value)
|
|
|
|
|
})
|
|
|
|
|
|
2024-05-09 23:36:58 +02:00
|
|
|
const labelcombo = computed(() => (item: any) => {
|
|
|
|
|
let lab = item.label
|
|
|
|
|
if (item.showcount)
|
|
|
|
|
lab += ' (' + valoriopt.value(item, false, false).length + ')'
|
|
|
|
|
return lab
|
|
|
|
|
})
|
|
|
|
|
|
2024-05-04 14:49:09 +02:00
|
|
|
const arrLoaded = computed(() => {
|
|
|
|
|
if (arrProducts.value && numRecLoaded.value)
|
|
|
|
|
return arrProducts.value.slice(0, numRecLoaded.value)
|
|
|
|
|
else {
|
|
|
|
|
return []
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
const getTestoIntroduttivo = computed(() => (recscheda: ISchedaSingola) => {
|
|
|
|
|
|
|
|
|
|
let testo = recscheda.scheda!.dimensioni.pagina?.testo_up?.contenuto
|
|
|
|
|
|
|
|
|
|
if (recscheda.scheda!.isPagIntro) {
|
|
|
|
|
|
|
|
|
|
const catalogStore = useCatalogStore()
|
2025-02-11 18:58:06 +01:00
|
|
|
const catalog = getCatalogoByMyPage.value
|
2025-02-10 22:48:53 +01:00
|
|
|
if (catalog && catalog.descr_introduttiva) {
|
|
|
|
|
// Cerca se la descrizione introduttiva è stata impostata
|
|
|
|
|
testo = catalog.descr_introduttiva
|
|
|
|
|
let clcol = ''
|
|
|
|
|
if (catalog.pagina_introduttiva_sfondo_nero) {
|
|
|
|
|
clcol = `text-white`
|
|
|
|
|
}
|
|
|
|
|
testo = `<span class="book-text-up ${clcol}">` + testo + `</span>`
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return testo
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
function getTextSostituito(testo: IText) {
|
|
|
|
|
const replacements = {
|
|
|
|
|
'{titolo_catalogo}': getTitoloCatalogo() || '',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Esegue le sostituzioni
|
|
|
|
|
let result = testo.contenuto;
|
|
|
|
|
for (const [key, value] of Object.entries(replacements)) {
|
|
|
|
|
result = result.replace(new RegExp(key, 'g'), value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getTitoloPagina = computed(() => (product: IProduct, recscheda: ISchedaSingola) => {
|
|
|
|
|
|
|
|
|
|
let testo = getTextSostituito(recscheda.scheda!.dimensioni.pagina?.testo_title)
|
|
|
|
|
|
|
|
|
|
return testo
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
const getCatalogoByMyPage = computed(() => {
|
|
|
|
|
return catalogStore.catalogs?.find((catalog: ICatalog) => catalog.idPageAssigned === props.idPage)
|
|
|
|
|
})
|
|
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
const lista_prodotti = computed(() => {
|
|
|
|
|
const arr = catalogStore.catalogs?.find((catalog: ICatalog) => catalog.idPageAssigned === props.idPage)
|
|
|
|
|
return arr?.lista_prodotti
|
|
|
|
|
})
|
|
|
|
|
|
2025-02-12 18:32:10 +01:00
|
|
|
const ispageCatalogata = computed(() => {
|
|
|
|
|
return !!getCatalogoByMyPage.value
|
|
|
|
|
})
|
|
|
|
|
|
2024-01-30 14:00:48 +01:00
|
|
|
// Register the scroll event on component mount
|
|
|
|
|
const handleScroll = () => {
|
|
|
|
|
const scrollTop = window.scrollY || document.documentElement.scrollTop;
|
|
|
|
|
|
|
|
|
|
// Set a threshold value based on how much scroll is needed to fix the components
|
2025-03-21 19:51:55 +01:00
|
|
|
const threshold = 300
|
2024-01-30 14:00:48 +01:00
|
|
|
|
|
|
|
|
// Update the isFixed ref based on the scroll position
|
|
|
|
|
isFixed.value = scrollTop > threshold;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
watch(() => cat.value, (newval, oldval) => {
|
2024-06-19 00:21:06 +02:00
|
|
|
|
2024-11-22 20:23:37 +01:00
|
|
|
if (loadpage.value)
|
|
|
|
|
tools.setCookie(tools.COOK_CATEGORIA, cat.value.toString())
|
2025-03-01 14:14:43 +01:00
|
|
|
filter.value.author = '' // disattivo il filtro autore
|
2024-11-22 20:23:37 +01:00
|
|
|
resetSearch()
|
2024-06-19 00:21:06 +02:00
|
|
|
|
2024-01-30 14:00:48 +01:00
|
|
|
calcArrProducts()
|
|
|
|
|
})
|
2024-05-04 14:49:09 +02:00
|
|
|
|
|
|
|
|
watch(() => idGasSel.value, (newval, oldval) => {
|
|
|
|
|
calcArrProducts()
|
|
|
|
|
})
|
|
|
|
|
|
2024-06-20 17:22:46 +02:00
|
|
|
watch(() => getSearchText(), (newval, oldval) => {
|
2024-01-30 14:00:48 +01:00
|
|
|
calcArrProducts()
|
|
|
|
|
if (tools.scrollTop() > 300) {
|
|
|
|
|
tools.scrollToTopValue(300)
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-05-09 23:36:58 +02:00
|
|
|
watch(() => filter.value.author, (newval, oldval) => {
|
|
|
|
|
|
2024-06-19 00:21:06 +02:00
|
|
|
// Se filtroAuthor attivato, allora evito il filtro per Categoria
|
|
|
|
|
if (filter.value.author) {
|
|
|
|
|
cat.value = '' // disattivo il filtro categoria
|
2024-07-31 15:02:30 +02:00
|
|
|
if (loadpage.value)
|
|
|
|
|
tools.setCookie(tools.COOK_CATEGORIA, '')
|
2024-06-20 17:22:46 +02:00
|
|
|
resetSearch()
|
2024-06-19 00:21:06 +02:00
|
|
|
}
|
|
|
|
|
|
2024-05-09 23:36:58 +02:00
|
|
|
calcArrProducts()
|
|
|
|
|
if (tools.scrollTop() > 300) {
|
|
|
|
|
tools.scrollToTopValue(300)
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-01-30 14:00:48 +01:00
|
|
|
|
2025-01-07 17:17:08 +01:00
|
|
|
watch(() => filter.value.sort_field, (newval, oldval) => {
|
|
|
|
|
|
|
|
|
|
calcArrProducts()
|
|
|
|
|
if (tools.scrollTop() > 300) {
|
|
|
|
|
tools.scrollToTopValue(300)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
watch(() => filter.value.sort_dir, (newval, oldval) => {
|
2024-07-03 13:22:57 +02:00
|
|
|
|
|
|
|
|
calcArrProducts()
|
|
|
|
|
if (tools.scrollTop() > 300) {
|
|
|
|
|
tools.scrollToTopValue(300)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2024-01-30 14:00:48 +01:00
|
|
|
watch(() => cosa.value, (newval, oldval) => {
|
2024-07-31 15:02:30 +02:00
|
|
|
if (oldval !== 0) {
|
|
|
|
|
tools.setCookie(tools.COOK_COSA_PRODOTTI, cosa.value.toString())
|
|
|
|
|
if (cosa.value !== shared_consts.PROD.TUTTI) {
|
|
|
|
|
cat.value = ''
|
|
|
|
|
if (loadpage.value)
|
|
|
|
|
tools.setCookie(tools.COOK_CATEGORIA, '')
|
|
|
|
|
}
|
|
|
|
|
calcArrProducts()
|
|
|
|
|
}
|
2024-01-30 14:00:48 +01:00
|
|
|
})
|
|
|
|
|
|
2024-12-09 12:32:19 +01:00
|
|
|
watch(() => optcatalogo.value.aggiorna, (newval, oldval) => {
|
2024-11-24 14:40:29 +01:00
|
|
|
console.log('Aggiorna array...')
|
|
|
|
|
generatearrProdToViewSorted()
|
|
|
|
|
})
|
|
|
|
|
|
2024-06-20 17:22:46 +02:00
|
|
|
function resetSearch() {
|
|
|
|
|
const mialista = getSearchList()
|
2025-03-01 14:14:43 +01:00
|
|
|
if (mialista && mialista.value && tools.existProp(mialista.value, 'name')) {
|
2024-06-20 17:22:46 +02:00
|
|
|
mialista.value = null
|
2024-07-03 13:22:57 +02:00
|
|
|
}
|
2024-06-20 17:22:46 +02:00
|
|
|
search.value = ''
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSearchList() {
|
|
|
|
|
const mylist = searchList.value.find((rec: any) => rec.table === 'products' && rec.key === 'titolo')
|
|
|
|
|
|
|
|
|
|
return mylist
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSearchText(): string {
|
|
|
|
|
const lista = getSearchList()
|
2025-03-01 14:14:43 +01:00
|
|
|
return lista && lista.value && tools.existProp(lista.value, 'name') ? lista.value.name : ''
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getTitoloCatalogo(): string {
|
|
|
|
|
const trovatocatalogo = getCatalogoByMyPage.value
|
|
|
|
|
|
|
|
|
|
return trovatocatalogo ? trovatocatalogo.title : 'Catalogo'
|
2024-06-20 17:22:46 +02:00
|
|
|
}
|
|
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
function getImgIntroCatalogo(scheda: IMyScheda): IImg {
|
2025-03-01 14:14:43 +01:00
|
|
|
const trovatocatalogo = getCatalogoByMyPage.value
|
2025-02-05 12:13:36 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
let imagefile = ''
|
2025-03-26 23:23:35 +01:00
|
|
|
let fit = 'contain'
|
2025-02-05 12:13:36 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
if (trovatocatalogo && scheda.isPagIntro) {
|
|
|
|
|
const recimg = trovatocatalogo.img_intro
|
|
|
|
|
if (recimg) {
|
|
|
|
|
imagefile = recimg.imagefile!
|
|
|
|
|
fit = recimg.fit! || 'contain'
|
2025-03-01 14:14:43 +01:00
|
|
|
imagefile = imagefile ? `url(${tools.getDirUpload() + shared_consts.getDirectoryByTable(shared_consts.TABLES_CATALOG) + '/' + trovatocatalogo._id + '/' + imagefile})` : ''
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { imagefile, fit }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSfondoImgCatalogo(scheda?: IMyScheda | null, mypage?: IDimensioni): IImg {
|
2025-03-01 14:14:43 +01:00
|
|
|
const trovatocatalogo = getCatalogoByMyPage.value
|
2025-02-10 22:48:53 +01:00
|
|
|
|
|
|
|
|
let imagefile = ''
|
2025-03-26 23:23:35 +01:00
|
|
|
let fit = 'contain'
|
2025-02-10 22:48:53 +01:00
|
|
|
|
|
|
|
|
if (trovatocatalogo) {
|
|
|
|
|
// Cerca prima se c'è un Immagine Introduttiva
|
2025-03-01 14:14:43 +01:00
|
|
|
const recimgintro = getImgIntroCatalogo(scheda)
|
2025-02-10 22:48:53 +01:00
|
|
|
if (recimgintro.imagefile) {
|
|
|
|
|
imagefile = recimgintro.imagefile!
|
|
|
|
|
fit = recimgintro.fit! || 'contain'
|
|
|
|
|
}
|
2025-02-05 12:13:36 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
// Poi cerca se c'è l'immagine di sfondo
|
|
|
|
|
const recimg = trovatocatalogo.img_bordata!
|
|
|
|
|
if (!imagefile && recimg) {
|
|
|
|
|
imagefile = recimg.imagefile!
|
|
|
|
|
fit = recimg.fit! || 'contain'
|
2025-03-01 14:14:43 +01:00
|
|
|
imagefile = imagefile ? `url(${tools.getDirUpload() + shared_consts.getDirectoryByTable(shared_consts.TABLES_CATALOG) + '/' + trovatocatalogo._id + '/' + imagefile})` : ''
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
2025-03-26 23:23:35 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (!imagefile) {
|
|
|
|
|
let myimg = costanti.CATALOGHI.PAG_SFONDO_DEFAULT
|
|
|
|
|
if (scheda.isPagIntro) {
|
|
|
|
|
myimg = costanti.CATALOGHI.PAG_INTRO_DEFAULT
|
|
|
|
|
}
|
|
|
|
|
// Se non c'è un immagine di sfondo, allora prende quella di default
|
|
|
|
|
imagefile = `url(${tools.getDirUpload() + shared_consts.getDirectoryByTable(shared_consts.TABLES_CATALOG) + '/' + myimg})`
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!imagefile && scheda) {
|
2025-03-01 14:14:43 +01:00
|
|
|
imagefile = scheda.dimensioni?.pagina?.dimensioni?.imgsfondo!.imagefile
|
|
|
|
|
imagefile = imagefile ? `url(${tools.getDirUpload() + costanti.DIR_SCHEDA + imagefile})` : ''
|
|
|
|
|
fit = scheda.dimensioni?.pagina?.dimensioni?.imgsfondo!.fit
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
|
|
|
|
if (!imagefile && mypage) {
|
|
|
|
|
imagefile = mypage.imgsfondo!.imagefile!
|
2025-03-01 14:14:43 +01:00
|
|
|
imagefile = imagefile ? `url(${tools.getDirUpload() + costanti.DIR_CATALOGO + imagefile})` : ''
|
2025-02-10 22:48:53 +01:00
|
|
|
fit = mypage.imgsfondo!.fit!
|
|
|
|
|
}
|
2025-02-05 12:13:36 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
return { imagefile, fit }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getIdCollaneDaFiltrare(def_idCollane?: number[]) {
|
|
|
|
|
let idCollane: number[] = []
|
|
|
|
|
|
|
|
|
|
// Cerca se nella lista cataloghi c'è la Collana di questa Pagina !
|
2025-03-01 14:14:43 +01:00
|
|
|
const trovatocatalogo = getCatalogoByMyPage.value
|
2025-02-10 22:48:53 +01:00
|
|
|
|
|
|
|
|
if (trovatocatalogo) {
|
|
|
|
|
idCollane = trovatocatalogo.idCollane! || []
|
2025-02-05 12:13:36 +01:00
|
|
|
} else {
|
2025-02-10 22:48:53 +01:00
|
|
|
idCollane = def_idCollane || []
|
2025-02-05 12:13:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return idCollane
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-11 18:58:06 +01:00
|
|
|
function getArgomentiDaFiltrare(def_argomenti?: string[]) {
|
|
|
|
|
let argomenti: string[] = []
|
|
|
|
|
|
|
|
|
|
// Cerca se nella lista cataloghi c'è la Collana di questa Pagina !
|
2025-03-01 14:14:43 +01:00
|
|
|
const trovatocatalogo = getCatalogoByMyPage.value
|
2025-02-11 18:58:06 +01:00
|
|
|
|
|
|
|
|
if (trovatocatalogo) {
|
|
|
|
|
argomenti = trovatocatalogo.argomenti! || []
|
|
|
|
|
} else {
|
2025-03-01 14:14:43 +01:00
|
|
|
if (def_argomenti && def_argomenti.length > 0) {
|
|
|
|
|
argomenti = def_argomenti
|
|
|
|
|
} else {
|
|
|
|
|
argomenti = []
|
|
|
|
|
}
|
2025-02-11 18:58:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return argomenti
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
function getEditoreDaFiltrare(def_editori?: string[]) {
|
|
|
|
|
let editore: string[] = []
|
|
|
|
|
|
|
|
|
|
// Cerca se nella lista cataloghi c'è la Collana di questa Pagina !
|
2025-03-01 14:14:43 +01:00
|
|
|
const trovatocatalogo = getCatalogoByMyPage.value
|
2025-02-10 22:48:53 +01:00
|
|
|
|
|
|
|
|
if (trovatocatalogo) {
|
|
|
|
|
editore = trovatocatalogo.editore! || []
|
|
|
|
|
} else {
|
|
|
|
|
editore = def_editori || []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return editore
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-28 16:04:48 +01:00
|
|
|
|
|
|
|
|
function sovrascriviSchedaFromTemplate(idTemplate: string, origScheda: ISchedaSingola) {
|
2024-12-09 12:32:19 +01:00
|
|
|
if (!optcatalogo.value)
|
2024-11-28 16:04:48 +01:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
const arrschede: ISchedaSingola[] = globalStore.getMySchede()
|
|
|
|
|
const myfindscheda = arrschede.find((recscheda: ISchedaSingola) => recscheda.scheda?._id === idTemplate)
|
|
|
|
|
|
2025-03-01 14:14:43 +01:00
|
|
|
const mynewscheda = tools.jsonCopy(origScheda)
|
2024-11-28 16:04:48 +01:00
|
|
|
|
|
|
|
|
const linkIdTemplate = origScheda.scheda?.linkIdTemplate
|
|
|
|
|
const precname = origScheda.scheda?.name
|
|
|
|
|
|
|
|
|
|
if (myfindscheda) {
|
2025-03-01 14:14:43 +01:00
|
|
|
const myschedatocopy = tools.jsonCopy(myfindscheda)
|
2024-11-28 16:04:48 +01:00
|
|
|
|
|
|
|
|
if (myschedatocopy) {
|
|
|
|
|
myschedatocopy.scheda._id = origScheda.scheda?._id
|
|
|
|
|
myschedatocopy.scheda.isTemplate = false
|
|
|
|
|
myschedatocopy.scheda.name = precname
|
|
|
|
|
myschedatocopy.scheda.linkIdTemplate = linkIdTemplate
|
|
|
|
|
|
|
|
|
|
return myschedatocopy.scheda
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function populateDataWithlinkIdTemplate() {
|
2025-03-01 14:14:43 +01:00
|
|
|
// console.log('populateDataWithlinkIdTemplate')
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2024-12-09 12:32:19 +01:00
|
|
|
if (optcatalogo.value) {
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2024-12-09 12:32:19 +01:00
|
|
|
for (const recscheda of optcatalogo.value.arrSchede!) {
|
2024-11-28 16:04:48 +01:00
|
|
|
if (recscheda.scheda?.linkIdTemplate) {
|
|
|
|
|
// ricopia da Template:
|
|
|
|
|
const myscheda = sovrascriviSchedaFromTemplate(recscheda.scheda?.linkIdTemplate, recscheda)
|
|
|
|
|
if (myscheda) {
|
|
|
|
|
recscheda.scheda = myscheda
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-01 14:14:43 +01:00
|
|
|
// console.log(' FINE - populateDataWithlinkIdTemplate')
|
2024-11-28 16:04:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
function filterProducts(
|
|
|
|
|
products: IProduct[],
|
|
|
|
|
searchtext: string | string[],
|
|
|
|
|
filtroAuthor: string,
|
|
|
|
|
filtroProductTypes: number[],
|
|
|
|
|
filtroExcludeProductTypes: number[],
|
|
|
|
|
editore: string[],
|
2025-03-31 23:55:53 +02:00
|
|
|
idCollane: number[],
|
2025-03-26 23:23:35 +01:00
|
|
|
arrargomstr: any[],
|
|
|
|
|
catstr: string,
|
|
|
|
|
gasselstr: string,
|
|
|
|
|
cosaValue: any,
|
|
|
|
|
sortField?: string,
|
2025-03-31 23:55:53 +02:00
|
|
|
sortDir?: number
|
2025-03-26 23:23:35 +01:00
|
|
|
): IProduct[] {
|
|
|
|
|
const lowerSearchTexts = Array.isArray(searchtext)
|
|
|
|
|
? searchtext.map((text: string) => text.toLowerCase().trim().replace(/[-@:=]/g, ''))
|
|
|
|
|
: [searchtext.toLowerCase().trim().replace(/[-@:=]/g, '')];
|
|
|
|
|
|
|
|
|
|
const boolfiltroVuotoProductTypes =
|
|
|
|
|
filtroProductTypes.length === 0 || (filtroProductTypes.length === 1 && filtroProductTypes[0] === 0);
|
|
|
|
|
const boolfiltroVuotoExcludeProductTypes = filtroExcludeProductTypes.length === 0;
|
|
|
|
|
const boolfiltroVuotoEditore = editore.length === 0;
|
|
|
|
|
const boolfiltroVuotoCollane = idCollane.length === 0;
|
2025-03-31 23:55:53 +02:00
|
|
|
// const boolfiltroVuotoArgomenti = arrargomstr.length === 0;
|
2025-03-26 23:23:35 +01:00
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
const arrris = products
|
2025-03-26 23:23:35 +01:00
|
|
|
.filter((product: IProduct) => {
|
|
|
|
|
if (!product || !product.productInfo) {
|
|
|
|
|
console.error('product or product.productInfo is null');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-03-01 14:14:43 +01:00
|
|
|
const lowerName = (product.productInfo.name || '').toLowerCase();
|
|
|
|
|
const lowerCode = (product.productInfo.code || '').toLowerCase();
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
// Filtri per argomenti e categorie
|
|
|
|
|
let hasCategoria = false;
|
|
|
|
|
let hasArgomentiCat = true;
|
2025-01-07 17:17:08 +01:00
|
|
|
if (arrargomstr && arrargomstr.length > 0) {
|
2025-03-26 23:23:35 +01:00
|
|
|
hasArgomentiCat = (product.productInfo.idCatProds || []).some((idCat: any) => arrargomstr.includes(idCat));
|
|
|
|
|
hasCategoria = true;
|
2025-02-11 18:58:06 +01:00
|
|
|
} else {
|
2025-03-26 23:23:35 +01:00
|
|
|
hasCategoria = !catstr || (catstr && (product.productInfo.idCatProds || []).includes(catstr));
|
2025-01-07 17:17:08 +01:00
|
|
|
}
|
|
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
// Filtri per autore
|
|
|
|
|
const hasAuthor = !filtroAuthor || (product.productInfo.idAuthors || []).includes(filtroAuthor);
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
// Filtri per tipi di prodotto
|
|
|
|
|
const hasProductTypes = boolfiltroVuotoProductTypes
|
|
|
|
|
? true
|
|
|
|
|
: (product.productInfo.productTypes || []).some((item: any) => filtroProductTypes.includes(item));
|
|
|
|
|
|
|
|
|
|
// Filtri per esclusione di tipi di prodotto
|
|
|
|
|
const hasExcludeProductTypes = boolfiltroVuotoExcludeProductTypes
|
|
|
|
|
? false
|
|
|
|
|
: (product.productInfo.productTypes || []).every((item: any) => filtroExcludeProductTypes.includes(item));
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
// Filtri per editore
|
|
|
|
|
const hasPublished = boolfiltroVuotoEditore
|
|
|
|
|
? true
|
|
|
|
|
: editore.includes(product.productInfo.idPublisher);
|
|
|
|
|
|
|
|
|
|
// Filtri per collana
|
|
|
|
|
const hasCollana = boolfiltroVuotoCollane
|
|
|
|
|
? true
|
|
|
|
|
: idCollane.includes(product.productInfo.idCollana);
|
|
|
|
|
|
|
|
|
|
// Filtri per GAS
|
|
|
|
|
const productgassel = !gasselstr || (cosaValue === shared_consts.PROD.GAS && product.idGasordine === gasselstr);
|
|
|
|
|
|
|
|
|
|
// Filtri per testo di ricerca
|
|
|
|
|
const searchMatch = lowerSearchTexts.length === 0 || lowerSearchTexts.some((searchTerm: string) => {
|
|
|
|
|
const codeMatch = new RegExp(`\\b${searchTerm}\\b`, 'i').test(lowerCode);
|
2025-03-01 14:14:43 +01:00
|
|
|
const allWordsPresent = searchTerm.split(/\s+/).every((word: string) =>
|
2024-10-31 23:23:06 +01:00
|
|
|
new RegExp(`\\b${word}\\b`, 'i').test(lowerName)
|
|
|
|
|
);
|
|
|
|
|
return codeMatch || allWordsPresent;
|
|
|
|
|
});
|
|
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
return (
|
|
|
|
|
searchMatch &&
|
|
|
|
|
hasAuthor &&
|
|
|
|
|
productgassel &&
|
|
|
|
|
hasProductTypes &&
|
|
|
|
|
(
|
2025-03-31 23:55:53 +02:00
|
|
|
hasPublished &&
|
|
|
|
|
hasCollana &&
|
|
|
|
|
hasCategoria &&
|
2025-03-26 23:23:35 +01:00
|
|
|
hasArgomentiCat
|
|
|
|
|
)
|
|
|
|
|
&&
|
|
|
|
|
!hasExcludeProductTypes
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
.sort((a, b) => getProductsSorted([a, b], sortField, sortDir)[0] === a ? -1 : 1);
|
2025-03-31 23:55:53 +02:00
|
|
|
|
|
|
|
|
console.log(' Filtro=' + arrargomstr)
|
|
|
|
|
console.log(' idCollane=' + idCollane)
|
|
|
|
|
console.log('PRODOTTI FILTRATI:', arrris.length)
|
|
|
|
|
|
|
|
|
|
return arrris
|
2025-03-26 23:23:35 +01:00
|
|
|
}
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
function calcArrProducts(generalista?: boolean) {
|
|
|
|
|
console.log('calcArrProducts (generalista=' + generalista + ')')
|
|
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
const searchtext = getSearchText();
|
2025-03-31 23:55:53 +02:00
|
|
|
let arrprod = [];
|
2025-03-26 23:23:35 +01:00
|
|
|
const filtroAuthor = filter.value.author || '';
|
|
|
|
|
const filtroProductTypes = optcatalogo.value.productTypes || [0];
|
|
|
|
|
const filtroExcludeProductTypes = optcatalogo.value.excludeproductTypes || [0];
|
|
|
|
|
const editore = getEditoreDaFiltrare(optcatalogo.value.editore);
|
|
|
|
|
const filtroPublishers = editore || [];
|
|
|
|
|
const idCollane = getIdCollaneDaFiltrare(optcatalogo.value.idCollane);
|
|
|
|
|
const filtroCollane = idCollane || [];
|
|
|
|
|
const arrargomstr = optcatalogo.value.argomenti && optcatalogo.value.argomenti.length > 0
|
|
|
|
|
? getArgomentiDaFiltrare(optcatalogo.value.argomenti)
|
|
|
|
|
: getArgomentiDaFiltrare(cat.value ? [cat.value] : []);
|
|
|
|
|
const catstr = cat.value || '';
|
|
|
|
|
const gasselstr = cosa.value === shared_consts.PROD.GAS ? idGasSel.value || '' : '';
|
|
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
let salva = false
|
|
|
|
|
// Se nel catalogo è stato già generato, allora gli passo quello.
|
|
|
|
|
const trovatocatalogo = getCatalogoByMyPage.value
|
|
|
|
|
|
|
|
|
|
if (trovatocatalogo.lista_prodotti.length === 0) {
|
|
|
|
|
generalista = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!generalista && (trovatocatalogo.lista_prodotti.length > 0)) {
|
|
|
|
|
arrprod = trovatocatalogo.lista_prodotti
|
|
|
|
|
} else {
|
|
|
|
|
arrprod = productStore.getProducts(cosa.value)
|
|
|
|
|
arrprod = filterProducts(
|
|
|
|
|
arrprod,
|
|
|
|
|
searchtext,
|
|
|
|
|
filtroAuthor,
|
|
|
|
|
filtroProductTypes,
|
|
|
|
|
filtroExcludeProductTypes,
|
|
|
|
|
filtroPublishers,
|
|
|
|
|
filtroCollane,
|
|
|
|
|
arrargomstr,
|
|
|
|
|
catstr,
|
|
|
|
|
gasselstr,
|
|
|
|
|
cosa.value,
|
|
|
|
|
filter.value.sort_field,
|
|
|
|
|
filter.value.sort_dir
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
salva = true
|
|
|
|
|
}
|
2025-03-26 23:23:35 +01:00
|
|
|
|
|
|
|
|
arrProducts.value = arrprod;
|
2025-03-31 23:55:53 +02:00
|
|
|
|
|
|
|
|
console.log('arrprod', arrprod)
|
|
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
populateDataWithlinkIdTemplate();
|
2025-03-31 23:55:53 +02:00
|
|
|
generatearrProdToViewSorted(!generalista, salva);
|
2025-03-26 23:23:35 +01:00
|
|
|
loaddata();
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
refreshpage.value = false;
|
|
|
|
|
}
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
function generaListaLibri() {
|
|
|
|
|
calcArrProducts(true)
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
function getProductsFilteredByScheda(scheda: IMyScheda): IProduct[] {
|
|
|
|
|
let arrprod = productStore.getProducts(cosa.value) || [];
|
|
|
|
|
const filtroAuthor = filter.value.author || '';
|
|
|
|
|
const filtroProductTypes = scheda.productTypes || [0];
|
|
|
|
|
const filtroExcludeProductTypes = scheda.excludeproductTypes || [0];
|
|
|
|
|
const editore = getEditoreDaFiltrare(scheda.editore);
|
|
|
|
|
const filtroPublishers = editore || [];
|
|
|
|
|
const idCollane = getIdCollaneDaFiltrare(scheda.idCollane);
|
|
|
|
|
const filtroCollane = idCollane || [];
|
|
|
|
|
const arrargomstr = optcatalogo.value.argomenti && optcatalogo.value.argomenti.length > 0
|
|
|
|
|
? getArgomentiDaFiltrare(optcatalogo.value.argomenti)
|
|
|
|
|
: [];
|
|
|
|
|
const catstr = cat.value || '';
|
|
|
|
|
const gasselstr = cosa.value === shared_consts.PROD.GAS ? idGasSel.value || '' : '';
|
|
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
const trovatocatalogo = getCatalogoByMyPage.value
|
|
|
|
|
if (trovatocatalogo.lista_prodotti.length > 0) {
|
|
|
|
|
arrprod = trovatocatalogo.lista_prodotti
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
arrprod = filterProducts(
|
|
|
|
|
arrprod,
|
|
|
|
|
scheda.arrProdottiSpeciali || [],
|
|
|
|
|
filtroAuthor,
|
|
|
|
|
filtroProductTypes,
|
|
|
|
|
filtroExcludeProductTypes,
|
|
|
|
|
filtroPublishers,
|
|
|
|
|
filtroCollane,
|
|
|
|
|
arrargomstr,
|
|
|
|
|
catstr,
|
|
|
|
|
gasselstr,
|
|
|
|
|
cosa.value,
|
|
|
|
|
scheda?.sort_field,
|
|
|
|
|
scheda?.sort_dir
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-03-26 23:23:35 +01:00
|
|
|
|
|
|
|
|
return arrprod;
|
2024-11-28 16:04:48 +01:00
|
|
|
}
|
|
|
|
|
|
2025-01-07 17:17:08 +01:00
|
|
|
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];
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-01-07 17:17:08 +01:00
|
|
|
if (valA === undefined || valB === undefined) {
|
|
|
|
|
return 0; // Gestisce il caso in cui il campo non esiste
|
|
|
|
|
}
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-01-07 17:17:08 +01:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-01-07 17:17:08 +01:00
|
|
|
return sortedArr.map((product, index) => ({
|
|
|
|
|
...product,
|
|
|
|
|
indiceRanking: index + 1
|
|
|
|
|
}));
|
2024-10-31 23:23:06 +01:00
|
|
|
}
|
|
|
|
|
|
2025-01-07 17:17:08 +01:00
|
|
|
return arrprod;
|
2024-10-31 23:23:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addNextProductToTheView(arrproductfiltrati: IProduct[], indprod: number) {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
let rectrovato = null;
|
|
|
|
|
while (true) {
|
|
|
|
|
if (indprod >= arrproductfiltrati.length) {
|
|
|
|
|
return { end: true }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e);
|
|
|
|
|
return { rec: null, indprod }; // Assicurati di gestire correttamente l'errore
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-19 19:19:14 +01:00
|
|
|
function getProdBySchedaRigaCol(recscheda: ISchedaSingola, pagina: number, riga: number, col: number) {
|
2024-10-31 23:23:06 +01:00
|
|
|
try {
|
2024-11-19 19:19:14 +01:00
|
|
|
return recscheda.arrProdToShow![pagina][riga][col]
|
2024-10-31 23:23:06 +01:00
|
|
|
} catch (e) {
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
function generatearrProdToViewSorted(usaprodottiSalvati?: boolean, salva?: boolean) {
|
|
|
|
|
console.log('generatearrProdToViewSorted... usaprodottiSalvati=', usaprodottiSalvati, ' salva=', salva)
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
try {
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
// Svuota
|
|
|
|
|
arrProdToView.value = []
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
const trovatocatalogo = getCatalogoByMyPage.value
|
|
|
|
|
|
|
|
|
|
let arrGeneraleProdotti = []
|
|
|
|
|
|
|
|
|
|
if (usaprodottiSalvati) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
arrGeneraleProdotti = arrProducts.value;
|
|
|
|
|
}
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
let indprod = 0
|
2025-03-01 14:14:43 +01:00
|
|
|
const indprodGenerale = 0
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-02-11 18:58:06 +01:00
|
|
|
let indtotale = 0
|
|
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
let arrprod = []
|
|
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
for (const recscheda of optcatalogo.value.arrSchede!) {
|
|
|
|
|
if (recscheda && recscheda.scheda) {
|
2025-03-01 14:14:43 +01:00
|
|
|
const schedePerRiga = recscheda.scheda.numschede_perRiga || 1
|
|
|
|
|
const schedePerCol = recscheda.scheda.numschede_perCol || 1
|
|
|
|
|
const schedePerPagina = schedePerRiga * schedePerCol
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
let arrProdFiltrati: IProduct[] = []
|
|
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
if (usaprodottiSalvati && trovatocatalogo.lista_prodotti.length > 0) {
|
|
|
|
|
arrProdFiltrati = trovatocatalogo.lista_prodotti
|
2024-11-28 16:04:48 +01:00
|
|
|
} else {
|
2025-03-31 23:55:53 +02:00
|
|
|
if (recscheda.scheda.productTypes!.length > 0) {
|
|
|
|
|
// Filtra i prodotti in base ai filtri impostati !
|
|
|
|
|
arrProdFiltrati = getProductsFilteredByScheda(recscheda.scheda)
|
2025-02-10 22:48:53 +01:00
|
|
|
indprod = 0
|
|
|
|
|
} else {
|
2025-03-31 23:55:53 +02:00
|
|
|
if (recscheda.scheda.sort_field!) {
|
|
|
|
|
arrProdFiltrati = getProductsSorted(arrGeneraleProdotti, recscheda.scheda.sort_field, recscheda.scheda.sort_dir);
|
|
|
|
|
indprod = 0
|
|
|
|
|
} else {
|
|
|
|
|
indprod = indprodGenerale
|
|
|
|
|
arrProdFiltrati = arrGeneraleProdotti
|
|
|
|
|
}
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
2024-11-28 16:04:48 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
let indadded = 0
|
|
|
|
|
recscheda.arrProdToShow = []
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
for (let pagina = 0; pagina < 60; pagina++) {
|
|
|
|
|
indadded = 0
|
|
|
|
|
if (!recscheda.arrProdToShow[pagina]) {
|
|
|
|
|
recscheda.arrProdToShow[pagina] = [];
|
|
|
|
|
}
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
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) {
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-03-01 14:14:43 +01:00
|
|
|
const riga = Math.floor(indadded / schedePerCol)
|
|
|
|
|
const col = indadded % schedePerCol
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
if (!recscheda.arrProdToShow[pagina][riga]) {
|
|
|
|
|
recscheda.arrProdToShow[pagina][riga] = [];
|
|
|
|
|
}
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
// console.log('RANKING: ', result.myrec.indiceRanking!)
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
arrprod.push(result.myrec)
|
|
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
recscheda.arrProdToShow[pagina][riga][col] = result.myrec
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
indadded++
|
2025-02-11 18:58:06 +01:00
|
|
|
indtotale++
|
2025-02-10 22:48:53 +01:00
|
|
|
// console.log('indadded', indadded)
|
2025-02-11 18:58:06 +01:00
|
|
|
if (optcatalogo.value.maxnumlibri! > 0) {
|
|
|
|
|
if (indtotale > optcatalogo.value.maxnumlibri!)
|
|
|
|
|
return
|
2025-03-01 14:14:43 +01:00
|
|
|
|
2025-02-11 18:58:06 +01:00
|
|
|
} else {
|
|
|
|
|
if (indtotale > 200)
|
|
|
|
|
return
|
|
|
|
|
}
|
2025-03-01 14:14:43 +01:00
|
|
|
|
2024-11-19 19:19:14 +01:00
|
|
|
}
|
|
|
|
|
}
|
2024-10-31 23:23:06 +01:00
|
|
|
}
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-02-11 18:58:06 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
if (recscheda.numPagineMax! > 0) {
|
|
|
|
|
if (pagina + 1 >= recscheda.numPagineMax!)
|
|
|
|
|
break; // fine pagine
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-11 18:58:06 +01:00
|
|
|
|
2024-11-28 16:04:48 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
// console.log('*** arrProdToShow', recscheda.arrProdToShow)
|
2024-10-31 23:23:06 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
// console.log('Fine Generazione')
|
2024-10-31 23:23:06 +01:00
|
|
|
}
|
2025-02-10 22:48:53 +01:00
|
|
|
|
2025-03-01 14:14:43 +01:00
|
|
|
// console.log(' FINE - generatearrProdToViewSorted !')
|
2025-02-11 18:58:06 +01:00
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
|
|
|
|
|
if (!usaprodottiSalvati && salva) {
|
|
|
|
|
trovatocatalogo.lista_prodotti = arrprod
|
|
|
|
|
|
|
|
|
|
salvaListaProdotti(false)
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
} catch (e) {
|
|
|
|
|
console.error('Err', e)
|
2024-10-31 23:23:06 +01:00
|
|
|
}
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-01-07 17:17:08 +01:00
|
|
|
// console.log('Fine...')
|
2024-10-31 23:23:06 +01:00
|
|
|
}
|
|
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
function salvaListaProdotti(ricarica: boolean) {
|
|
|
|
|
// Estrai solo gli ID dei prodotti filtrati
|
|
|
|
|
const myarr = [...getCatalogoByMyPage.value.lista_prodotti]
|
|
|
|
|
const productIds = myarr.map(product => product._id);
|
|
|
|
|
|
|
|
|
|
let mydata = {
|
|
|
|
|
lista_prodotti: productIds
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Salva gli ID dei prodotti nel catalogo
|
|
|
|
|
tools.saveFieldToServer($q, 'catalogs', getCatalogoByMyPage.value._id, mydata, true, false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ricarica) {
|
|
|
|
|
generatearrProdToViewSorted(true, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-31 23:23:06 +01:00
|
|
|
function getNextProd() {
|
2025-03-01 14:14:43 +01:00
|
|
|
const nextRecord = arrProdToView.value.find((rec: any) => !rec.showed)
|
2024-10-31 23:23:06 +01:00
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-09 23:36:58 +02:00
|
|
|
|
2024-01-30 14:00:48 +01:00
|
|
|
/*function getProducts() {
|
|
|
|
|
let arrprod = productStore.getProducts(cosa.value)
|
|
|
|
|
if (!search.value) {
|
|
|
|
|
return arrprod
|
|
|
|
|
}
|
2025-03-01 14:14:43 +01:00
|
|
|
|
2024-01-30 14:00:48 +01:00
|
|
|
let lowerSearchText = search.value.toLowerCase();
|
|
|
|
|
let catstr = cat.value;
|
2025-03-01 14:14:43 +01:00
|
|
|
|
2024-01-30 14:00:48 +01:00
|
|
|
return arrprod.filter((product: IProduct) => {
|
|
|
|
|
let lowerName = product.productInfo.name!.toLowerCase();
|
|
|
|
|
const hasCategoria = !catstr || (catstr && product.productInfo.idCatProds?.includes(catstr));
|
|
|
|
|
return (product.productInfo.code!.includes(search.value) || lowerName.includes(lowerSearchText)) && hasCategoria
|
|
|
|
|
});
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
async function mounted() {
|
2025-01-07 17:17:08 +01:00
|
|
|
// console.log('mounted Catalogo')
|
2025-03-31 23:55:53 +02:00
|
|
|
|
|
|
|
|
tabcatalogo.value = tools.getCookie('TAB_CAT', 'visu')
|
|
|
|
|
|
2024-01-30 14:00:48 +01:00
|
|
|
loadpage.value = false
|
|
|
|
|
await productStore.loadProducts()
|
2024-05-09 23:36:58 +02:00
|
|
|
|
|
|
|
|
mycolumns.value = fieldsTable.getArrColsByTable('products')
|
|
|
|
|
|
|
|
|
|
searchList.value = [
|
|
|
|
|
{
|
2025-01-15 15:39:58 +01:00
|
|
|
visible: true,
|
2024-05-09 23:36:58 +02:00
|
|
|
label: 'Ricerca',
|
|
|
|
|
table: 'products',
|
|
|
|
|
key: 'titolo',
|
|
|
|
|
type: costanti.FieldType.select_by_server,
|
|
|
|
|
value: '',
|
2024-06-20 17:22:46 +02:00
|
|
|
// addall: true,
|
2024-05-09 23:36:58 +02:00
|
|
|
arrvalue: [],
|
|
|
|
|
useinput: true,
|
|
|
|
|
filter: null,
|
|
|
|
|
tablesel: 'products',
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
optauthors.value = productStore.getAuthors()
|
|
|
|
|
|
2024-06-20 17:22:46 +02:00
|
|
|
//++Todo: Per ora visualizzo solo il "Negozio" e non i GAS...
|
|
|
|
|
cosa.value = shared_consts.PROD.BOTTEGA
|
|
|
|
|
|
2024-07-31 15:02:30 +02:00
|
|
|
cat.value = tools.getCookie(tools.COOK_CATEGORIA, '')
|
|
|
|
|
|
2024-06-20 17:22:46 +02:00
|
|
|
//cosa.value = tools.getCookie(tools.COOK_COSA_PRODOTTI, shared_consts.PROD.GAS, true)
|
|
|
|
|
//if (cosa.value === shared_consts.PROD.TUTTI)
|
|
|
|
|
|
2024-05-04 14:49:09 +02:00
|
|
|
|
2024-01-30 14:00:48 +01:00
|
|
|
// Inizializza
|
|
|
|
|
loadpage.value = true
|
|
|
|
|
window.addEventListener('scroll', handleScroll);
|
|
|
|
|
|
|
|
|
|
calcArrProducts()
|
2024-05-04 14:49:09 +02:00
|
|
|
|
|
|
|
|
loaddata()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loaddata() {
|
|
|
|
|
numRecLoaded.value = 20
|
2024-01-30 14:00:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove the event listener on component destroy
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
window.removeEventListener('scroll', handleScroll);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function getCatProds() {
|
2025-03-01 14:14:43 +01:00
|
|
|
const arrcat = productStore.getCatProds(cosa.value)
|
|
|
|
|
const riscat: any = [{ label: 'Tutti', value: '', icon: undefined, color: undefined }]
|
2024-01-30 14:00:48 +01:00
|
|
|
for (const rec of arrcat) {
|
|
|
|
|
riscat.push({ label: rec.name, value: rec._id, icon: rec.icon, color: rec.color })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return riscat
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-04 14:49:09 +02:00
|
|
|
|
|
|
|
|
function onLoadScroll(index: number, done: any) {
|
|
|
|
|
if (index >= 1) {
|
|
|
|
|
if (numRecLoaded.value < arrProducts.value.length) {
|
|
|
|
|
|
|
|
|
|
const step = 10
|
|
|
|
|
let mynrec = numRecLoaded.value + step
|
|
|
|
|
|
|
|
|
|
if (mynrec > arrProducts.value.length)
|
|
|
|
|
mynrec = arrProducts.value.length
|
|
|
|
|
|
|
|
|
|
numRecLoaded.value = mynrec
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
done()
|
|
|
|
|
} else {
|
|
|
|
|
done(true)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-09 23:36:58 +02:00
|
|
|
function filterFn(val: any, update: any, abort: any) {
|
|
|
|
|
update(() => {
|
|
|
|
|
const needle = val.toLowerCase();
|
|
|
|
|
optauthors.value = productStore.getAuthors().filter(v => {
|
|
|
|
|
const authorName = v.label.toLowerCase();
|
|
|
|
|
const wordsToSearch = needle.split(' ');
|
|
|
|
|
return wordsToSearch.every((word: any) => {
|
|
|
|
|
if (word.length > 1) {
|
|
|
|
|
return authorName.includes(word);
|
|
|
|
|
} else {
|
|
|
|
|
return authorName.split(' ').some((namePart: any) => namePart.startsWith(word));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function selauthor(id: string, value: string) {
|
|
|
|
|
filter.value.author = id
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-20 17:22:46 +02:00
|
|
|
/*function searchval(newval: any, table: any, tablesel: any) {
|
2024-05-09 23:36:58 +02:00
|
|
|
console.log('REFRR searchval', newval, table, 'tablesel', tablesel)
|
2024-06-20 17:22:46 +02:00
|
|
|
if (newval) {
|
|
|
|
|
if (newval.hasOwnProperty('name')) {
|
|
|
|
|
search.value = newval.name
|
|
|
|
|
}
|
2024-06-19 00:21:06 +02:00
|
|
|
} else {
|
2024-06-20 17:22:46 +02:00
|
|
|
resetSearch()
|
2024-05-09 23:36:58 +02:00
|
|
|
}
|
2024-06-20 17:22:46 +02:00
|
|
|
}*/
|
2024-05-09 23:36:58 +02:00
|
|
|
|
2025-03-21 19:51:55 +01:00
|
|
|
const valoriopt = computed(() => (item: any, addall: boolean, addnone: boolean = false) => {
|
2024-05-09 23:36:58 +02:00
|
|
|
// console.log('valoriopt', item.table)
|
|
|
|
|
return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter)
|
|
|
|
|
})
|
|
|
|
|
|
2024-10-31 23:23:06 +01:00
|
|
|
const loadImage = (src: any) => {
|
2024-07-31 15:02:30 +02:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
const img = new Image()
|
|
|
|
|
img.onload = () => resolve(img)
|
|
|
|
|
img.onerror = reject
|
|
|
|
|
img.src = src
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-22 20:23:37 +01:00
|
|
|
|
2024-05-09 23:36:58 +02:00
|
|
|
|
2024-11-22 20:23:37 +01:00
|
|
|
function groupedPages(recscheda: ISchedaSingola) {
|
2024-11-28 16:04:48 +01:00
|
|
|
return recscheda.arrProdToShow
|
|
|
|
|
}
|
2025-02-03 17:18:33 +01:00
|
|
|
function generateStyleCatalogo(optcatalogo: IOptCatalogo) {
|
2024-11-22 20:23:37 +01:00
|
|
|
|
2024-11-28 16:04:48 +01:00
|
|
|
return {
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2024-11-28 16:04:48 +01:00
|
|
|
}
|
|
|
|
|
}
|
2024-10-26 17:12:05 +02:00
|
|
|
|
2025-02-03 17:18:33 +01:00
|
|
|
function generateStylePageScheda(optcatalogo: IOptCatalogo, scheda: IMyScheda) {
|
2024-12-09 12:32:19 +01:00
|
|
|
const marginTop = scheda.dimensioni?.pagina?.dimensioni?.margini?.top ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.margini?.top) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.top) || '')
|
|
|
|
|
const marginBottom = scheda.dimensioni?.pagina?.dimensioni?.margini?.bottom ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.margini?.bottom) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.bottom) || '')
|
|
|
|
|
const marginLeft = scheda.dimensioni?.pagina?.dimensioni?.margini?.left ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.margini?.left) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.left) || '')
|
|
|
|
|
const marginRight = scheda.dimensioni?.pagina?.dimensioni?.margini?.right ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.margini?.right) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.right) || '')
|
2024-11-22 20:23:37 +01:00
|
|
|
|
2024-12-09 12:32:19 +01:00
|
|
|
const paddingTop = scheda.dimensioni?.pagina?.dimensioni?.padding?.top ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.padding?.top) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.top) || '')
|
|
|
|
|
const paddingBottom = scheda.dimensioni?.pagina?.dimensioni?.padding?.bottom ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.padding?.bottom) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.bottom) || '')
|
|
|
|
|
const paddingLeft = scheda.dimensioni?.pagina?.dimensioni?.padding?.left ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.padding?.left) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.left) || '')
|
|
|
|
|
const paddingRight = scheda.dimensioni?.pagina?.dimensioni?.padding?.right ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.padding?.right) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.right) || '')
|
2024-10-26 17:12:05 +02:00
|
|
|
|
|
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
// Esiste un immagine di sfondo specifica della singola pagina ?
|
2025-03-01 14:14:43 +01:00
|
|
|
const recimg = getSfondoImgCatalogo(scheda)
|
|
|
|
|
const backgroundImage = recimg.imagefile! ?? ''
|
|
|
|
|
const backgroundSize = recimg.fit
|
2024-10-26 17:12:05 +02:00
|
|
|
|
2025-03-01 14:14:43 +01:00
|
|
|
const width = scheda.dimensioni?.pagina?.dimensioni?.size?.width ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.size?.width) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.width) ?? '')
|
|
|
|
|
const height = scheda.dimensioni?.pagina?.dimensioni?.size?.height ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.size?.height) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.height) ?? '')
|
2024-11-02 18:06:27 +01:00
|
|
|
|
2024-11-19 19:19:14 +01:00
|
|
|
return {
|
2024-11-28 16:04:48 +01:00
|
|
|
marginBottom,
|
|
|
|
|
marginTop,
|
|
|
|
|
marginLeft,
|
|
|
|
|
marginRight,
|
|
|
|
|
paddingBottom,
|
|
|
|
|
paddingTop,
|
|
|
|
|
paddingLeft,
|
|
|
|
|
paddingRight,
|
|
|
|
|
backgroundImage,
|
|
|
|
|
backgroundSize,
|
|
|
|
|
'--width': width,
|
|
|
|
|
'--height': height,
|
2025-02-10 22:48:53 +01:00
|
|
|
...((width && width !== '0px') ? { width: `${width} !important` } : {}),
|
|
|
|
|
...((height && height !== '0px') ? { height: `${height} !important` } : {}) // Aggiungi l'altezza solo se è valorizzata
|
2024-11-28 16:04:48 +01:00
|
|
|
};
|
2024-11-19 19:19:14 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-03 17:18:33 +01:00
|
|
|
function generateStyleByPageDim(optcatalogo: IOptCatalogo, mypage: IDimensioni) {
|
2025-03-01 14:14:43 +01:00
|
|
|
const marginTop = mypage.margini?.top ? tools.adjustSize(optcatalogo, mypage.margini?.top) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.top) || '')
|
|
|
|
|
const marginBottom = mypage.margini?.bottom ? tools.adjustSize(optcatalogo, mypage.margini?.bottom) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.bottom) || '')
|
|
|
|
|
const marginLeft = mypage.margini?.left ? tools.adjustSize(optcatalogo, mypage.margini?.left) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.left) || '')
|
|
|
|
|
const marginRight = mypage.margini?.right ? tools.adjustSize(optcatalogo, mypage.margini?.right) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.right) || '')
|
2024-11-19 19:19:14 +01:00
|
|
|
|
2025-03-01 14:14:43 +01:00
|
|
|
const paddingTop = mypage.padding?.top ? tools.adjustSize(optcatalogo, mypage.padding?.top) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.top) || '')
|
|
|
|
|
const paddingBottom = mypage.padding?.bottom ? tools.adjustSize(optcatalogo, mypage.padding?.bottom) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.bottom) ?? '')
|
|
|
|
|
const paddingLeft = mypage.padding?.left ? tools.adjustSize(optcatalogo, mypage.padding?.left) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.left) ?? '')
|
|
|
|
|
const paddingRight = mypage.padding?.right ? tools.adjustSize(optcatalogo, mypage.padding?.right) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.right) ?? '')
|
2024-11-19 19:19:14 +01:00
|
|
|
|
|
|
|
|
// Esiste un immagine di sfondo specifica della singola pagina ?
|
2025-03-01 14:14:43 +01:00
|
|
|
const recimg = getSfondoImgCatalogo(null, mypage)
|
2025-02-10 22:48:53 +01:00
|
|
|
let fileimg = recimg.imagefile! ?? ''
|
|
|
|
|
let backgroundSize = recimg.fit
|
2024-11-02 18:06:27 +01:00
|
|
|
|
2024-11-19 19:19:14 +01:00
|
|
|
if (!fileimg) {
|
|
|
|
|
// Esiste un immagine di sfondo uguali per tutte le pagine ?
|
2025-03-01 14:14:43 +01:00
|
|
|
fileimg = optcatalogo.dimensioni_def?.pagina.imgsfondo?.imagefile
|
|
|
|
|
backgroundSize = optcatalogo.dimensioni_def?.pagina.imgsfondo?.fit
|
|
|
|
|
fileimg = fileimg ? `url(${tools.getDirUpload() + costanti.DIR_CATALOGO + fileimg})` : ''
|
2024-11-19 19:19:14 +01:00
|
|
|
}
|
2024-11-02 18:06:27 +01:00
|
|
|
|
2025-03-01 14:14:43 +01:00
|
|
|
const backgroundImage = fileimg ?? ''
|
2024-11-02 18:06:27 +01:00
|
|
|
|
2025-03-01 14:14:43 +01:00
|
|
|
const width = mypage.size?.width ? tools.adjustSize(optcatalogo, mypage.size?.width) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.width) ?? '')
|
|
|
|
|
const height = mypage.size?.height ? tools.adjustSize(optcatalogo, mypage.size?.height) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.height) ?? '')
|
2024-11-02 18:06:27 +01:00
|
|
|
|
|
|
|
|
return {
|
2024-11-19 19:19:14 +01:00
|
|
|
marginBottom,
|
|
|
|
|
marginTop,
|
|
|
|
|
marginLeft,
|
|
|
|
|
marginRight,
|
|
|
|
|
paddingBottom,
|
|
|
|
|
paddingTop,
|
|
|
|
|
paddingLeft,
|
|
|
|
|
paddingRight,
|
2024-11-02 18:06:27 +01:00
|
|
|
backgroundImage,
|
|
|
|
|
backgroundSize,
|
2024-11-19 19:19:14 +01:00
|
|
|
'--width': width,
|
|
|
|
|
'--height': height,
|
2025-02-10 22:48:53 +01:00
|
|
|
...((width && width !== '0px') ? { width: `${width} !important` } : {}),
|
|
|
|
|
...((height && height !== '0px') ? { height: `${height} !important` } : {}) // Aggiungi l'altezza solo se è valorizzata
|
2024-11-02 18:06:27 +01:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 17:18:33 +01:00
|
|
|
function getWidthPagina(optcatalogo: IOptCatalogo, scheda: IMyScheda) {
|
2024-11-28 16:04:48 +01:00
|
|
|
return scheda.dimensioni?.pagina?.dimensioni?.size?.width ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.size?.width) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.width) ?? '')
|
2024-11-19 19:19:14 +01:00
|
|
|
}
|
2025-02-03 17:18:33 +01:00
|
|
|
function getHeightPagina(optcatalogo: IOptCatalogo, scheda: IMyScheda) {
|
2024-11-28 16:04:48 +01:00
|
|
|
return scheda.dimensioni?.pagina?.dimensioni?.size?.height ? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.size?.height) : (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.height) ?? '')
|
2024-11-22 20:23:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getStyleRowSeparator(recscheda: ISchedaSingola) {
|
2024-12-09 12:32:19 +01:00
|
|
|
const paddingLeft = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.scheda_prodotto?.padding?.left) ?? '0px';
|
|
|
|
|
const paddingRight = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.scheda_prodotto?.padding?.right) ?? '0px';
|
2024-11-22 20:23:37 +01:00
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
paddingLeft: `${paddingLeft}`,
|
|
|
|
|
paddingRight: `${paddingRight}`,
|
|
|
|
|
};
|
2024-11-19 19:19:14 +01:00
|
|
|
}
|
2024-11-02 18:06:27 +01:00
|
|
|
|
2024-11-19 19:19:14 +01:00
|
|
|
function getStyleRow(recscheda: ISchedaSingola) {
|
|
|
|
|
const placeContent = 'center';
|
2024-11-02 18:06:27 +01:00
|
|
|
|
2024-12-09 12:32:19 +01:00
|
|
|
const width = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.size?.width) ?? '';
|
2025-02-10 22:48:53 +01:00
|
|
|
const height = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.size?.height) ?? '';
|
2024-11-22 20:23:37 +01:00
|
|
|
|
2024-12-09 12:32:19 +01:00
|
|
|
const marginTop = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.margini?.top) || '0';
|
|
|
|
|
const marginBottom = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.margini?.bottom) || '0';
|
|
|
|
|
const marginLeft = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.margini?.left) || '0';
|
|
|
|
|
const marginRight = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.margini?.right) || '0';
|
2024-11-22 20:23:37 +01:00
|
|
|
|
2024-12-09 12:32:19 +01:00
|
|
|
const paddingTop = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.padding?.top) || '0';
|
|
|
|
|
const paddingBottom = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.padding?.bottom) || '0';
|
|
|
|
|
const paddingLeft = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.padding?.left) || '0';
|
|
|
|
|
const paddingRight = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.padding?.right) || '0';
|
2024-11-22 20:23:37 +01:00
|
|
|
|
2025-03-01 14:14:43 +01:00
|
|
|
const out: any = {
|
2024-11-22 20:23:37 +01:00
|
|
|
placeContent,
|
2025-02-10 22:48:53 +01:00
|
|
|
flex: `0 1 ${width} !important`,
|
2024-11-22 20:23:37 +01:00
|
|
|
margin: `${marginTop} ${marginRight} ${marginBottom} ${marginLeft}`,
|
2025-02-10 22:48:53 +01:00
|
|
|
padding: `${paddingTop} ${paddingRight} ${paddingBottom} ${paddingLeft}`,
|
|
|
|
|
...((width && width !== '0px') ? { width: `${width} !important` } : {}),
|
|
|
|
|
...((height && height !== '0px') ? { height: `${height} !important` } : {})
|
2024-12-13 18:10:04 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
/*if (width) {
|
|
|
|
|
out.width = `${width} !important`
|
2024-12-13 18:10:04 +01:00
|
|
|
}
|
|
|
|
|
if (height) {
|
2025-02-10 22:48:53 +01:00
|
|
|
out.height = `${height} !important`
|
|
|
|
|
}*/
|
2024-12-13 18:10:04 +01:00
|
|
|
|
|
|
|
|
return out
|
2024-11-22 20:23:37 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getStyleSchedaProdotto(recscheda: ISchedaSingola) {
|
|
|
|
|
const placeContent = 'center';
|
|
|
|
|
|
2024-12-09 12:32:19 +01:00
|
|
|
const width = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.scheda_prodotto?.size?.width) ?? '100px';
|
|
|
|
|
const height = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.scheda_prodotto?.size?.height);
|
2024-11-02 18:06:27 +01:00
|
|
|
|
2024-12-09 12:32:19 +01:00
|
|
|
const marginTop = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.scheda_prodotto?.margini?.top) || '0px';
|
|
|
|
|
const marginBottom = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.scheda_prodotto?.margini?.bottom) || '0px';
|
|
|
|
|
const marginLeft = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.scheda_prodotto?.margini?.left) || '0px';
|
|
|
|
|
const marginRight = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.scheda_prodotto?.margini?.right) || '0px';
|
2024-11-02 18:06:27 +01:00
|
|
|
|
2024-12-09 12:32:19 +01:00
|
|
|
const paddingTop = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.scheda_prodotto?.padding?.top) || '0px';
|
|
|
|
|
const paddingBottom = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.scheda_prodotto?.padding?.bottom) || '0px';
|
|
|
|
|
const paddingLeft = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.scheda_prodotto?.padding?.left) || '0px';
|
|
|
|
|
const paddingRight = tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.scheda_prodotto?.padding?.right) || '0px';
|
2024-11-02 18:06:27 +01:00
|
|
|
|
|
|
|
|
return {
|
2024-11-19 19:19:14 +01:00
|
|
|
placeContent,
|
2024-12-13 18:10:04 +01:00
|
|
|
alignSelf: 'flex-start',
|
2025-02-10 22:48:53 +01:00
|
|
|
flex: `0 1 ${width} !important`,
|
2024-11-19 19:19:14 +01:00
|
|
|
margin: `${marginTop} ${marginRight} ${marginBottom} ${marginLeft}`,
|
|
|
|
|
padding: `${paddingTop} ${paddingRight} ${paddingBottom} ${paddingLeft}`,
|
2025-02-10 22:48:53 +01:00
|
|
|
...((height && height !== '0px') ? { height: `${height} !important` } : {}) // Aggiungi l'altezza solo se è valorizzata
|
2024-11-02 18:06:27 +01:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-02 19:38:01 +01:00
|
|
|
function containsProducts(page: IProduct[][]) {
|
|
|
|
|
return page && page.length > 0 && page[0] && page[0].length > 0
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-12 18:32:10 +01:00
|
|
|
function naviga(path: string) {
|
|
|
|
|
router.push(path)
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
function updateProducts(arr: any) {
|
|
|
|
|
getCatalogoByMyPage.value.lista_prodotti = [...arr]
|
|
|
|
|
|
|
|
|
|
salvaListaProdotti(true)
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-30 14:00:48 +01:00
|
|
|
onMounted(mounted)
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
userStore,
|
|
|
|
|
costanti,
|
|
|
|
|
tools,
|
|
|
|
|
toolsext,
|
|
|
|
|
search,
|
|
|
|
|
cosa,
|
|
|
|
|
shared_consts,
|
|
|
|
|
getCatProds,
|
|
|
|
|
cat,
|
2024-05-04 14:49:09 +02:00
|
|
|
idGasSel,
|
2024-01-30 14:00:48 +01:00
|
|
|
productStore,
|
|
|
|
|
t,
|
|
|
|
|
loadpage,
|
|
|
|
|
refreshpage,
|
|
|
|
|
componentToFixRef,
|
|
|
|
|
isFixed,
|
|
|
|
|
arrProducts,
|
2024-05-04 14:49:09 +02:00
|
|
|
show_hide,
|
|
|
|
|
onLoadScroll,
|
|
|
|
|
numRecLoaded,
|
|
|
|
|
arrLoaded,
|
|
|
|
|
filter,
|
2024-05-09 23:36:58 +02:00
|
|
|
optauthors,
|
|
|
|
|
filterFn,
|
|
|
|
|
selauthor,
|
|
|
|
|
searchList,
|
|
|
|
|
fieldsTable,
|
|
|
|
|
valoriopt,
|
|
|
|
|
labelcombo,
|
|
|
|
|
mycolumns,
|
2024-06-20 17:22:46 +02:00
|
|
|
tabvisu,
|
2024-07-03 13:22:57 +02:00
|
|
|
getSearchText,
|
2024-07-31 15:02:30 +02:00
|
|
|
pdfContent,
|
2024-10-26 17:12:05 +02:00
|
|
|
tabcatalogo,
|
|
|
|
|
groupedPages,
|
2024-10-31 23:23:06 +01:00
|
|
|
getNextProd,
|
|
|
|
|
getProdBySchedaRigaCol,
|
2024-11-02 18:06:27 +01:00
|
|
|
generateStylePageScheda,
|
|
|
|
|
generateStyleCatalogo,
|
2024-11-19 19:19:14 +01:00
|
|
|
getStyleRow,
|
2024-11-22 20:23:37 +01:00
|
|
|
getStyleSchedaProdotto,
|
2024-11-19 19:19:14 +01:00
|
|
|
getWidthPagina,
|
|
|
|
|
getHeightPagina,
|
2024-11-22 20:23:37 +01:00
|
|
|
getStyleRowSeparator,
|
2024-11-28 16:04:48 +01:00
|
|
|
generateStyleByPageDim,
|
2024-12-02 19:38:01 +01:00
|
|
|
containsProducts,
|
2024-12-09 12:32:19 +01:00
|
|
|
updateOptCatalogo,
|
|
|
|
|
optcatalogo,
|
2025-02-10 22:48:53 +01:00
|
|
|
getTestoIntroduttivo,
|
2025-02-12 18:32:10 +01:00
|
|
|
ispageCatalogata,
|
|
|
|
|
naviga,
|
2025-03-01 14:14:43 +01:00
|
|
|
getTitoloCatalogo,
|
2025-03-31 23:55:53 +02:00
|
|
|
getTitoloPagina,
|
|
|
|
|
generaListaLibri,
|
|
|
|
|
lista_prodotti,
|
|
|
|
|
updateProducts,
|
2024-01-30 14:00:48 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|