Aggiornamento modifiche preOrdini

This commit is contained in:
Surya Paolo
2023-12-20 21:56:30 +01:00
parent 265c8f4d9e
commit 56b433dae3
13 changed files with 252 additions and 71 deletions

View File

@@ -18,6 +18,10 @@
font-size: 1.2rem;
}
.prod_preorder{
font-size: 1.2rem;
}
.prod_qtywarn{
padding-left: 10px;
font-size: 1rem;

View File

@@ -88,33 +88,39 @@ export default defineComponent({
}
products.addToCart({ product: myproduct.value, order: myorder, addqty: add }).then((ris) => {
let strprod = t('ecomm.prodotto')
if (myproduct.value) {
products.addToCart({ product: myproduct.value, order: myorder, addqty: add }).then((ris: any) => {
let strprod = t('ecomm.prodotto')
if (myorder.quantity > 1 || myorder.quantity === 0)
strprod = t('ecomm.prodotti')
let msg = ''
if (ris === null)
msg = t('ecomm.error_cart')
else {
if (myorder.quantity === 0) {
msg = t('ecomm.prodotto_tolto')
let msg = ''
console.log('ris', ris)
if (ris === null || ris.myord == null) {
msg = t('ecomm.error_cart')
tools.showNegativeNotif($q, msg)
return
} else {
msg = t('ecomm.prod_sul_carrello', { strprod, qty: myorder.quantity })
let qta = ris.myord.quantity + ris.myord.quantitypreordered
if (qta > 1 || qta === 0)
strprod = t('ecomm.prodotti')
if (qta === 0) {
msg = t('ecomm.prodotto_tolto')
} else {
msg = t('ecomm.prod_sul_carrello', { strprod, qty: qta })
}
}
}
updateproduct()
updateproduct()
if (ris === null || ris.myord.quantity === 0)
tools.showNotif($q, msg)
else
tools.showPositiveNotif($q, msg)
if (ris === null || myorder.quantity === 0)
tools.showNotif($q, msg)
else
tools.showPositiveNotif($q, msg)
})
})
}
}
function getnumstore() {
@@ -141,13 +147,13 @@ export default defineComponent({
function updateproduct() {
myproduct.value = products.getProduct(props.code)
products.updateQuantityAvailable(myproduct.value._id)
// products.updateQuantityAvailable(myproduct.value._id)
}
function getStorehouses() {
if (!myproduct.value)
return []
const myarr: any = []
let ind = 1
myproduct.value.storehouses.forEach((store) => {
@@ -175,6 +181,11 @@ export default defineComponent({
return qty
}
function getQtyBookableAvailable() {
let qty = myproduct.value.bookableAvailableQty!
return qty
}
function getQtyWarn() {
if (myorder.quantity > 0) {
return t('ecomm.di_cui_x_in_carrello', { qty: myorder.quantity })
@@ -182,6 +193,13 @@ export default defineComponent({
return ''
}
function getQtyWarnPreOrdered() {
if (myorder.quantitypreordered > 0) {
return t('ecomm.di_cui_x_in_carrello', { qty: myorder.quantitypreordered })
}
return ''
}
watch(() => props.code, (newval, oldval) => {
console.log('change code')
load()
@@ -206,6 +224,7 @@ export default defineComponent({
const ord = products.getOrderProductInCart(myproduct.value._id)
if (ord) {
myorder.quantity = ord.quantity
myorder.quantitypreordered = ord.quantitypreordered
}
}
@@ -222,7 +241,8 @@ export default defineComponent({
}
function enableSubQty() {
return myorder.quantity ? myorder.quantity > 0 : false
let qty = myorder.quantity + myorder.quantitypreordered
return qty ? qty > 0 : false
}
function enableAddQty() {
@@ -262,6 +282,8 @@ export default defineComponent({
endload,
shared_consts,
site,
getQtyWarnPreOrdered,
getQtyBookableAvailable,
}
}
})

View File

@@ -51,16 +51,17 @@
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"
class="prod_sconti"
v-for="(sconti, index) of myproduct.scontisticas"
:key="index"
>
{{ sconti.description }}
</div>
</div>
</q-item-label>
</q-item-section>
</q-item>
</q-list>
@@ -116,29 +117,18 @@
<q-item-section>
<q-item-label>
<span v-if="getQtyAvailable() < 0">
{{ t('ecomm.preorders') }}
</span>
<span v-else>
{{ t('ecomm.available') }}
</span>
{{ t('ecomm.available') }}
</q-item-label>
<q-item-label>
<span class="prod_disp">
<span v-if="getQtyAvailable() < 0">
{{ -getQtyAvailable() }}
</span>
<span v-else>
{{ getQtyAvailable() }}
</span>
{{ getQtyAvailable() }}
</span>
<div class="prod_qtywarn">
{{ getQtyWarn() }}
<div
v-if="
tools.isManager() &&
!!myproduct.QuantitaOrdinateInAttesa
tools.isManager() && !!myproduct.QuantitaOrdinateInAttesa
"
>
{{
@@ -152,6 +142,43 @@
<q-item-label> </q-item-label>
</q-item-section>
</q-item>
<q-item
v-if="getQtyBookableAvailable() > 0"
:clickable="tools.isManager()"
@click="tools.isManager() ? (openlistorders = true) : null"
>
<q-item-section avatar>
<q-icon color="blue" name="fas fa-edit" />
</q-item-section>
<q-item-section>
<q-item-label>
{{ t('ecomm.preorders') }}
</q-item-label>
<q-item-label>
<span class="prod_preorder">
{{ getQtyBookableAvailable() }}
</span>
<div class="prod_qtywarn">
<span v-if="getQtyWarnPreOrdered()">{{
getQtyWarnPreOrdered()
}}</span>
<div
v-if="
tools.isManager() && !!myproduct.QuantitaPrenotateInAttesa
"
>
{{
$t('ecomm.qta_prenotate_in_attesa', {
qty: myproduct.QuantitaPrenotateInAttesa,
})
}}
</div>
</div>
</q-item-label>
</q-item-section>
</q-item>
</q-list>
<div class="row q-mb-sm no-wrap items-center centeritems">
<q-btn
@@ -175,6 +202,13 @@
<div class="self-center no-outline" tabindex="0">
{{ myorder.quantity }}
</div>
<div
v-if="myorder.quantitypreordered"
class="self-center no-outline"
tabindex="0"
>
Preord.: {{ myorder.quantitypreordered }}
</div>
</template>
</q-field>
@@ -221,7 +255,7 @@
<q-card-actions vertical align="center">
<q-btn
v-if="myorder.quantity > 0"
v-if="myorder.quantity + myorder.quantitypreordered > 0"
rounded
icon="fas fa-shopping-cart"
color="primary"
@@ -282,9 +316,22 @@
</td>
<td class="text-center">
<div v-for="(singleord, index) in ordcart.items" :key="index">
<span v-if="singleord.order.idProduct === myproduct._id">{{
singleord.order.quantity
}}</span>
<span
v-if="
singleord.order.idProduct === myproduct._id &&
singleord.order.quantity > 0
"
>
{{ singleord.order.quantity }}</span
>
<span
v-if="
singleord.order.idProduct === myproduct._id &&
singleord.order.quantitypreordered > 0
"
>
{{ singleord.order.quantitypreordered }}</span
>
</div>
</td>
<td class="text-center">

View File

@@ -40,14 +40,29 @@ export default defineComponent({
}
function addsubqty(addqty: boolean, subqty: boolean) {
if (addqty) {
if (props.order.quantity >= 10)
return false
}
if (products.isQtyAvailableByOrder(props.order)) {
if (addqty) {
if (props.order.quantity >= 20)
return false
}
if (subqty) {
if (props.order.quantity === 0)
return false
if (subqty) {
if (props.order.quantity === 0)
return false
}
} else {
if (products.isInPreorderByOrder(props.order)) {
if (addqty) {
if (props.order.quantitypreordered >= 20)
return false
}
if (subqty) {
if (props.order.quantitypreordered === 0)
return false
}
}
}
products.addSubQtyToItem({
@@ -56,14 +71,15 @@ export default defineComponent({
order: props.order,
}).then((res: any) => {
if (res.risult) {
order.value.quantity = res.qty
order.value.quantity = res.myord.quantity
order.value.quantitypreordered = res.myord.quantitypreordered
}
})
}
function isApplicatoSconto() {
const totalipotetico = order.value.price! * order.value.quantity
if (totalipotetico > order.value.TotalPriceProduct!) {
const totalipotetico = order.value.price * (order.value.quantity + order.value.quantitypreordered)
if (totalipotetico > order.value.TotalPriceProduct) {
return true
}
return false

View File

@@ -22,14 +22,14 @@
<div class="self-center no-outline" tabindex="0" >{{ order.quantity }}</div>
</template>
</q-field>-->
<div :class="`q-mx-sm text-blue-14`">{{ order.quantity }}</div>
<div v-if="order.quantity > 0" :class="`q-mx-sm text-blue-14`">{{ order.quantity + order.quantitypreordered }}</div>
<q-btn v-if="showall && !nomodif" round size="xs" text-color="grey" icon="fas fa-plus"
@click="addsubqty(true, false)"></q-btn>
</div>
</div>
<div class="col-2 no-wrap text-subtitle3 q-mr-sm">
<div v-if="isApplicatoSconto()">
<span class="ordine_scontato_barrato">&nbsp; {{ (order.price * order.quantity).toFixed(2) }}</span>
<span class="ordine_scontato_barrato">&nbsp; {{ ((order.price * order.quantity) + (order.price * order.quantitypreordered)).toFixed(2) }}</span>
</div>
&nbsp;{{ order.TotalPriceProduct ? order.TotalPriceProduct.toFixed(2) : 0 }}
</div>