- Aggiunto bottone Aggiungi al Carrello sulla lista dei libri dei cataloghi
This commit is contained in:
@@ -246,4 +246,9 @@ body {
|
||||
&:hover {
|
||||
color: #5c8ef4;
|
||||
}
|
||||
}
|
||||
.clCondiz {
|
||||
margin-bottom: 2px;
|
||||
margin-left: 2px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
@@ -317,10 +317,12 @@ export default defineComponent({
|
||||
|
||||
const tabvisu = ref('categorie');
|
||||
const tabcatalogo = ref('visu');
|
||||
const tabgen = ref('condizioni');
|
||||
|
||||
const searchList = ref([] as ISearchList[]);
|
||||
|
||||
const arrProducts = ref<IProduct[]>([]);
|
||||
const arrListaTemporanea = ref<IProduct[]>([]);
|
||||
const arrProdToView = ref<IProdView[]>([]);
|
||||
|
||||
const numRecLoaded = ref(0);
|
||||
@@ -1000,7 +1002,7 @@ export default defineComponent({
|
||||
return arrris;
|
||||
}
|
||||
|
||||
async function calcArrProducts(generalista?: boolean) {
|
||||
async function calcArrProducts(generalista?: boolean, salva_listatemp: boolean) {
|
||||
// console.log('calcArrProducts (generalista=' + generalista + ')');
|
||||
|
||||
if (generalista) {
|
||||
@@ -1089,31 +1091,35 @@ export default defineComponent({
|
||||
salva = true;
|
||||
}
|
||||
|
||||
arrProducts.value = arrprod;
|
||||
if (salva_listatemp) {
|
||||
arrListaTemporanea.value = arrprod;
|
||||
} else {
|
||||
arrProducts.value = arrprod;
|
||||
|
||||
// console.log('arrprod', arrprod)
|
||||
optcatalogo.value = productStore.populateDataWithlinkIdTemplate(
|
||||
optcatalogo.value
|
||||
);
|
||||
|
||||
optcatalogo.value = productStore.populateDataWithlinkIdTemplate(optcatalogo.value);
|
||||
// Ordina la lista
|
||||
generatearrProdToViewSorted(!generalista, salva, !showListaFiltrata.value);
|
||||
loaddata();
|
||||
|
||||
// Ordina la lista
|
||||
generatearrProdToViewSorted(!generalista, salva, !showListaFiltrata.value);
|
||||
loaddata();
|
||||
|
||||
if (generalista) {
|
||||
const catalog = myCatalog.value;
|
||||
if (catalog && !showListaFiltrata.value) {
|
||||
catalog.data_lista_generata = tools.getDateNow();
|
||||
catalog.username_lista_generata = userStore.my.username;
|
||||
await saveCatalog();
|
||||
if (generalista) {
|
||||
const catalog = myCatalog.value;
|
||||
if (catalog && !showListaFiltrata.value) {
|
||||
catalog.data_lista_generata = tools.getDateNow();
|
||||
catalog.username_lista_generata = userStore.my.username;
|
||||
await saveCatalog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// console.log('***** FINE calcArrPROD');
|
||||
|
||||
// console.log('areadistampa FINITO...', optcatalogo.value.areadistampa)
|
||||
|
||||
generatinglist.value = false;
|
||||
rigeneraLibri.value = false;
|
||||
if (!salva_listatemp) {
|
||||
rigeneraLibri.value = false;
|
||||
} else {
|
||||
tabgen.value = 'generato'
|
||||
}
|
||||
}
|
||||
|
||||
async function saveCatalog() {
|
||||
@@ -1146,6 +1152,13 @@ export default defineComponent({
|
||||
});
|
||||
}
|
||||
|
||||
function generaListaTempLibri() {
|
||||
// chiedi prima "Sei sicuro di rigenerare il catalogo?"
|
||||
let risposta_si = false;
|
||||
|
||||
calcArrProducts(true, true);
|
||||
}
|
||||
|
||||
function reSortList() {
|
||||
let risposta_si = false;
|
||||
|
||||
@@ -1344,12 +1357,12 @@ export default defineComponent({
|
||||
salva?: boolean,
|
||||
salvasudb?: boolean
|
||||
) {
|
||||
console.log(
|
||||
/*console.log(
|
||||
'generatearrProdToViewSorted... usaprodottiSalvati=',
|
||||
usaprodottiSalvati,
|
||||
' salva=',
|
||||
salva
|
||||
);
|
||||
);*/
|
||||
|
||||
try {
|
||||
// Svuota
|
||||
@@ -2922,6 +2935,7 @@ export default defineComponent({
|
||||
componentToFixRef,
|
||||
isFixed,
|
||||
arrProducts,
|
||||
arrListaTemporanea,
|
||||
show_hide,
|
||||
onLoadScroll,
|
||||
numRecLoaded,
|
||||
@@ -2996,6 +3010,8 @@ export default defineComponent({
|
||||
isStampa,
|
||||
onlyCatalogoPDF,
|
||||
updatecatalogmodif,
|
||||
tabgen,
|
||||
generaListaTempLibri,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -188,7 +188,7 @@
|
||||
icon="fas fa-redo"
|
||||
label="Rigenera Lista"
|
||||
color="primary"
|
||||
@click="rigeneraLibri = true"
|
||||
@click="rigeneraLibri = true; tabgen = 'condizioni'"
|
||||
></q-btn>
|
||||
|
||||
<!--<q-bcctn
|
||||
@@ -619,7 +619,10 @@
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div v-if="myCatalog.pdf_online" class="catalog-download-section">
|
||||
<div
|
||||
v-if="myCatalog.pdf_online"
|
||||
class="catalog-download-section"
|
||||
>
|
||||
<q-card class="catalog-card shadow-8">
|
||||
<q-card-section class="text-center">
|
||||
<q-img
|
||||
@@ -1532,144 +1535,197 @@
|
||||
title="Rigenera Lista"
|
||||
class="q-ma-sm"
|
||||
>
|
||||
<q-card class="q-ma-sm">
|
||||
<q-card-section>
|
||||
<div style="width: 800px; margin: 0 auto">
|
||||
<CMyValueDb
|
||||
v-if="myCatalog"
|
||||
:editOn="true"
|
||||
:title="t('cataloglist.idTipoFormato')"
|
||||
table="catalogs"
|
||||
:id="myCatalog._id"
|
||||
:rec="myCatalog"
|
||||
mykey="idTipoFormato"
|
||||
debounce="1000"
|
||||
:type="costanti.FieldType.multiselect"
|
||||
jointable="t_web_tipiformatos"
|
||||
class="q-mb-md"
|
||||
@save="(v) => updatecatalogmodif('idTipoFormato', v)"
|
||||
:dense="false"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<q-tabs
|
||||
dense
|
||||
class="bg-green text-white"
|
||||
v-model="tabgen"
|
||||
>
|
||||
<q-tab
|
||||
name="condizioni"
|
||||
icon="fas fa-list"
|
||||
label="Rigenera"
|
||||
/>
|
||||
<q-tab
|
||||
name="generato"
|
||||
icon="fas fa-list"
|
||||
label="Anteprima Lista"
|
||||
/>
|
||||
</q-tabs>
|
||||
<q-tab-panels
|
||||
v-model="tabgen"
|
||||
animated
|
||||
keep-alive
|
||||
>
|
||||
<q-tab-panel name="condizioni">
|
||||
<q-card>
|
||||
<q-card-section class="q-ma-sm">
|
||||
<div style="min-width: 800px; width: 100%; margin: 0 auto">
|
||||
<div class="row">
|
||||
<CMyValueDb
|
||||
v-if="myCatalog"
|
||||
:editOn="true"
|
||||
table="catalogs"
|
||||
:title="t('cataloglist.op_andor')"
|
||||
:id="myCatalog._id"
|
||||
:rec="myCatalog"
|
||||
mykey="condition_andor"
|
||||
debounce="1000"
|
||||
:type="costanti.FieldType.op_andor"
|
||||
class="clCondiz"
|
||||
@save="(v) => updatecatalogmodif('condition_andor', v)"
|
||||
:dense="false"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<CMyValueDb
|
||||
v-if="myCatalog"
|
||||
:editOn="true"
|
||||
:title="t('cataloglist.argomenti')"
|
||||
table="catalogs"
|
||||
:id="myCatalog._id"
|
||||
:rec="myCatalog"
|
||||
mykey="argomenti"
|
||||
debounce="1000"
|
||||
:type="costanti.FieldType.multiselect"
|
||||
jointable="catprods"
|
||||
@save="(v) => updatecatalogmodif('argomenti', v)"
|
||||
class="clCondiz"
|
||||
:dense="false"
|
||||
>
|
||||
</CMyValueDb>
|
||||
|
||||
<div class="row">
|
||||
<CMyValueDb
|
||||
v-if="myCatalog"
|
||||
:editOn="true"
|
||||
table="catalogs"
|
||||
:title="t('cataloglist.op_andor')"
|
||||
:id="myCatalog._id"
|
||||
:rec="myCatalog"
|
||||
mykey="condition_andor"
|
||||
debounce="1000"
|
||||
:type="costanti.FieldType.op_andor"
|
||||
class="q-mb-md"
|
||||
@save="(v) => updatecatalogmodif('condition_andor', v)"
|
||||
:dense="false"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<CMyValueDb
|
||||
v-if="myCatalog"
|
||||
:editOn="true"
|
||||
:title="t('cataloglist.argomenti')"
|
||||
table="catalogs"
|
||||
:id="myCatalog._id"
|
||||
:rec="myCatalog"
|
||||
mykey="argomenti"
|
||||
debounce="1000"
|
||||
:type="costanti.FieldType.multiselect"
|
||||
jointable="catprods"
|
||||
@save="(v) => updatecatalogmodif('argomenti', v)"
|
||||
class="q-mb-md"
|
||||
:dense="false"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<CMyValueDb
|
||||
v-if="myCatalog"
|
||||
:editOn="true"
|
||||
:title="t('cataloglist.collane')"
|
||||
table="catalogs"
|
||||
:id="myCatalog._id"
|
||||
:rec="myCatalog"
|
||||
mykey="idCollane"
|
||||
debounce="1000"
|
||||
:type="costanti.FieldType.multiselect"
|
||||
jointable="collanastotali"
|
||||
@save="(v) => updatecatalogmodif('idCollane', v)"
|
||||
class="q-mb-md"
|
||||
:dense="false"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<CMyValueDb
|
||||
v-if="myCatalog"
|
||||
:editOn="true"
|
||||
:title="t('cataloglist.editore_includi')"
|
||||
table="catalogs"
|
||||
:id="myCatalog._id"
|
||||
:rec="myCatalog"
|
||||
mykey="editore"
|
||||
debounce="1000"
|
||||
:type="costanti.FieldType.multiselect"
|
||||
jointable="publishers_totali"
|
||||
@save="(v) => updatecatalogmodif('editore', v)"
|
||||
class="q-mb-md"
|
||||
:dense="false"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<CMyValueDb
|
||||
v-if="myCatalog"
|
||||
:editOn="true"
|
||||
:title="t('cataloglist.editore_escludi')"
|
||||
table="catalogs"
|
||||
:id="myCatalog._id"
|
||||
:rec="myCatalog"
|
||||
mykey="editore_escludi"
|
||||
debounce="1000"
|
||||
:type="costanti.FieldType.multiselect"
|
||||
jointable="publishers_totali"
|
||||
@save="(v) => updatecatalogmodif('editore_escludi', v)"
|
||||
class="q-mb-md"
|
||||
:dense="false"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<CMyValueDb
|
||||
v-if="myCatalog"
|
||||
:editOn="true"
|
||||
:title="t('cataloglist.collane')"
|
||||
table="catalogs"
|
||||
:id="myCatalog._id"
|
||||
:rec="myCatalog"
|
||||
mykey="idCollane"
|
||||
debounce="1000"
|
||||
:type="costanti.FieldType.multiselect"
|
||||
jointable="collanastotali"
|
||||
@save="(v) => updatecatalogmodif('idCollane', v)"
|
||||
class="clCondiz"
|
||||
:dense="false"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<CMyValueDb
|
||||
v-if="myCatalog"
|
||||
:editOn="true"
|
||||
:title="t('cataloglist.editore_includi')"
|
||||
table="catalogs"
|
||||
:id="myCatalog._id"
|
||||
:rec="myCatalog"
|
||||
mykey="editore"
|
||||
debounce="1000"
|
||||
:type="costanti.FieldType.multiselect"
|
||||
jointable="publishers_totali_sort_qty"
|
||||
@save="(v) => updatecatalogmodif('editore', v)"
|
||||
class="clCondiz"
|
||||
:dense="false"
|
||||
>
|
||||
</CMyValueDb>
|
||||
<CMyValueDb
|
||||
v-if="myCatalog"
|
||||
:editOn="true"
|
||||
:title="t('cataloglist.editore_escludi')"
|
||||
table="catalogs"
|
||||
:id="myCatalog._id"
|
||||
:rec="myCatalog"
|
||||
mykey="editore_escludi"
|
||||
debounce="1000"
|
||||
:type="costanti.FieldType.multiselect"
|
||||
jointable="publishers_totali_sort_qty"
|
||||
@save="(v) => updatecatalogmodif('editore_escludi', v)"
|
||||
class="clCondiz"
|
||||
:dense="false"
|
||||
>
|
||||
</CMyValueDb>
|
||||
|
||||
</div>
|
||||
|
||||
<CMyValueDb
|
||||
v-if="myCatalog"
|
||||
:editOn="true"
|
||||
:title="t('cataloglist.idTipoFormato')"
|
||||
table="catalogs"
|
||||
:id="myCatalog._id"
|
||||
:rec="myCatalog"
|
||||
mykey="idTipoFormato"
|
||||
debounce="1000"
|
||||
:type="costanti.FieldType.multiselect"
|
||||
jointable="t_web_tipiformatos"
|
||||
class="clCondiz"
|
||||
@save="(v) => updatecatalogmodif('idTipoFormato', v)"
|
||||
:dense="false"
|
||||
>
|
||||
</CMyValueDb>
|
||||
|
||||
<div>Filtra per Disponibilità Magazzino:</div>
|
||||
<q-btn-toggle
|
||||
v-model="optrigenera.visibilitaDisp"
|
||||
toggle-color="green"
|
||||
class="q-my-md"
|
||||
:options="optDisp"
|
||||
>
|
||||
</q-btn-toggle>
|
||||
<div>Modalità di Creazione:</div>
|
||||
<q-btn-toggle
|
||||
v-model="optrigenera.rig_mod"
|
||||
toggle-color="red"
|
||||
class="q-my-md"
|
||||
:options="optRigeneraModalita"
|
||||
>
|
||||
</q-btn-toggle>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<div class="row justify-center">
|
||||
<q-spinner-hourglass
|
||||
v-if="generatinglist"
|
||||
size="4em"
|
||||
/>
|
||||
</div>
|
||||
<q-card-actions align="center">
|
||||
<q-btn
|
||||
rounded
|
||||
label="Anteprima"
|
||||
color="positive"
|
||||
icon="fas fa-eye"
|
||||
@click="generaListaTempLibri()"
|
||||
class="float-right"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
rounded
|
||||
label="Rigenera"
|
||||
color="primary"
|
||||
icon="fas fa-redo"
|
||||
@click="generaListaLibri()"
|
||||
class="float-right"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
rounded
|
||||
label="Chiudi"
|
||||
outlined
|
||||
class="float-right"
|
||||
@click="rigeneraLibri = false"
|
||||
></q-btn>
|
||||
</q-card-actions>
|
||||
|
||||
<div>Filtra per Disponibilità Magazzino:</div>
|
||||
<q-btn-toggle
|
||||
v-model="optrigenera.visibilitaDisp"
|
||||
toggle-color="green"
|
||||
class="q-my-md"
|
||||
:options="optDisp"
|
||||
>
|
||||
</q-btn-toggle>
|
||||
<div>Modalità di Creazione:</div>
|
||||
<q-btn-toggle
|
||||
v-model="optrigenera.rig_mod"
|
||||
toggle-color="red"
|
||||
class="q-my-md"
|
||||
:options="optRigeneraModalita"
|
||||
>
|
||||
</q-btn-toggle>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-actions align="center">
|
||||
<q-btn
|
||||
rounded
|
||||
label="Rigenera"
|
||||
color="primary"
|
||||
icon="fas fa-redo"
|
||||
@click="generaListaLibri()"
|
||||
class="float-right"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
rounded
|
||||
label="Chiudi"
|
||||
outlined
|
||||
class="float-right"
|
||||
@click="rigeneraLibri = false"
|
||||
></q-btn>
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-card>
|
||||
</q-tab-panel>
|
||||
<q-tab-panel name="generato">
|
||||
|
||||
<CProductTable
|
||||
v-if="arrListaTemporanea?.length > 0"
|
||||
:lista_prodotti="arrListaTemporanea"
|
||||
:optcatalogo="optcatalogo"
|
||||
table="products"
|
||||
@rigenera="generaListaLibri()"
|
||||
/>
|
||||
|
||||
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
</CMyDialog>
|
||||
|
||||
<CMyDialog
|
||||
|
||||
@@ -1,45 +1,44 @@
|
||||
import { defineComponent, onMounted, ref, watch, computed, onBeforeUnmount } from 'vue'
|
||||
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 { defineComponent, onMounted, ref, watch, computed, onBeforeUnmount } from 'vue';
|
||||
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 { CSelectUserActive } from '@src/components/CSelectUserActive'
|
||||
import type { IProduct } from '@src/model'
|
||||
import { shared_consts } from '@src/common/shared_vuejs';
|
||||
import { CProductCard } from '@src/components/CProductCard';
|
||||
import { CSelectUserActive } from '@src/components/CSelectUserActive';
|
||||
import type { IProduct } from '@src/model';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ProductsList',
|
||||
components: { CProductCard, CSelectUserActive },
|
||||
props: {},
|
||||
setup() {
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
const productStore = useProducts()
|
||||
const router = useRouter()
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore();
|
||||
const globalStore = useGlobalStore();
|
||||
const productStore = useProducts();
|
||||
const router = useRouter();
|
||||
const $q = useQuasar();
|
||||
const { t } = useI18n();
|
||||
|
||||
const search = ref('')
|
||||
const search = ref('');
|
||||
|
||||
const cosa = ref(0)
|
||||
const cat = ref('')
|
||||
const subcat = ref('')
|
||||
const idGasSel = ref('')
|
||||
const loadpage = ref(false)
|
||||
const refreshpage = ref(false)
|
||||
const show_hide = ref(false)
|
||||
const cosa = ref(0);
|
||||
const cat = ref('');
|
||||
const subcat = ref('');
|
||||
const idGasSel = ref('');
|
||||
const loadpage = ref(false);
|
||||
const refreshpage = ref(false);
|
||||
const show_hide = ref(false);
|
||||
|
||||
const arrProducts = ref<any>([])
|
||||
|
||||
const numRecLoaded = ref(0)
|
||||
const arrProducts = ref<any>([]);
|
||||
|
||||
const numRecLoaded = ref(0);
|
||||
|
||||
// Create a ref for the component to fix
|
||||
const componentToFixRef = ref(<any>null);
|
||||
@@ -48,11 +47,11 @@ export default defineComponent({
|
||||
|
||||
const arrLoaded = computed(() => {
|
||||
if (arrProducts.value && numRecLoaded.value)
|
||||
return arrProducts.value.slice(0, numRecLoaded.value)
|
||||
return arrProducts.value.slice(0, numRecLoaded.value);
|
||||
else {
|
||||
return []
|
||||
return [];
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// Register the scroll event on component mount
|
||||
const handleScroll = () => {
|
||||
@@ -65,60 +64,93 @@ export default defineComponent({
|
||||
isFixed.value = scrollTop > threshold;
|
||||
};
|
||||
|
||||
watch(() => cat.value, (newval, oldval) => {
|
||||
calcArrProducts()
|
||||
})
|
||||
|
||||
watch(() => subcat.value, (newval, oldval) => {
|
||||
calcArrProducts()
|
||||
})
|
||||
|
||||
watch(() => idGasSel.value, (newval, oldval) => {
|
||||
calcArrProducts()
|
||||
})
|
||||
|
||||
watch(() => search.value, (newval, oldval) => {
|
||||
calcArrProducts()
|
||||
if (tools.scrollTop() > 300) {
|
||||
tools.scrollToTopValue(300)
|
||||
watch(
|
||||
() => cat.value,
|
||||
(newval, oldval) => {
|
||||
if (loadpage.value) {
|
||||
tools.setCookie(tools.COOK_ARGOM, cat.value.toString());
|
||||
calcArrProducts();
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
watch(() => cosa.value, (newval, oldval) => {
|
||||
tools.setCookie(tools.COOK_COSA_PRODOTTI, cosa.value.toString())
|
||||
if (cosa.value !== shared_consts.PROD.TUTTI) {
|
||||
cat.value = ''
|
||||
subcat.value = ''
|
||||
watch(
|
||||
() => subcat.value,
|
||||
(newval, oldval) => {
|
||||
if (loadpage.value) {
|
||||
calcArrProducts();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
calcArrProducts()
|
||||
})
|
||||
watch(
|
||||
() => idGasSel.value,
|
||||
(newval, oldval) => {
|
||||
if (loadpage.value) {
|
||||
calcArrProducts();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => search.value,
|
||||
(newval, oldval) => {
|
||||
if (loadpage.value) {
|
||||
calcArrProducts();
|
||||
if (tools.scrollTop() > 300) {
|
||||
tools.scrollToTopValue(300);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => cosa.value,
|
||||
(newval, oldval) => {
|
||||
if (loadpage.value) {
|
||||
tools.setCookie(tools.COOK_COSA_PRODOTTI, cosa.value.toString());
|
||||
if (cosa.value !== shared_consts.PROD.TUTTI) {
|
||||
cat.value = '';
|
||||
subcat.value = '';
|
||||
}
|
||||
|
||||
calcArrProducts();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
function calcArrProducts() {
|
||||
// console.log('calcArrProducts')
|
||||
|
||||
refreshpage.value = true
|
||||
let arrprod = productStore.getProducts(cosa.value)
|
||||
refreshpage.value = true;
|
||||
let arrprod = productStore.getProducts(cosa.value);
|
||||
const catstr = cat.value;
|
||||
const subcatstr = subcat.value;
|
||||
let gasselstr = ''
|
||||
let gasselstr = '';
|
||||
if (cosa.value === shared_consts.PROD.GAS) {
|
||||
gasselstr = idGasSel.value
|
||||
gasselstr = idGasSel.value;
|
||||
}
|
||||
const lowerSearchText = search.value.toLowerCase().trim();
|
||||
if ((!lowerSearchText || (lowerSearchText && lowerSearchText.length < 2)) && !catstr && !subcatstr && (!gasselstr && (cosa.value !== shared_consts.PROD.GAS))) {
|
||||
|
||||
if (
|
||||
(!lowerSearchText || (lowerSearchText && lowerSearchText.length < 2)) &&
|
||||
!catstr &&
|
||||
!subcatstr &&
|
||||
!gasselstr &&
|
||||
cosa.value !== shared_consts.PROD.GAS
|
||||
) {
|
||||
} else {
|
||||
|
||||
arrprod = arrprod.filter((product: IProduct) => {
|
||||
if (product && product.productInfo && !!product.productInfo.name) {
|
||||
const lowerName = product.productInfo.name.toLowerCase();
|
||||
const hasCategoria = !catstr || (catstr && product.productInfo.idCatProds?.includes(catstr));
|
||||
const hasSubCategoria = !subcatstr || (subcatstr && product.productInfo.idSubCatProds?.includes(subcatstr));
|
||||
const hasCategoria =
|
||||
!catstr || (catstr && product.productInfo.idCatProds?.includes(catstr));
|
||||
const hasSubCategoria =
|
||||
!subcatstr ||
|
||||
(subcatstr && product.productInfo.idSubCatProds?.includes(subcatstr));
|
||||
|
||||
let productgassel = true
|
||||
if (gasselstr || (cosa.value === shared_consts.PROD.GAS)) {
|
||||
productgassel = (product.idGasordine === gasselstr)
|
||||
let productgassel = true;
|
||||
if (gasselstr || cosa.value === shared_consts.PROD.GAS) {
|
||||
productgassel = product.idGasordine === gasselstr;
|
||||
}
|
||||
|
||||
// Use a regular expression to match whole words
|
||||
@@ -126,16 +158,23 @@ export default defineComponent({
|
||||
const nameMatch = new RegExp(`\\b${lowerSearchText}`, 'i');
|
||||
|
||||
// Check if any word in lowerName starts with lowerSearchText
|
||||
const anyWordStartsWithSearch = lowerName.split(/\s+/).some(word => nameMatch.test(word));
|
||||
const anyWordStartsWithSearch = lowerName
|
||||
.split(/\s+/)
|
||||
.some((word) => nameMatch.test(word));
|
||||
|
||||
return (codeMatch.test(product.productInfo.code) || anyWordStartsWithSearch) && hasCategoria && hasSubCategoria && productgassel;
|
||||
return (
|
||||
(codeMatch.test(product.productInfo.code) || anyWordStartsWithSearch) &&
|
||||
hasCategoria &&
|
||||
hasSubCategoria &&
|
||||
productgassel
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
arrProducts.value = arrprod
|
||||
loaddata()
|
||||
refreshpage.value = false
|
||||
arrProducts.value = arrprod;
|
||||
loaddata();
|
||||
refreshpage.value = false;
|
||||
}
|
||||
|
||||
/*function getProducts() {
|
||||
@@ -155,23 +194,30 @@ export default defineComponent({
|
||||
}*/
|
||||
|
||||
async function mounted() {
|
||||
loadpage.value = false
|
||||
await productStore.loadProducts(true)
|
||||
cosa.value = tools.getCookie(tools.COOK_COSA_PRODOTTI, shared_consts.PROD.GAS, true)
|
||||
if (cosa.value === shared_consts.PROD.TUTTI)
|
||||
cosa.value = shared_consts.PROD.GAS
|
||||
loadpage.value = false;
|
||||
|
||||
cosa.value = tools.getCookie(
|
||||
tools.COOK_COSA_PRODOTTI,
|
||||
shared_consts.PROD.GAS,
|
||||
true
|
||||
);
|
||||
if (cosa.value === shared_consts.PROD.TUTTI) cosa.value = shared_consts.PROD.GAS;
|
||||
|
||||
cat.value = tools.getCookie(tools.COOK_ARGOM, '');
|
||||
|
||||
await productStore.loadProducts(true);
|
||||
|
||||
// Inizializza
|
||||
loadpage.value = true
|
||||
loadpage.value = true;
|
||||
window.addEventListener('scroll', handleScroll);
|
||||
|
||||
calcArrProducts()
|
||||
calcArrProducts();
|
||||
|
||||
loaddata()
|
||||
loaddata();
|
||||
}
|
||||
|
||||
function loaddata() {
|
||||
numRecLoaded.value = 20
|
||||
numRecLoaded.value = 20;
|
||||
}
|
||||
|
||||
// Remove the event listener on component destroy
|
||||
@@ -180,65 +226,76 @@ export default defineComponent({
|
||||
});
|
||||
|
||||
function getCatProds() {
|
||||
const arrcat = productStore.getCatProds(shared_consts.PROD.BOTTEGA)
|
||||
const arrcat = productStore.getCatProds(shared_consts.PROD.BOTTEGA);
|
||||
|
||||
// console.log('getCatProds', arrcat)
|
||||
let riscat: any = []
|
||||
let riscat: any = [];
|
||||
if (arrcat && arrcat.length > 0) {
|
||||
riscat = [{ label: 'Tutti', value: '', icon: undefined, color: undefined }]
|
||||
riscat = [{ label: 'Tutti', value: '', icon: undefined, color: undefined }];
|
||||
for (const rec of arrcat) {
|
||||
riscat.push({ label: rec.name, value: rec._id, icon: rec.icon, color: rec.color })
|
||||
riscat.push({
|
||||
label: rec.name,
|
||||
value: rec._id,
|
||||
icon: rec.icon,
|
||||
color: rec.color,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return riscat
|
||||
return riscat;
|
||||
}
|
||||
function getCatProdsByGas(idGasOrdine: string): any {
|
||||
const arrcat = productStore.getCatProdsByGas(idGasOrdine)
|
||||
let riscat: any = []
|
||||
const arrcat = productStore.getCatProdsByGas(idGasOrdine);
|
||||
let riscat: any = [];
|
||||
if (arrcat && arrcat.length > 0) {
|
||||
riscat = [{ label: 'Tutti', value: '', icon: undefined, color: undefined }]
|
||||
riscat = [{ label: 'Tutti', value: '', icon: undefined, color: undefined }];
|
||||
for (const rec of arrcat) {
|
||||
riscat.push({ label: rec.name, value: rec._id, icon: rec.icon, color: rec.color })
|
||||
riscat.push({
|
||||
label: rec.name,
|
||||
value: rec._id,
|
||||
icon: rec.icon,
|
||||
color: rec.color,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return riscat
|
||||
return riscat;
|
||||
}
|
||||
function getSubCatProdsByGas(idGasOrdine: string, idCatProd: string): any {
|
||||
const arrcat = productStore.getSubCatProdsByGas(idGasOrdine, idCatProd)
|
||||
let riscat: any = []
|
||||
const arrcat = productStore.getSubCatProdsByGas(idGasOrdine, idCatProd);
|
||||
let riscat: any = [];
|
||||
if (arrcat && arrcat.length > 0) {
|
||||
riscat = [{ label: 'Tutti', value: '', icon: undefined, color: undefined }]
|
||||
riscat = [{ label: 'Tutti', value: '', icon: undefined, color: undefined }];
|
||||
for (const rec of arrcat) {
|
||||
riscat.push({ label: rec.name, value: rec._id, icon: rec.icon, color: rec.color })
|
||||
riscat.push({
|
||||
label: rec.name,
|
||||
value: rec._id,
|
||||
icon: rec.icon,
|
||||
color: rec.color,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return riscat
|
||||
return riscat;
|
||||
}
|
||||
|
||||
|
||||
function onLoadScroll(index: number, done: any) {
|
||||
if (index >= 1) {
|
||||
if (numRecLoaded.value < arrProducts.value.length) {
|
||||
const step = 10;
|
||||
let mynrec = numRecLoaded.value + step;
|
||||
|
||||
const step = 10
|
||||
let mynrec = numRecLoaded.value + step
|
||||
|
||||
if (mynrec > arrProducts.value.length)
|
||||
mynrec = arrProducts.value.length
|
||||
|
||||
numRecLoaded.value = mynrec
|
||||
if (mynrec > arrProducts.value.length) mynrec = arrProducts.value.length;
|
||||
|
||||
numRecLoaded.value = mynrec;
|
||||
}
|
||||
done()
|
||||
done();
|
||||
} else {
|
||||
done(true)
|
||||
done(true);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
onMounted(mounted);
|
||||
|
||||
return {
|
||||
userStore,
|
||||
@@ -265,7 +322,6 @@ export default defineComponent({
|
||||
numRecLoaded,
|
||||
arrLoaded,
|
||||
getSubCatProdsByGas,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user