- filtro se GAS o Prodotti
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user