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

View File

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

View File

@@ -14,3 +14,8 @@
height: 50px; height: 50px;
width: 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() { function removeFromCard() {
products.removeFromCart({ order: order.value }) products.removeFromCart({ order: order.value })
} }
@@ -69,6 +77,7 @@ export default defineComponent({
myimgclass, myimgclass,
addsubqty, addsubqty,
removeFromCard, removeFromCard,
isApplicatoSconto,
} }
}, },
}) })

View File

@@ -28,7 +28,10 @@
</div> </div>
</div> </div>
<div class="col-2 no-wrap text-subtitle3 q-mr-sm"> <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>
<div class="col-1"> <div class="col-1">
<q-btn v-if="!nomodif" icon="fas fa-times" color="negative" round size="xs" @click="removeFromCard"> <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, description?: string,
department?: string, department?: string,
category?: string, category?: string,
price?: number, price: number,
after_price?: string, after_price?: string,
color?: string, color?: string,
size?: string, size?: string,
@@ -48,7 +48,8 @@ export interface IOrder {
idProvider?: string idProvider?: string
idStorehouse?: string idStorehouse?: string
idScontisticas?: string[] idScontisticas?: string[]
price?: number price: number
TotalPriceProduct: number
after_price?: string after_price?: string
color?: string color?: string
size?: string size?: string

View File

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