- Aggiunto bottone Aggiungi al Carrello sulla lista dei libri dei cataloghi

This commit is contained in:
Surya Paolo
2025-06-06 00:07:47 +02:00
parent 06fe6eb861
commit 664975b1fd
36 changed files with 1110 additions and 751 deletions

View File

@@ -36,7 +36,7 @@ import { defineStore } from 'pinia';
import { useUserStore } from '@store/UserStore';
import { toolsext } from '@store/Modules/toolsext';
import { useGlobalStore } from './globalStore';
import { ref } from 'vue';
import { ref, reactive } from 'vue';
import objectId from '@src/js/objectId';
import { costanti } from '@costanti';
@@ -1109,7 +1109,7 @@ export const useProducts = defineStore('Products', {
ris = await Api.SendReq('/products/id/' + id, 'GET', null)
.then((res) => {
console.log('product', res.data.product);
// console.log('product', res.data.product);
if (res.data.product) {
// console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
this.updateDataProduct(res);
@@ -1242,8 +1242,8 @@ export const useProducts = defineStore('Products', {
if (res && res.msgerr) {
return res;
} else if (res && res.risult) {
order.quantity = res.myord.quantity;
order.quantitypreordered = res.myord.quantitypreordered;
order.quantity = res?.myord?.quantity;
order.quantitypreordered = res?.myord?.quantitypreordered;
}
return res;
});
@@ -1672,7 +1672,7 @@ export const useProducts = defineStore('Products', {
},
qtaNextAdd(myorder: IOrder, myproduct: IProduct): number {
let step = myproduct.minStepQty;
let step = myproduct.minStepQty || 1;
if (this.getQtyAvailable(myproduct) > 0) {
if (myorder.quantity === 0) step = myproduct.minBuyQty;
} else {
@@ -2557,5 +2557,52 @@ export const useProducts = defineStore('Products', {
return '';
}
},
createMyOrder() {
let myorder = reactive(<IOrder>{
idapp: tools.getEnv('VITE_APP_ID'),
quantity: 0,
quantitypreordered: 0,
idStorehouse: '',
idGasordine: '',
storehouse: {},
gasordine: { active: false },
});
return myorder;
},
initproduct(myorder: IOrder) {
myorder.quantity = 0;
myorder.quantitypreordered = 0;
myorder.idStorehouse = '';
myorder.idGasordine = '';
},
setMyOrder(myorder: IOrder, myproduct: IProduct, storeSelected: any = null, options: any = {setstore: false}) {
if (myproduct.storehouses && myproduct.storehouses.length === 1) {
// Se solo 1 presente, metto fisso l'unico negozio !
myorder.idStorehouse = myproduct.storehouses[0]._id;
} else if (myproduct.storehouse) {
myorder.idStorehouse = myproduct.storehouse._id;
}
if (myproduct.gasordine) {
myorder.idGasordine = myproduct.gasordine._id;
}
const ord = this.getOrderProductInCart(myproduct._id);
if (ord) {
myorder.quantity = ord.quantity;
myorder.quantitypreordered = ord.quantitypreordered;
// Seleziona il Negozio che avevo già scelto nell'ordine !
if (options.setstore && ord.idStorehouse) {
storeSelected = ord.idStorehouse;
}
}
}
},
});