Risolto problema blocco

This commit is contained in:
Surya Paolo
2023-12-18 08:02:35 +01:00
parent c2af144c05
commit 265c8f4d9e
7 changed files with 160 additions and 132 deletions

View File

@@ -118,11 +118,14 @@ export default defineComponent({
}
function getnumstore() {
if (myproduct.value) {
if (myproduct.value.storehouses)
return myproduct.value.storehouses.length
else
return 0
}
return 0
}
function getSingleStorehouse() {
try {
@@ -138,9 +141,12 @@ export default defineComponent({
function updateproduct() {
myproduct.value = products.getProduct(props.code)
products.updateQuantityAvailable(myproduct.value._id)
}
function getStorehouses() {
if (!myproduct.value)
return []
const myarr: any = []
let ind = 1
@@ -165,7 +171,6 @@ export default defineComponent({
}
function getQtyAvailable() {
products.updateQuantityAvailable(myproduct.value._id)
let qty = myproduct.value.quantityAvailable!
return qty
}
@@ -188,7 +193,7 @@ export default defineComponent({
function load() {
updateproduct()
console.log('Load', myproduct.value.name)
// console.log('Load', myproduct.value.name)
// console.log('created Cproductcard', code)
arrordersCart.value = products.getOrdersCartByIdProduct(myproduct.value._id)
@@ -204,7 +209,7 @@ export default defineComponent({
}
}
console.log('°°° ENDLOAD °°°')
// console.log('°°° ENDLOAD °°°')
endload.value = true
}

View File

@@ -51,7 +51,7 @@
myproduct.after_price
}}</span>
</q-item-label>
<!--<q-item-label v-if="myproduct.scontisticas && myproduct.scontisticas.length > 0">
<q-item-label v-if="myproduct.scontisticas && myproduct.scontisticas.length > 0">
<div
class="prod_sconti"
v-for="(sconti, index) of myproduct.scontisticas"
@@ -60,11 +60,11 @@
{{ sconti.description }}
</div>
</q-item-label>
-->
</q-item-section>
</q-item>
</q-list>
<div>
<div v-if="true">
<div v-if="complete && myproduct.producer && myproduct.producer.city">
<div class="text-grey text-title row items-center q-mt-sm">
<q-icon name="map" class="q-mr-xs" />
@@ -92,8 +92,7 @@
>
<q-icon name="fas fa-balance-scale" class="q-mr-xs" />
{{ t('products.weight') }}:
<span class="text-black q-ml-xs text-h8"
v-if="myproduct.unit">
<span class="text-black q-ml-xs text-h8" v-if="myproduct.unit">
{{ myproduct.weight }}
{{ tools.getUnitsMeasure(myproduct.unit, true) }}</span
>
@@ -102,6 +101,7 @@
<!--<q-rating v-model="myproduct.stars" :max="5" size="32px" readonly/>-->
<div>
<q-list>
<q-item
:clickable="tools.isManager()"
@@ -137,7 +137,8 @@
<div
v-if="
tools.isManager() && myproduct.QuantitaOrdinateInAttesa && myproduct.QuantitaOrdinateInAttesa > 0
tools.isManager() &&
!!myproduct.QuantitaOrdinateInAttesa
"
>
{{
@@ -189,7 +190,9 @@
</q-btn>
</div>
<div v-if="complete || getnumstore() > 1">
<div class="text-blue text-title row items-center q-mr-md centeritems">
<div
class="text-blue text-title row items-center q-mr-md centeritems"
>
<q-icon size="sm" name="fas fa-shipping-fast" class="q-mr-sm" />
{{ t('products.ritiro_presso') }}:
</div>
@@ -231,6 +234,7 @@
</q-btn>
-->
</q-card-actions>
</div>
</q-card>
<q-dialog v-model="openlistorders">
<q-card class="dialog_card">

View File

@@ -14,3 +14,8 @@
height: 50px;
width: 50px;
}
.ordine_scontato_barrato{
text-decoration: line-through;
color: gray;
}

View File

@@ -61,6 +61,14 @@ export default defineComponent({
})
}
function isApplicatoSconto() {
const totalipotetico = order.value.price! * order.value.quantity
if (totalipotetico > order.value.TotalPriceProduct!) {
return true
}
return false
}
function removeFromCard() {
products.removeFromCart({ order: order.value })
}
@@ -69,6 +77,7 @@ export default defineComponent({
myimgclass,
addsubqty,
removeFromCard,
isApplicatoSconto,
}
},
})

View File

@@ -28,7 +28,10 @@
</div>
</div>
<div class="col-2 no-wrap text-subtitle3 q-mr-sm">
&nbsp;{{ (order.price * order.quantity) ? (order.price * order.quantity).toFixed(2) : 0 }}
<div v-if="isApplicatoSconto()">
<span class="ordine_scontato_barrato">&nbsp; {{ (order.price * order.quantity).toFixed(2) }}</span>
</div>
&nbsp;{{ order.TotalPriceProduct ? order.TotalPriceProduct.toFixed(2) : 0 }}
</div>
<div class="col-1">
<q-btn v-if="!nomodif" icon="fas fa-times" color="negative" round size="xs" @click="removeFromCard">

View File

@@ -17,7 +17,7 @@ export interface IProduct {
description?: string,
department?: string,
category?: string,
price?: number,
price: number,
after_price?: string,
color?: string,
size?: string,
@@ -48,7 +48,8 @@ export interface IOrder {
idProvider?: string
idStorehouse?: string
idScontisticas?: string[]
price?: number
price: number
TotalPriceProduct: number
after_price?: string
color?: string
size?: string

View File

@@ -44,7 +44,7 @@ export const useProducts = defineStore('Products', {
getProduct: (state: IProductsState) => (code: string): IProduct => {
const prod = state.products.find((prod: IProduct) => prod.code === code)
return prod ? prod : { active: false, img: '', code: '', name: '', storehouses: [], scontisticas: [] }
return prod ? prod : { active: false, img: '', code: '', name: '', storehouses: [], scontisticas: [], price: 0 }
},
getCart: (state: IProductsState) => (): ICart => {
@@ -127,7 +127,7 @@ export const useProducts = defineStore('Products', {
},
getOrdersCartByIdProduct: (state: IProductsState) => (idproduct: string): IOrderCart[] | [] => {
console.log('getOrdersCartByIdProduct')
// console.log('getOrdersCartByIdProduct')
// console.log('.cart.items', this.cart.items)
try {
if (state.orders) {
@@ -137,7 +137,7 @@ export const useProducts = defineStore('Products', {
return item.order.idProduct === idproduct
})
})
console.log('Ordini ', ris)
// console.log('Ordini ', ris)
return ris ? ris : []
}
} catch (e) {
@@ -210,6 +210,7 @@ export const useProducts = defineStore('Products', {
idProduct: product._id,
idProducer: product.idProducer,
status: shared_consts.OrderStatus.IN_CART,
TotalPriceProduct: 0,
price: product.price,
after_price: product.after_price,
color: product.color,