Risolto problema blocco
This commit is contained in:
@@ -118,10 +118,13 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getnumstore() {
|
function getnumstore() {
|
||||||
if (myproduct.value.storehouses)
|
if (myproduct.value) {
|
||||||
return myproduct.value.storehouses.length
|
if (myproduct.value.storehouses)
|
||||||
else
|
return myproduct.value.storehouses.length
|
||||||
return 0
|
else
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSingleStorehouse() {
|
function getSingleStorehouse() {
|
||||||
@@ -138,10 +141,13 @@ 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
|
||||||
myproduct.value.storehouses.forEach((store) => {
|
myproduct.value.storehouses.forEach((store) => {
|
||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,135 +101,140 @@
|
|||||||
|
|
||||||
<!--<q-rating v-model="myproduct.stars" :max="5" size="32px" readonly/>-->
|
<!--<q-rating v-model="myproduct.stars" :max="5" size="32px" readonly/>-->
|
||||||
|
|
||||||
<q-list>
|
<div>
|
||||||
<q-item
|
<q-list>
|
||||||
:clickable="tools.isManager()"
|
<q-item
|
||||||
@click="tools.isManager() ? (openlistorders = true) : null"
|
:clickable="tools.isManager()"
|
||||||
>
|
@click="tools.isManager() ? (openlistorders = true) : null"
|
||||||
<q-item-section avatar>
|
>
|
||||||
<q-icon
|
<q-item-section avatar>
|
||||||
:color="getQtyAvailable() >= 0 ? 'green' : 'blue'"
|
<q-icon
|
||||||
:name="getQtyAvailable() >= 0 ? 'fas fa-store' : 'fas fa-edit'"
|
:color="getQtyAvailable() >= 0 ? 'green' : 'blue'"
|
||||||
/>
|
:name="getQtyAvailable() >= 0 ? 'fas fa-store' : 'fas fa-edit'"
|
||||||
</q-item-section>
|
/>
|
||||||
|
</q-item-section>
|
||||||
|
|
||||||
<q-item-section>
|
<q-item-section>
|
||||||
<q-item-label>
|
<q-item-label>
|
||||||
<span v-if="getQtyAvailable() < 0">
|
|
||||||
{{ t('ecomm.preorders') }}
|
|
||||||
</span>
|
|
||||||
<span v-else>
|
|
||||||
{{ t('ecomm.available') }}
|
|
||||||
</span>
|
|
||||||
</q-item-label>
|
|
||||||
<q-item-label>
|
|
||||||
<span class="prod_disp">
|
|
||||||
<span v-if="getQtyAvailable() < 0">
|
<span v-if="getQtyAvailable() < 0">
|
||||||
{{ -getQtyAvailable() }}
|
{{ t('ecomm.preorders') }}
|
||||||
</span>
|
</span>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
{{ getQtyAvailable() }}
|
{{ t('ecomm.available') }}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</q-item-label>
|
||||||
<div class="prod_qtywarn">
|
<q-item-label>
|
||||||
{{ getQtyWarn() }}
|
<span class="prod_disp">
|
||||||
|
<span v-if="getQtyAvailable() < 0">
|
||||||
|
{{ -getQtyAvailable() }}
|
||||||
|
</span>
|
||||||
|
<span v-else>
|
||||||
|
{{ getQtyAvailable() }}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<div class="prod_qtywarn">
|
||||||
|
{{ getQtyWarn() }}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="
|
v-if="
|
||||||
tools.isManager() && myproduct.QuantitaOrdinateInAttesa && myproduct.QuantitaOrdinateInAttesa > 0
|
tools.isManager() &&
|
||||||
"
|
!!myproduct.QuantitaOrdinateInAttesa
|
||||||
>
|
"
|
||||||
{{
|
>
|
||||||
$t('ecomm.qta_in_attesa', {
|
{{
|
||||||
qty: myproduct.QuantitaOrdinateInAttesa,
|
$t('ecomm.qta_in_attesa', {
|
||||||
})
|
qty: myproduct.QuantitaOrdinateInAttesa,
|
||||||
}}
|
})
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</q-item-label>
|
||||||
|
<q-item-label> </q-item-label>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
<div class="row q-mb-sm no-wrap items-center centeritems">
|
||||||
|
<q-btn
|
||||||
|
icon="fas fa-cart-arrow-down"
|
||||||
|
:color="enableSubQty() ? 'negative' : 'grey'"
|
||||||
|
:disable="checkifCartDisable() || !enableSubQty()"
|
||||||
|
rounded
|
||||||
|
size="md"
|
||||||
|
:label="t('products.subcart', { qta: 1 })"
|
||||||
|
@click="addtoCart(false)"
|
||||||
|
>
|
||||||
|
</q-btn>
|
||||||
|
|
||||||
|
<q-field
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
style="width: 40px; height: 30px"
|
||||||
|
class="q-mx-xs"
|
||||||
|
>
|
||||||
|
<template v-slot:control>
|
||||||
|
<div class="self-center no-outline" tabindex="0">
|
||||||
|
{{ myorder.quantity }}
|
||||||
</div>
|
</div>
|
||||||
</q-item-label>
|
</template>
|
||||||
<q-item-label> </q-item-label>
|
</q-field>
|
||||||
</q-item-section>
|
|
||||||
</q-item>
|
|
||||||
</q-list>
|
|
||||||
<div class="row q-mb-sm no-wrap items-center centeritems">
|
|
||||||
<q-btn
|
|
||||||
icon="fas fa-cart-arrow-down"
|
|
||||||
:color="enableSubQty() ? 'negative' : 'grey'"
|
|
||||||
:disable="checkifCartDisable() || !enableSubQty()"
|
|
||||||
rounded
|
|
||||||
size="md"
|
|
||||||
:label="t('products.subcart', { qta: 1 })"
|
|
||||||
@click="addtoCart(false)"
|
|
||||||
>
|
|
||||||
</q-btn>
|
|
||||||
|
|
||||||
<q-field
|
<q-btn
|
||||||
outlined
|
icon-right="fas fa-cart-plus"
|
||||||
dense
|
color="positive"
|
||||||
style="width: 40px; height: 30px"
|
:disable="checkifCartDisable() || !enableAddQty()"
|
||||||
class="q-mx-xs"
|
rounded
|
||||||
>
|
size="md"
|
||||||
<template v-slot:control>
|
:label="t('products.addcart', { qta: 1 })"
|
||||||
<div class="self-center no-outline" tabindex="0">
|
@click="addtoCart(true)"
|
||||||
{{ myorder.quantity }}
|
>
|
||||||
|
</q-btn>
|
||||||
|
</div>
|
||||||
|
<div v-if="complete || getnumstore() > 1">
|
||||||
|
<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>
|
||||||
|
<div
|
||||||
|
class="text-green-6 text-title row items-center q-my-sm centeritems"
|
||||||
|
>
|
||||||
|
<div v-if="getnumstore() > 1">
|
||||||
|
<q-select
|
||||||
|
:behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
|
||||||
|
outlined
|
||||||
|
v-model="storeSelected"
|
||||||
|
:options="getStorehouses()"
|
||||||
|
:label="t('products.magazzino') + `:`"
|
||||||
|
emit-value
|
||||||
|
map-options
|
||||||
|
>
|
||||||
|
</q-select>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<span class="text-title text-center">{{
|
||||||
|
getSingleStorehouse()
|
||||||
|
}}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
|
||||||
</q-field>
|
|
||||||
|
|
||||||
<q-btn
|
|
||||||
icon-right="fas fa-cart-plus"
|
|
||||||
color="positive"
|
|
||||||
:disable="checkifCartDisable() || !enableAddQty()"
|
|
||||||
rounded
|
|
||||||
size="md"
|
|
||||||
:label="t('products.addcart', { qta: 1 })"
|
|
||||||
@click="addtoCart(true)"
|
|
||||||
>
|
|
||||||
</q-btn>
|
|
||||||
</div>
|
|
||||||
<div v-if="complete || getnumstore() > 1">
|
|
||||||
<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>
|
|
||||||
<div
|
|
||||||
class="text-green-6 text-title row items-center q-my-sm centeritems"
|
|
||||||
>
|
|
||||||
<div v-if="getnumstore() > 1">
|
|
||||||
<q-select
|
|
||||||
:behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
|
|
||||||
outlined
|
|
||||||
v-model="storeSelected"
|
|
||||||
:options="getStorehouses()"
|
|
||||||
:label="t('products.magazzino') + `:`"
|
|
||||||
emit-value
|
|
||||||
map-options
|
|
||||||
>
|
|
||||||
</q-select>
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
<span class="text-title text-center">{{
|
|
||||||
getSingleStorehouse()
|
|
||||||
}}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<q-card-actions vertical align="center">
|
<q-card-actions vertical align="center">
|
||||||
<q-btn
|
<q-btn
|
||||||
v-if="myorder.quantity > 0"
|
v-if="myorder.quantity > 0"
|
||||||
rounded
|
rounded
|
||||||
icon="fas fa-shopping-cart"
|
icon="fas fa-shopping-cart"
|
||||||
color="primary"
|
color="primary"
|
||||||
:label="$t('ecomm.btn_cassa')"
|
:label="$t('ecomm.btn_cassa')"
|
||||||
class="q-mb-sm"
|
class="q-mb-sm"
|
||||||
to="/checkout"
|
to="/checkout"
|
||||||
></q-btn>
|
></q-btn>
|
||||||
<!--
|
<!--
|
||||||
<q-btn :icon="iconWhishlist(myproduct)" flat color="primary" rounded label="Lista Desideri">
|
<q-btn :icon="iconWhishlist(myproduct)" flat color="primary" rounded label="Lista Desideri">
|
||||||
</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">
|
||||||
|
|||||||
@@ -14,3 +14,8 @@
|
|||||||
height: 50px;
|
height: 50px;
|
||||||
width: 50px;
|
width: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ordine_scontato_barrato{
|
||||||
|
text-decoration: line-through;
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
@@ -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,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -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">
|
||||||
€ {{ (order.price * order.quantity) ? (order.price * order.quantity).toFixed(2) : 0 }}
|
<div v-if="isApplicatoSconto()">
|
||||||
|
<span class="ordine_scontato_barrato">€ {{ (order.price * order.quantity).toFixed(2) }}</span>
|
||||||
|
</div>
|
||||||
|
€ {{ 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">
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user