- aggiornamento con proj RISO. postcss, pwa.
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import type { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd, IText, IOptCatalogo, ICatPrTotali } from 'model';
|
||||
import { ICatalog } from 'model'
|
||||
import { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd, IText, IOptCatalogo, ICatalog, ICatPrTotali, ISingleProductOrdered, ISchedaSingola, IMyScheda } from 'model'
|
||||
|
||||
import { Api } from '@api'
|
||||
import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||
import * as Types from '@src/store/Api/ApiTypes'
|
||||
import { static_data } from '@src/db/static_data'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
import { tools } from '@tools'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { defineStore } from 'pinia'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { toolsext } from '@store/Modules/toolsext'
|
||||
@@ -120,7 +119,7 @@ export const useProducts = defineStore('Products', {
|
||||
getCatProds: (state: IProductsState) => (cosa: number): ICatProd[] => {
|
||||
if (cosa === shared_consts.PROD.GAS)
|
||||
return state.catprods_gas
|
||||
else if (cosa === shared_consts.PROD.BOTTEGA)
|
||||
else if (cosa === shared_consts.PROD.GAS)
|
||||
return state.catprods
|
||||
else
|
||||
return [...state.catprods, ...state.catprods_gas]
|
||||
@@ -163,6 +162,42 @@ export const useProducts = defineStore('Products', {
|
||||
return mystr
|
||||
},
|
||||
|
||||
getSubCatProdsStrBySubCatProds: (state: IProductsState) => (idSubCatProds: string[]): string => {
|
||||
let mystr = '';
|
||||
if (Array.isArray(idSubCatProds) && idSubCatProds.length > 0) {
|
||||
const names = idSubCatProds.map(id => {
|
||||
const subCatProd = state.subcatprods.find((rec: ISubCatProd) => rec._id === id);
|
||||
return subCatProd ? subCatProd.name : '';
|
||||
}).filter(name => name !== '');
|
||||
|
||||
mystr = names.join(' - ');
|
||||
}
|
||||
return mystr;
|
||||
},
|
||||
|
||||
getTotaleOrdineByOrdId: (state: IProductsState) => (idOrdine: string, idGasordine: string, mostra_solo_ordini_produttore: boolean): number => {
|
||||
|
||||
const arrprod = state.orders.filter((rec: IOrderCart) => {
|
||||
if (idGasordine && !rec.items?.some(item => item.order && item.order.idGasordine === idGasordine) || (rec._id !== idOrdine)) {
|
||||
return false; // Skip records not matching gasordine condition
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
let subtotalPrice = 0
|
||||
|
||||
arrprod.forEach((rec: IOrderCart) => {
|
||||
rec.items?.forEach(item => {
|
||||
if (item.order && ((mostra_solo_ordini_produttore && (item.order.idGasordine === idGasordine)) || !mostra_solo_ordini_produttore)) {
|
||||
const qtyparz = item.order.quantity + item.order.quantitypreordered
|
||||
subtotalPrice += item.order.price * qtyparz
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return subtotalPrice;
|
||||
},
|
||||
|
||||
getCatProdDescrStrByIdCatProd: (state: IProductsState) => (idCatProd: string): string => {
|
||||
const myfirstcat = state.catprods.find((rec: ICatProd) => rec._id === idCatProd)
|
||||
|
||||
@@ -180,6 +215,7 @@ export const useProducts = defineStore('Products', {
|
||||
return 0
|
||||
},
|
||||
|
||||
|
||||
getSubCatProdsByGas: (state: IProductsState) => (idGasOrdine: string, idCatProd: string): ISubCatProd[] => {
|
||||
let arrcat = state.subcatprods
|
||||
|
||||
@@ -469,7 +505,7 @@ export const useProducts = defineStore('Products', {
|
||||
const userStore = useUserStore()
|
||||
const myorder: IOrder = {
|
||||
userId: this.userActive._id,
|
||||
idapp: tools.getEnv('VITE_APP_ID'),
|
||||
idapp: import.meta.env.VITE_APP_ID,
|
||||
status: shared_consts.OrderStatus.IN_CART,
|
||||
TotalPriceProduct: 0,
|
||||
TotalPriceProductCalc: 0,
|
||||
@@ -563,9 +599,6 @@ export const useProducts = defineStore('Products', {
|
||||
this.orders = []
|
||||
}
|
||||
|
||||
if (import.meta.env.VITE_DEBUG === '1') {
|
||||
}
|
||||
|
||||
return res
|
||||
})
|
||||
.catch((error) => {
|
||||
@@ -1049,7 +1082,7 @@ export const useProducts = defineStore('Products', {
|
||||
mystr += ' + '
|
||||
}
|
||||
if (order.quantitypreordered > 0) {
|
||||
mystr += ' ' + order.quantitypreordered + ' ' + $t('ecomm.preord');
|
||||
mystr += ' ' + order.quantitypreordered + ' ';
|
||||
}
|
||||
return mystr
|
||||
},
|
||||
@@ -1249,6 +1282,14 @@ export const useProducts = defineStore('Products', {
|
||||
return mystr
|
||||
},
|
||||
|
||||
getGasordineNameById(idGasordine: string) {
|
||||
|
||||
const globalStore = useGlobalStore()
|
||||
const rec = globalStore.gasordines.find((gasordine: IGasordine) => gasordine._id === idGasordine)
|
||||
return rec ? rec.name : ''
|
||||
|
||||
},
|
||||
|
||||
getGasordines() {
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
@@ -1258,16 +1299,22 @@ export const useProducts = defineStore('Products', {
|
||||
value: ''
|
||||
}]
|
||||
let ind = 1
|
||||
globalStore.gasordines.forEach((gasordine: IGasordine) => {
|
||||
myarr.push(
|
||||
{
|
||||
id: ind,
|
||||
label: gasordine.name,
|
||||
value: gasordine._id
|
||||
})
|
||||
|
||||
ind++
|
||||
})
|
||||
if (globalStore.gasordines) {
|
||||
globalStore.gasordines.forEach((gasordine: IGasordine) => {
|
||||
if (gasordine) {
|
||||
myarr.push(
|
||||
{
|
||||
id: ind,
|
||||
label: gasordine.name
|
||||
+ (gasordine.dataora_chiusura_ordini ? (' - chiusura: ' + tools.getstrDateShort(gasordine.dataora_chiusura_ordini)) : '')
|
||||
+ (gasordine.dataora_ritiro ? (' - consegna ' + tools.getstrDateShort(gasordine.dataora_ritiro)) : '')
|
||||
,
|
||||
value: gasordine._id
|
||||
})
|
||||
ind++
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return myarr
|
||||
},
|
||||
@@ -1419,6 +1466,82 @@ export const useProducts = defineStore('Products', {
|
||||
return result.trim()
|
||||
},
|
||||
|
||||
getSubCatStrByProduct(myproductInfo: IProductInfo): string {
|
||||
return this.getSubCatProdsStrBySubCatProds(myproductInfo.idSubCatProds || [])
|
||||
},
|
||||
|
||||
getListProductBySumQuantity(idGasordine: string): ISingleProductOrdered[] {
|
||||
|
||||
const arrprod = this.orders.filter((rec: IOrderCart) => {
|
||||
if (idGasordine && !rec.items?.some(item => item.order && item.order.idGasordine === idGasordine)) {
|
||||
return false; // Skip records not matching gasordine condition
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
const productMap = new Map<string, ISingleProductOrdered>();
|
||||
|
||||
arrprod.forEach((rec: IOrderCart) => {
|
||||
rec.items?.forEach(item => {
|
||||
if (item.order && item.order.idGasordine === idGasordine) {
|
||||
const productId: string = item.order.idProduct!;
|
||||
const qtyparz = item.order.quantity + item.order.quantitypreordered
|
||||
if (productMap.has(productId)) {
|
||||
const existingProduct: ISingleProductOrdered = productMap.get(productId)!
|
||||
existingProduct.qty += qtyparz
|
||||
existingProduct.subtotalPrice += item.order.price * qtyparz
|
||||
existingProduct.subtotalPrice = Number((existingProduct.subtotalPrice).toFixed(2))
|
||||
} else {
|
||||
|
||||
const sottocategoria = item.order.product?.productInfo.subcatprods && item.order.product?.productInfo.subcatprods.length > 0 ? item.order.product?.productInfo.subcatprods[0].name! : ''
|
||||
productMap.set(productId, {
|
||||
subCat: sottocategoria,
|
||||
strSubCatProds: this.getSubCatProdsStrBySubCatProds(item.order.product?.productInfo.idSubCatProds!),
|
||||
index: productMap.size + 1,
|
||||
idProduct: productId,
|
||||
code: item.order.product?.productInfo.code!,
|
||||
codice_interno: item.order.product?.productInfo.codice!,
|
||||
qty: qtyparz,
|
||||
singlePrice: item.order.price,
|
||||
subtotalPrice: Number((item.order.price * qtyparz).toFixed(2)),
|
||||
productName: item.order.product?.productInfo.name!,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return Array.from(productMap.values());
|
||||
|
||||
},
|
||||
|
||||
getSchedeOpt(arrschede: IMyScheda[]): any[] {
|
||||
|
||||
let arr: any = []
|
||||
|
||||
arr.push({ label: '[Nessuna]', value: '' })
|
||||
|
||||
if (arrschede) {
|
||||
arrschede.forEach((recscheda: ISchedaSingola) => {
|
||||
let pagename = ''
|
||||
if (recscheda.scheda) {
|
||||
if (recscheda.idPageOrig) {
|
||||
const page = this.mypage.find((page) => (`${page._id}`) === recscheda.idPageOrig)
|
||||
pagename = page ? page.title! : ''
|
||||
}
|
||||
if (pagename)
|
||||
pagename = '[Pag: ' + pagename + '] '
|
||||
|
||||
const mylabel = pagename + (recscheda.scheda ? recscheda.scheda!.name : '')
|
||||
arr.push({ label: mylabel, value: recscheda.scheda!._id })
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return arr
|
||||
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user