- Altri aggiornamenti della scheda
This commit is contained in:
@@ -24,6 +24,7 @@ import type {
|
||||
IMyScheda, IProdView, IProduct, ISchedaSingola, ISearchList, ICatalog, IImg,
|
||||
IText,
|
||||
ICollana,
|
||||
IOptRigenera,
|
||||
} from 'model';
|
||||
import {
|
||||
IMyPage,
|
||||
@@ -60,12 +61,31 @@ export default defineComponent({
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n()
|
||||
|
||||
const rigeneraLibri = ref(false)
|
||||
|
||||
const search = ref('')
|
||||
const optauthors = ref(<any>[])
|
||||
|
||||
const pdfContent = ref(null);
|
||||
const addnewProd = ref(false)
|
||||
|
||||
const optDisp = ref([
|
||||
{ label: 'Tutti', value: costanti.DISP.TUTTI },
|
||||
{ label: 'Disponibili', value: costanti.DISP.DISPONIBILI },
|
||||
{ label: 'Esauriti', value: costanti.DISP.ESAURITI }])
|
||||
|
||||
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 },
|
||||
])
|
||||
|
||||
const generatinglist = ref(false)
|
||||
|
||||
const optrigenera = ref<IOptRigenera>({ visibilitaDisp: costanti.DISP.DISPONIBILI, stato: costanti.STATO.IN_COMMERCIO })
|
||||
|
||||
const optcatalogo = ref(<IOptCatalogo>{ ...props.modelValue });
|
||||
|
||||
function updateCatalogoPadre() {
|
||||
@@ -84,6 +104,12 @@ export default defineComponent({
|
||||
optcatalogo.value = { ...newVal };
|
||||
}, { deep: false });
|
||||
|
||||
watch(optrigenera.value, (newVal) => {
|
||||
tools.setCookie(showListaArgomenti.value ? 'INC_ES' : 'VIS_DISP', newVal.visibilitaDisp);
|
||||
if (showListaArgomenti.value)
|
||||
calcArrProducts()
|
||||
}, { deep: true });
|
||||
|
||||
/*watch(optcatalogo, (newValue) => {
|
||||
emit('update:modelValue', newValue);
|
||||
}, { deep: true });*/
|
||||
@@ -99,7 +125,6 @@ export default defineComponent({
|
||||
const cat = ref('')
|
||||
const idGasSel = ref('')
|
||||
const loadpage = ref(false)
|
||||
const refreshpage = ref(false)
|
||||
const show_hide = ref(false)
|
||||
|
||||
const mycolumns = ref([])
|
||||
@@ -215,12 +240,13 @@ export default defineComponent({
|
||||
|
||||
watch(() => cat.value, (newval, oldval) => {
|
||||
|
||||
if (loadpage.value)
|
||||
tools.setCookie(tools.COOK_CATEGORIA, cat.value.toString())
|
||||
filter.value.author = '' // disattivo il filtro autore
|
||||
resetSearch()
|
||||
if (loadpage.value) {
|
||||
tools.setCookie(getKeyCatAtLoad(), cat.value.toString())
|
||||
filter.value.author = '' // disattivo il filtro autore
|
||||
resetSearch()
|
||||
|
||||
calcArrProducts()
|
||||
calcArrProducts()
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => idGasSel.value, (newval, oldval) => {
|
||||
@@ -239,7 +265,7 @@ export default defineComponent({
|
||||
if (filter.value.author) {
|
||||
cat.value = '' // disattivo il filtro categoria
|
||||
if (loadpage.value)
|
||||
tools.setCookie(tools.COOK_CATEGORIA, '')
|
||||
tools.setCookie(getKeyCatAtLoad(), '')
|
||||
resetSearch()
|
||||
}
|
||||
|
||||
@@ -270,7 +296,7 @@ export default defineComponent({
|
||||
if (cosa.value !== shared_consts.PROD.TUTTI) {
|
||||
cat.value = ''
|
||||
if (loadpage.value)
|
||||
tools.setCookie(tools.COOK_CATEGORIA, '')
|
||||
tools.setCookie(getKeyCatAtLoad(), '')
|
||||
}
|
||||
calcArrProducts()
|
||||
}
|
||||
@@ -447,6 +473,7 @@ export default defineComponent({
|
||||
filtroAuthor: string,
|
||||
filtroProductTypes: number[],
|
||||
filtroExcludeProductTypes: number[],
|
||||
filtroidTipologie: number[],
|
||||
editore: string[],
|
||||
idCollane: ICollana[],
|
||||
arrargomstr: any[],
|
||||
@@ -463,6 +490,7 @@ export default defineComponent({
|
||||
const boolfiltroVuotoProductTypes =
|
||||
filtroProductTypes.length === 0 || (filtroProductTypes.length === 1 && filtroProductTypes[0] === 0);
|
||||
const boolfiltroVuotoExcludeProductTypes = filtroExcludeProductTypes.length === 0;
|
||||
const boolfiltroVuotoidTipologie = filtroidTipologie.length === 0;
|
||||
const boolfiltroVuotoEditore = editore.length === 0;
|
||||
const boolfiltroVuotoCollane = idCollane.length === 0;
|
||||
// const boolfiltroVuotoArgomenti = arrargomstr.length === 0;
|
||||
@@ -475,8 +503,23 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
// il prodotto dev'essere disponibile
|
||||
if (!productStore.isPubblicato(product))
|
||||
return false
|
||||
//if (!productStore.isPubblicato(product.productInfo))
|
||||
// return false
|
||||
|
||||
if (!(optrigenera.value.visibilitaDisp === costanti.DISP.TUTTI ||
|
||||
(optrigenera.value.visibilitaDisp === costanti.DISP.ESAURITI && productStore.isEsaurito(product)) ||
|
||||
(optrigenera.value.visibilitaDisp === costanti.DISP.DISPONIBILI && productStore.isDisponibile(product)))) {
|
||||
return false;
|
||||
}
|
||||
if (!(optrigenera.value.stato === costanti.STATO.TUTTI ||
|
||||
(optrigenera.value.stato === costanti.STATO.IN_COMMERCIO && productStore.isPubblicato(product.productInfo)) ||
|
||||
(optrigenera.value.stato === costanti.STATO.SOLO_PROSSIMA_USCITA && 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))
|
||||
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const lowerName = (product.productInfo.name || '').toLowerCase();
|
||||
const lowerCode = (product.productInfo.code || '').toLowerCase();
|
||||
@@ -504,6 +547,10 @@ export default defineComponent({
|
||||
? false
|
||||
: (product.productInfo.productTypes || []).every((item: any) => filtroExcludeProductTypes.includes(item));
|
||||
|
||||
const hasidTipologie = boolfiltroVuotoidTipologie
|
||||
? true
|
||||
: filtroidTipologie.includes(product.arrvariazioni?.[0].idTipologia);
|
||||
|
||||
// Filtri per editore
|
||||
const hasPublished = boolfiltroVuotoEditore
|
||||
? true
|
||||
@@ -530,15 +577,15 @@ export default defineComponent({
|
||||
searchMatch &&
|
||||
hasAuthor &&
|
||||
productgassel &&
|
||||
hasProductTypes &&
|
||||
hasidTipologie &&
|
||||
// hasProductTypes &&
|
||||
(
|
||||
hasPublished &&
|
||||
hasCollana &&
|
||||
hasCategoria &&
|
||||
hasArgomentiCat
|
||||
)
|
||||
&&
|
||||
!hasExcludeProductTypes
|
||||
// && !hasExcludeProductTypes
|
||||
);
|
||||
})
|
||||
.sort((a, b) => getProductsSorted([a, b], sortField, sortDir)[0] === a ? -1 : 1);
|
||||
@@ -552,14 +599,20 @@ export default defineComponent({
|
||||
return arrris
|
||||
}
|
||||
|
||||
function calcArrProducts(generalista?: boolean) {
|
||||
async function calcArrProducts(generalista?: boolean) {
|
||||
console.log('calcArrProducts (generalista=' + generalista + ')')
|
||||
|
||||
if (!loadpage.value)
|
||||
return
|
||||
|
||||
generatinglist.value = true
|
||||
|
||||
const searchtext = getSearchText();
|
||||
let arrprod = [];
|
||||
const filtroAuthor = filter.value.author || '';
|
||||
const filtroProductTypes = optcatalogo.value.productTypes || [0];
|
||||
const filtroExcludeProductTypes = optcatalogo.value.excludeproductTypes || [0];
|
||||
const filtroidTipologie = optcatalogo.value.idTipologie || [];
|
||||
const editore = getEditoreDaFiltrare(optcatalogo.value.editore);
|
||||
const filtroPublishers = editore || [];
|
||||
const idCollane = getIdCollaneDaFiltrare(optcatalogo.value.idCollane);
|
||||
@@ -574,6 +627,9 @@ export default defineComponent({
|
||||
// Se nel catalogo è stato già generato, allora gli passo quello.
|
||||
const trovatocatalogo = getCatalogoByMyPage.value
|
||||
|
||||
if (editore)
|
||||
console.log('FILTRO editore', editore)
|
||||
|
||||
if (optcatalogo.value.showListaArgomenti) {
|
||||
generalista = true
|
||||
}
|
||||
@@ -592,6 +648,7 @@ export default defineComponent({
|
||||
filtroAuthor,
|
||||
filtroProductTypes,
|
||||
filtroExcludeProductTypes,
|
||||
filtroidTipologie,
|
||||
filtroPublishers,
|
||||
filtroCollane,
|
||||
arrargomstr,
|
||||
@@ -599,7 +656,7 @@ export default defineComponent({
|
||||
gasselstr,
|
||||
cosa.value,
|
||||
filter.value.sort_field,
|
||||
filter.value.sort_dir
|
||||
filter.value.sort_dir,
|
||||
);
|
||||
|
||||
salva = true
|
||||
@@ -613,7 +670,10 @@ export default defineComponent({
|
||||
generatearrProdToViewSorted(!generalista, salva, !optcatalogo.value.showListaArgomenti);
|
||||
loaddata();
|
||||
|
||||
refreshpage.value = false;
|
||||
console.log('***** FINE calcArrPROD')
|
||||
|
||||
generatinglist.value = false
|
||||
rigeneraLibri.value = false
|
||||
}
|
||||
|
||||
function generaListaLibri() {
|
||||
@@ -630,11 +690,38 @@ export default defineComponent({
|
||||
})
|
||||
}
|
||||
|
||||
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) {
|
||||
if (schedaprec === null)
|
||||
return true
|
||||
|
||||
const isDifferent =
|
||||
!arraysEqual(scheda.productTypes, schedaprec?.productTypes) ||
|
||||
!arraysEqual(scheda.excludeproductTypes, schedaprec?.excludeproductTypes) ||
|
||||
!arraysEqual(scheda.idTipologie, schedaprec?.idTipologie) ||
|
||||
!arraysEqual(scheda.editore, schedaprec?.editore) ||
|
||||
!arraysEqual(scheda.idCollane, schedaprec?.idCollane)
|
||||
;
|
||||
|
||||
return isDifferent;
|
||||
|
||||
}
|
||||
|
||||
function getProductsFilteredByScheda(scheda: IMyScheda): IProduct[] {
|
||||
let arrprod = productStore.getProducts(cosa.value) || [];
|
||||
let arrprod = [];
|
||||
|
||||
const filtroAuthor = filter.value.author || '';
|
||||
const filtroProductTypes = scheda.productTypes || [0];
|
||||
const filtroExcludeProductTypes = scheda.excludeproductTypes || [0];
|
||||
const filtroidTipologie = scheda.idTipologie || [];
|
||||
const editore = getEditoreDaFiltrare(scheda.editore);
|
||||
const filtroPublishers = editore || [];
|
||||
const idCollane = getIdCollaneDaFiltrare(scheda.idCollane);
|
||||
@@ -649,6 +736,7 @@ export default defineComponent({
|
||||
if (trovatocatalogo?.lista_prodotti.length > 0) {
|
||||
arrprod = trovatocatalogo?.lista_prodotti
|
||||
} else {
|
||||
arrprod = productStore.getProducts(cosa.value)
|
||||
|
||||
arrprod = filterProducts(
|
||||
arrprod,
|
||||
@@ -656,6 +744,7 @@ export default defineComponent({
|
||||
filtroAuthor,
|
||||
filtroProductTypes,
|
||||
filtroExcludeProductTypes,
|
||||
filtroidTipologie,
|
||||
filtroPublishers,
|
||||
filtroCollane,
|
||||
arrargomstr,
|
||||
@@ -785,6 +874,8 @@ export default defineComponent({
|
||||
|
||||
let arrprod = []
|
||||
|
||||
let schedaprec = null;
|
||||
|
||||
for (const recscheda of optcatalogo.value.arrSchede!) {
|
||||
if (recscheda && recscheda.scheda) {
|
||||
const schedePerRiga = recscheda.scheda.numschede_perRiga || 1
|
||||
@@ -798,8 +889,11 @@ export default defineComponent({
|
||||
} else {
|
||||
if (recscheda.scheda.productTypes!.length > 0) {
|
||||
// Filtra i prodotti in base ai filtri impostati !
|
||||
arrProdFiltrati = getProductsFilteredByScheda(recscheda.scheda)
|
||||
indprod = 0
|
||||
if (checkIfFiltriDiversi(recscheda.scheda, schedaprec) || indprod === 0) {
|
||||
arrProdFiltrati = getProductsFilteredByScheda(recscheda.scheda)
|
||||
schedaprec = { ...recscheda.scheda }
|
||||
indprod = 0
|
||||
}
|
||||
} else {
|
||||
let sort_field = recscheda.scheda.sort_field! || optcatalogo.value.sort_field
|
||||
let sort_dir = recscheda.scheda.sort_dir || optcatalogo.value.sort_dir
|
||||
@@ -852,9 +946,9 @@ export default defineComponent({
|
||||
if (indtotale > optcatalogo.value.maxnumlibri!)
|
||||
return
|
||||
|
||||
//} else {
|
||||
// if (indtotale > 5000)
|
||||
// return
|
||||
//} else {
|
||||
// if (indtotale > 5000)
|
||||
// return
|
||||
}
|
||||
|
||||
}
|
||||
@@ -934,11 +1028,19 @@ export default defineComponent({
|
||||
});
|
||||
}*/
|
||||
|
||||
function getKeyCatAtLoad() {
|
||||
return tools.COOK_CATEGORIA + (showListaArgomenti.value ? '_LA' : '')
|
||||
}
|
||||
|
||||
async function mounted() {
|
||||
// console.log('mounted Catalogo')
|
||||
|
||||
cat.value = tools.getCookie(getKeyCatAtLoad(), '')
|
||||
|
||||
tabcatalogo.value = tools.getCookie('TAB_CAT', 'visu')
|
||||
|
||||
optrigenera.value.visibilitaDisp = tools.getCookie(showListaArgomenti.value ? 'INC_ES' : 'VIS_DISP', 'tutti')
|
||||
|
||||
loadpage.value = false
|
||||
await productStore.loadProducts()
|
||||
|
||||
@@ -965,7 +1067,7 @@ export default defineComponent({
|
||||
//++Todo: Per ora visualizzo solo il "Negozio" e non i GAS...
|
||||
cosa.value = shared_consts.PROD.BOTTEGA
|
||||
|
||||
cat.value = tools.getCookie(tools.COOK_CATEGORIA, '')
|
||||
|
||||
|
||||
//cosa.value = tools.getCookie(tools.COOK_COSA_PRODOTTI, shared_consts.PROD.GAS, true)
|
||||
//if (cosa.value === shared_consts.PROD.TUTTI)
|
||||
@@ -977,7 +1079,6 @@ export default defineComponent({
|
||||
|
||||
calcArrProducts()
|
||||
|
||||
loaddata()
|
||||
}
|
||||
|
||||
function loaddata() {
|
||||
@@ -990,17 +1091,18 @@ export default defineComponent({
|
||||
});
|
||||
|
||||
function getCatProds() {
|
||||
const arrcat = productStore.getCatProds(cosa.value)
|
||||
const riscat: any = [{ label: 'Tutti', value: '', icon: undefined, color: undefined }]
|
||||
for (const rec of arrcat) {
|
||||
const label = rec.name + ' (' + productStore.getTotaliProdottiByIdCatProd(rec._id) + ')'
|
||||
riscat.push({ label, value: rec._id, icon: rec.icon, color: rec.color })
|
||||
}
|
||||
|
||||
return riscat
|
||||
return [{ label: 'Tutti', value: '', icon: undefined, color: undefined }].concat(
|
||||
productStore.getCatProds(cosa.value).map(rec => ({
|
||||
label: `${rec.name} (${productStore.getTotaliProdottiByIdCatProd(rec._id)})`,
|
||||
value: rec._id,
|
||||
icon: rec.icon,
|
||||
color: rec.color,
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function onLoadScroll(index: number, done: any) {
|
||||
if (index >= 1) {
|
||||
if (numRecLoaded.value < arrProducts.value.length) {
|
||||
@@ -1299,7 +1401,6 @@ export default defineComponent({
|
||||
productStore,
|
||||
t,
|
||||
loadpage,
|
||||
refreshpage,
|
||||
componentToFixRef,
|
||||
isFixed,
|
||||
arrProducts,
|
||||
@@ -1345,6 +1446,11 @@ export default defineComponent({
|
||||
addProductToList,
|
||||
addnewProd,
|
||||
showListaArgomenti,
|
||||
rigeneraLibri,
|
||||
optrigenera,
|
||||
generatinglist,
|
||||
optDisp,
|
||||
optStato,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user