- 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
|
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 cosa = ref(0)
|
||||||
const cat = ref('')
|
const cat = ref('')
|
||||||
|
const idGasSel = ref('')
|
||||||
const loadpage = ref(false)
|
const loadpage = ref(false)
|
||||||
const refreshpage = ref(false)
|
const refreshpage = ref(false)
|
||||||
const show_hide = ref(false)
|
const show_hide = ref(false)
|
||||||
@@ -66,6 +67,11 @@ export default defineComponent({
|
|||||||
watch(() => cat.value, (newval, oldval) => {
|
watch(() => cat.value, (newval, oldval) => {
|
||||||
calcArrProducts()
|
calcArrProducts()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(() => idGasSel.value, (newval, oldval) => {
|
||||||
|
calcArrProducts()
|
||||||
|
})
|
||||||
|
|
||||||
watch(() => search.value, (newval, oldval) => {
|
watch(() => search.value, (newval, oldval) => {
|
||||||
calcArrProducts()
|
calcArrProducts()
|
||||||
if (tools.scrollTop() > 300) {
|
if (tools.scrollTop() > 300) {
|
||||||
@@ -86,8 +92,12 @@ export default defineComponent({
|
|||||||
refreshpage.value = true
|
refreshpage.value = true
|
||||||
let arrprod = productStore.getProducts(cosa.value)
|
let arrprod = productStore.getProducts(cosa.value)
|
||||||
let catstr = cat.value;
|
let catstr = cat.value;
|
||||||
|
let gasselstr = ''
|
||||||
|
if (cosa.value === shared_consts.PROD.GAS) {
|
||||||
|
gasselstr = idGasSel.value
|
||||||
|
}
|
||||||
let lowerSearchText = search.value.toLowerCase().trim();
|
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 {
|
} else {
|
||||||
|
|
||||||
@@ -95,6 +105,11 @@ export default defineComponent({
|
|||||||
let lowerName = product.productInfo.name!.toLowerCase();
|
let lowerName = product.productInfo.name!.toLowerCase();
|
||||||
let hasCategoria = !catstr || (catstr && product.productInfo.idCatProds?.includes(catstr));
|
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
|
// Use a regular expression to match whole words
|
||||||
let codeMatch = new RegExp(`\\b${lowerSearchText}\\b`, 'i');
|
let codeMatch = new RegExp(`\\b${lowerSearchText}\\b`, 'i');
|
||||||
let nameMatch = new RegExp(`\\b${lowerSearchText}`, 'i');
|
let nameMatch = new RegExp(`\\b${lowerSearchText}`, 'i');
|
||||||
@@ -102,7 +117,7 @@ export default defineComponent({
|
|||||||
// Check if any word in lowerName starts with lowerSearchText
|
// Check if any word in lowerName starts with lowerSearchText
|
||||||
let anyWordStartsWithSearch = lowerName.split(/\s+/).some(word => nameMatch.test(word));
|
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() {
|
async function mounted() {
|
||||||
loadpage.value = false
|
loadpage.value = false
|
||||||
await productStore.loadProducts()
|
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
|
// Inizializza
|
||||||
loadpage.value = true
|
loadpage.value = true
|
||||||
window.addEventListener('scroll', handleScroll);
|
window.addEventListener('scroll', handleScroll);
|
||||||
@@ -191,6 +209,7 @@ export default defineComponent({
|
|||||||
shared_consts,
|
shared_consts,
|
||||||
getCatProds,
|
getCatProds,
|
||||||
cat,
|
cat,
|
||||||
|
idGasSel,
|
||||||
productStore,
|
productStore,
|
||||||
t,
|
t,
|
||||||
loadpage,
|
loadpage,
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
glossy
|
glossy
|
||||||
toggle-color="primary"
|
toggle-color="primary"
|
||||||
:options="[
|
:options="[
|
||||||
{ value: shared_consts.PROD.TUTTI, slot: 'tutti' },
|
|
||||||
{ value: shared_consts.PROD.GAS, slot: 'gas' },
|
{ value: shared_consts.PROD.GAS, slot: 'gas' },
|
||||||
{ value: shared_consts.PROD.BOTTEGA, slot: 'bottega' },
|
{ value: shared_consts.PROD.BOTTEGA, slot: 'bottega' },
|
||||||
]"
|
]"
|
||||||
@@ -92,68 +91,142 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</q-slide-transition>
|
</q-slide-transition>
|
||||||
<div class="row q-gutter-xs justify-center q-mx-auto">
|
<div v-if="cosa === shared_consts.PROD.GAS">
|
||||||
<div v-for="(reccat, index) in getCatProds()" :key="index">
|
<div v-if="!idGasSel">
|
||||||
<q-btn
|
<div class="text-center text-h6 text-red">Scegli l'Ordine di Acquisto:</div>
|
||||||
:push="cat === reccat.value"
|
</div>
|
||||||
dense
|
<div class="row q-gutter-xs justify-center q-mx-auto">
|
||||||
:size="tools.isMobile() ? '0.70rem' : '1rem'"
|
<div v-for="(recgas, index) in productStore.getGasordinesActives()" :key="index">
|
||||||
:icon="reccat.icon ? reccat.icon : undefined"
|
<q-btn
|
||||||
:color="cat === reccat.value ? 'primary' : undefined"
|
push
|
||||||
:text-color="cat === reccat.value ? 'white' : 'black'"
|
dense
|
||||||
rounded
|
:size="tools.isMobile() ? '1rem' : '1.25rem'"
|
||||||
:label="reccat.label"
|
:color="idGasSel === recgas._id ? 'primary' : undefined"
|
||||||
@click="cat = reccat.value"
|
: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
|
||||||
>
|
>
|
||||||
</q-btn>
|
</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>
|
</div>
|
||||||
<div class="text-center q-py-sm prod_trov">
|
<div v-else>
|
||||||
<span v-show="productStore.getNumProdTot() !== arrProducts.length">{{
|
<div class="row q-gutter-xs justify-center q-mx-auto">
|
||||||
t('ecomm.prodotti_trovati', {
|
<div v-for="(reccat, index) in getCatProds()" :key="index">
|
||||||
qta: arrProducts.length,
|
<q-btn
|
||||||
qtatot: productStore.getNumProdTot(),
|
:push="cat === reccat.value"
|
||||||
})
|
dense
|
||||||
}}</span>
|
:size="tools.isMobile() ? '0.70rem' : '1rem'"
|
||||||
</div>
|
:icon="reccat.icon ? reccat.icon : undefined"
|
||||||
<div class="row justify-around" v-if="tools.isManager()">
|
:color="cat === reccat.value ? 'primary' : undefined"
|
||||||
<q-toggle
|
:text-color="cat === reccat.value ? 'white' : 'black'"
|
||||||
v-model="show_hide"
|
rounded
|
||||||
push
|
:label="reccat.label"
|
||||||
label="Mostra Nascosti"
|
@click="cat = reccat.value"
|
||||||
rounded
|
>
|
||||||
glossy
|
</q-btn>
|
||||||
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>
|
</div>
|
||||||
<template v-slot:loading>
|
</div>
|
||||||
<div class="text-center">
|
<div class="text-center q-py-sm prod_trov">
|
||||||
<q-spinner-dots color="primary" size="40px" />
|
<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>
|
</div>
|
||||||
</template>
|
<template v-slot:loading>
|
||||||
</q-infinite-scroll>
|
<div class="text-center">
|
||||||
|
<q-spinner-dots color="primary" size="40px" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</q-infinite-scroll>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user