- edit campi prodotti
- edit ordini
This commit is contained in:
@@ -8259,18 +8259,18 @@ export const tools = {
|
||||
let unitrec = shared_consts.Units_Of_Measure_ListBox.find((rec: any) => rec.value === unit)
|
||||
let mystr = ''
|
||||
if (unitrec && unitrec.value === shared_consts.UNITS_OF_MEASURE.CHILI && weight && weight < 1) {
|
||||
unitrec = shared_consts.Units_Of_Measure_ListBox.find((rec: any) => rec.value === shared_consts.UNITS_OF_MEASURE.GRAMMI)
|
||||
unitrec = shared_consts.Units_Of_Measure_ListBox.find((rec: any) => rec.value === shared_consts.UNITS_OF_MEASURE.GRAMMI)
|
||||
}
|
||||
if (unitrec && unitrec.value === shared_consts.UNITS_OF_MEASURE.LITRI && weight && weight < 1) {
|
||||
unitrec = shared_consts.Units_Of_Measure_ListBox.find((rec: any) => rec.value === shared_consts.UNITS_OF_MEASURE.MILLILITRI)
|
||||
unitrec = shared_consts.Units_Of_Measure_ListBox.find((rec: any) => rec.value === shared_consts.UNITS_OF_MEASURE.MILLILITRI)
|
||||
}
|
||||
mystr = unitrec ? (short ? unitrec.short : unitrec.label) : ''
|
||||
mystr = unitrec ? (short ? unitrec.short : unitrec.label) : ''
|
||||
return mystr
|
||||
},
|
||||
|
||||
getWeightByUnit(unit: number, short: boolean, weight: number|undefined) {
|
||||
getWeightByUnit(unit: number, short: boolean, weight: number | undefined) {
|
||||
let unitrec = shared_consts.Units_Of_Measure_ListBox.find((rec: any) => rec.value === unit)
|
||||
if (unitrec && unitrec.value === shared_consts.UNITS_OF_MEASURE.CHILI && weight && weight < 1) {
|
||||
if (unitrec && unitrec.value === shared_consts.UNITS_OF_MEASURE.CHILI && weight && weight < 1) {
|
||||
return weight * 1000
|
||||
}
|
||||
if (unitrec && unitrec.value === shared_consts.UNITS_OF_MEASURE.LITRI && weight && weight < 1) {
|
||||
@@ -8323,18 +8323,22 @@ export const tools = {
|
||||
// Calculate the difference in milliseconds
|
||||
const countdown = targetTime - currentDate.getTime();
|
||||
|
||||
// Convert milliseconds to seconds
|
||||
const countdownInSeconds = Math.floor(countdown / 1000);
|
||||
if (countdown > 0) {
|
||||
// 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 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` : ''
|
||||
const gg = days > 0 ? 'giorni' : ''
|
||||
const strgg = gg ? `${days} giorni` : ''
|
||||
|
||||
return (`${strgg} ${this.pad(hours)}:${this.pad(minutes)}:${this.pad(seconds)}`);
|
||||
return (`${strgg} ${this.pad(hours)}:${this.pad(minutes)}:${this.pad(seconds)}`);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
@@ -303,8 +303,8 @@ export const useProducts = defineStore('Products', {
|
||||
getOrdersCartByIdProduct: (state: IProductsState) => (idproduct: string): IOrderCart[] | [] => {
|
||||
try {
|
||||
if (state.orders) {
|
||||
const ris = state.orders.filter((ordercart: IOrderCart) => {
|
||||
return ordercart.items!.some(item => {
|
||||
const ris = state.orders.filter((orderscart: IOrderCart) => {
|
||||
return orderscart.items!.some(item => {
|
||||
if (item.order)
|
||||
return (item.order.idProduct === idproduct)
|
||||
&& (item.order.status! < shared_consts.OrderStatus.CHECKOUT_SENT)
|
||||
@@ -322,8 +322,8 @@ export const useProducts = defineStore('Products', {
|
||||
getOrdersCartInAttesaByIdProduct: (state: IProductsState) => (idproduct: string): IOrderCart[] | [] => {
|
||||
try {
|
||||
if (state.orders) {
|
||||
const ris = state.orders.filter((ordercart: IOrderCart) => {
|
||||
return ordercart.items!.some(item => {
|
||||
const ris = state.orders.filter((orderscart: IOrderCart) => {
|
||||
return orderscart.items!.some(item => {
|
||||
if (item.order)
|
||||
return (item.order.idProduct === idproduct)
|
||||
&& (item.order.status! <= shared_consts.OrderStatus.CHECKOUT_SENT)
|
||||
@@ -435,24 +435,100 @@ export const useProducts = defineStore('Products', {
|
||||
return ris
|
||||
},
|
||||
|
||||
async loadProduct({ code }: { code: any }) {
|
||||
async updateOrderByOrder(idOrdersCart: string, idOrder: string, paramstoupdate: any) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
// console.log('loadProducts')
|
||||
|
||||
if (!globalStore.site.confpages.enableEcommerce)
|
||||
return null
|
||||
|
||||
console.log('updateOrderByOrder', 'userid=', userStore.my._id)
|
||||
|
||||
let ris = null
|
||||
|
||||
ris = await Api.SendReq('/orders/updateord', 'POST', { idOrdersCart, idOrder, paramstoupdate })
|
||||
.then((res) => {
|
||||
let myorderscart = res.data.orderscart
|
||||
if (res) {
|
||||
myorderscart = res.data && res.data.orderscart ? res.data.orderscart : null
|
||||
if (myorderscart) {
|
||||
const idord = this.orders.findIndex((ord: IOrderCart) => ord._id === myorderscart._id)
|
||||
if (idord >= 0) {
|
||||
console.log('aggiorna ordine')
|
||||
this.orders[idord] = {...myorderscart}
|
||||
}
|
||||
}
|
||||
}
|
||||
return myorderscart
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error updateOrderByOrder', error)
|
||||
userStore.setErrorCatch(error)
|
||||
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, error)
|
||||
})
|
||||
|
||||
// ApiTables.aftercalling(ris, checkPending, 'categories')
|
||||
|
||||
return ris
|
||||
},
|
||||
|
||||
async updateOrdersCartById(idOrdersCart: string, paramstoupdate: any) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
// console.log('loadProducts')
|
||||
|
||||
if (!globalStore.site.confpages.enableEcommerce)
|
||||
return null
|
||||
|
||||
console.log('updateOrdersCartById', 'userid=', userStore.my._id)
|
||||
|
||||
let ris = null
|
||||
|
||||
ris = await Api.SendReq('/orders/update', 'POST', { idOrdersCart, paramstoupdate })
|
||||
.then((res) => {
|
||||
let myorderscart = res.data.orderscart
|
||||
if (res) {
|
||||
if (myorderscart) {
|
||||
const idord = this.orders.findIndex((ord: IOrderCart) => ord._id === myorderscart._id)
|
||||
if (idord >= 0) {
|
||||
console.log('aggiorna orderscart')
|
||||
this.orders[idord] = myorderscart
|
||||
}
|
||||
}
|
||||
}
|
||||
return myorderscart
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error updateOrderByOrder', error)
|
||||
userStore.setErrorCatch(error)
|
||||
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, error)
|
||||
})
|
||||
|
||||
// ApiTables.aftercalling(ris, checkPending, 'categories')
|
||||
|
||||
return ris
|
||||
},
|
||||
|
||||
async loadProductById(id: string) {
|
||||
|
||||
console.log('loadProduct', code)
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
if (!globalStore.site.confpages.enableEcommerce)
|
||||
return null
|
||||
|
||||
console.log('getProduct', 'code', code)
|
||||
|
||||
// if (userStore.my._id === '') {
|
||||
// return new Types.AxiosError(0, null, 0, '')
|
||||
// }
|
||||
|
||||
let ris = null
|
||||
|
||||
ris = await Api.SendReq('/products/' + code, 'POST', { code })
|
||||
ris = await Api.SendReq('/products/id/' + id, 'GET', null)
|
||||
.then((res) => {
|
||||
console.log('product', res.data.product)
|
||||
if (res.data.product) { // console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
|
||||
|
||||
Reference in New Issue
Block a user