- filtro se GAS o Prodotti
This commit is contained in:
@@ -18,6 +18,7 @@ export const shared_consts = {
|
||||
LIMIT_NOTIF_FOR_USER: 200,
|
||||
|
||||
PROD: {
|
||||
TUTTI: 0,
|
||||
GAS: 1,
|
||||
BOTTEGA: 2,
|
||||
},
|
||||
@@ -47,8 +48,8 @@ export const shared_consts = {
|
||||
value: 2,
|
||||
},
|
||||
{
|
||||
label: 'Litri (L)',
|
||||
short: 'L',
|
||||
label: 'Litri (Lt)',
|
||||
short: 'Lt',
|
||||
value: 3,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -53,3 +53,8 @@
|
||||
font-size: 1.15rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.countdown_scadenza{
|
||||
font-size: 1.15rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { defineComponent, ref, toRef, computed, PropType, watch, onMounted, reactive } from 'vue'
|
||||
import { defineComponent, ref, toRef, computed, PropType, watch, onMounted, reactive, onBeforeUnmount } from 'vue'
|
||||
import { useI18n } from '@src/boot/i18n'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
@@ -65,8 +65,12 @@ export default defineComponent({
|
||||
|
||||
const storeSelected = ref('')
|
||||
const gasordineSelected = ref('')
|
||||
const recgasordineSelected = ref(<any>null)
|
||||
const arrordersCart = ref(<IOrderCart[]>[])
|
||||
|
||||
const timerInterval = ref(<any>null)
|
||||
const timerLabelScadenza = ref('')
|
||||
|
||||
const openlistorders = ref(false)
|
||||
const endload = ref(false)
|
||||
const myproduct = ref(<IProduct>{})
|
||||
@@ -217,8 +221,33 @@ export default defineComponent({
|
||||
|
||||
watch(() => gasordineSelected.value, (newval, oldval) => {
|
||||
myorder.idGasordine = newval
|
||||
recgasordineSelected.value = myproduct.value.gasordines.find((rec: any) => rec._id === gasordineSelected.value)
|
||||
|
||||
})
|
||||
|
||||
function mounted() {
|
||||
load()
|
||||
// Start the timer when the component is mounted
|
||||
startTimer();
|
||||
}
|
||||
|
||||
function beforeDestroy() {
|
||||
// Clear the interval when the component is destroyed to prevent memory leaks
|
||||
clearInterval(timerInterval.value);
|
||||
}
|
||||
|
||||
function updateTimerLabel() {
|
||||
if (recgasordineSelected.value)
|
||||
timerLabelScadenza.value = tools.getCountDown(recgasordineSelected.value.dataora_chiusura_ordini)
|
||||
else
|
||||
timerLabelScadenza.value = ''
|
||||
}
|
||||
|
||||
function startTimer() {
|
||||
// Update the timer label every second
|
||||
timerInterval.value = setInterval(() => updateTimerLabel(), 1000);
|
||||
}
|
||||
|
||||
function load() {
|
||||
updateproduct()
|
||||
// console.log('Load', myproduct.value.name)
|
||||
@@ -234,22 +263,29 @@ export default defineComponent({
|
||||
|
||||
if (myproduct.value.gasordines && myproduct.value.gasordines.length === 1) {
|
||||
myorder.idGasordine = myproduct.value.gasordines[0]._id
|
||||
gasordineSelected.value = myorder.idGasordine!
|
||||
}
|
||||
|
||||
|
||||
const ord = products.getOrderProductInCart(myproduct.value._id)
|
||||
if (ord) {
|
||||
myorder.quantity = ord.quantity
|
||||
myorder.quantitypreordered = ord.quantitypreordered
|
||||
|
||||
if (ord.idGasordine)
|
||||
if (ord.idGasordine) {
|
||||
gasordineSelected.value = ord.idGasordine!
|
||||
recgasordineSelected.value = myproduct.value.gasordines.find((rec: IGasordine) => rec._id === ord.idGasordine!)
|
||||
}
|
||||
|
||||
// Seleziona il Negozio che avevo già scelto nell'ordine !
|
||||
if (ord.idStorehouse)
|
||||
storeSelected.value = ord.idStorehouse
|
||||
|
||||
}
|
||||
|
||||
if (gasordineSelected.value) {
|
||||
recgasordineSelected.value = myproduct.value.gasordines.find((rec: IGasordine) => rec._id === gasordineSelected.value)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// console.log('°°° ENDLOAD °°°')
|
||||
@@ -283,7 +319,8 @@ export default defineComponent({
|
||||
}, 0))
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
onMounted(mounted)
|
||||
onBeforeUnmount(beforeDestroy)
|
||||
|
||||
return {
|
||||
visuListDisponibili,
|
||||
@@ -316,6 +353,8 @@ export default defineComponent({
|
||||
listord,
|
||||
sumval,
|
||||
getGasordines,
|
||||
recgasordineSelected,
|
||||
timerLabelScadenza,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -131,6 +131,20 @@
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item v-if="myproduct.gasordines && myproduct.gasordines.length >= 1">
|
||||
<q-item-section avatar>
|
||||
<q-icon color="blue" name="fas fa-hourglass-half" />
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section>
|
||||
<q-item-label>
|
||||
{{ t('gas.dataora_chiusura_ordini') }}
|
||||
</q-item-label>
|
||||
<q-item-label class="countdown_scadenza">
|
||||
{{ timerLabelScadenza }}
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
<div v-if="true">
|
||||
<div v-if="complete && myproduct.producer && myproduct.producer.city">
|
||||
@@ -166,7 +180,7 @@
|
||||
(cosa === shared_consts.PROD.GAS && products.getQtyAvailable(myproduct) > 0)
|
||||
"
|
||||
:clickable="tools.isManager()"
|
||||
@click="tools.isManager() ? visuListDisponibili() : null"
|
||||
@click="tools.isManager() && (myproduct.QuantitaOrdinateInAttesa && myproduct.QuantitaOrdinateInAttesa > 0) ? visuListDisponibili() : null"
|
||||
>
|
||||
<q-item-section avatar>
|
||||
<q-icon color="green" name="fas fa-store" />
|
||||
@@ -200,7 +214,7 @@
|
||||
<q-item
|
||||
v-if="products.getQtyBookableAvailable(myproduct) > 0 || myproduct.bookableQty > 0"
|
||||
:clickable="tools.isManager()"
|
||||
@click="tools.isManager() ? visuListBookable() : null"
|
||||
@click="tools.isManager() && (myproduct.QuantitaPrenotateInAttesa && myproduct.QuantitaPrenotateInAttesa > 0) ? visuListBookable() : null"
|
||||
>
|
||||
<q-item-section avatar>
|
||||
<q-icon color="blue" name="fas fa-edit" />
|
||||
|
||||
@@ -74,6 +74,7 @@ export interface IOrder {
|
||||
date_shipping?: Date
|
||||
date_delivered?: Date
|
||||
notes?: string
|
||||
modify_at?: Date
|
||||
}
|
||||
|
||||
export interface IProductsState {
|
||||
|
||||
@@ -1694,6 +1694,7 @@ const msg_it = {
|
||||
bottega: 'Bottega',
|
||||
x_prodotti_gas: '{qta} prodotti',
|
||||
x_prodotti_bottega: '{qta} prodotti',
|
||||
tutti: 'Tutti',
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -8281,6 +8281,33 @@ export const tools = {
|
||||
|
||||
strToVal(mystr: string) {
|
||||
return parseInt(mystr)
|
||||
},
|
||||
|
||||
pad(value: any) {
|
||||
// Helper function to pad single-digit values with leading zeros
|
||||
return value < 10 ? `0${value}` : value;
|
||||
},
|
||||
|
||||
getCountDown(mydate: Date) {
|
||||
const currentDate = new Date();
|
||||
const targetTime = new Date(mydate).getTime();
|
||||
|
||||
// Calculate the difference in milliseconds
|
||||
const countdown = targetTime - currentDate.getTime();
|
||||
|
||||
// Convert milliseconds to seconds
|
||||
const countdownInSeconds = Math.floor(countdown / 1000);
|
||||
|
||||
const days = Math.floor(countdownInSeconds / (60 * 60 * 24));
|
||||
const hours = Math.floor((countdownInSeconds % (60 * 60 * 24)) / (60 * 60));
|
||||
const minutes = Math.floor((countdownInSeconds % (60 * 60)) / 60);
|
||||
const seconds = countdownInSeconds % 60;
|
||||
|
||||
const gg = days > 0 ? 'giorni' : ''
|
||||
const strgg = gg ? `${days} giorni` : ''
|
||||
|
||||
return (`${strgg} ${this.pad(hours)}:${this.pad(minutes)}:${this.pad(seconds)}`);
|
||||
|
||||
}
|
||||
|
||||
// FINE !
|
||||
|
||||
@@ -141,24 +141,31 @@ export const useProducts = defineStore('Products', {
|
||||
return state.orders.length
|
||||
},
|
||||
|
||||
getOrdersCart: (state: IProductsState) => (tipoord: number): IOrderCart[] | undefined => {
|
||||
console.log('state.orders', state.orders)
|
||||
getOrdersCart: (state: IProductsState) => (tipoord: number, hasGasordine: any): IOrderCart[] | undefined => {
|
||||
if (tipoord === shared_consts.OrderStat.IN_CORSO.value)
|
||||
return state.orders.filter((rec: IOrderCart) => (rec.status ? rec.status : 0) <= shared_consts.OrderStatus.CHECKOUT_SENT)
|
||||
return state.orders.filter((rec: IOrderCart) => ((rec.status ? rec.status : 0) <= shared_consts.OrderStatus.CHECKOUT_SENT)
|
||||
&& (hasGasordine ? rec.items?.some(item => item.order.idGasordine) : true))
|
||||
else if (tipoord === shared_consts.OrderStat.CONFERMATI.value)
|
||||
return state.orders.filter((rec: IOrderCart) => rec.status === shared_consts.OrderStatus.ORDER_CONFIRMED)
|
||||
return state.orders.filter((rec: IOrderCart) => (rec.status === shared_consts.OrderStatus.ORDER_CONFIRMED)
|
||||
&& (hasGasordine ? rec.items?.some(item => item.order.idGasordine) : true))
|
||||
else if (tipoord === shared_consts.OrderStat.PAGATI.value)
|
||||
return state.orders.filter((rec: IOrderCart) => rec.status === shared_consts.OrderStatus.PAYED)
|
||||
return state.orders.filter((rec: IOrderCart) => (rec.status === shared_consts.OrderStatus.PAYED)
|
||||
&& (hasGasordine ? rec.items?.some(item => item.order.idGasordine) : true))
|
||||
else if (tipoord === shared_consts.OrderStat.DELIVERED.value)
|
||||
return state.orders.filter((rec: IOrderCart) => rec.status === shared_consts.OrderStatus.DELIVERED)
|
||||
return state.orders.filter((rec: IOrderCart) => (rec.status === shared_consts.OrderStatus.DELIVERED)
|
||||
&& (hasGasordine ? rec.items?.some(item => item.order.idGasordine) : true))
|
||||
else if (tipoord === shared_consts.OrderStat.SHIPPED.value)
|
||||
return state.orders.filter((rec: IOrderCart) => rec.status === shared_consts.OrderStatus.SHIPPED)
|
||||
return state.orders.filter((rec: IOrderCart) => (rec.status === shared_consts.OrderStatus.SHIPPED)
|
||||
&& (hasGasordine ? rec.items?.some(item => item.order.idGasordine) : true))
|
||||
else if (tipoord === shared_consts.OrderStat.RECEIVED.value)
|
||||
return state.orders.filter((rec: IOrderCart) => rec.status === shared_consts.OrderStatus.RECEIVED)
|
||||
return state.orders.filter((rec: IOrderCart) => (rec.status === shared_consts.OrderStatus.RECEIVED)
|
||||
&& (hasGasordine ? rec.items?.some(item => item.order.idGasordine) : true))
|
||||
else if (tipoord === shared_consts.OrderStat.COMPLETATI.value)
|
||||
return state.orders.filter((rec: IOrderCart) => rec.status === shared_consts.OrderStatus.COMPLETED)
|
||||
return state.orders.filter((rec: IOrderCart) => (rec.status === shared_consts.OrderStatus.COMPLETED)
|
||||
&& (hasGasordine ? rec.items?.some(item => item.order.idGasordine) : true))
|
||||
else if (tipoord === shared_consts.OrderStat.CANCELLATI.value)
|
||||
return state.orders.filter((rec: IOrderCart) => rec.status === shared_consts.OrderStatus.CANCELED)
|
||||
return state.orders.filter((rec: IOrderCart) => (rec.status === shared_consts.OrderStatus.CANCELED)
|
||||
&& (hasGasordine ? rec.items?.some(item => item.order.idGasordine) : true))
|
||||
},
|
||||
|
||||
existProductInCart: (state: IProductsState) => (idproduct: string): boolean => {
|
||||
@@ -260,7 +267,7 @@ export const useProducts = defineStore('Products', {
|
||||
return ordercart.items!.some(item => {
|
||||
if (item.order)
|
||||
return (item.order.idProduct === idproduct)
|
||||
&& (item.order.status! < shared_consts.OrderStatus.CHECKOUT_SENT)
|
||||
&& (item.order.status! <= shared_consts.OrderStatus.CHECKOUT_SENT)
|
||||
})
|
||||
})
|
||||
// console.log('Ordini ', ris)
|
||||
@@ -326,6 +333,8 @@ export const useProducts = defineStore('Products', {
|
||||
quantity: order.quantity,
|
||||
quantitypreordered: order.quantitypreordered,
|
||||
idStorehouse: order.idStorehouse,
|
||||
idGasordine: order.idGasordine,
|
||||
//++Add Fields
|
||||
}
|
||||
|
||||
return myorder
|
||||
@@ -541,6 +550,13 @@ export const useProducts = defineStore('Products', {
|
||||
order.idStorehouse = globalStore.storehouses ? globalStore.storehouses[0]._id : ''
|
||||
}
|
||||
}
|
||||
if (!order.idGasordine && order.quantitypreordered > 0) {
|
||||
if (product.gasordines.length === 1) {
|
||||
order.idGasordine = product.gasordines[0]._id
|
||||
} else {
|
||||
order.idGasordine = globalStore.gasordines ? globalStore.gasordines[0]._id : ''
|
||||
}
|
||||
}
|
||||
|
||||
if (order.idStorehouse) {
|
||||
neworder = this.createOrderByProduct(product, order)
|
||||
@@ -856,6 +872,17 @@ export const useProducts = defineStore('Products', {
|
||||
return step
|
||||
},
|
||||
|
||||
getNumQtaGas() {
|
||||
const arrprod = this.getProducts(shared_consts.PROD.GAS)
|
||||
return arrprod.length
|
||||
},
|
||||
|
||||
getNumQtaBottega() {
|
||||
const arrprod = this.getProducts(shared_consts.PROD.BOTTEGA)
|
||||
return arrprod.length
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { defineComponent, onMounted, ref } from 'vue'
|
||||
import { defineComponent, onMounted, ref, watch } from 'vue'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useRouter } from 'vue-router'
|
||||
@@ -31,6 +31,15 @@ export default defineComponent({
|
||||
const myarrrec = ref(<any>{})
|
||||
const myoldrec = ref(<any>{})
|
||||
|
||||
const cosa = ref(0)
|
||||
|
||||
const initialPagination = ref({
|
||||
sortBy: 'desc',
|
||||
descending: false,
|
||||
rowsPerPage: 10,
|
||||
// rowsNumber: xx if getting data from a server
|
||||
})
|
||||
|
||||
const conferma_carrello = ref(false)
|
||||
const conferma_ordine = ref(false)
|
||||
const endload = ref(false)
|
||||
@@ -136,6 +145,10 @@ export default defineComponent({
|
||||
}
|
||||
])
|
||||
|
||||
watch(() => cosa.value, (newval, oldval) => {
|
||||
|
||||
})
|
||||
|
||||
// const { setValDb, getValDb } = MixinBase()
|
||||
|
||||
function getCols(props: any) {
|
||||
@@ -143,8 +156,10 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function getOrdersCart(): IOrderCart[] | undefined {
|
||||
const ris = productStore.getOrdersCart(taborders.value)
|
||||
// console.log(ris)
|
||||
const hasGasordine: any = (cosa.value === shared_consts.PROD.TUTTI) ? undefined : (cosa.value === shared_consts.PROD.GAS)
|
||||
console.log('hasgas', hasGasordine)
|
||||
const ris = productStore.getOrdersCart(taborders.value, hasGasordine)
|
||||
|
||||
return ris
|
||||
}
|
||||
|
||||
@@ -314,6 +329,8 @@ export default defineComponent({
|
||||
getOrdersCartWithTotals,
|
||||
productStore,
|
||||
t,
|
||||
initialPagination,
|
||||
cosa,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -2,6 +2,56 @@
|
||||
<q-page>
|
||||
<CTitleBanner title="Ordini"></CTitleBanner>
|
||||
<q-spinner v-if="!endload" color="primary" size="3em" :thickness="2" />
|
||||
|
||||
<div class="q-gutter-md text-center">
|
||||
<q-btn-toggle
|
||||
v-model="cosa"
|
||||
push
|
||||
rounded
|
||||
glossy
|
||||
toggle-color="purple"
|
||||
:options="[
|
||||
{ value: shared_consts.PROD.TUTTI, slot: 'tutti' },
|
||||
{ value: shared_consts.PROD.BOTTEGA, slot: 'bottega' },
|
||||
{ value: shared_consts.PROD.GAS, slot: 'gas' },
|
||||
]"
|
||||
>
|
||||
<template v-slot:tutti>
|
||||
<div class="row items-center no-wrap">
|
||||
<div class="text-center">
|
||||
{{ t('gas.tutti') }}
|
||||
<br />
|
||||
{{ t('gas.x_prodotti_gas', { qta: productStore.getNumQtaGas()+productStore.getNumQtaBottega() }) }}
|
||||
</div>
|
||||
<q-icon right name="fas fa-user-friends" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-slot:gas>
|
||||
<div class="row items-center no-wrap">
|
||||
<div class="text-center">
|
||||
{{ t('gas.ordina_sul_gas') }}
|
||||
<br />
|
||||
{{ t('gas.x_prodotti_gas', { qta: productStore.getNumQtaGas() }) }}
|
||||
</div>
|
||||
<q-icon right name="fas fa-user-friends" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-slot:bottega>
|
||||
<div class="row items-center no-wrap">
|
||||
<div class="text-center">
|
||||
{{ t('gas.bottega') }}
|
||||
<br />
|
||||
{{
|
||||
t('gas.x_prodotti_bottega', { qta: productStore.getNumQtaBottega() })
|
||||
}}
|
||||
</div>
|
||||
<q-icon right name="fas fa-store" />
|
||||
</div>
|
||||
</template>
|
||||
</q-btn-toggle>
|
||||
</div>
|
||||
˚
|
||||
<div v-if="endload" class="panel">
|
||||
<q-tabs v-model="taborders" inline-label class="text-blue">
|
||||
<span v-for="(stat, index) of shared_consts.OrderStat" :key="index">
|
||||
@@ -21,6 +71,7 @@
|
||||
:hide-header="$q.screen.lt.sm"
|
||||
:columns="columns"
|
||||
row-key="numorder"
|
||||
:pagination="initialPagination"
|
||||
:rows="getOrdersCartWithTotals()"
|
||||
>
|
||||
<template v-if="$q.screen.lt.sm" v-slot:item="props">
|
||||
|
||||
@@ -84,16 +84,6 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
|
||||
function getNumQtaGas() {
|
||||
const arrprod = productStore.getProducts(shared_consts.PROD.GAS)
|
||||
return arrprod.length
|
||||
}
|
||||
|
||||
function getNumQtaBottega() {
|
||||
const arrprod = productStore.getProducts(shared_consts.PROD.BOTTEGA)
|
||||
return arrprod.length
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
@@ -105,8 +95,6 @@ export default defineComponent({
|
||||
search,
|
||||
cosa,
|
||||
shared_consts,
|
||||
getNumQtaGas,
|
||||
getNumQtaBottega,
|
||||
getCatProds,
|
||||
cat,
|
||||
productStore,
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<div class="text-center">
|
||||
{{ t('gas.ordina_sul_gas') }}
|
||||
<br />
|
||||
{{ t('gas.x_prodotti_gas', { qta: getNumQtaGas() }) }}
|
||||
{{ t('gas.x_prodotti_gas', { qta: productStore.getNumQtaGas() }) }}
|
||||
</div>
|
||||
<q-icon right name="fas fa-user-friends" />
|
||||
</div>
|
||||
@@ -32,7 +32,7 @@
|
||||
{{ t('gas.bottega') }}
|
||||
<br />
|
||||
{{
|
||||
t('gas.x_prodotti_bottega', { qta: getNumQtaBottega() })
|
||||
t('gas.x_prodotti_bottega', { qta: productStore.getNumQtaBottega() })
|
||||
}}
|
||||
</div>
|
||||
<q-icon right name="fas fa-store" />
|
||||
|
||||
Reference in New Issue
Block a user