- fix with old_code
- filtro per GAS
This commit is contained in:
BIN
_ALL_SITES/piuchebuono.app/upload/products/uova.png
Normal file
BIN
_ALL_SITES/piuchebuono.app/upload/products/uova.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 170 KiB |
@@ -1161,6 +1161,12 @@ export const useProducts = defineStore('Products', {
|
||||
return myarr
|
||||
},
|
||||
|
||||
getGasordinesActives() {
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
return globalStore.gasordines.filter((rec) => rec.active)
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ export default defineComponent({
|
||||
|
||||
const cosa = ref(0)
|
||||
const cat = ref('')
|
||||
const idGasSel = ref('')
|
||||
const loadpage = ref(false)
|
||||
const refreshpage = ref(false)
|
||||
const show_hide = ref(false)
|
||||
@@ -66,6 +67,11 @@ export default defineComponent({
|
||||
watch(() => cat.value, (newval, oldval) => {
|
||||
calcArrProducts()
|
||||
})
|
||||
|
||||
watch(() => idGasSel.value, (newval, oldval) => {
|
||||
calcArrProducts()
|
||||
})
|
||||
|
||||
watch(() => search.value, (newval, oldval) => {
|
||||
calcArrProducts()
|
||||
if (tools.scrollTop() > 300) {
|
||||
@@ -86,8 +92,12 @@ export default defineComponent({
|
||||
refreshpage.value = true
|
||||
let arrprod = productStore.getProducts(cosa.value)
|
||||
let catstr = cat.value;
|
||||
let gasselstr = ''
|
||||
if (cosa.value === shared_consts.PROD.GAS) {
|
||||
gasselstr = idGasSel.value
|
||||
}
|
||||
let lowerSearchText = search.value.toLowerCase().trim();
|
||||
if ((!lowerSearchText || (lowerSearchText && lowerSearchText.length < 2)) && !catstr) {
|
||||
if ((!lowerSearchText || (lowerSearchText && lowerSearchText.length < 2)) && !catstr && (!gasselstr && (cosa.value !== shared_consts.PROD.GAS))) {
|
||||
|
||||
} else {
|
||||
|
||||
@@ -95,6 +105,11 @@ export default defineComponent({
|
||||
let lowerName = product.productInfo.name!.toLowerCase();
|
||||
let hasCategoria = !catstr || (catstr && product.productInfo.idCatProds?.includes(catstr));
|
||||
|
||||
let productgassel = true
|
||||
if (gasselstr || (cosa.value === shared_consts.PROD.GAS)) {
|
||||
productgassel = (product.idGasordine === gasselstr)
|
||||
}
|
||||
|
||||
// Use a regular expression to match whole words
|
||||
let codeMatch = new RegExp(`\\b${lowerSearchText}\\b`, 'i');
|
||||
let nameMatch = new RegExp(`\\b${lowerSearchText}`, 'i');
|
||||
@@ -102,7 +117,7 @@ export default defineComponent({
|
||||
// Check if any word in lowerName starts with lowerSearchText
|
||||
let anyWordStartsWithSearch = lowerName.split(/\s+/).some(word => nameMatch.test(word));
|
||||
|
||||
return (codeMatch.test(product.productInfo.code!) || anyWordStartsWithSearch) && hasCategoria;
|
||||
return (codeMatch.test(product.productInfo.code!) || anyWordStartsWithSearch) && hasCategoria && productgassel;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -130,7 +145,10 @@ export default defineComponent({
|
||||
async function mounted() {
|
||||
loadpage.value = false
|
||||
await productStore.loadProducts()
|
||||
cosa.value = tools.getCookie(tools.COOK_COSA_PRODOTTI, shared_consts.PROD.TUTTI, 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
|
||||
|
||||
// Inizializza
|
||||
loadpage.value = true
|
||||
window.addEventListener('scroll', handleScroll);
|
||||
@@ -191,6 +209,7 @@ export default defineComponent({
|
||||
shared_consts,
|
||||
getCatProds,
|
||||
cat,
|
||||
idGasSel,
|
||||
productStore,
|
||||
t,
|
||||
loadpage,
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
glossy
|
||||
toggle-color="primary"
|
||||
:options="[
|
||||
{ value: shared_consts.PROD.TUTTI, slot: 'tutti' },
|
||||
{ value: shared_consts.PROD.GAS, slot: 'gas' },
|
||||
{ value: shared_consts.PROD.BOTTEGA, slot: 'bottega' },
|
||||
]"
|
||||
@@ -92,6 +91,76 @@
|
||||
</div>
|
||||
</div>
|
||||
</q-slide-transition>
|
||||
<div v-if="cosa === shared_consts.PROD.GAS">
|
||||
<div v-if="!idGasSel">
|
||||
<div class="text-center text-h6 text-red">Scegli l'Ordine di Acquisto:</div>
|
||||
</div>
|
||||
<div class="row q-gutter-xs justify-center q-mx-auto">
|
||||
<div v-for="(recgas, index) in productStore.getGasordinesActives()" :key="index">
|
||||
<q-btn
|
||||
push
|
||||
dense
|
||||
:size="tools.isMobile() ? '1rem' : '1.25rem'"
|
||||
:color="idGasSel === recgas._id ? 'primary' : undefined"
|
||||
:text-color="idGasSel === recgas._id ? 'white' : 'black'"
|
||||
:label="recgas.name"
|
||||
@click="idGasSel = recgas._id"
|
||||
>
|
||||
</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center q-py-sm prod_trov">
|
||||
<span
|
||||
v-show="productStore.getNumProdTot() !== arrProducts.length"
|
||||
>{{
|
||||
t('ecomm.prodotti_trovati', {
|
||||
qta: arrProducts.length,
|
||||
qtatot: productStore.getNumProdTot(),
|
||||
})
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="row justify-around" v-if="tools.isManager()">
|
||||
<q-toggle
|
||||
v-model="show_hide"
|
||||
push
|
||||
label="Mostra Nascosti"
|
||||
rounded
|
||||
glossy
|
||||
toggle-color="primary"
|
||||
></q-toggle>
|
||||
</div>
|
||||
<div class="row justify-around">
|
||||
<q-infinite-scroll
|
||||
v-if="arrLoaded && arrLoaded.length > 0"
|
||||
ref="myinfscroll"
|
||||
:initial-index="0"
|
||||
@load="onLoadScroll"
|
||||
:offset="2000"
|
||||
debounce="200"
|
||||
class="q-pa-xs row items-start"
|
||||
>
|
||||
<div
|
||||
class="q-pa-xs"
|
||||
v-for="(product, index) in arrLoaded"
|
||||
:key="index"
|
||||
>
|
||||
<CProductCard
|
||||
v-if="product.active || show_hide"
|
||||
:id="product._id"
|
||||
:complete="false"
|
||||
:cosa="cosa"
|
||||
/>
|
||||
</div>
|
||||
<template v-slot:loading>
|
||||
<div class="text-center">
|
||||
<q-spinner-dots color="primary" size="40px" />
|
||||
</div>
|
||||
</template>
|
||||
</q-infinite-scroll>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div class="row q-gutter-xs justify-center q-mx-auto">
|
||||
<div v-for="(reccat, index) in getCatProds()" :key="index">
|
||||
<q-btn
|
||||
@@ -109,12 +178,15 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center q-py-sm prod_trov">
|
||||
<span v-show="productStore.getNumProdTot() !== arrProducts.length">{{
|
||||
<span
|
||||
v-show="productStore.getNumProdTot() !== arrProducts.length"
|
||||
>{{
|
||||
t('ecomm.prodotti_trovati', {
|
||||
qta: arrProducts.length,
|
||||
qtatot: productStore.getNumProdTot(),
|
||||
})
|
||||
}}</span>
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="row justify-around" v-if="tools.isManager()">
|
||||
<q-toggle
|
||||
@@ -157,6 +229,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</q-page>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user