2025-03-01 14:14:43 +01:00
|
|
|
import type { PropType } from 'vue';
|
2025-05-23 16:31:04 +02:00
|
|
|
import { defineComponent, onMounted, ref, watch, computed, onBeforeUnmount, nextTick } from 'vue';
|
2025-05-08 23:32:13 +02:00
|
|
|
import { tools } from '@tools';
|
|
|
|
|
import { useUserStore } from '@store/UserStore';
|
|
|
|
|
import { useRouter } from 'vue-router';
|
|
|
|
|
import { useGlobalStore } from '@store/globalStore';
|
|
|
|
|
import { useProducts } from '@store/Products';
|
|
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
|
import { toolsext } from '@store/Modules/toolsext';
|
|
|
|
|
import { useQuasar } from 'quasar';
|
|
|
|
|
import { costanti } from '@costanti';
|
|
|
|
|
|
|
|
|
|
import { shared_consts } from '@src/common/shared_vuejs';
|
|
|
|
|
import { CProductCard } from '@src/components/CProductCard';
|
|
|
|
|
|
|
|
|
|
import { CMyDialog } from '@src/components/CMyDialog';
|
2025-05-15 19:18:50 +02:00
|
|
|
import { CTitleBanner } from '@src/components/CTitleBanner';
|
2025-05-08 23:32:13 +02:00
|
|
|
import { CMySelect } from '@src/components/CMySelect';
|
2025-05-23 16:31:04 +02:00
|
|
|
import { CBorders } from '@src/components/CBorders';
|
2025-05-08 23:32:13 +02:00
|
|
|
import { CMyValueDb } from '@src/components/CMyValueDb';
|
|
|
|
|
import { CProductTable } from '@src/components/CProductTable';
|
|
|
|
|
import { CSearchProduct } from '@src/components/CSearchProduct';
|
|
|
|
|
import { CContainerCatalogoCard } from '@src/components/CContainerCatalogoCard';
|
|
|
|
|
import { CSelectUserActive } from '@src/components/CSelectUserActive';
|
|
|
|
|
|
|
|
|
|
import html2pdf from 'html2pdf.js';
|
|
|
|
|
import { PDFDocument } from 'pdf-lib';
|
|
|
|
|
import { saveAs } from 'file-saver';
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-03-01 14:14:43 +01:00
|
|
|
import type {
|
2025-05-08 23:32:13 +02:00
|
|
|
IOptCatalogo,
|
|
|
|
|
IDimensioni,
|
|
|
|
|
IFilterCatalogo,
|
|
|
|
|
IMyScheda,
|
|
|
|
|
IProdView,
|
|
|
|
|
IProduct,
|
|
|
|
|
ISchedaSingola,
|
|
|
|
|
ISearchList,
|
|
|
|
|
ICatalog,
|
|
|
|
|
IImg,
|
2025-04-16 23:28:21 +02:00
|
|
|
IText,
|
|
|
|
|
ICollana,
|
2025-04-24 19:31:34 +02:00
|
|
|
IOptRigenera,
|
2025-04-30 13:27:47 +02:00
|
|
|
IOpAndOr,
|
2025-03-01 14:14:43 +01:00
|
|
|
} from 'model';
|
2025-05-08 23:32:13 +02:00
|
|
|
import { IMyPage } from 'model';
|
2024-07-31 15:02:30 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
import { fieldsTable } from '@store/Modules/fieldsTable';
|
|
|
|
|
import { useCatalogStore } from '@src/store/CatalogStore';
|
2024-01-30 14:00:48 +01:00
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
name: 'Catalogo',
|
2025-04-04 18:15:14 +02:00
|
|
|
components: {
|
2025-05-08 23:32:13 +02:00
|
|
|
CContainerCatalogoCard,
|
|
|
|
|
CProductCard,
|
|
|
|
|
CSelectUserActive,
|
|
|
|
|
CMySelect,
|
|
|
|
|
CProductTable,
|
|
|
|
|
CSearchProduct,
|
|
|
|
|
CMyDialog,
|
2025-04-29 02:30:00 +02:00
|
|
|
CMyValueDb,
|
2025-05-15 19:18:50 +02:00
|
|
|
CTitleBanner,
|
2025-05-23 16:31:04 +02:00
|
|
|
CBorders,
|
2025-04-04 18:15:14 +02:00
|
|
|
},
|
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 }) {
|
2025-05-08 23:32:13 +02:00
|
|
|
const userStore = useUserStore();
|
|
|
|
|
const globalStore = useGlobalStore();
|
|
|
|
|
const productStore = useProducts();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const $q = useQuasar();
|
|
|
|
|
const { t } = useI18n();
|
2024-01-30 14:00:48 +01:00
|
|
|
|
2025-05-15 22:37:39 +02:00
|
|
|
const myCatalog = ref<ICatalog | null>(null as ICatalog);
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const rigeneraLibri = ref(false);
|
2025-04-24 19:31:34 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const search = ref('');
|
|
|
|
|
const optauthors = ref(<any>[]);
|
2024-05-08 16:07:42 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
const strout = ref('');
|
|
|
|
|
|
2024-07-31 15:02:30 +02:00
|
|
|
const pdfContent = ref(null);
|
2025-05-08 23:32:13 +02:00
|
|
|
const addnewProd = ref(false);
|
|
|
|
|
|
|
|
|
|
const widthpdf = ref('8.88');
|
|
|
|
|
const heightpdf = ref('12.31');
|
|
|
|
|
const compressionepdf = ref('prepress');
|
2024-07-31 15:02:30 +02:00
|
|
|
|
2025-05-15 19:18:50 +02:00
|
|
|
const ismounting = ref(false);
|
2025-05-23 16:31:04 +02:00
|
|
|
const ratioconvert = ref(0.927);
|
|
|
|
|
const nascondi = ref(false);
|
2025-05-15 19:18:50 +02:00
|
|
|
|
|
|
|
|
const pdfColumns = [
|
|
|
|
|
{ name: 'name', label: 'Nome', field: 'name', align: 'left' },
|
|
|
|
|
{ name: 'pdf', label: 'PDF', field: 'pdf', align: 'left' },
|
2025-05-23 19:02:45 +02:00
|
|
|
{ name: 'size', label: 'Dimensione del file', field: 'size', align: 'right' },
|
2025-05-15 19:18:50 +02:00
|
|
|
{ name: 'data', label: 'Data', field: 'data', align: 'left' },
|
|
|
|
|
{ name: 'azioni', label: 'Azioni', field: 'azioni', align: 'center' },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const pdfRows = computed(() => [
|
|
|
|
|
{
|
|
|
|
|
name: 'PDF Generato',
|
2025-05-15 22:37:39 +02:00
|
|
|
pdf: myCatalog.value.pdf_generato,
|
|
|
|
|
data: myCatalog.value.data_generato,
|
2025-05-23 19:02:45 +02:00
|
|
|
showButton: true,
|
2025-05-15 19:18:50 +02:00
|
|
|
buttonLabel: 'Pubblica PDF OnLine',
|
2025-05-23 19:02:45 +02:00
|
|
|
size: myCatalog.value.pdf_generato_size,
|
|
|
|
|
action: () => pubblicaPDF(false),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'PDF Generato (Compresso)',
|
|
|
|
|
pdf: myCatalog.value.pdf_generato_compressed,
|
|
|
|
|
data: myCatalog.value.data_generato,
|
|
|
|
|
showButton: true,
|
|
|
|
|
buttonLabel: 'Pubblica PDF OnLine (Compr)',
|
|
|
|
|
size: myCatalog.value.pdf_generato_compr_size,
|
|
|
|
|
action: () => pubblicaPDF(true),
|
2025-05-15 19:18:50 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'PDF Generato Stampa',
|
2025-05-15 22:37:39 +02:00
|
|
|
pdf: myCatalog.value.pdf_generato_stampa,
|
|
|
|
|
data: myCatalog.value.data_generato_stampa,
|
2025-05-23 19:02:45 +02:00
|
|
|
showButton: true,
|
2025-05-15 19:18:50 +02:00
|
|
|
buttonLabel: 'Pubblica PDF Stampa',
|
2025-05-23 19:02:45 +02:00
|
|
|
size: myCatalog.value.pdf_generato_stampa_size,
|
|
|
|
|
action: () => pubblicaPDFStampa(false),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'PDF Generato Stampa (Compresso)',
|
|
|
|
|
pdf: myCatalog.value.pdf_generato_stampa_compressed,
|
|
|
|
|
data: myCatalog.value.data_generato_stampa,
|
|
|
|
|
showButton: true,
|
|
|
|
|
buttonLabel: 'Pubblica PDF Stampa (Compr)',
|
|
|
|
|
size: myCatalog.value.pdf_generato_stampa_compr_size,
|
|
|
|
|
action: () => pubblicaPDFStampa(true),
|
2025-05-15 19:18:50 +02:00
|
|
|
},
|
|
|
|
|
]);
|
2025-05-14 20:18:04 +02:00
|
|
|
|
2025-04-24 19:31:34 +02:00
|
|
|
const optDisp = ref([
|
|
|
|
|
{ label: 'Tutti', value: costanti.DISP.TUTTI },
|
|
|
|
|
{ label: 'Disponibili', value: costanti.DISP.DISPONIBILI },
|
2025-05-08 23:32:13 +02:00
|
|
|
{ label: 'Esauriti', value: costanti.DISP.ESAURITI },
|
|
|
|
|
]);
|
2025-04-24 19:31:34 +02:00
|
|
|
|
2025-05-02 10:10:04 +02:00
|
|
|
const optRigeneraModalita = ref([
|
|
|
|
|
{ label: 'Sovrascrivi', value: costanti.RIGENERAMOD.SOVRASCRIVI },
|
|
|
|
|
{ label: 'Aggiungi solo', value: costanti.RIGENERAMOD.AGGIUNGI_SOLO },
|
2025-05-08 23:32:13 +02:00
|
|
|
]);
|
2025-05-02 10:10:04 +02:00
|
|
|
|
2025-04-24 19:31:34 +02:00
|
|
|
const optStato = ref([
|
|
|
|
|
{ label: 'Tutti', value: costanti.STATO.TUTTI },
|
|
|
|
|
{ label: 'In Commercio', value: costanti.STATO.IN_COMMERCIO },
|
|
|
|
|
{ label: 'Prossima Uscita', value: costanti.STATO.SOLO_PROSSIMA_USCITA },
|
|
|
|
|
{ label: 'Prevendita', value: costanti.STATO.PREVENDITA },
|
|
|
|
|
{ label: 'Non Vendibile', value: costanti.STATO.NON_VENDIBILE },
|
2025-05-08 23:32:13 +02:00
|
|
|
]);
|
2025-04-24 19:31:34 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const generatinglist = ref(false);
|
2025-04-24 19:31:34 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const optrigenera = ref<IOptRigenera>({
|
|
|
|
|
visibilitaDisp: costanti.DISP.DISPONIBILI,
|
|
|
|
|
stato: costanti.STATO.IN_COMMERCIO,
|
|
|
|
|
rig_mod: costanti.RIGENERAMOD.SOVRASCRIVI,
|
|
|
|
|
});
|
2025-04-24 19:31:34 +02:00
|
|
|
|
2025-02-03 17:18:33 +01:00
|
|
|
const optcatalogo = ref(<IOptCatalogo>{ ...props.modelValue });
|
2025-05-08 23:32:13 +02:00
|
|
|
const ispageCatalogata = computed(() => {
|
2025-05-15 22:37:39 +02:00
|
|
|
return !!myCatalog.value;
|
2025-05-08 23:32:13 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const filtroStrApplicato = computed(() => {
|
|
|
|
|
return optcatalogo.value.showListaArgomenti
|
|
|
|
|
? 'un Argomento'
|
|
|
|
|
: optcatalogo.value.showListaCollane
|
|
|
|
|
? 'una Collana'
|
|
|
|
|
: false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const showListaFiltrata = computed(() => {
|
2025-05-21 12:06:09 +02:00
|
|
|
return optcatalogo.value.showListaArgomenti
|
|
|
|
|
? true
|
|
|
|
|
: optcatalogo.value.showListaCollane
|
|
|
|
|
? true
|
|
|
|
|
: false;
|
2025-05-08 23:32:13 +02:00
|
|
|
});
|
|
|
|
|
|
2025-05-02 19:11:29 +02:00
|
|
|
const getPdfFilename = () => {
|
2025-05-08 23:32:13 +02:00
|
|
|
let myfilename = optcatalogo.value.pdf_filename ?? 'catalogo_completo';
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-15 22:37:39 +02:00
|
|
|
const catalog = myCatalog.value;
|
2025-05-02 19:11:29 +02:00
|
|
|
if (catalog) {
|
2025-05-08 23:32:13 +02:00
|
|
|
myfilename = productStore.getPathByPage(catalog.idPageAssigned);
|
2025-05-02 19:11:29 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
return myfilename;
|
|
|
|
|
};
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2024-12-09 12:32:19 +01:00
|
|
|
function updateCatalogoPadre() {
|
2025-05-15 18:22:37 +02:00
|
|
|
// console.log('catalogo.ts PADRE');
|
2024-12-09 12:32:19 +01:00
|
|
|
emit('update:modelValue', optcatalogo.value);
|
|
|
|
|
//emit('updateCatalogo', optcatalogo.value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Metodo per aggiornare optcatalogo
|
2025-05-23 16:31:04 +02:00
|
|
|
const updateOptCatalogo = <K extends keyof IOptCatalogo>(key: K, value: IOptCatalogo[K]) => {
|
2024-12-09 12:32:19 +01:00
|
|
|
optcatalogo.value[key] = value;
|
2025-05-08 23:32:13 +02:00
|
|
|
updateCatalogoPadre();
|
|
|
|
|
};
|
2024-12-09 12:32:19 +01:00
|
|
|
// Utile anche per sincronizzare con le modifiche ricevute da props
|
2025-05-08 23:32:13 +02:00
|
|
|
watch(
|
|
|
|
|
() => props.modelValue,
|
|
|
|
|
(newVal) => {
|
|
|
|
|
optcatalogo.value = { ...newVal };
|
|
|
|
|
},
|
|
|
|
|
{ deep: false }
|
|
|
|
|
);
|
|
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
watch(
|
|
|
|
|
() => props.modelValue.selectedVersionStampabile,
|
|
|
|
|
async () => {
|
|
|
|
|
if (loadpage.value) {
|
|
|
|
|
//nascondi.value = true;
|
|
|
|
|
arrProducts.value = [];
|
|
|
|
|
console.log('aggiorna... ');
|
|
|
|
|
//await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
|
|
|
//await nextTick();
|
|
|
|
|
calcArrProducts(false);
|
|
|
|
|
updateCatalogoPadre();
|
|
|
|
|
//nascondi.value = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
watch(
|
|
|
|
|
optrigenera.value,
|
|
|
|
|
(newVal) => {
|
2025-05-21 12:06:09 +02:00
|
|
|
tools.setCookie(
|
|
|
|
|
(showListaFiltrata.value ? 'INC_ES_' : '') + 'VIS_DISP',
|
|
|
|
|
newVal.visibilitaDisp
|
|
|
|
|
);
|
2025-05-23 16:31:04 +02:00
|
|
|
tools.setCookie((showListaFiltrata.value ? 'INC_ES_' : '') + 'VIS_STATO', newVal.stato);
|
|
|
|
|
tools.setCookie((showListaFiltrata.value ? 'INC_ES_' : '') + 'RIG_MOD', newVal.rig_mod);
|
2025-05-08 23:32:13 +02:00
|
|
|
if (showListaFiltrata.value) calcArrProducts();
|
|
|
|
|
},
|
|
|
|
|
{ deep: true }
|
|
|
|
|
);
|
2025-04-24 19:31:34 +02:00
|
|
|
|
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: '',
|
2025-05-08 23:32:13 +02:00
|
|
|
ageGroup: '',
|
|
|
|
|
});
|
2024-01-30 14:00:48 +01:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const cosa = ref(0);
|
|
|
|
|
const cat = ref('');
|
|
|
|
|
const collana = ref('');
|
|
|
|
|
const idGasSel = ref('');
|
|
|
|
|
const loadpage = ref(false);
|
|
|
|
|
const show_hide = ref(false);
|
2024-01-30 14:00:48 +01:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const mycolumns = ref([]);
|
2024-05-09 23:36:58 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const catalogStore = useCatalogStore();
|
2025-02-10 22:48:53 +01:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const tabvisu = ref('categorie');
|
|
|
|
|
const tabcatalogo = ref('lista');
|
2024-06-20 17:22:46 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const searchList = ref([] as ISearchList[]);
|
2024-05-09 23:36:58 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const arrProducts = ref<IProduct[]>([]);
|
|
|
|
|
const arrProdToView = ref<IProdView[]>([]);
|
2024-01-30 14:00:48 +01:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const numRecLoaded = ref(0);
|
2024-05-04 14:49:09 +02:00
|
|
|
|
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-05-08 23:32:13 +02:00
|
|
|
watch(
|
|
|
|
|
() => tabcatalogo.value,
|
|
|
|
|
() => {
|
|
|
|
|
tools.setCookie('TAB_CAT', tabcatalogo.value);
|
|
|
|
|
}
|
|
|
|
|
);
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2024-05-09 23:36:58 +02:00
|
|
|
const labelcombo = computed(() => (item: any) => {
|
2025-05-08 23:32:13 +02:00
|
|
|
let lab = item.label;
|
2025-05-23 16:31:04 +02:00
|
|
|
if (item.showcount) lab += ' (' + valoriopt.value(item, false, false).length + ')';
|
2025-05-08 23:32:13 +02:00
|
|
|
return lab;
|
|
|
|
|
});
|
2024-05-09 23:36:58 +02:00
|
|
|
|
2024-05-04 14:49:09 +02:00
|
|
|
const arrLoaded = computed(() => {
|
2025-05-21 12:06:09 +02:00
|
|
|
if (arrProducts.value && numRecLoaded.value)
|
|
|
|
|
return arrProducts.value.slice(0, numRecLoaded.value);
|
2024-05-04 14:49:09 +02:00
|
|
|
else {
|
2025-05-08 23:32:13 +02:00
|
|
|
return [];
|
2024-05-04 14:49:09 +02:00
|
|
|
}
|
2025-05-08 23:32:13 +02:00
|
|
|
});
|
2024-05-04 14:49:09 +02:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
const getTestoIntroduttivo = computed(() => (recscheda: ISchedaSingola) => {
|
2025-05-08 23:32:13 +02:00
|
|
|
let testo = recscheda.scheda!.dimensioni.pagina?.testo_up?.contenuto;
|
2025-02-10 22:48:53 +01:00
|
|
|
|
|
|
|
|
if (recscheda.scheda!.isPagIntro) {
|
2025-05-15 22:37:39 +02:00
|
|
|
const catalog = myCatalog.value;
|
2025-02-10 22:48:53 +01:00
|
|
|
if (catalog && catalog.descr_introduttiva) {
|
|
|
|
|
// Cerca se la descrizione introduttiva è stata impostata
|
2025-05-08 23:32:13 +02:00
|
|
|
testo = catalog.descr_introduttiva;
|
|
|
|
|
let clcol = '';
|
2025-05-21 12:06:09 +02:00
|
|
|
let mystyle = '';
|
2025-05-02 10:10:04 +02:00
|
|
|
if (catalog?.pagina_introduttiva_sfondo_nero) {
|
2025-05-08 23:32:13 +02:00
|
|
|
clcol = `text-white`;
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
2025-05-21 12:06:09 +02:00
|
|
|
if (catalog?.backcolor) {
|
|
|
|
|
mystyle = `background-color: ` + catalog?.backcolor + '; ';
|
|
|
|
|
}
|
2025-05-23 16:31:04 +02:00
|
|
|
testo = `<span class="book-text-up ${clcol}" style=${mystyle}>` + testo + `</span>`;
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
return testo;
|
|
|
|
|
});
|
2025-02-10 22:48:53 +01:00
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
function getTextSostituito(testo: IText) {
|
|
|
|
|
const replacements = {
|
|
|
|
|
'{titolo_catalogo}': getTitoloCatalogo() || '',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Esegue le sostituzioni
|
2025-05-23 16:31:04 +02:00
|
|
|
let result = testo?.contenuto;
|
|
|
|
|
if (result) {
|
|
|
|
|
for (const [key, value] of Object.entries(replacements)) {
|
|
|
|
|
result = result.replace(new RegExp(key, 'g'), value);
|
|
|
|
|
}
|
2025-03-31 23:55:53 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
return result;
|
2025-03-31 23:55:53 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-21 12:06:09 +02:00
|
|
|
const getTitoloPagina = computed(
|
|
|
|
|
() => (product: IProduct, recscheda: ISchedaSingola, fondo?: boolean) => {
|
2025-05-23 16:31:04 +02:00
|
|
|
let testo = getTextSostituito(recscheda.scheda!.dimensioni.pagina?.testo_title);
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-05-21 12:06:09 +02:00
|
|
|
const catalog = myCatalog.value;
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-05-21 12:06:09 +02:00
|
|
|
let clcol = '';
|
2025-05-01 00:20:02 +02:00
|
|
|
|
2025-05-21 12:06:09 +02:00
|
|
|
if (catalog?.pagina_introduttiva_sfondo_nero) {
|
|
|
|
|
clcol = `text-white`;
|
|
|
|
|
}
|
2025-05-01 00:20:02 +02:00
|
|
|
|
2025-05-21 12:06:09 +02:00
|
|
|
let myclass = '';
|
2025-04-23 01:59:39 +02:00
|
|
|
|
2025-05-21 12:06:09 +02:00
|
|
|
if (fondo) myclass = 'book-pagina-title-footer';
|
|
|
|
|
else myclass = 'book-pagina-title';
|
|
|
|
|
|
|
|
|
|
testo = `<span class="${myclass} ${clcol}">` + testo + `</span>`;
|
|
|
|
|
|
|
|
|
|
return testo;
|
|
|
|
|
}
|
|
|
|
|
);
|
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-05-08 23:32:13 +02: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;
|
|
|
|
|
};
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
watch(
|
|
|
|
|
() => cat.value,
|
|
|
|
|
(newval, oldval) => {
|
|
|
|
|
if (showListaFiltrata.value) {
|
|
|
|
|
if (loadpage.value) {
|
|
|
|
|
tools.setCookie(getKeyCatAtLoad(), cat.value.toString());
|
|
|
|
|
filter.value.author = ''; // disattivo il filtro autore
|
|
|
|
|
resetSearch();
|
2024-06-19 00:21:06 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
calcArrProducts();
|
|
|
|
|
}
|
2025-04-30 13:27:47 +02:00
|
|
|
}
|
2025-04-24 19:31:34 +02:00
|
|
|
}
|
2025-05-08 23:32:13 +02:00
|
|
|
);
|
|
|
|
|
watch(
|
|
|
|
|
() => collana.value,
|
|
|
|
|
(newval, oldval) => {
|
|
|
|
|
if (showListaFiltrata.value) {
|
|
|
|
|
if (loadpage.value) {
|
|
|
|
|
tools.setCookie(getKeyCollanaAtLoad(), collana.value.toString());
|
|
|
|
|
filter.value.author = ''; // disattivo il filtro autore
|
|
|
|
|
resetSearch();
|
|
|
|
|
|
|
|
|
|
calcArrProducts();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
2024-05-04 14:49:09 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
watch(
|
|
|
|
|
() => idGasSel.value,
|
|
|
|
|
(newval, oldval) => {
|
|
|
|
|
calcArrProducts();
|
2024-01-30 14:00:48 +01:00
|
|
|
}
|
2025-05-08 23:32:13 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => getSearchText(),
|
|
|
|
|
(newval, oldval) => {
|
|
|
|
|
calcArrProducts();
|
|
|
|
|
if (tools.scrollTop() > 300) {
|
|
|
|
|
tools.scrollToTopValue(300);
|
|
|
|
|
}
|
2024-06-19 00:21:06 +02:00
|
|
|
}
|
2025-05-08 23:32:13 +02:00
|
|
|
);
|
|
|
|
|
watch(
|
|
|
|
|
() => filter.value.author,
|
|
|
|
|
(newval, oldval) => {
|
|
|
|
|
// Se filtroAuthor attivato, allora evito il filtro per Categoria
|
|
|
|
|
if (filter.value.author) {
|
|
|
|
|
cat.value = ''; // disattivo il filtro categoria
|
|
|
|
|
collana.value = '';
|
|
|
|
|
if (loadpage.value) tools.setCookie(getKeyCatAtLoad(), '');
|
|
|
|
|
resetSearch();
|
|
|
|
|
}
|
2024-06-19 00:21:06 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
calcArrProducts();
|
|
|
|
|
if (tools.scrollTop() > 300) {
|
|
|
|
|
tools.scrollToTopValue(300);
|
|
|
|
|
}
|
2024-05-09 23:36:58 +02:00
|
|
|
}
|
2025-05-08 23:32:13 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => filter.value.sort_field,
|
|
|
|
|
(newval, oldval) => {
|
|
|
|
|
calcArrProducts();
|
|
|
|
|
if (tools.scrollTop() > 300) {
|
|
|
|
|
tools.scrollToTopValue(300);
|
|
|
|
|
}
|
2025-01-07 17:17:08 +01:00
|
|
|
}
|
2025-05-08 23:32:13 +02:00
|
|
|
);
|
|
|
|
|
watch(
|
|
|
|
|
() => filter.value.sort_dir,
|
|
|
|
|
(newval, oldval) => {
|
|
|
|
|
calcArrProducts();
|
|
|
|
|
if (tools.scrollTop() > 300) {
|
|
|
|
|
tools.scrollToTopValue(300);
|
|
|
|
|
}
|
2024-07-03 13:22:57 +02:00
|
|
|
}
|
2025-05-08 23:32:13 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => cosa.value,
|
|
|
|
|
(newval, oldval) => {
|
|
|
|
|
if (oldval !== 0) {
|
|
|
|
|
tools.setCookie(tools.COOK_COSA_PRODOTTI, cosa.value.toString());
|
|
|
|
|
if (cosa.value !== shared_consts.PROD.TUTTI) {
|
|
|
|
|
cat.value = '';
|
|
|
|
|
collana.value = '';
|
|
|
|
|
if (loadpage.value) tools.setCookie(getKeyCatAtLoad(), '');
|
|
|
|
|
}
|
|
|
|
|
calcArrProducts();
|
2024-07-31 15:02:30 +02:00
|
|
|
}
|
|
|
|
|
}
|
2025-05-08 23:32:13 +02:00
|
|
|
);
|
2024-01-30 14:00:48 +01:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
watch(
|
|
|
|
|
() => optcatalogo.value.aggiorna,
|
|
|
|
|
(newval, oldval) => {
|
2025-05-15 18:22:37 +02:00
|
|
|
// console.log('Aggiorna array...');
|
2025-05-08 23:32:13 +02:00
|
|
|
generatearrProdToViewSorted();
|
|
|
|
|
}
|
|
|
|
|
);
|
2024-11-24 14:40:29 +01:00
|
|
|
|
2024-06-20 17:22:46 +02:00
|
|
|
function resetSearch() {
|
2025-05-08 23:32:13 +02:00
|
|
|
const mialista = getSearchList();
|
2025-05-23 16:31:04 +02:00
|
|
|
if (mialista && mialista.value && tools.existProp(mialista.value, 'name')) {
|
2025-05-08 23:32:13 +02:00
|
|
|
mialista.value = null;
|
2024-07-03 13:22:57 +02:00
|
|
|
}
|
2025-05-08 23:32:13 +02:00
|
|
|
search.value = '';
|
2024-06-20 17:22:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSearchList() {
|
2025-05-21 12:06:09 +02:00
|
|
|
const mylist = searchList.value.find(
|
|
|
|
|
(rec: any) => rec.table === 'products' && rec.key === 'titolo'
|
|
|
|
|
);
|
2024-06-20 17:22:46 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
return mylist;
|
2024-06-20 17:22:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSearchText(): string {
|
2025-05-08 23:32:13 +02:00
|
|
|
const lista = getSearchList();
|
2025-05-23 16:31:04 +02:00
|
|
|
return lista && lista.value && tools.existProp(lista.value, 'name') ? lista.value.name : '';
|
2025-03-01 14:14:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getTitoloCatalogo(): string {
|
2025-05-15 22:37:39 +02:00
|
|
|
const trovatocatalogo = myCatalog.value;
|
2025-03-01 14:14:43 +01:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
return trovatocatalogo ? trovatocatalogo.title : 'Catalogo';
|
2024-06-20 17:22:46 +02:00
|
|
|
}
|
2025-04-29 02:30:00 +02:00
|
|
|
function getReferentiCatalogo(): string {
|
2025-05-15 22:37:39 +02:00
|
|
|
const trovatocatalogo = myCatalog.value;
|
2025-04-29 02:30:00 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
if (trovatocatalogo && trovatocatalogo.referenti && trovatocatalogo.referenti.length > 0) {
|
2025-04-29 02:30:00 +02:00
|
|
|
return trovatocatalogo.referenti.join(', ');
|
|
|
|
|
} else {
|
|
|
|
|
return '[Nessun Referente]';
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-06-20 17:22:46 +02:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
function getImgIntroCatalogo(scheda: IMyScheda): IImg {
|
2025-05-15 22:37:39 +02:00
|
|
|
const trovatocatalogo = myCatalog.value;
|
2025-02-05 12:13:36 +01:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
let imagefile = '';
|
2025-05-23 16:31:04 +02:00
|
|
|
let fit = 'cover';
|
2025-02-05 12:13:36 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
if (trovatocatalogo && scheda.isPagIntro) {
|
2025-05-23 16:31:04 +02:00
|
|
|
const recimg = isStampa() ? trovatocatalogo.img_intro_stampa : trovatocatalogo.img_intro;
|
2025-02-10 22:48:53 +01:00
|
|
|
if (recimg) {
|
2025-05-08 23:32:13 +02:00
|
|
|
imagefile = recimg.imagefile!;
|
2025-05-23 16:31:04 +02:00
|
|
|
fit = recimg.fit! || 'cover';
|
2025-05-08 23:32:13 +02:00
|
|
|
imagefile = imagefile
|
2025-05-21 12:06:09 +02:00
|
|
|
? `url("${tools.getDirUpload() + shared_consts.getDirectoryByTable(shared_consts.TABLES_CATALOG) + '/' + trovatocatalogo._id + '/' + imagefile}")`
|
2025-05-08 23:32:13 +02:00
|
|
|
: '';
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
return { imagefile, fit };
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
function getSfondoImgCatalogo(scheda?: IMyScheda | null, mypage?: IDimensioni): IImg {
|
2025-05-15 22:37:39 +02:00
|
|
|
const trovatocatalogo = myCatalog.value;
|
2025-02-10 22:48:53 +01:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
let imagefile = '';
|
2025-05-23 16:31:04 +02:00
|
|
|
let fit = 'cover';
|
2025-02-10 22:48:53 +01:00
|
|
|
|
|
|
|
|
if (trovatocatalogo) {
|
|
|
|
|
// Cerca prima se c'è un Immagine Introduttiva
|
2025-05-08 23:32:13 +02:00
|
|
|
const recimgintro = getImgIntroCatalogo(scheda);
|
2025-02-10 22:48:53 +01:00
|
|
|
if (recimgintro.imagefile) {
|
2025-05-08 23:32:13 +02:00
|
|
|
imagefile = recimgintro.imagefile!;
|
2025-05-23 16:31:04 +02:00
|
|
|
fit = recimgintro.fit! || 'cover';
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
2025-02-05 12:13:36 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
// Poi cerca se c'è l'immagine di sfondo
|
2025-05-23 16:31:04 +02:00
|
|
|
const recimg = isStampa()
|
|
|
|
|
? trovatocatalogo.img_bordata_stampa
|
|
|
|
|
: trovatocatalogo.img_bordata!;
|
2025-02-10 22:48:53 +01:00
|
|
|
if (!imagefile && recimg) {
|
2025-05-08 23:32:13 +02:00
|
|
|
imagefile = recimg.imagefile!;
|
2025-05-23 16:31:04 +02:00
|
|
|
fit = recimg.fit! || 'cover';
|
2025-05-08 23:32:13 +02:00
|
|
|
imagefile = imagefile
|
2025-05-21 12:06:09 +02:00
|
|
|
? `url("${tools.getDirUpload() + shared_consts.getDirectoryByTable(shared_consts.TABLES_CATALOG) + '/' + trovatocatalogo._id + '/' + imagefile}")`
|
2025-05-08 23:32:13 +02:00
|
|
|
: '';
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
2025-05-23 16:31:04 +02:00
|
|
|
} else {
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!imagefile && scheda) {
|
2025-05-08 23:32:13 +02:00
|
|
|
imagefile = scheda.dimensioni?.pagina?.dimensioni?.imgsfondo!.imagefile;
|
2025-05-21 12:06:09 +02:00
|
|
|
imagefile = imagefile
|
|
|
|
|
? `url("${tools.getDirUpload() + costanti.DIR_SCHEDA + imagefile}")`
|
|
|
|
|
: '';
|
2025-05-08 23:32:13 +02:00
|
|
|
fit = scheda.dimensioni?.pagina?.dimensioni?.imgsfondo!.fit;
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
|
|
|
|
if (!imagefile && mypage) {
|
2025-05-08 23:32:13 +02:00
|
|
|
imagefile = mypage.imgsfondo!.imagefile!;
|
2025-05-21 12:06:09 +02:00
|
|
|
imagefile = imagefile
|
|
|
|
|
? `url("${tools.getDirUpload() + costanti.DIR_CATALOGO + imagefile}")`
|
|
|
|
|
: '';
|
2025-05-08 23:32:13 +02:00
|
|
|
fit = mypage.imgsfondo!.fit!;
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
2025-02-05 12:13:36 +01:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
if (!imagefile && optcatalogo.value.dimensioni_def.pagina) {
|
|
|
|
|
imagefile = optcatalogo.value.dimensioni_def.pagina.imgsfondo!.imagefile!;
|
|
|
|
|
imagefile = imagefile
|
|
|
|
|
? `url("${tools.getDirUpload() + costanti.DIR_CATALOGO + imagefile}")`
|
|
|
|
|
: '';
|
|
|
|
|
fit = optcatalogo.value.dimensioni_def.pagina.imgsfondo!.fit!;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Se non è stato impostato nessun immagine, allora metto quelli di default
|
|
|
|
|
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-05-08 23:32:13 +02:00
|
|
|
return { imagefile, fit };
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
2025-04-29 02:30:00 +02:00
|
|
|
function getIdCollaneDaFiltrare(def_idCollane?: string[]) {
|
2025-05-08 23:32:13 +02:00
|
|
|
let idCollane: string[] = [];
|
2025-02-10 22:48:53 +01:00
|
|
|
|
|
|
|
|
// Cerca se nella lista cataloghi c'è la Collana di questa Pagina !
|
2025-05-15 22:37:39 +02:00
|
|
|
const trovatocatalogo = myCatalog.value;
|
2025-02-10 22:48:53 +01:00
|
|
|
|
|
|
|
|
if (trovatocatalogo) {
|
2025-05-08 23:32:13 +02:00
|
|
|
idCollane = trovatocatalogo.idCollane! || [];
|
2025-02-05 12:13:36 +01:00
|
|
|
} else {
|
2025-05-08 23:32:13 +02:00
|
|
|
idCollane = def_idCollane || [];
|
2025-02-05 12:13:36 +01:00
|
|
|
}
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
return idCollane;
|
2025-02-05 12:13:36 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-11 18:58:06 +01:00
|
|
|
function getArgomentiDaFiltrare(def_argomenti?: string[]) {
|
2025-05-08 23:32:13 +02:00
|
|
|
let argomenti: string[] = [];
|
2025-02-11 18:58:06 +01:00
|
|
|
|
|
|
|
|
// Cerca se nella lista cataloghi c'è la Collana di questa Pagina !
|
2025-05-15 22:37:39 +02:00
|
|
|
const trovatocatalogo = myCatalog.value;
|
2025-02-11 18:58:06 +01:00
|
|
|
|
|
|
|
|
if (trovatocatalogo) {
|
2025-05-08 23:32:13 +02:00
|
|
|
argomenti = trovatocatalogo.argomenti! || [];
|
2025-02-11 18:58:06 +01:00
|
|
|
} else {
|
2025-03-01 14:14:43 +01:00
|
|
|
if (def_argomenti && def_argomenti.length > 0) {
|
2025-05-08 23:32:13 +02:00
|
|
|
argomenti = def_argomenti;
|
2025-03-01 14:14:43 +01:00
|
|
|
} else {
|
2025-05-08 23:32:13 +02:00
|
|
|
argomenti = [];
|
2025-03-01 14:14:43 +01:00
|
|
|
}
|
2025-02-11 18:58:06 +01:00
|
|
|
}
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
return argomenti;
|
2025-02-11 18:58:06 +01:00
|
|
|
}
|
|
|
|
|
|
2025-05-02 19:11:29 +02:00
|
|
|
function getidTipoFormatoDaFiltrare(def_idTipoFormato?: number[]) {
|
2025-05-08 23:32:13 +02:00
|
|
|
let idTipoFormato: number[] = [];
|
2025-05-02 19:11:29 +02:00
|
|
|
|
|
|
|
|
// Cerca se nella lista cataloghi c'è la Collana di questa Pagina !
|
2025-05-15 22:37:39 +02:00
|
|
|
const trovatocatalogo = myCatalog.value;
|
2025-05-02 19:11:29 +02:00
|
|
|
|
|
|
|
|
if (trovatocatalogo) {
|
2025-05-08 23:32:13 +02:00
|
|
|
idTipoFormato = trovatocatalogo.idTipoFormato! || [];
|
2025-05-02 19:11:29 +02:00
|
|
|
} else {
|
|
|
|
|
if (def_idTipoFormato && def_idTipoFormato.length > 0) {
|
2025-05-08 23:32:13 +02:00
|
|
|
idTipoFormato = def_idTipoFormato;
|
2025-05-02 19:11:29 +02:00
|
|
|
} else {
|
2025-05-08 23:32:13 +02:00
|
|
|
idTipoFormato = [];
|
2025-05-02 19:11:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
return idTipoFormato;
|
2025-05-02 19:11:29 +02:00
|
|
|
}
|
|
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
function getEditoreDaFiltrare(def_editori?: string[]) {
|
2025-05-08 23:32:13 +02:00
|
|
|
let editore: string[] = [];
|
2025-02-10 22:48:53 +01:00
|
|
|
|
|
|
|
|
// Cerca se nella lista cataloghi c'è la Collana di questa Pagina !
|
2025-05-15 22:37:39 +02:00
|
|
|
const trovatocatalogo = myCatalog.value;
|
2025-02-10 22:48:53 +01:00
|
|
|
|
|
|
|
|
if (trovatocatalogo) {
|
2025-05-08 23:32:13 +02:00
|
|
|
editore = trovatocatalogo.editore! || [];
|
2025-02-10 22:48:53 +01:00
|
|
|
} else {
|
2025-05-08 23:32:13 +02:00
|
|
|
editore = def_editori || [];
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
return editore;
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
function filterProducts(
|
|
|
|
|
products: IProduct[],
|
|
|
|
|
searchtext: string | string[],
|
|
|
|
|
filtroAuthor: string,
|
|
|
|
|
filtroProductTypes: number[],
|
|
|
|
|
filtroExcludeProductTypes: number[],
|
2025-04-24 19:31:34 +02:00
|
|
|
filtroidTipologie: number[],
|
2025-05-01 00:20:02 +02:00
|
|
|
filtroidTipoFormato: number[],
|
2025-03-26 23:23:35 +01:00
|
|
|
editore: string[],
|
2025-04-29 02:30:00 +02:00
|
|
|
idCollane: string[],
|
2025-03-26 23:23:35 +01:00
|
|
|
arrargomstr: any[],
|
2025-04-30 13:27:47 +02:00
|
|
|
op_andor: IOpAndOr,
|
2025-03-26 23:23:35 +01:00
|
|
|
catstr: string,
|
2025-05-08 23:32:13 +02:00
|
|
|
collanastr: string,
|
2025-03-26 23:23:35 +01:00
|
|
|
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)
|
2025-05-08 23:32:13 +02:00
|
|
|
? searchtext.map((text: string) =>
|
|
|
|
|
text
|
|
|
|
|
.toLowerCase()
|
|
|
|
|
.trim()
|
|
|
|
|
.replace(/[-@:=]/g, '')
|
|
|
|
|
)
|
|
|
|
|
: [
|
|
|
|
|
searchtext
|
|
|
|
|
.toLowerCase()
|
|
|
|
|
.trim()
|
|
|
|
|
.replace(/[-@:=]/g, ''),
|
|
|
|
|
];
|
2025-03-26 23:23:35 +01:00
|
|
|
|
|
|
|
|
const boolfiltroVuotoProductTypes =
|
2025-05-21 12:06:09 +02:00
|
|
|
filtroProductTypes.length === 0 ||
|
|
|
|
|
(filtroProductTypes.length === 1 && filtroProductTypes[0] === 0);
|
2025-05-23 16:31:04 +02:00
|
|
|
const boolfiltroVuotoExcludeProductTypes = filtroExcludeProductTypes.length === 0;
|
2025-04-24 19:31:34 +02:00
|
|
|
const boolfiltroVuotoidTipologie = filtroidTipologie.length === 0;
|
2025-05-01 00:20:02 +02:00
|
|
|
const boolfiltroVuotoidTipoFormato = filtroidTipoFormato.length === 0;
|
2025-03-26 23:23:35 +01:00
|
|
|
const boolfiltroVuotoEditore = editore.length === 0;
|
|
|
|
|
const boolfiltroVuotoCollane = idCollane.length === 0;
|
2025-04-30 13:27:47 +02:00
|
|
|
const boolfiltroVuotoArgomenti = arrargomstr.length === 0;
|
|
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
const se_tutti_veri = op_andor.condition_andor === costanti.OP_ANDOR.OP_AND;
|
2025-04-30 13:27:47 +02:00
|
|
|
|
2025-05-15 22:37:39 +02:00
|
|
|
const trovatocatalogo = myCatalog.value;
|
2025-05-08 23:32:13 +02:00
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
boolfiltroVuotoProductTypes &&
|
|
|
|
|
boolfiltroVuotoExcludeProductTypes &&
|
|
|
|
|
boolfiltroVuotoidTipologie &&
|
|
|
|
|
boolfiltroVuotoidTipoFormato &&
|
|
|
|
|
boolfiltroVuotoEditore &&
|
|
|
|
|
boolfiltroVuotoCollane &&
|
|
|
|
|
boolfiltroVuotoArgomenti &&
|
|
|
|
|
catstr === '' &&
|
|
|
|
|
collanastr === ''
|
2025-05-06 18:19:03 +02:00
|
|
|
) {
|
|
|
|
|
// Nessun filtro selezionato, pertanto non mostrare niente!
|
2025-05-08 23:32:13 +02:00
|
|
|
return [];
|
2025-05-06 18:19:03 +02: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-04-22 18:30:42 +02:00
|
|
|
// il prodotto dev'essere disponibile
|
2025-04-24 19:31:34 +02:00
|
|
|
//if (!productStore.isPubblicato(product.productInfo))
|
|
|
|
|
// return false
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
if (
|
|
|
|
|
!(
|
|
|
|
|
optrigenera.value.visibilitaDisp === costanti.DISP.TUTTI ||
|
2025-05-21 12:06:09 +02:00
|
|
|
(optrigenera.value.visibilitaDisp === costanti.DISP.ESAURITI &&
|
|
|
|
|
productStore.isEsaurito(product)) ||
|
2025-05-08 23:32:13 +02:00
|
|
|
(optrigenera.value.visibilitaDisp === costanti.DISP.DISPONIBILI &&
|
2025-05-21 12:06:09 +02:00
|
|
|
(productStore.isDisponibile(product) ||
|
|
|
|
|
productStore.isPrevendita(product.productInfo)))
|
2025-05-08 23:32:13 +02:00
|
|
|
)
|
|
|
|
|
) {
|
2025-04-24 19:31:34 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2025-05-08 23:32:13 +02:00
|
|
|
if (
|
|
|
|
|
!(
|
|
|
|
|
optrigenera.value.stato === costanti.STATO.TUTTI ||
|
|
|
|
|
(optrigenera.value.stato === costanti.STATO.IN_COMMERCIO &&
|
|
|
|
|
productStore.isPubblicato(product.productInfo)) ||
|
2025-05-23 16:31:04 +02:00
|
|
|
(optrigenera.value.stato === costanti.STATO.SOLO_PROSSIMA_USCITA &&
|
2025-05-08 23:32:13 +02:00
|
|
|
productStore.isProssimaUscita(product.productInfo)) ||
|
|
|
|
|
(optrigenera.value.stato === costanti.STATO.PREVENDITA &&
|
|
|
|
|
productStore.isPrevendita(product.productInfo)) ||
|
|
|
|
|
(optrigenera.value.stato === costanti.STATO.NON_VENDIBILE &&
|
|
|
|
|
productStore.isNonVendibile(product.productInfo))
|
|
|
|
|
)
|
|
|
|
|
) {
|
2025-04-24 19:31:34 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2025-04-22 18:30:42 +02: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-05-23 16:31:04 +02:00
|
|
|
const boolfiltroVuotoCat = product.productInfo.idCatProds?.length === 0;
|
2025-04-30 13:27:47 +02:00
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
// Filtri per argomenti e categorie
|
2025-04-30 13:27:47 +02:00
|
|
|
let hasCategoria = se_tutti_veri;
|
|
|
|
|
let hasArgomentiCat = se_tutti_veri;
|
2025-01-07 17:17:08 +01:00
|
|
|
if (arrargomstr && arrargomstr.length > 0) {
|
2025-05-23 16:31:04 +02:00
|
|
|
hasArgomentiCat = (product.productInfo.idCatProds || []).some((idCat: any) =>
|
|
|
|
|
arrargomstr.includes(idCat)
|
2025-05-21 12:06:09 +02:00
|
|
|
);
|
2025-04-30 13:27:47 +02:00
|
|
|
hasCategoria = se_tutti_veri;
|
2025-02-11 18:58:06 +01:00
|
|
|
} else {
|
2025-05-08 23:32:13 +02:00
|
|
|
if (optcatalogo.value.showListaArgomenti) {
|
2025-05-21 12:06:09 +02:00
|
|
|
const isCatVuoto =
|
2025-05-23 16:31:04 +02:00
|
|
|
boolfiltroVuotoCat || (product.productInfo.idCatProds || []).length === 0;
|
2025-05-06 18:19:03 +02:00
|
|
|
const isCatSenzaArgomento = catstr === costanti.NO_CATEGORY;
|
2025-05-21 12:06:09 +02:00
|
|
|
const isCatCorretto =
|
2025-05-23 16:31:04 +02:00
|
|
|
!catstr || (product.productInfo.idCatProds || []).includes(catstr);
|
|
|
|
|
hasCategoria = isCatSenzaArgomento && isCatVuoto ? true : isCatCorretto;
|
|
|
|
|
|
|
|
|
|
hasArgomentiCat = boolfiltroVuotoArgomenti ? se_tutti_veri : hasArgomentiCat;
|
2025-04-29 02:30:00 +02:00
|
|
|
}
|
2025-01-07 17:17:08 +01:00
|
|
|
}
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
let hasCollana = se_tutti_veri;
|
|
|
|
|
let hasCollanaStr = se_tutti_veri;
|
|
|
|
|
if (idCollane && idCollane.length > 0) {
|
|
|
|
|
hasCollanaStr = idCollane.includes(product.productInfo.idCollana);
|
|
|
|
|
hasCollana = se_tutti_veri;
|
|
|
|
|
} else {
|
|
|
|
|
if (optcatalogo.value.showListaCollane) {
|
2025-05-21 12:06:09 +02:00
|
|
|
const isCollanaVuoto =
|
2025-05-23 16:31:04 +02:00
|
|
|
boolfiltroVuotoCollane || (product.productInfo.idCollana || []).length === 0;
|
2025-05-08 23:32:13 +02:00
|
|
|
const isCollanaSenzaColl = collanastr === costanti.NO_CATEGORY;
|
2025-05-23 16:31:04 +02:00
|
|
|
const isCollanaCorretto = !collanastr || product.productInfo.idCollana === collanastr;
|
|
|
|
|
hasCollana = isCollanaSenzaColl && isCollanaVuoto ? true : isCollanaCorretto;
|
|
|
|
|
|
|
|
|
|
hasCollanaStr = boolfiltroVuotoCollane ? se_tutti_veri : hasCollanaStr;
|
2025-05-08 23:32:13 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Filtri per collana
|
|
|
|
|
/*
|
|
|
|
|
const hasCollana = boolfiltroVuotoCollane
|
2025-04-30 13:27:47 +02:00
|
|
|
? se_tutti_veri
|
2025-05-08 23:32:13 +02:00
|
|
|
: (idCollane || []).includes(product.productInfo.idCollana);
|
|
|
|
|
*/
|
2025-04-30 13:27:47 +02:00
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
// Filtri per autore
|
2025-05-21 12:06:09 +02:00
|
|
|
const hasAuthor =
|
2025-05-23 16:31:04 +02:00
|
|
|
!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
|
2025-05-21 12:06:09 +02:00
|
|
|
: (product.productInfo.productTypes || []).some((item: any) =>
|
|
|
|
|
filtroProductTypes.includes(item)
|
|
|
|
|
);
|
2025-03-26 23:23:35 +01:00
|
|
|
|
|
|
|
|
// Filtri per esclusione di tipi di prodotto
|
|
|
|
|
const hasExcludeProductTypes = boolfiltroVuotoExcludeProductTypes
|
|
|
|
|
? false
|
2025-05-21 12:06:09 +02:00
|
|
|
: (product.productInfo.productTypes || []).every((item: any) =>
|
|
|
|
|
filtroExcludeProductTypes.includes(item)
|
|
|
|
|
);
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-04-24 19:31:34 +02:00
|
|
|
const hasidTipologie = boolfiltroVuotoidTipologie
|
|
|
|
|
? true
|
2025-05-23 16:31:04 +02:00
|
|
|
: filtroidTipologie.includes(product.arrvariazioni?.[0].idTipologia);
|
2025-04-24 19:31:34 +02:00
|
|
|
|
2025-05-01 00:20:02 +02:00
|
|
|
const hasidTipoFormato = boolfiltroVuotoidTipoFormato
|
|
|
|
|
? true
|
2025-05-23 16:31:04 +02:00
|
|
|
: filtroidTipoFormato.includes(product.arrvariazioni?.[0].idTipoFormato);
|
2025-05-01 00:20:02 +02:00
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
// Filtri per editore
|
|
|
|
|
const hasPublished = boolfiltroVuotoEditore
|
2025-04-30 13:27:47 +02:00
|
|
|
? se_tutti_veri
|
2025-03-26 23:23:35 +01:00
|
|
|
: editore.includes(product.productInfo.idPublisher);
|
|
|
|
|
|
|
|
|
|
// Filtri per GAS
|
2025-05-08 23:32:13 +02:00
|
|
|
const productgassel =
|
2025-05-21 12:06:09 +02:00
|
|
|
!gasselstr ||
|
2025-05-23 16:31:04 +02:00
|
|
|
(cosaValue === shared_consts.PROD.GAS && product.idGasordine === gasselstr);
|
2025-03-26 23:23:35 +01:00
|
|
|
|
|
|
|
|
// Filtri per testo di ricerca
|
2025-05-08 23:32:13 +02:00
|
|
|
const searchMatch =
|
|
|
|
|
lowerSearchTexts.length === 0 ||
|
|
|
|
|
lowerSearchTexts.some((searchTerm: string) => {
|
2025-05-23 16:31:04 +02:00
|
|
|
const codeMatch = new RegExp(`\\b${searchTerm}\\b`, 'i').test(lowerCode);
|
2025-05-08 23:32:13 +02:00
|
|
|
const allWordsPresent = searchTerm
|
|
|
|
|
.split(/\s+/)
|
2025-05-23 16:31:04 +02:00
|
|
|
.every((word: string) => new RegExp(`\\b${word}\\b`, 'i').test(lowerName));
|
2025-05-08 23:32:13 +02:00
|
|
|
return codeMatch || allWordsPresent;
|
|
|
|
|
});
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-04-30 13:27:47 +02:00
|
|
|
// Funzione che valuta un gruppo in base a OP_AND o OP_OR
|
|
|
|
|
|
|
|
|
|
// Raccolgo tutti i gruppi attivi
|
2025-05-23 16:31:04 +02:00
|
|
|
const filtri = [hasArgomentiCat, hasCategoria, hasCollana, hasCollanaStr, hasPublished];
|
2025-04-30 13:27:47 +02:00
|
|
|
|
|
|
|
|
// Decido se combinare in AND o OR sulla base della scelta globale
|
2025-05-21 12:06:09 +02:00
|
|
|
let risult =
|
2025-05-23 16:31:04 +02:00
|
|
|
searchMatch && hasAuthor && productgassel && hasidTipologie && hasidTipoFormato;
|
2025-04-30 13:27:47 +02:00
|
|
|
|
|
|
|
|
if (op_andor.condition_andor === costanti.OP_ANDOR.OP_AND) {
|
|
|
|
|
risult = risult && filtri.every(Boolean); // Tutti i gruppi devono essere veri
|
|
|
|
|
} else {
|
2025-05-08 23:32:13 +02:00
|
|
|
risult = risult && filtri.some(Boolean);
|
2025-04-30 13:27:47 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
return risult;
|
2025-04-30 13:27:47 +02:00
|
|
|
|
|
|
|
|
// && !hasExcludeProductTypes
|
2025-03-26 23:23:35 +01:00
|
|
|
})
|
2025-05-23 16:31:04 +02:00
|
|
|
.sort((a, b) => (getProductsSorted([a, b], sortField, sortDir)[0] === a ? -1 : 1));
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-05-15 18:22:37 +02:00
|
|
|
// console.log(' sortField=' + sortField);
|
|
|
|
|
// console.log(' sortDir=' + sortDir);
|
|
|
|
|
// console.log(' Filtro=' + arrargomstr);
|
|
|
|
|
// console.log(' idCollane=' + idCollane);
|
|
|
|
|
// console.log('PRODOTTI FILTRATI:', arrris.length);
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
return arrris;
|
2025-03-26 23:23:35 +01:00
|
|
|
}
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-04-24 19:31:34 +02:00
|
|
|
async function calcArrProducts(generalista?: boolean) {
|
2025-05-15 18:22:37 +02:00
|
|
|
// console.log('calcArrProducts (generalista=' + generalista + ')');
|
|
|
|
|
|
|
|
|
|
if (generalista) {
|
|
|
|
|
// Devono esistere tutti i prodotti
|
|
|
|
|
await productStore.loadProducts(true);
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
if (!loadpage.value) return;
|
2025-04-24 19:31:34 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
generatinglist.value = true;
|
2025-04-24 19:31:34 +02:00
|
|
|
|
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];
|
2025-05-23 16:31:04 +02:00
|
|
|
const filtroExcludeProductTypes = optcatalogo.value.excludeproductTypes || [0];
|
2025-04-24 19:31:34 +02:00
|
|
|
const filtroidTipologie = optcatalogo.value.idTipologie || [];
|
2025-05-23 16:31:04 +02:00
|
|
|
const filtroidTipoFormato = getidTipoFormatoDaFiltrare(optcatalogo.value.idTipoFormato);
|
2025-03-26 23:23:35 +01:00
|
|
|
const editore = getEditoreDaFiltrare(optcatalogo.value.editore);
|
|
|
|
|
const filtroPublishers = editore || [];
|
|
|
|
|
const idCollane = getIdCollaneDaFiltrare(optcatalogo.value.idCollane);
|
|
|
|
|
const filtroCollane = idCollane || [];
|
2025-05-08 23:32:13 +02:00
|
|
|
|
|
|
|
|
const arrargomstr =
|
|
|
|
|
optcatalogo.value.argomenti && optcatalogo.value.argomenti.length > 0
|
|
|
|
|
? getArgomentiDaFiltrare(optcatalogo.value.argomenti)
|
|
|
|
|
: getArgomentiDaFiltrare(cat.value ? [cat.value] : []);
|
|
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
const catstr = cat.value || '';
|
2025-05-08 23:32:13 +02:00
|
|
|
const collanastr = collana.value || '';
|
|
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
const gasselstr = cosa.value === shared_consts.PROD.GAS ? idGasSel.value || '' : '';
|
2025-03-26 23:23:35 +01:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
let salva = false;
|
2025-03-31 23:55:53 +02:00
|
|
|
// Se nel catalogo è stato già generato, allora gli passo quello.
|
2025-05-15 22:37:39 +02:00
|
|
|
const trovatocatalogo = myCatalog.value;
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-05-15 18:22:37 +02:00
|
|
|
// if (editore) console.log('FILTRO editore', editore);
|
2025-04-24 19:31:34 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
if (showListaFiltrata.value) {
|
|
|
|
|
generalista = true;
|
2025-03-31 23:55:53 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-15 22:37:39 +02:00
|
|
|
/*if (myCatalog.value.lista_prodotti.length === 0) {
|
2025-04-23 01:59:39 +02:00
|
|
|
generalista = true
|
|
|
|
|
}*/
|
|
|
|
|
|
2025-04-30 13:27:47 +02:00
|
|
|
let op_andor: IOpAndOr = {
|
2025-05-08 23:32:13 +02:00
|
|
|
condition_andor:
|
2025-05-21 12:06:09 +02:00
|
|
|
trovatocatalogo?.condition_andor !== undefined
|
|
|
|
|
? trovatocatalogo.condition_andor
|
|
|
|
|
: costanti.OP_ANDOR.OP_AND,
|
2025-05-08 23:32:13 +02:00
|
|
|
};
|
2025-04-30 13:27:47 +02:00
|
|
|
|
2025-05-16 10:26:29 +02:00
|
|
|
if (!generalista && myCatalog.value?.lista_prodotti?.length > 0) {
|
2025-05-15 22:37:39 +02:00
|
|
|
arrprod = myCatalog.value.lista_prodotti;
|
2025-03-31 23:55:53 +02:00
|
|
|
} else {
|
2025-05-08 23:32:13 +02:00
|
|
|
arrprod = productStore.getProducts(cosa.value);
|
2025-03-31 23:55:53 +02:00
|
|
|
arrprod = filterProducts(
|
|
|
|
|
arrprod,
|
|
|
|
|
searchtext,
|
|
|
|
|
filtroAuthor,
|
|
|
|
|
filtroProductTypes,
|
|
|
|
|
filtroExcludeProductTypes,
|
2025-04-24 19:31:34 +02:00
|
|
|
filtroidTipologie,
|
2025-05-01 00:20:02 +02:00
|
|
|
filtroidTipoFormato,
|
2025-03-31 23:55:53 +02:00
|
|
|
filtroPublishers,
|
|
|
|
|
filtroCollane,
|
|
|
|
|
arrargomstr,
|
2025-04-30 13:27:47 +02:00
|
|
|
op_andor,
|
2025-03-31 23:55:53 +02:00
|
|
|
catstr,
|
2025-05-08 23:32:13 +02:00
|
|
|
collanastr,
|
2025-03-31 23:55:53 +02:00
|
|
|
gasselstr,
|
|
|
|
|
cosa.value,
|
|
|
|
|
filter.value.sort_field,
|
2025-05-08 23:32:13 +02:00
|
|
|
filter.value.sort_dir
|
2025-03-31 23:55:53 +02:00
|
|
|
);
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
salva = true;
|
2025-03-31 23:55:53 +02:00
|
|
|
}
|
2025-03-26 23:23:35 +01:00
|
|
|
|
|
|
|
|
arrProducts.value = arrprod;
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-04-01 18:36:45 +02:00
|
|
|
// console.log('arrprod', arrprod)
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
optcatalogo.value = productStore.populateDataWithlinkIdTemplate(optcatalogo.value);
|
2025-05-02 10:10:04 +02:00
|
|
|
|
|
|
|
|
// Ordina la lista
|
2025-05-23 16:31:04 +02:00
|
|
|
generatearrProdToViewSorted(!generalista, salva, !showListaFiltrata.value);
|
2025-03-26 23:23:35 +01:00
|
|
|
loaddata();
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-05-02 19:11:29 +02:00
|
|
|
if (generalista) {
|
2025-05-15 22:37:39 +02:00
|
|
|
const catalog = myCatalog.value;
|
2025-05-08 23:32:13 +02:00
|
|
|
if (catalog && !showListaFiltrata.value) {
|
|
|
|
|
catalog.data_lista_generata = tools.getDateNow();
|
|
|
|
|
catalog.username_lista_generata = userStore.my.username;
|
|
|
|
|
await saveCatalog();
|
2025-05-02 19:11:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-15 18:22:37 +02:00
|
|
|
// console.log('***** FINE calcArrPROD');
|
2025-04-24 19:31:34 +02:00
|
|
|
|
2025-05-15 18:22:37 +02:00
|
|
|
// console.log('areadistampa FINITO...', optcatalogo.value.areadistampa)
|
2025-05-14 20:18:04 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
generatinglist.value = false;
|
|
|
|
|
rigeneraLibri.value = false;
|
2025-03-26 23:23:35 +01:00
|
|
|
}
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-05-02 19:11:29 +02:00
|
|
|
async function saveCatalog() {
|
2025-05-15 22:37:39 +02:00
|
|
|
const catalog = myCatalog.value;
|
2025-05-02 19:11:29 +02:00
|
|
|
const mydata = {
|
|
|
|
|
table: 'catalogs',
|
2025-05-08 23:32:13 +02:00
|
|
|
data: catalog,
|
|
|
|
|
};
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
await globalStore.saveTable(mydata);
|
2025-05-02 19:11:29 +02:00
|
|
|
}
|
|
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
function generaListaLibri() {
|
2025-04-01 18:36:45 +02:00
|
|
|
// chiedi prima "Sei sicuro di rigenerare il catalogo?"
|
2025-05-08 23:32:13 +02:00
|
|
|
let risposta_si = false;
|
2025-04-01 18:36:45 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
let msg = 'Sicuri di RIGENERARE Sovrascrivendo questa lista di libri ?';
|
2025-05-02 10:10:04 +02:00
|
|
|
|
|
|
|
|
if (optrigenera.value.rig_mod == costanti.RIGENERAMOD.AGGIUNGI_SOLO) {
|
2025-05-08 23:32:13 +02:00
|
|
|
msg = 'Aggiungere i libri di questa nuova generazione ?';
|
2025-05-02 10:10:04 +02:00
|
|
|
}
|
|
|
|
|
|
2025-04-01 18:36:45 +02:00
|
|
|
$q.dialog({
|
2025-04-04 18:15:14 +02:00
|
|
|
title: 'Rigenera lista',
|
2025-05-02 10:10:04 +02:00
|
|
|
message: msg,
|
2025-04-01 18:36:45 +02:00
|
|
|
cancel: true,
|
2025-05-08 23:32:13 +02:00
|
|
|
persistent: false,
|
2025-04-01 18:36:45 +02:00
|
|
|
}).onOk(() => {
|
2025-05-08 23:32:13 +02:00
|
|
|
calcArrProducts(true);
|
|
|
|
|
});
|
2025-03-31 23:55:53 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-02 10:10:04 +02:00
|
|
|
function reSortList() {
|
2025-05-08 23:32:13 +02:00
|
|
|
let risposta_si = false;
|
2025-05-02 10:10:04 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
let msg = 'Sicuri di Riordinare questa lista ?';
|
2025-05-02 10:10:04 +02:00
|
|
|
|
|
|
|
|
$q.dialog({
|
|
|
|
|
title: 'Riordina lista',
|
|
|
|
|
message: msg,
|
|
|
|
|
cancel: true,
|
2025-05-08 23:32:13 +02:00
|
|
|
persistent: false,
|
2025-05-02 10:10:04 +02:00
|
|
|
}).onOk(() => {
|
2025-05-08 23:32:13 +02:00
|
|
|
calcArrProducts(false);
|
|
|
|
|
});
|
2025-05-02 10:10:04 +02:00
|
|
|
}
|
|
|
|
|
|
2025-04-24 19:31:34 +02:00
|
|
|
function arraysEqual(arr1, arr2) {
|
|
|
|
|
return (
|
|
|
|
|
Array.isArray(arr1) &&
|
|
|
|
|
Array.isArray(arr2) &&
|
|
|
|
|
arr1.length === arr2.length &&
|
|
|
|
|
arr1.every((val, index) => val === arr2[index])
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function checkIfFiltriDiversi(scheda: IMyScheda, schedaprec: IMyScheda) {
|
2025-05-08 23:32:13 +02:00
|
|
|
if (schedaprec === null) return true;
|
2025-04-24 19:31:34 +02:00
|
|
|
|
|
|
|
|
const isDifferent =
|
|
|
|
|
!arraysEqual(scheda.productTypes, schedaprec?.productTypes) ||
|
2025-05-23 16:31:04 +02:00
|
|
|
!arraysEqual(scheda.excludeproductTypes, schedaprec?.excludeproductTypes) ||
|
2025-04-24 19:31:34 +02:00
|
|
|
!arraysEqual(scheda.idTipologie, schedaprec?.idTipologie) ||
|
2025-05-01 00:20:02 +02:00
|
|
|
!arraysEqual(scheda.idTipoFormato, schedaprec?.idTipoFormato) ||
|
2025-04-24 19:31:34 +02:00
|
|
|
!arraysEqual(scheda.editore, schedaprec?.editore) ||
|
2025-05-08 23:32:13 +02:00
|
|
|
!arraysEqual(scheda.idCollane, schedaprec?.idCollane);
|
2025-04-24 19:31:34 +02:00
|
|
|
return isDifferent;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
function getProductsFilteredByScheda(scheda: IMyScheda): IProduct[] {
|
2025-04-24 19:31:34 +02:00
|
|
|
let arrprod = [];
|
|
|
|
|
|
2025-03-26 23:23:35 +01:00
|
|
|
const filtroAuthor = filter.value.author || '';
|
|
|
|
|
const filtroProductTypes = scheda.productTypes || [0];
|
|
|
|
|
const filtroExcludeProductTypes = scheda.excludeproductTypes || [0];
|
2025-04-24 19:31:34 +02:00
|
|
|
const filtroidTipologie = scheda.idTipologie || [];
|
2025-05-23 16:31:04 +02:00
|
|
|
const filtroidTipoFormato = getidTipoFormatoDaFiltrare(scheda.idTipoFormato);
|
2025-03-26 23:23:35 +01:00
|
|
|
const editore = getEditoreDaFiltrare(scheda.editore);
|
|
|
|
|
const filtroPublishers = editore || [];
|
|
|
|
|
const idCollane = getIdCollaneDaFiltrare(scheda.idCollane);
|
|
|
|
|
const filtroCollane = idCollane || [];
|
2025-05-08 23:32:13 +02:00
|
|
|
const arrargomstr =
|
|
|
|
|
optcatalogo.value.argomenti && optcatalogo.value.argomenti.length > 0
|
|
|
|
|
? getArgomentiDaFiltrare(optcatalogo.value.argomenti)
|
|
|
|
|
: [];
|
2025-03-26 23:23:35 +01:00
|
|
|
const catstr = cat.value || '';
|
2025-05-08 23:32:13 +02:00
|
|
|
const collanastr = collana.value || '';
|
2025-05-23 16:31:04 +02:00
|
|
|
const gasselstr = cosa.value === shared_consts.PROD.GAS ? idGasSel.value || '' : '';
|
2025-03-26 23:23:35 +01:00
|
|
|
|
2025-05-15 22:37:39 +02:00
|
|
|
const trovatocatalogo = myCatalog.value;
|
2025-04-30 13:27:47 +02:00
|
|
|
|
|
|
|
|
let op_andor: IOpAndOr = {
|
2025-05-23 16:31:04 +02:00
|
|
|
condition_andor: trovatocatalogo?.condition_andor ?? costanti.OP_ANDOR.OP_AND,
|
2025-05-08 23:32:13 +02:00
|
|
|
};
|
2025-04-30 13:27:47 +02:00
|
|
|
|
2025-05-16 10:26:29 +02:00
|
|
|
if (myCatalog.value?.lista_prodotti?.length > 0) {
|
2025-05-15 22:37:39 +02:00
|
|
|
arrprod = myCatalog.value.lista_prodotti;
|
2025-03-31 23:55:53 +02:00
|
|
|
} else {
|
2025-05-08 23:32:13 +02:00
|
|
|
arrprod = productStore.getProducts(cosa.value);
|
2025-03-31 23:55:53 +02:00
|
|
|
|
|
|
|
|
arrprod = filterProducts(
|
|
|
|
|
arrprod,
|
|
|
|
|
scheda.arrProdottiSpeciali || [],
|
|
|
|
|
filtroAuthor,
|
|
|
|
|
filtroProductTypes,
|
|
|
|
|
filtroExcludeProductTypes,
|
2025-04-24 19:31:34 +02:00
|
|
|
filtroidTipologie,
|
2025-05-01 00:20:02 +02:00
|
|
|
filtroidTipoFormato,
|
2025-03-31 23:55:53 +02:00
|
|
|
filtroPublishers,
|
|
|
|
|
filtroCollane,
|
|
|
|
|
arrargomstr,
|
2025-04-30 13:27:47 +02:00
|
|
|
op_andor,
|
2025-03-31 23:55:53 +02:00
|
|
|
catstr,
|
2025-05-08 23:32:13 +02:00
|
|
|
collanastr,
|
2025-03-31 23:55:53 +02:00
|
|
|
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-04-11 18:49:42 +02:00
|
|
|
/**
|
|
|
|
|
* Funzione che ordina un array di prodotti in base a un campo specifico
|
|
|
|
|
* @param arrprod array di prodotti da ordinare
|
|
|
|
|
* @param sort_field campo su cui effettuare l'ordinamento
|
|
|
|
|
* @param sort_dir direzione dell'ordinamento (1 asc, -1 desc)
|
|
|
|
|
* @returns array di prodotti ordinati
|
|
|
|
|
*/
|
2025-05-21 12:06:09 +02:00
|
|
|
function getProductsSorted(
|
|
|
|
|
arrprod: IProduct[],
|
|
|
|
|
sort_field: string,
|
|
|
|
|
sort_dir: number
|
|
|
|
|
): IProduct[] {
|
2025-01-07 17:17:08 +01:00
|
|
|
if (sort_field) {
|
2025-04-30 13:27:47 +02:00
|
|
|
// console.log('--- Primi 10 elementi INIZIALI:');
|
2025-05-15 18:22:37 +02:00
|
|
|
/*arrprod.slice(0, 15).forEach((product, index) => {
|
2025-05-08 23:32:13 +02:00
|
|
|
console.log(`${index + 1}. ${product.productInfo?.name} (${product.productInfo?.date_pub})`);
|
2025-05-15 18:22:37 +02:00
|
|
|
});*/
|
2025-04-11 18:49:42 +02:00
|
|
|
|
2025-01-07 17:17:08 +01:00
|
|
|
// Crea una copia dell'array per non modificare l'originale
|
|
|
|
|
const sortedArr = [...arrprod].sort((a: IProduct, b: IProduct) => {
|
2025-05-21 12:06:09 +02:00
|
|
|
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 : '');
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-04-11 18:49:42 +02:00
|
|
|
// Ordinamento per data
|
|
|
|
|
if (valA instanceof Date && valB instanceof Date) {
|
2025-05-21 12:06:09 +02:00
|
|
|
return sort_dir === 1
|
|
|
|
|
? valA.getTime() - valB.getTime()
|
|
|
|
|
: valB.getTime() - valA.getTime();
|
2025-04-11 18:49:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ordinamento per numeri
|
2025-01-07 17:17:08 +01:00
|
|
|
if (typeof valA === 'number' && typeof valB === 'number') {
|
|
|
|
|
return sort_dir === 1 ? valA - valB : valB - valA;
|
|
|
|
|
}
|
2025-04-11 18:49:42 +02:00
|
|
|
|
|
|
|
|
// Ordinamento per stringhe o altri tipi
|
|
|
|
|
const compA = valA.toString().toLowerCase();
|
|
|
|
|
const compB = valB.toString().toLowerCase();
|
2025-05-23 16:31:04 +02:00
|
|
|
return sort_dir === 1 ? compA.localeCompare(compB) : compB.localeCompare(compA);
|
2025-01-07 17:17:08 +01:00
|
|
|
});
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-04-18 13:23:52 +02:00
|
|
|
// logga i primi N elementi, mostrando il nome del prodotto (productInfo.name e la data di pibblicazione : productinfo.date_pub
|
2025-04-11 18:49:42 +02:00
|
|
|
if (sortedArr.length > 0) {
|
2025-04-30 13:27:47 +02:00
|
|
|
// console.log('Primi 15 elementi ordinati: ***** ');
|
2025-05-15 18:22:37 +02:00
|
|
|
/*sortedArr.slice(0, 15).forEach((product, index) => {
|
2025-05-08 23:32:13 +02:00
|
|
|
console.log(`${index + 1}. ${product.productInfo?.name} (${product.productInfo?.date_pub})`);
|
2025-05-15 18:22:37 +02:00
|
|
|
});*/
|
2025-04-11 18:49:42 +02:00
|
|
|
} else {
|
2025-05-15 18:22:37 +02:00
|
|
|
// console.log('Nessun prodotto trovato.');
|
2025-04-11 18:49:42 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
return sortedArr;
|
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
|
|
|
}
|
|
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
function addNextProductToTheView(arrproductfiltrati: IProduct[], indprod: number) {
|
2024-10-31 23:23:06 +01:00
|
|
|
try {
|
2025-04-18 13:23:52 +02:00
|
|
|
while (indprod < arrproductfiltrati.length) {
|
|
|
|
|
const rectrovato = arrProdToView.value.find(
|
2025-05-23 16:31:04 +02:00
|
|
|
(prodview: IProdView) => prodview.id === arrproductfiltrati[indprod]._id
|
2024-10-31 23:23:06 +01:00
|
|
|
);
|
|
|
|
|
|
2025-04-18 13:23:52 +02:00
|
|
|
if (!rectrovato) {
|
|
|
|
|
const myrec = arrproductfiltrati[indprod];
|
|
|
|
|
arrProdToView.value.push({ id: myrec._id });
|
|
|
|
|
return { myrec, added: true, indprod: indprod + 1 };
|
2024-10-31 23:23:06 +01:00
|
|
|
}
|
|
|
|
|
|
2025-04-18 13:23:52 +02:00
|
|
|
indprod++;
|
2024-10-31 23:23:06 +01:00
|
|
|
}
|
|
|
|
|
|
2025-04-18 13:23:52 +02:00
|
|
|
return { end: true };
|
2024-10-31 23:23:06 +01:00
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e);
|
2025-04-18 13:23:52 +02:00
|
|
|
return { rec: null, indprod };
|
2024-10-31 23:23:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-21 12:06:09 +02:00
|
|
|
function getProdBySchedaRigaCol(
|
|
|
|
|
recscheda: ISchedaSingola,
|
|
|
|
|
pagina: number,
|
|
|
|
|
riga: number,
|
|
|
|
|
col: number
|
|
|
|
|
) {
|
2024-10-31 23:23:06 +01:00
|
|
|
try {
|
2025-05-08 23:32:13 +02:00
|
|
|
return recscheda.arrProdToShow![pagina][riga][col];
|
2024-10-31 23:23:06 +01:00
|
|
|
} catch (e) {
|
2025-05-08 23:32:13 +02:00
|
|
|
return null;
|
2024-10-31 23:23:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-21 12:06:09 +02:00
|
|
|
function generatearrProdToViewSorted(
|
|
|
|
|
usaprodottiSalvati?: boolean,
|
|
|
|
|
salva?: boolean,
|
|
|
|
|
salvasudb?: 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 {
|
|
|
|
|
// Svuota
|
2025-05-08 23:32:13 +02:00
|
|
|
arrProdToView.value = [];
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-05-15 22:37:39 +02:00
|
|
|
const trovatocatalogo = myCatalog.value;
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
let arrGeneraleProdotti = [];
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-05-16 10:26:29 +02:00
|
|
|
if (usaprodottiSalvati && myCatalog.value?.lista_prodotti?.length > 0) {
|
2025-03-31 23:55:53 +02:00
|
|
|
} else {
|
|
|
|
|
arrGeneraleProdotti = arrProducts.value;
|
|
|
|
|
}
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
let indprod = 0;
|
|
|
|
|
const indprodGenerale = 0;
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
let indtotale = 0;
|
2025-02-11 18:58:06 +01:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
let arrprod = [];
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-04-24 19:31:34 +02:00
|
|
|
let schedaprec = null;
|
|
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
for (const recscheda of optcatalogo.value.arrSchede!) {
|
|
|
|
|
if (recscheda && recscheda.scheda) {
|
2025-05-08 23:32:13 +02: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-05-08 23:32:13 +02:00
|
|
|
let arrProdFiltrati: IProduct[] = [];
|
2025-02-10 22:48:53 +01:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
if (usaprodottiSalvati && myCatalog.value?.lista_prodotti?.length > 0) {
|
2025-05-15 22:37:39 +02:00
|
|
|
arrProdFiltrati = myCatalog.value.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 !
|
2025-05-23 16:31:04 +02:00
|
|
|
if (checkIfFiltriDiversi(recscheda.scheda, schedaprec) || indprod === 0) {
|
|
|
|
|
arrProdFiltrati = getProductsFilteredByScheda(recscheda.scheda);
|
2025-05-08 23:32:13 +02:00
|
|
|
schedaprec = { ...recscheda.scheda };
|
|
|
|
|
indprod = 0;
|
2025-04-24 19:31:34 +02:00
|
|
|
}
|
2025-02-10 22:48:53 +01:00
|
|
|
} else {
|
2025-05-23 16:31:04 +02:00
|
|
|
let sort_field = recscheda.scheda.sort_field! || optcatalogo.value.sort_field;
|
|
|
|
|
let sort_dir = recscheda.scheda.sort_dir || optcatalogo.value.sort_dir;
|
2025-04-22 18:30:42 +02:00
|
|
|
if (sort_field) {
|
2025-05-23 16:31:04 +02:00
|
|
|
arrProdFiltrati = getProductsSorted(arrGeneraleProdotti, sort_field, sort_dir);
|
2025-05-08 23:32:13 +02:00
|
|
|
indprod = 0;
|
2025-03-31 23:55:53 +02:00
|
|
|
} else {
|
2025-05-08 23:32:13 +02:00
|
|
|
indprod = indprodGenerale;
|
|
|
|
|
arrProdFiltrati = arrGeneraleProdotti;
|
2025-03-31 23:55:53 +02:00
|
|
|
}
|
2025-02-10 22:48:53 +01:00
|
|
|
}
|
2024-11-28 16:04:48 +01:00
|
|
|
}
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
let indadded = 0;
|
|
|
|
|
recscheda.arrProdToShow = [];
|
2024-11-28 16:04:48 +01:00
|
|
|
|
2025-04-18 13:23:52 +02:00
|
|
|
for (let pagina = 0; pagina < 600; pagina++) {
|
2025-05-08 23:32:13 +02:00
|
|
|
indadded = 0;
|
|
|
|
|
let lastresultend = false;
|
2025-02-10 22:48:53 +01:00
|
|
|
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
|
2025-05-23 16:31:04 +02:00
|
|
|
const result = addNextProductToTheView(arrProdFiltrati, indprod);
|
2025-02-10 22:48:53 +01:00
|
|
|
if (result.end) {
|
2025-05-08 23:32:13 +02:00
|
|
|
lastresultend = true;
|
2025-02-10 22:48:53 +01:00
|
|
|
break; // Esci dal ciclo se non ci sono più prodotti disponibili
|
|
|
|
|
} else {
|
2025-05-08 23:32:13 +02:00
|
|
|
if (result.indprod) indprod = result.indprod; // Aggiorna indprod per il prossimo giro
|
2025-02-10 22:48:53 +01:00
|
|
|
if (result.myrec) {
|
2025-05-08 23:32:13 +02: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-05-08 23:32:13 +02:00
|
|
|
arrprod.push(result.myrec);
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
recscheda.arrProdToShow[pagina][riga][col] = result.myrec;
|
2024-10-31 23:23:06 +01:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
indadded++;
|
|
|
|
|
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) {
|
2025-05-08 23:32:13 +02:00
|
|
|
if (indtotale > optcatalogo.value.maxnumlibri!) break;
|
2025-05-06 18:19:03 +02:00
|
|
|
} else {
|
|
|
|
|
// if (indtotale > 1000)
|
|
|
|
|
// break
|
2025-02-11 18:58:06 +01:00
|
|
|
}
|
2024-11-19 19:19:14 +01:00
|
|
|
}
|
|
|
|
|
}
|
2024-10-31 23:23:06 +01:00
|
|
|
}
|
2025-05-08 23:32:13 +02:00
|
|
|
if (lastresultend) break; // Esci dal ciclo se non ci sono più prodotti disponibili
|
2025-02-11 18:58:06 +01:00
|
|
|
|
2025-02-10 22:48:53 +01:00
|
|
|
if (recscheda.numPagineMax! > 0) {
|
2025-05-08 23:32:13 +02:00
|
|
|
if (pagina + 1 >= recscheda.numPagineMax!) break; // fine pagine
|
2025-02-10 22:48:53 +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) {
|
2025-04-01 18:36:45 +02:00
|
|
|
if (trovatocatalogo) {
|
2025-05-23 16:31:04 +02:00
|
|
|
if (optrigenera.value.rig_mod === costanti.RIGENERAMOD.AGGIUNGI_SOLO) {
|
2025-05-02 10:10:04 +02:00
|
|
|
// aggiungi solo i record che non sono presenti su lista_prodotti
|
2025-05-23 16:31:04 +02:00
|
|
|
trovatocatalogo.lista_prodotti = trovatocatalogo.lista_prodotti.filter(
|
|
|
|
|
(p) => !arrprod.some((ap) => ap._id === p._id)
|
|
|
|
|
);
|
2025-05-08 23:32:13 +02:00
|
|
|
trovatocatalogo.lista_prodotti.push(
|
2025-05-21 12:06:09 +02:00
|
|
|
...arrprod.filter(
|
2025-05-23 16:31:04 +02:00
|
|
|
(ap) => !trovatocatalogo.lista_prodotti.some((p) => p._id === ap._id)
|
2025-05-21 12:06:09 +02:00
|
|
|
)
|
2025-05-08 23:32:13 +02:00
|
|
|
);
|
2025-05-02 10:10:04 +02:00
|
|
|
} else {
|
2025-05-08 23:32:13 +02:00
|
|
|
trovatocatalogo.lista_prodotti = arrprod;
|
2025-05-02 10:10:04 +02:00
|
|
|
}
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-04-23 01:59:39 +02:00
|
|
|
if (salvasudb) {
|
2025-05-08 23:32:13 +02:00
|
|
|
salvaListaProdotti(false);
|
2025-04-23 01:59:39 +02:00
|
|
|
}
|
2025-04-01 18:36:45 +02:00
|
|
|
}
|
2025-03-31 23:55:53 +02:00
|
|
|
}
|
2025-02-10 22:48:53 +01:00
|
|
|
} catch (e) {
|
2025-05-08 23:32:13 +02:00
|
|
|
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
|
2025-05-15 22:37:39 +02:00
|
|
|
const myarr = [...myCatalog.value.lista_prodotti];
|
2025-05-08 23:32:13 +02:00
|
|
|
const productIds = myarr.map((product) => product._id);
|
2025-03-31 23:55:53 +02:00
|
|
|
|
|
|
|
|
let mydata = {
|
2025-05-08 23:32:13 +02:00
|
|
|
lista_prodotti: productIds,
|
|
|
|
|
};
|
2025-03-31 23:55:53 +02:00
|
|
|
|
|
|
|
|
// Salva gli ID dei prodotti nel catalogo
|
2025-05-21 12:06:09 +02:00
|
|
|
tools.saveFieldToServer(
|
|
|
|
|
$q,
|
|
|
|
|
'catalogs',
|
|
|
|
|
myCatalog.value._id,
|
|
|
|
|
mydata,
|
|
|
|
|
!showListaFiltrata.value,
|
|
|
|
|
false
|
|
|
|
|
);
|
2025-03-31 23:55:53 +02:00
|
|
|
|
|
|
|
|
if (ricarica) {
|
|
|
|
|
generatearrProdToViewSorted(true, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
});
|
|
|
|
|
}*/
|
|
|
|
|
|
2025-04-24 19:31:34 +02:00
|
|
|
function getKeyCatAtLoad() {
|
2025-05-08 23:32:13 +02:00
|
|
|
return tools.COOK_CATEGORIA + (showListaFiltrata.value ? '_LA' : '');
|
|
|
|
|
}
|
|
|
|
|
function getKeyCollanaAtLoad() {
|
|
|
|
|
return tools.COOK_COLLANA + (showListaFiltrata.value ? '_LA' : '');
|
2025-04-24 19:31:34 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
function isStampa() {
|
|
|
|
|
return optcatalogo.value.selectedVersionStampabile === shared_consts.PREPARA_PDF.STAMPA;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-30 14:00:48 +01:00
|
|
|
async function mounted() {
|
2025-01-07 17:17:08 +01:00
|
|
|
// console.log('mounted Catalogo')
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-05-15 22:37:39 +02:00
|
|
|
let mycat = catalogStore.getCatalogByIdPageAssigned(props.idPage) || null;
|
|
|
|
|
if (mycat && !mycat.lista_prodotti) {
|
|
|
|
|
mycat = await catalogStore.fetchCatalogById(mycat._id);
|
|
|
|
|
}
|
|
|
|
|
myCatalog.value = mycat;
|
|
|
|
|
|
2025-05-15 19:18:50 +02:00
|
|
|
ismounting.value = true;
|
2025-05-08 23:32:13 +02:00
|
|
|
generatinglist.value = true;
|
|
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
if (optcatalogo.value.showListaArgomenti) cat.value = tools.getCookie(getKeyCatAtLoad(), '');
|
|
|
|
|
|
|
|
|
|
optcatalogo.value.selectedVersionStampabile = shared_consts.PREPARA_PDF.WEB;
|
2025-04-29 02:30:00 +02:00
|
|
|
|
2025-05-21 12:06:09 +02:00
|
|
|
if (optcatalogo.value.showListaCollane)
|
|
|
|
|
collana.value = tools.getCookie(getKeyCollanaAtLoad(), '');
|
2025-04-24 19:31:34 +02:00
|
|
|
|
2025-05-15 22:37:39 +02:00
|
|
|
if (myCatalog.value) {
|
2025-05-08 23:32:13 +02:00
|
|
|
tabcatalogo.value = tools.getCookie('TAB_CAT', 'lista');
|
2025-05-01 00:20:02 +02:00
|
|
|
} else {
|
2025-05-15 22:37:39 +02:00
|
|
|
tabcatalogo.value = 'visu';
|
2025-05-01 00:20:02 +02:00
|
|
|
}
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
optrigenera.value.visibilitaDisp = tools.getCookie(
|
|
|
|
|
(showListaFiltrata.value ? 'INC_ES_' : '') + 'VIS_DISP',
|
|
|
|
|
costanti.DISP.DISPONIBILI
|
|
|
|
|
);
|
|
|
|
|
if (!showListaFiltrata.value)
|
|
|
|
|
optrigenera.value.rig_mod = tools.getCookie(
|
|
|
|
|
(showListaFiltrata.value ? 'INC_ES_' : '') + 'RIG_MOD',
|
|
|
|
|
costanti.RIGENERAMOD.AGGIUNGI_SOLO
|
|
|
|
|
);
|
|
|
|
|
optrigenera.value.stato = tools.getCookie(
|
|
|
|
|
(showListaFiltrata.value ? 'INC_ES_' : '') + 'VIS_STATO',
|
|
|
|
|
costanti.STATO.IN_COMMERCIO
|
|
|
|
|
);
|
2025-04-24 19:31:34 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
loadpage.value = false;
|
2025-05-15 22:37:39 +02:00
|
|
|
if (showListaFiltrata.value || !myCatalog.value) {
|
2025-05-15 18:22:37 +02:00
|
|
|
// Carica tutti i prodotti
|
|
|
|
|
await productStore.loadProducts(true);
|
|
|
|
|
} else {
|
2025-05-15 22:37:39 +02:00
|
|
|
/*if (myCatalog.value && props.idPage) {
|
|
|
|
|
myCatalog.value.lista_prodotti = await catalogStore.loadProductsOnlyByIdPageCatalog(props.idPage);
|
|
|
|
|
}*/
|
2025-05-15 18:22:37 +02:00
|
|
|
}
|
2024-05-09 23:36:58 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
mycolumns.value = fieldsTable.getArrColsByTable('products');
|
2024-05-09 23:36:58 +02:00
|
|
|
|
|
|
|
|
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',
|
|
|
|
|
},
|
2025-05-08 23:32:13 +02:00
|
|
|
];
|
2024-05-09 23:36:58 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
optauthors.value = productStore.getAuthors();
|
2024-05-09 23:36:58 +02:00
|
|
|
|
2024-06-20 17:22:46 +02:00
|
|
|
//++Todo: Per ora visualizzo solo il "Negozio" e non i GAS...
|
2025-05-08 23:32:13 +02:00
|
|
|
cosa.value = shared_consts.PROD.BOTTEGA;
|
2024-07-31 15:02:30 +02:00
|
|
|
|
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-01-30 14:00:48 +01:00
|
|
|
// Inizializza
|
2025-05-08 23:32:13 +02:00
|
|
|
loadpage.value = true;
|
2024-01-30 14:00:48 +01:00
|
|
|
window.addEventListener('scroll', handleScroll);
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
calcArrProducts();
|
2025-05-14 20:18:04 +02:00
|
|
|
|
2025-05-15 19:18:50 +02:00
|
|
|
ismounting.value = false;
|
2024-05-04 14:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loaddata() {
|
2025-05-08 23:32:13 +02:00
|
|
|
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-05-21 12:06:09 +02:00
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
label: '[Seleziona un Argomento]',
|
|
|
|
|
value: '',
|
|
|
|
|
icon: undefined,
|
|
|
|
|
color: undefined,
|
|
|
|
|
},
|
|
|
|
|
].concat(
|
2025-05-08 23:32:13 +02:00
|
|
|
productStore
|
|
|
|
|
.getCatProds(cosa.value)
|
|
|
|
|
.map((rec) => ({
|
|
|
|
|
label: `${rec.name} (${productStore.getTotaliProdottiByIdCatProd(rec._id)})`,
|
|
|
|
|
value: rec._id,
|
|
|
|
|
icon: rec.icon,
|
|
|
|
|
color: rec.color,
|
|
|
|
|
}))
|
2025-05-21 12:06:09 +02:00
|
|
|
.concat({
|
|
|
|
|
label: '[Senza Argomento]',
|
|
|
|
|
value: costanti.NO_CATEGORY,
|
|
|
|
|
icon: undefined,
|
|
|
|
|
color: undefined,
|
|
|
|
|
})
|
2025-05-08 23:32:13 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
function getCollane() {
|
2025-05-21 12:06:09 +02:00
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
label: '[Seleziona una Collana]',
|
|
|
|
|
value: '',
|
|
|
|
|
icon: undefined,
|
|
|
|
|
color: undefined,
|
|
|
|
|
},
|
|
|
|
|
].concat(
|
2025-05-08 23:32:13 +02:00
|
|
|
productStore
|
|
|
|
|
.getCollane()
|
|
|
|
|
.map((rec) => ({
|
|
|
|
|
label: `${rec.title} (${productStore.getTotaliProdottiByIdCollana(rec._id)})`,
|
|
|
|
|
value: rec._id,
|
|
|
|
|
icon: rec.icon,
|
|
|
|
|
color: rec.color,
|
|
|
|
|
}))
|
2025-05-21 12:06:09 +02:00
|
|
|
.concat({
|
|
|
|
|
label: '[Senza Collana]',
|
|
|
|
|
value: costanti.NO_CATEGORY,
|
|
|
|
|
icon: undefined,
|
|
|
|
|
color: undefined,
|
|
|
|
|
})
|
2025-04-24 19:31:34 +02:00
|
|
|
);
|
2024-01-30 14:00:48 +01:00
|
|
|
}
|
|
|
|
|
|
2025-04-30 13:27:47 +02:00
|
|
|
// productStore.getTotaliProdottiByIdCollana(rec._id)
|
2025-04-24 19:31:34 +02:00
|
|
|
|
2024-05-04 14:49:09 +02:00
|
|
|
function onLoadScroll(index: number, done: any) {
|
|
|
|
|
if (index >= 1) {
|
|
|
|
|
if (numRecLoaded.value < arrProducts.value.length) {
|
2025-05-08 23:32:13 +02:00
|
|
|
const step = 10;
|
|
|
|
|
let mynrec = numRecLoaded.value + step;
|
2024-05-04 14:49:09 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
if (mynrec > arrProducts.value.length) mynrec = arrProducts.value.length;
|
2024-05-04 14:49:09 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
numRecLoaded.value = mynrec;
|
2024-05-04 14:49:09 +02:00
|
|
|
}
|
2025-05-08 23:32:13 +02:00
|
|
|
done();
|
2024-05-04 14:49:09 +02:00
|
|
|
} else {
|
2025-05-08 23:32:13 +02:00
|
|
|
done(true);
|
2024-05-04 14:49:09 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-09 23:36:58 +02:00
|
|
|
function filterFn(val: any, update: any, abort: any) {
|
|
|
|
|
update(() => {
|
|
|
|
|
const needle = val.toLowerCase();
|
2025-05-08 23:32:13 +02:00
|
|
|
optauthors.value = productStore.getAuthors().filter((v) => {
|
2024-05-09 23:36:58 +02:00
|
|
|
const authorName = v.label.toLowerCase();
|
|
|
|
|
const wordsToSearch = needle.split(' ');
|
|
|
|
|
return wordsToSearch.every((word: any) => {
|
|
|
|
|
if (word.length > 1) {
|
|
|
|
|
return authorName.includes(word);
|
|
|
|
|
} else {
|
2025-05-23 16:31:04 +02:00
|
|
|
return authorName.split(' ').some((namePart: any) => namePart.startsWith(word));
|
2024-05-09 23:36:58 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function selauthor(id: string, value: string) {
|
2025-05-08 23:32:13 +02:00
|
|
|
filter.value.author = id;
|
2024-05-09 23:36:58 +02:00
|
|
|
}
|
|
|
|
|
|
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-05-23 16:31:04 +02:00
|
|
|
const valoriopt = computed(() => (item: any, addall: boolean, addnone: boolean = false) => {
|
|
|
|
|
// console.log('valoriopt', item.table)
|
|
|
|
|
return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter);
|
|
|
|
|
});
|
2024-05-09 23:36:58 +02:00
|
|
|
|
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) => {
|
2025-05-08 23:32:13 +02:00
|
|
|
const img = new Image();
|
|
|
|
|
img.onload = () => resolve(img);
|
|
|
|
|
img.onerror = reject;
|
|
|
|
|
img.src = src;
|
|
|
|
|
});
|
|
|
|
|
};
|
2024-05-09 23:36:58 +02:00
|
|
|
|
2024-11-22 20:23:37 +01:00
|
|
|
function groupedPages(recscheda: ISchedaSingola) {
|
2025-05-08 23:32:13 +02:00
|
|
|
return recscheda.arrProdToShow;
|
2024-11-28 16:04:48 +01:00
|
|
|
}
|
2025-02-03 17:18:33 +01:00
|
|
|
function generateStyleCatalogo(optcatalogo: IOptCatalogo) {
|
2025-05-08 23:32:13 +02:00
|
|
|
return {};
|
2024-11-28 16:04:48 +01:00
|
|
|
}
|
2024-10-26 17:12:05 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
function generateStylePageScheda(optcatalogo: IOptCatalogo, scheda: IMyScheda) {
|
2025-05-08 23:32:13 +02:00
|
|
|
const marginTop = scheda.dimensioni?.pagina?.dimensioni?.margini?.top
|
2025-05-23 16:31:04 +02:00
|
|
|
? 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) || '';
|
2025-05-08 23:32:13 +02:00
|
|
|
const marginLeft = scheda.dimensioni?.pagina?.dimensioni?.margini?.left
|
2025-05-23 16:31:04 +02:00
|
|
|
? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.margini?.left)
|
|
|
|
|
: tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.left) || '';
|
2025-05-08 23:32:13 +02:00
|
|
|
const marginRight = scheda.dimensioni?.pagina?.dimensioni?.margini?.right
|
2025-05-23 16:31:04 +02:00
|
|
|
? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.margini?.right)
|
|
|
|
|
: tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.right) || '';
|
2025-05-08 23:32:13 +02:00
|
|
|
|
|
|
|
|
const paddingTop = scheda.dimensioni?.pagina?.dimensioni?.padding?.top
|
2025-05-23 16:31:04 +02:00
|
|
|
? 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) || '';
|
2025-05-08 23:32:13 +02:00
|
|
|
const paddingLeft = scheda.dimensioni?.pagina?.dimensioni?.padding?.left
|
2025-05-23 16:31:04 +02:00
|
|
|
? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.padding?.left)
|
|
|
|
|
: tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.left) || '';
|
2025-05-08 23:32:13 +02:00
|
|
|
const paddingRight = scheda.dimensioni?.pagina?.dimensioni?.padding?.right
|
2025-05-23 16:31:04 +02:00
|
|
|
? 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-05-08 23:32:13 +02:00
|
|
|
const recimg = getSfondoImgCatalogo(scheda);
|
|
|
|
|
const backgroundImage = recimg.imagefile! ?? '';
|
|
|
|
|
const backgroundSize = recimg.fit;
|
2024-10-26 17:12:05 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const width = scheda.dimensioni?.pagina?.dimensioni?.size?.width
|
2025-05-23 16:31:04 +02:00
|
|
|
? tools.adjustSize(optcatalogo, scheda.dimensioni?.pagina?.dimensioni?.size?.width)
|
|
|
|
|
: (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.width) ?? '');
|
2025-05-08 23:32:13 +02:00
|
|
|
const height = scheda.dimensioni?.pagina?.dimensioni?.size?.height
|
2025-05-23 16:31:04 +02:00
|
|
|
? 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,
|
2025-05-23 16:31:04 +02:00
|
|
|
position: 'relative',
|
2024-11-28 16:04:48 +01:00
|
|
|
'--width': width,
|
|
|
|
|
'--height': height,
|
2025-05-08 23:32:13 +02:00
|
|
|
...(width && width !== '0px' ? { width: `${width} !important` } : {}),
|
2025-05-23 16:31:04 +02:00
|
|
|
...(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-05-23 16:31:04 +02:00
|
|
|
function generateStyleByPageDim(optcatalogo: IOptCatalogo, mypage: IDimensioni) {
|
2025-05-08 23:32:13 +02:00
|
|
|
const marginTop = mypage.margini?.top
|
|
|
|
|
? tools.adjustSize(optcatalogo, mypage.margini?.top)
|
2025-05-23 16:31:04 +02:00
|
|
|
: tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.top) || '';
|
2025-05-08 23:32:13 +02:00
|
|
|
const marginBottom = mypage.margini?.bottom
|
|
|
|
|
? tools.adjustSize(optcatalogo, mypage.margini?.bottom)
|
2025-05-23 16:31:04 +02:00
|
|
|
: tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.bottom) || '';
|
2025-05-08 23:32:13 +02:00
|
|
|
const marginLeft = mypage.margini?.left
|
|
|
|
|
? tools.adjustSize(optcatalogo, mypage.margini?.left)
|
2025-05-23 16:31:04 +02:00
|
|
|
: tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.left) || '';
|
2025-05-08 23:32:13 +02:00
|
|
|
const marginRight = mypage.margini?.right
|
|
|
|
|
? tools.adjustSize(optcatalogo, mypage.margini?.right)
|
2025-05-23 16:31:04 +02:00
|
|
|
: tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.margini?.right) || '';
|
2025-05-08 23:32:13 +02:00
|
|
|
|
|
|
|
|
const paddingTop = mypage.padding?.top
|
|
|
|
|
? tools.adjustSize(optcatalogo, mypage.padding?.top)
|
2025-05-23 16:31:04 +02:00
|
|
|
: tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.top) || '';
|
2025-05-08 23:32:13 +02:00
|
|
|
const paddingBottom = mypage.padding?.bottom
|
|
|
|
|
? tools.adjustSize(optcatalogo, mypage.padding?.bottom)
|
2025-05-23 16:31:04 +02:00
|
|
|
: (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.bottom) ??
|
|
|
|
|
'');
|
2025-05-08 23:32:13 +02:00
|
|
|
const paddingLeft = mypage.padding?.left
|
|
|
|
|
? tools.adjustSize(optcatalogo, mypage.padding?.left)
|
2025-05-23 16:31:04 +02:00
|
|
|
: (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.padding?.left) ?? '');
|
2025-05-08 23:32:13 +02:00
|
|
|
const paddingRight = mypage.padding?.right
|
|
|
|
|
? tools.adjustSize(optcatalogo, mypage.padding?.right)
|
2025-05-23 16:31:04 +02:00
|
|
|
: (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-05-08 23:32:13 +02:00
|
|
|
const recimg = getSfondoImgCatalogo(null, mypage);
|
|
|
|
|
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-05-08 23:32:13 +02:00
|
|
|
fileimg = optcatalogo.dimensioni_def?.pagina.imgsfondo?.imagefile;
|
|
|
|
|
backgroundSize = optcatalogo.dimensioni_def?.pagina.imgsfondo?.fit;
|
2025-05-23 16:31:04 +02:00
|
|
|
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-05-08 23:32:13 +02:00
|
|
|
const backgroundImage = fileimg ?? '';
|
2024-11-02 18:06:27 +01:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const width = mypage.size?.width
|
|
|
|
|
? tools.adjustSize(optcatalogo, mypage.size?.width)
|
2025-05-23 16:31:04 +02:00
|
|
|
: (tools.adjustSize(optcatalogo, optcatalogo.dimensioni_def?.pagina?.size?.width) ?? '');
|
2025-05-08 23:32:13 +02:00
|
|
|
const height = mypage.size?.height
|
|
|
|
|
? tools.adjustSize(optcatalogo, mypage.size?.height)
|
2025-05-23 16:31:04 +02:00
|
|
|
: (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-05-08 23:32:13 +02:00
|
|
|
...(width && width !== '0px' ? { width: `${width} !important` } : {}),
|
2025-05-23 16:31:04 +02:00
|
|
|
...(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) {
|
2025-05-08 23:32:13 +02:00
|
|
|
return scheda.dimensioni?.pagina?.dimensioni?.size?.width
|
2025-05-23 16:31:04 +02:00
|
|
|
? 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) {
|
2025-05-08 23:32:13 +02:00
|
|
|
return scheda.dimensioni?.pagina?.dimensioni?.size?.height
|
2025-05-23 16:31:04 +02:00
|
|
|
? 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) {
|
2025-05-08 23:32:13 +02:00
|
|
|
const paddingLeft =
|
2025-05-21 12:06:09 +02:00
|
|
|
tools.adjustSize(
|
|
|
|
|
optcatalogo.value,
|
|
|
|
|
recscheda.scheda?.dimensioni?.scheda_prodotto?.padding?.left
|
|
|
|
|
) ?? '0px';
|
2025-05-08 23:32:13 +02:00
|
|
|
const paddingRight =
|
2025-05-21 12:06:09 +02:00
|
|
|
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
|
|
|
|
2025-05-21 12:06:09 +02:00
|
|
|
const width =
|
2025-05-23 16:31:04 +02:00
|
|
|
tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.size?.width) ?? '';
|
2025-05-21 12:06:09 +02:00
|
|
|
const height =
|
2025-05-23 16:31:04 +02:00
|
|
|
tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.size?.height) ?? '';
|
2024-11-22 20:23:37 +01:00
|
|
|
|
2025-05-21 12:06:09 +02:00
|
|
|
const marginTop =
|
2025-05-23 16:31:04 +02:00
|
|
|
tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.margini?.top) ||
|
|
|
|
|
'0';
|
2025-05-08 23:32:13 +02:00
|
|
|
const marginBottom =
|
2025-05-23 16:31:04 +02:00
|
|
|
tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.margini?.bottom) ||
|
|
|
|
|
'0';
|
2025-05-21 12:06:09 +02:00
|
|
|
const marginLeft =
|
2025-05-23 16:31:04 +02:00
|
|
|
tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.margini?.left) ||
|
|
|
|
|
'0';
|
2025-05-08 23:32:13 +02:00
|
|
|
const marginRight =
|
2025-05-23 16:31:04 +02:00
|
|
|
tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.margini?.right) ||
|
|
|
|
|
'0';
|
2024-11-22 20:23:37 +01:00
|
|
|
|
2025-05-21 12:06:09 +02:00
|
|
|
const paddingTop =
|
2025-05-23 16:31:04 +02:00
|
|
|
tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.padding?.top) ||
|
|
|
|
|
'0';
|
2025-05-08 23:32:13 +02:00
|
|
|
const paddingBottom =
|
2025-05-23 16:31:04 +02:00
|
|
|
tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.padding?.bottom) ||
|
|
|
|
|
'0';
|
2025-05-21 12:06:09 +02:00
|
|
|
const paddingLeft =
|
2025-05-23 16:31:04 +02:00
|
|
|
tools.adjustSize(optcatalogo.value, recscheda.scheda?.dimensioni?.riga?.padding?.left) ||
|
|
|
|
|
'0';
|
2025-05-08 23:32:13 +02:00
|
|
|
const paddingRight =
|
2025-05-23 16:31:04 +02:00
|
|
|
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}`,
|
2025-05-08 23:32:13 +02:00
|
|
|
...(width && width !== '0px' ? { width: `${width} !important` } : {}),
|
2025-05-23 16:31:04 +02:00
|
|
|
...(height && height !== '0px' ? { height: `${height} !important` } : {}),
|
2025-05-08 23:32:13 +02:00
|
|
|
};
|
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
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
return out;
|
2024-11-22 20:23:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getStyleSchedaProdotto(recscheda: ISchedaSingola) {
|
|
|
|
|
const placeContent = 'center';
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const width =
|
2025-05-21 12:06:09 +02:00
|
|
|
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
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const marginTop =
|
2025-05-21 12:06:09 +02:00
|
|
|
tools.adjustSize(
|
|
|
|
|
optcatalogo.value,
|
|
|
|
|
recscheda.scheda?.dimensioni?.scheda_prodotto?.margini?.top
|
|
|
|
|
) || '0px';
|
2025-05-08 23:32:13 +02:00
|
|
|
const marginBottom =
|
2025-05-21 12:06:09 +02:00
|
|
|
tools.adjustSize(
|
|
|
|
|
optcatalogo.value,
|
|
|
|
|
recscheda.scheda?.dimensioni?.scheda_prodotto?.margini?.bottom
|
|
|
|
|
) || '0px';
|
2025-05-08 23:32:13 +02:00
|
|
|
const marginLeft =
|
2025-05-21 12:06:09 +02:00
|
|
|
tools.adjustSize(
|
|
|
|
|
optcatalogo.value,
|
|
|
|
|
recscheda.scheda?.dimensioni?.scheda_prodotto?.margini?.left
|
|
|
|
|
) || '0px';
|
2025-05-08 23:32:13 +02:00
|
|
|
const marginRight =
|
2025-05-21 12:06:09 +02:00
|
|
|
tools.adjustSize(
|
|
|
|
|
optcatalogo.value,
|
|
|
|
|
recscheda.scheda?.dimensioni?.scheda_prodotto?.margini?.right
|
|
|
|
|
) || '0px';
|
2025-05-08 23:32:13 +02:00
|
|
|
|
|
|
|
|
const paddingTop =
|
2025-05-21 12:06:09 +02:00
|
|
|
tools.adjustSize(
|
|
|
|
|
optcatalogo.value,
|
|
|
|
|
recscheda.scheda?.dimensioni?.scheda_prodotto?.padding?.top
|
|
|
|
|
) || '0px';
|
2025-05-08 23:32:13 +02:00
|
|
|
const paddingBottom =
|
2025-05-21 12:06:09 +02:00
|
|
|
tools.adjustSize(
|
|
|
|
|
optcatalogo.value,
|
|
|
|
|
recscheda.scheda?.dimensioni?.scheda_prodotto?.padding?.bottom
|
|
|
|
|
) || '0px';
|
2025-05-08 23:32:13 +02:00
|
|
|
const paddingLeft =
|
2025-05-21 12:06:09 +02:00
|
|
|
tools.adjustSize(
|
|
|
|
|
optcatalogo.value,
|
|
|
|
|
recscheda.scheda?.dimensioni?.scheda_prodotto?.padding?.left
|
|
|
|
|
) || '0px';
|
2025-05-08 23:32:13 +02:00
|
|
|
const paddingRight =
|
2025-05-21 12:06:09 +02:00
|
|
|
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-05-23 16:31:04 +02: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[][]) {
|
2025-05-08 23:32:13 +02:00
|
|
|
return page && page.length > 0 && page[0] && page[0].length > 0;
|
2024-12-02 19:38:01 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-12 18:32:10 +01:00
|
|
|
function naviga(path: string) {
|
2025-05-08 23:32:13 +02:00
|
|
|
router.push(path);
|
2025-02-12 18:32:10 +01:00
|
|
|
}
|
|
|
|
|
|
2025-03-31 23:55:53 +02:00
|
|
|
function updateProducts(arr: any) {
|
2025-05-15 22:37:39 +02:00
|
|
|
if (myCatalog.value) {
|
2025-05-23 16:31:04 +02:00
|
|
|
if (
|
|
|
|
|
myCatalog.value.lista_prodotti.length !== arr.length ||
|
|
|
|
|
!myCatalog.value.lista_prodotti.every((prod, index) => prod._id === arr[index]._id)
|
|
|
|
|
) {
|
|
|
|
|
myCatalog.value.lista_prodotti = [...arr];
|
2025-03-31 23:55:53 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
if (!showListaFiltrata.value && !tools.isUtente()) salvaListaProdotti(true);
|
|
|
|
|
else generatearrProdToViewSorted(true, false);
|
|
|
|
|
}
|
2025-04-01 18:36:45 +02:00
|
|
|
}
|
2025-03-31 23:55:53 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-14 15:02:14 +02:00
|
|
|
function addProductToList(element: IProduct, where: string) {
|
2025-04-04 18:15:14 +02:00
|
|
|
// console.log('addProductToList', element)
|
|
|
|
|
|
|
|
|
|
if (element) {
|
|
|
|
|
// add this record to lista_prodotti
|
2025-05-21 12:06:09 +02:00
|
|
|
if (
|
|
|
|
|
myCatalog.value &&
|
|
|
|
|
!myCatalog.value?.lista_prodotti?.some((p) => p._id === element._id)
|
|
|
|
|
) {
|
2025-04-04 18:15:14 +02:00
|
|
|
// inserire il record in cima
|
2025-05-16 10:26:29 +02:00
|
|
|
const arr = myCatalog.value?.lista_prodotti || [];
|
2025-05-15 19:18:50 +02:00
|
|
|
if (where === shared_consts.WHERE_INSERT.ONTOP) arr.unshift(element);
|
2025-05-23 16:31:04 +02:00
|
|
|
else if (where === shared_consts.WHERE_INSERT.ONBOTTOM) arr.push(element);
|
2025-04-04 18:15:14 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
updateProducts(arr);
|
2025-04-04 18:15:14 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
addnewProd.value = false;
|
2025-04-04 18:15:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clickaddNewBook() {
|
2025-05-08 23:32:13 +02:00
|
|
|
addnewProd.value = true;
|
2025-04-04 18:15:14 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-02 19:11:29 +02:00
|
|
|
function toggleDebug() {
|
2025-05-08 23:32:13 +02:00
|
|
|
optcatalogo.value.indebug = !optcatalogo.value.indebug;
|
2025-05-02 19:11:29 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
const preparePDFWeb = () => {
|
|
|
|
|
preparePDF(false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const preparePDFStampa = () => {
|
|
|
|
|
preparePDF(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const preparePDF = (instampa: boolean) => {
|
|
|
|
|
let str = '';
|
|
|
|
|
if (instampa) {
|
|
|
|
|
str = 'per la stampa';
|
|
|
|
|
}
|
2025-05-12 18:43:25 +02:00
|
|
|
$q.dialog({
|
2025-05-23 16:31:04 +02:00
|
|
|
message: `Generare il PDF ${str}?`,
|
2025-05-12 18:43:25 +02:00
|
|
|
ok: {
|
|
|
|
|
label: t('dialog.yes'),
|
|
|
|
|
push: true,
|
|
|
|
|
},
|
|
|
|
|
cancel: {
|
|
|
|
|
label: t('dialog.cancel'),
|
|
|
|
|
},
|
|
|
|
|
title: 'Generazione PDF',
|
|
|
|
|
}).onOk(async () => {
|
2025-05-23 16:31:04 +02:00
|
|
|
optcatalogo.value.selectedVersionStampabile = instampa
|
|
|
|
|
? shared_consts.PREPARA_PDF.STAMPA
|
|
|
|
|
: shared_consts.PREPARA_PDF.WEB;
|
|
|
|
|
|
|
|
|
|
arrProducts.value = [];
|
|
|
|
|
console.log('aggiorna... ');
|
|
|
|
|
//await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
|
|
|
//await nextTick();
|
|
|
|
|
calcArrProducts(false);
|
|
|
|
|
updateCatalogoPadre();
|
|
|
|
|
|
2025-05-12 18:43:25 +02:00
|
|
|
optcatalogo.value.generazionePDFInCorso = true;
|
2025-05-23 16:31:04 +02:00
|
|
|
optcatalogo.value.areadistampa!.scale = optcatalogo.value.areadistampa!.scale_printable;
|
|
|
|
|
optcatalogo.value.selectedVersionStampabile = instampa
|
|
|
|
|
? shared_consts.PREPARA_PDF.STAMPA
|
|
|
|
|
: shared_consts.PREPARA_PDF.WEB;
|
2025-05-12 18:43:25 +02:00
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
optcatalogo.value.generazionePDFInCorso = true;
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
generatePDF();
|
|
|
|
|
}, 500);
|
|
|
|
|
}, 500);
|
|
|
|
|
});
|
2025-05-08 23:32:13 +02:00
|
|
|
};
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-12 18:43:25 +02:00
|
|
|
const terminaPDF = () => {
|
2025-05-08 23:32:13 +02:00
|
|
|
optcatalogo.value.generazionePDFInCorso = false;
|
|
|
|
|
optcatalogo.value.areadistampa!.scale = 1;
|
|
|
|
|
};
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
async function generateLargePDF(
|
2025-05-23 16:31:04 +02:00
|
|
|
instampa: boolean,
|
2025-05-08 23:32:13 +02:00
|
|
|
opt: any,
|
|
|
|
|
pagesSelector = '.page',
|
|
|
|
|
salvasufiledascaricare: boolean,
|
|
|
|
|
dir_out: string,
|
|
|
|
|
file_out: string
|
|
|
|
|
) {
|
|
|
|
|
const pages = document.querySelectorAll(pagesSelector);
|
|
|
|
|
const pdfs = [];
|
|
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
const TESTPAO = false;
|
|
|
|
|
|
|
|
|
|
let primapagina = 0;
|
|
|
|
|
let numpagine = pages.length;
|
|
|
|
|
|
|
|
|
|
if (TESTPAO) {
|
|
|
|
|
primapagina = 2;
|
|
|
|
|
numpagine = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-12 16:33:58 +02:00
|
|
|
try {
|
2025-05-23 16:31:04 +02:00
|
|
|
for (let i = primapagina; i < numpagine; i++) {
|
2025-05-12 16:33:58 +02:00
|
|
|
const page = pages[i];
|
|
|
|
|
|
|
|
|
|
// Nascondi altre pagine
|
|
|
|
|
pages.forEach((p) => p.classList.add('hidden'));
|
|
|
|
|
page.classList.remove('hidden');
|
|
|
|
|
|
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
|
|
|
|
|
|
|
|
// Genera singolo PDF
|
|
|
|
|
const pdfBlob = await new Promise<Blob | null>((resolve) => {
|
|
|
|
|
html2pdf()
|
|
|
|
|
.set(opt)
|
|
|
|
|
.from(page)
|
|
|
|
|
.toPdf()
|
|
|
|
|
.output('blob', { compress: true })
|
|
|
|
|
.then(resolve)
|
|
|
|
|
.catch(() => resolve(null));
|
|
|
|
|
});
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-12 16:33:58 +02:00
|
|
|
if (pdfBlob) {
|
|
|
|
|
pdfs.push(pdfBlob);
|
|
|
|
|
}
|
2025-05-08 23:32:13 +02:00
|
|
|
}
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-12 16:33:58 +02:00
|
|
|
// Unisci PDF
|
|
|
|
|
const finalPdf = await PDFDocument.create();
|
|
|
|
|
for (const blob of pdfs) {
|
|
|
|
|
const pdf = await PDFDocument.load(await blob.arrayBuffer());
|
2025-05-23 16:31:04 +02:00
|
|
|
const copiedPages = await finalPdf.copyPages(pdf, pdf.getPageIndices());
|
2025-05-12 16:33:58 +02:00
|
|
|
copiedPages.forEach((p) => finalPdf.addPage(p));
|
|
|
|
|
}
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-12 16:33:58 +02:00
|
|
|
const finalPdfBytes = await finalPdf.save(); // Uint8Array
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-12 16:33:58 +02:00
|
|
|
// ✅ Conversione in Blob
|
|
|
|
|
const blob = new Blob([finalPdfBytes], { type: 'application/pdf' });
|
2025-05-08 23:32:13 +02:00
|
|
|
|
2025-05-12 16:33:58 +02:00
|
|
|
// ✅ Download
|
|
|
|
|
if (salvasufiledascaricare) {
|
|
|
|
|
saveAs(blob, opt.filename);
|
|
|
|
|
} else {
|
|
|
|
|
// ✅ Crea un oggetto File da Blob
|
2025-05-21 12:06:09 +02:00
|
|
|
const pdfFile = new File([blob], 'report.pdf', {
|
|
|
|
|
type: 'application/pdf',
|
|
|
|
|
});
|
2025-05-12 16:33:58 +02:00
|
|
|
|
|
|
|
|
// Converti il file appena generato
|
|
|
|
|
const ris = await globalStore.convertPdf(
|
|
|
|
|
pdfFile,
|
2025-05-23 16:31:04 +02:00
|
|
|
salvasufiledascaricare,
|
2025-05-12 16:33:58 +02:00
|
|
|
widthpdf.value,
|
|
|
|
|
heightpdf.value,
|
2025-05-23 19:02:45 +02:00
|
|
|
optcatalogo.value.areadistampa.compress ? (instampa ? compressionepdf.value : 'printer') : '',
|
2025-05-23 16:31:04 +02:00
|
|
|
instampa,
|
2025-05-12 16:33:58 +02:00
|
|
|
dir_out,
|
|
|
|
|
file_out,
|
|
|
|
|
true,
|
2025-05-23 16:31:04 +02:00
|
|
|
optcatalogo.value
|
2025-05-12 16:33:58 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (ris) {
|
2025-05-15 22:37:39 +02:00
|
|
|
const catalog = myCatalog.value;
|
2025-05-23 16:31:04 +02:00
|
|
|
if (catalog) {
|
|
|
|
|
if (instampa) {
|
2025-05-23 19:02:45 +02:00
|
|
|
catalog.pdf_generato_stampa = ris.fileout;
|
|
|
|
|
catalog.pdf_generato_stampa_compressed = ris.fileout_compressed;
|
|
|
|
|
|
|
|
|
|
catalog.pdf_generato_stampa_size = ris.filesize;
|
|
|
|
|
catalog.pdf_generato_stampa_compr_size = ris.filesize_compressed;
|
|
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
catalog.data_generato_stampa = tools.getDateNow();
|
|
|
|
|
} else {
|
2025-05-23 19:02:45 +02:00
|
|
|
catalog.pdf_generato_compressed = ris.fileout_compressed;
|
|
|
|
|
catalog.pdf_generato = ris.fileout;
|
|
|
|
|
|
|
|
|
|
catalog.pdf_generato_size = ris.filesize;
|
|
|
|
|
catalog.pdf_generato_compr_size = ris.filesize_compressed;
|
|
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
catalog.data_generato = tools.getDateNow();
|
|
|
|
|
}
|
|
|
|
|
await saveCatalog();
|
|
|
|
|
} else {
|
|
|
|
|
strout.value = JSON.stringify(ris, null, 2);
|
2025-05-12 16:33:58 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ripristina visibilità
|
|
|
|
|
pages.forEach((p) => p.classList.remove('hidden'));
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('Err', e.message);
|
|
|
|
|
}
|
2025-05-08 23:32:13 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
// Conversione da unità a pixel, con base 96 DPI
|
|
|
|
|
function unitToPx(val: number, unit: string): number {
|
|
|
|
|
const dpi = shared_consts.PUNTI_PER_POLLICE;
|
|
|
|
|
const conversionMap: Record<string, number> = {
|
|
|
|
|
mm: dpi / 25.4,
|
|
|
|
|
cm: dpi / 2.54,
|
|
|
|
|
pt: dpi / 72,
|
|
|
|
|
px: 1,
|
|
|
|
|
};
|
|
|
|
|
return val * (conversionMap[unit] || 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Calcola scala tra dimensioni desiderate e quelle reali del contenuto
|
|
|
|
|
function getBestFitScale(
|
|
|
|
|
contentWidthPx: number,
|
|
|
|
|
contentHeightPx: number,
|
|
|
|
|
targetWidthPx: number,
|
|
|
|
|
targetHeightPx: number
|
|
|
|
|
): number {
|
|
|
|
|
return Math.min(targetWidthPx / contentWidthPx, targetHeightPx / contentHeightPx);
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
const generatePDF = async () => {
|
|
|
|
|
await nextTick();
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
const instampa = isStampa();
|
|
|
|
|
const msg = instampa ? 'stampa' : '';
|
|
|
|
|
|
|
|
|
|
console.log(`1) Generazione PDF ${msg} in corso, attendere ...`);
|
|
|
|
|
$q.loading.show({ message: `Generazione PDF ${msg} in corso, attendere ...` });
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-12 18:43:25 +02:00
|
|
|
try {
|
2025-05-23 16:31:04 +02:00
|
|
|
const defaultMargin = 0;
|
|
|
|
|
const area = optcatalogo.value.areadistampa!;
|
|
|
|
|
const unit = area.unit;
|
|
|
|
|
const orientation = area.orientation;
|
|
|
|
|
const compress = area.compress;
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
let originalFormat = area.format || A4_FORMAT_MM;
|
|
|
|
|
const scale = tools.getScale(optcatalogo.value, instampa);
|
|
|
|
|
const scalecanvas = area.scalecanvas;
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
const pagina = optcatalogo.value.dimensioni_def.pagina;
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
// Calcola dimensioni effettive in mm (ajustate)
|
|
|
|
|
//const formatWidthMm = tools.pxToMm(pagina.size.width) * scale * scalecanvas;
|
|
|
|
|
//const formatHeightMm = tools.pxToMm(pagina.size.height) * scale * scalecanvas;
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
const formatWidthMm = originalFormat[0];
|
|
|
|
|
const formatHeightMm = originalFormat[1];
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
let mioformato = [formatWidthMm * scale, formatHeightMm * scale];
|
2025-05-12 18:43:25 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
// Calcola dimensioni del PDF in pixel
|
|
|
|
|
const pdfWidthPx = unitToPx(originalFormat[0], unit);
|
|
|
|
|
const pdfHeightPx = unitToPx(originalFormat[1], unit);
|
2025-05-12 18:43:25 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
// Ottieni contenuto HTML
|
|
|
|
|
const element = document.querySelector('.pdf-section');
|
|
|
|
|
if (!element) throw new Error('Elemento pdf-content non trovato');
|
2025-05-12 18:43:25 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
const rect = element.getBoundingClientRect();
|
2025-05-23 19:02:45 +02:00
|
|
|
const contentWidthPx = rect.width * scale;
|
|
|
|
|
const contentHeightPx = rect.height * scale;
|
2025-05-12 18:43:25 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
const scale2 = getBestFitScale(rect.width, rect.height, pdfWidthPx, pdfHeightPx);
|
|
|
|
|
|
|
|
|
|
// Se formato non valido, fallback ad A4
|
|
|
|
|
const myfile = getPdfFilename() + '.pdf';
|
2025-05-12 18:43:25 +02:00
|
|
|
|
|
|
|
|
const opt = {
|
|
|
|
|
margin: [defaultMargin, defaultMargin, defaultMargin, defaultMargin],
|
|
|
|
|
filename: myfile,
|
|
|
|
|
image: {
|
|
|
|
|
type: 'jpeg',
|
|
|
|
|
quality: 0.98,
|
|
|
|
|
},
|
|
|
|
|
html2canvas: {
|
|
|
|
|
scale: scalecanvas,
|
|
|
|
|
useCORS: true,
|
|
|
|
|
letterRendering: true,
|
|
|
|
|
},
|
|
|
|
|
jsPDF: {
|
2025-05-23 16:31:04 +02:00
|
|
|
unit,
|
|
|
|
|
format: mioformato,
|
|
|
|
|
orientation,
|
|
|
|
|
compress,
|
2025-05-12 18:43:25 +02:00
|
|
|
},
|
|
|
|
|
enableLinks: true,
|
|
|
|
|
pagebreak: { mode: 'avoid-all', before: '.card-page' },
|
|
|
|
|
};
|
|
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
console.log(`📐 PDF: ${mioformato[0]} x ${mioformato[1]} mm | scala: ${scale}`, opt);
|
2025-05-12 18:43:25 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
await generateLargePDF(instampa, opt, '.pdf-section', false, 'upload/cataloghi/', myfile);
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-12 18:43:25 +02:00
|
|
|
optcatalogo.value.generazionePDFInCorso = false;
|
|
|
|
|
optcatalogo.value.areadistampa!.scale = 1;
|
2025-05-02 19:11:29 +02:00
|
|
|
|
2025-05-12 18:43:25 +02:00
|
|
|
$q.loading.hide();
|
|
|
|
|
$q.notify({
|
|
|
|
|
color: 'positive',
|
|
|
|
|
message: 'PDF generato con successo!',
|
|
|
|
|
icon: 'check',
|
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
$q.loading.hide();
|
|
|
|
|
$q.notify({
|
|
|
|
|
color: 'negative',
|
|
|
|
|
message: 'Errore nella generazione del PDF',
|
|
|
|
|
icon: 'error',
|
|
|
|
|
});
|
|
|
|
|
console.error('Errore nella generazione del PDF:', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
// Default formato A4 in mm
|
|
|
|
|
const A4_FORMAT_MM = [210, 297];
|
|
|
|
|
|
2025-05-23 19:02:45 +02:00
|
|
|
const pubblicaPDF = async (compresso: boolean) => {
|
2025-05-15 22:37:39 +02:00
|
|
|
const catalog = myCatalog.value;
|
2025-05-12 18:43:25 +02:00
|
|
|
|
2025-05-15 19:18:50 +02:00
|
|
|
const confirm = await $q
|
|
|
|
|
.dialog({
|
|
|
|
|
title: 'Conferma',
|
|
|
|
|
message: 'Vuoi pubblicare OnLine questo PDF?',
|
|
|
|
|
ok: {
|
|
|
|
|
label: 'S ',
|
|
|
|
|
push: true,
|
|
|
|
|
},
|
|
|
|
|
cancel: {
|
|
|
|
|
label: 'Annulla',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
.onOk(async () => {
|
|
|
|
|
if (!confirm) return;
|
2025-05-12 18:43:25 +02:00
|
|
|
|
2025-05-21 12:06:09 +02:00
|
|
|
const ris = await globalStore.execOnlinePDF({
|
|
|
|
|
id_catalog: catalog._id,
|
|
|
|
|
stampa: false,
|
2025-05-23 19:02:45 +02:00
|
|
|
compresso,
|
2025-05-21 12:06:09 +02:00
|
|
|
});
|
2025-05-15 19:18:50 +02:00
|
|
|
|
|
|
|
|
if (ris) {
|
|
|
|
|
if (ris.record?.pdf_online) {
|
|
|
|
|
catalog.pdf_online = ris.record.pdf_online;
|
2025-05-23 19:02:45 +02:00
|
|
|
catalog.pdf_online_size = ris.record.pdf_online_size;
|
2025-05-15 19:18:50 +02:00
|
|
|
catalog.data_online = ris.record.data_online;
|
|
|
|
|
}
|
|
|
|
|
$q.notify({
|
|
|
|
|
color: 'positive',
|
|
|
|
|
message: 'PDF inviato ONLINE!',
|
|
|
|
|
icon: 'check',
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
$q.loading.hide();
|
|
|
|
|
$q.notify({
|
|
|
|
|
color: 'negative',
|
|
|
|
|
message: "Errore nell'invio del PDF OnLine",
|
|
|
|
|
icon: 'error',
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-05-12 18:43:25 +02:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2025-05-23 19:02:45 +02:00
|
|
|
const pubblicaPDFStampa = async (compresso: boolean) => {
|
2025-05-15 22:37:39 +02:00
|
|
|
const catalog = myCatalog.value;
|
2025-05-12 18:43:25 +02:00
|
|
|
|
2025-05-15 19:18:50 +02:00
|
|
|
const confirm = await $q
|
|
|
|
|
.dialog({
|
|
|
|
|
title: 'Conferma',
|
|
|
|
|
message: 'Vuoi pubblicare OnLine questo PDF di STAMPA ?',
|
|
|
|
|
ok: {
|
|
|
|
|
label: 'S ',
|
|
|
|
|
push: true,
|
|
|
|
|
},
|
|
|
|
|
cancel: {
|
|
|
|
|
label: 'Annulla',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
.onOk(async () => {
|
2025-05-21 12:06:09 +02:00
|
|
|
const ris = await globalStore.execOnlinePDF({
|
|
|
|
|
id_catalog: catalog._id,
|
|
|
|
|
stampa: true,
|
2025-05-23 19:02:45 +02:00
|
|
|
compresso,
|
2025-05-21 12:06:09 +02:00
|
|
|
});
|
2025-05-12 18:43:25 +02:00
|
|
|
|
2025-05-15 19:18:50 +02:00
|
|
|
if (ris) {
|
|
|
|
|
if (ris.record.pdf_online_stampa) {
|
|
|
|
|
catalog.pdf_online_stampa = ris.record.pdf_online_stampa;
|
2025-05-23 19:02:45 +02:00
|
|
|
catalog.pdf_online_stampa_size = ris.record.pdf_online_stampa_size;
|
2025-05-15 19:18:50 +02:00
|
|
|
catalog.data_online_stampa = ris.record.data_online_stampa;
|
|
|
|
|
}
|
|
|
|
|
$q.notify({
|
|
|
|
|
color: 'positive',
|
|
|
|
|
message: 'PDF STAMPA inviato ONLINE!',
|
|
|
|
|
icon: 'check',
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
$q.loading.hide();
|
|
|
|
|
$q.notify({
|
|
|
|
|
color: 'negative',
|
|
|
|
|
message: "Errore nell'invio del PDF STAMPA OnLine",
|
|
|
|
|
icon: 'error',
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-05-12 18:43:25 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// await saveCatalog();
|
2025-05-08 23:32:13 +02:00
|
|
|
};
|
2025-04-04 18:15:14 +02:00
|
|
|
|
2025-05-23 16:31:04 +02:00
|
|
|
function modifElem() {
|
|
|
|
|
// modifica elemento...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function convertiValori() {
|
|
|
|
|
const ratio = ratioconvert.value;
|
|
|
|
|
const converti = (val: string) => tools.converticonratio(val, ratio);
|
|
|
|
|
|
|
|
|
|
function convertiLati(obj?: {
|
|
|
|
|
left?: string;
|
|
|
|
|
top?: string;
|
|
|
|
|
right?: string;
|
|
|
|
|
bottom?: string;
|
|
|
|
|
}) {
|
|
|
|
|
if (!obj) return;
|
|
|
|
|
['left', 'top', 'right', 'bottom'].forEach((side) => {
|
|
|
|
|
if (obj[side] !== undefined) obj[side] = converti(obj[side]!);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function convertiProps(obj?: Record<string, string | undefined>, props: string[]) {
|
|
|
|
|
if (!obj) return;
|
|
|
|
|
props.forEach((prop) => {
|
|
|
|
|
if (obj[prop] !== undefined) obj[prop] = converti(obj[prop]!);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const pagina = optcatalogo.value.dimensioni_def.pagina;
|
|
|
|
|
|
|
|
|
|
if (pagina.margini) convertiLati(pagina.margini);
|
|
|
|
|
if (pagina.padding) convertiLati(pagina.padding);
|
|
|
|
|
|
|
|
|
|
for (const recscheda of optcatalogo.value.arrSchede ?? []) {
|
|
|
|
|
const dim = recscheda.scheda?.dimensioni;
|
|
|
|
|
if (!dim) continue;
|
|
|
|
|
|
|
|
|
|
// dimensioni.pagina.dimensioni
|
|
|
|
|
const pagDim = dim.pagina?.dimensioni;
|
|
|
|
|
if (pagDim) {
|
|
|
|
|
convertiProps(pagDim.size, ['width', 'height']);
|
|
|
|
|
convertiLati(pagDim.margini);
|
|
|
|
|
convertiLati(pagDim.padding);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// dimensioni.scheda_prodotto
|
|
|
|
|
const schedaProd = dim.scheda_prodotto;
|
|
|
|
|
if (schedaProd) {
|
|
|
|
|
convertiProps(schedaProd.size, ['width', 'height', 'gap']);
|
|
|
|
|
convertiLati(schedaProd.margini);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// dimensioni.immagine_prodotto
|
|
|
|
|
const immProd = dim.immagine_prodotto;
|
|
|
|
|
if (immProd && immProd.size) {
|
|
|
|
|
convertiProps(immProd.size, ['width', 'height']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateCatalogoPadre();
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-08 23:32:13 +02:00
|
|
|
onMounted(mounted);
|
2024-01-30 14:00:48 +01:00
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
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
|
|
|
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,
|
|
|
|
|
updateProducts,
|
2025-04-04 18:15:14 +02:00
|
|
|
clickaddNewBook,
|
|
|
|
|
addProductToList,
|
|
|
|
|
addnewProd,
|
2025-05-08 23:32:13 +02:00
|
|
|
showListaFiltrata,
|
2025-04-24 19:31:34 +02:00
|
|
|
rigeneraLibri,
|
|
|
|
|
optrigenera,
|
|
|
|
|
generatinglist,
|
|
|
|
|
optDisp,
|
2025-05-02 10:10:04 +02:00
|
|
|
optRigeneraModalita,
|
2025-04-24 19:31:34 +02:00
|
|
|
optStato,
|
2025-05-15 22:37:39 +02:00
|
|
|
myCatalog,
|
2025-04-29 02:30:00 +02:00
|
|
|
getReferentiCatalogo,
|
2025-05-02 10:10:04 +02:00
|
|
|
reSortList,
|
2025-05-08 23:32:13 +02:00
|
|
|
preparePDF,
|
2025-05-23 16:31:04 +02:00
|
|
|
preparePDFWeb,
|
|
|
|
|
preparePDFStampa,
|
2025-05-08 23:32:13 +02:00
|
|
|
terminaPDF,
|
|
|
|
|
toggleDebug,
|
2025-05-02 19:11:29 +02:00
|
|
|
generatePDF,
|
|
|
|
|
getPdfFilename,
|
2025-05-08 23:32:13 +02:00
|
|
|
filtroStrApplicato,
|
|
|
|
|
getCollane,
|
2025-05-12 18:43:25 +02:00
|
|
|
pubblicaPDF,
|
|
|
|
|
pubblicaPDFStampa,
|
2025-05-14 20:18:04 +02:00
|
|
|
ismounting,
|
2025-05-15 19:18:50 +02:00
|
|
|
pdfColumns,
|
|
|
|
|
pdfRows,
|
2025-05-21 12:06:09 +02:00
|
|
|
getImgIntroCatalogo,
|
2025-05-23 16:31:04 +02:00
|
|
|
strout,
|
|
|
|
|
modifElem,
|
|
|
|
|
convertiValori,
|
|
|
|
|
ratioconvert,
|
|
|
|
|
nascondi,
|
2025-05-08 23:32:13 +02:00
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
});
|