Corretto incongruenze OrdersCart

This commit is contained in:
Surya Paolo
2023-12-21 01:34:39 +01:00
parent 9104a1eceb
commit 31014b21c0
7 changed files with 198 additions and 81 deletions

View File

@@ -10,7 +10,7 @@ import { CCopyBtn } from '../CCopyBtn'
import { func_tools, toolsext } from '@store/Modules/toolsext'
import { IOrder, IOrderCart, IProduct } from '@src/model'
import { IBaseOrder, IOrder, IOrderCart, IProduct } from '@src/model'
import { tools } from '@store/Modules/tools'
import { useProducts } from '@store/Products'
@@ -43,11 +43,15 @@ export default defineComponent({
const globalStore = useGlobalStore()
const products = useProducts()
const listord = ref(<IOrderCart[]>[])
const sumval = ref(0)
const site = ref(globalStore.site)
const myorder = reactive(<IOrder>{
idapp: process.env.APP_ID,
quantity: 0,
quantitypreordered: 0,
idStorehouse: '',
idProvider: ''
})
@@ -87,7 +91,11 @@ export default defineComponent({
return false
}
await products.addtoCartBase({ $q, t, code: myproduct.value.code!, order: myorder, addqty: add })
const ris = await products.addtoCartBase({ $q, t, code: myproduct.value.code!, order: myorder, addqty: add })
updateproduct()
if (ris && ris.myord) {
}
}
function getnumstore() {
@@ -214,16 +222,36 @@ export default defineComponent({
function enableAddQty() {
if (site.value.ecomm && site.value.ecomm.enablePreOrders) {
return true
return getQtyBookableAvailable() > 0 || getQtyAvailable() > 0
} else {
return getQtyAvailable() > 0
}
}
function visuListDisponibili() {
openlistorders.value = true
sumval.value = products.getSumQtyOrderProductInOrdersCart(myproduct.value._id)
listord.value = arrordersCart.value.filter((ordercart: IOrderCart) => ordercart.items!.reduce((accumulator, item) => {
return accumulator + item.order.quantity
}, 0))
}
function visuListBookable() {
openlistorders.value = true
sumval.value = products.getSumQtyPreOrderInOrdersCart(myproduct.value._id)
listord.value = arrordersCart.value.filter((ordercart: IOrderCart) => ordercart.items!.reduce((accumulator, item) => {
return accumulator + item.order.quantitypreordered
}, 0))
}
onMounted(load)
return {
visuListDisponibili,
visuListBookable,
addtoCart,
iconWhishlist,
getmycardcl,
@@ -251,6 +279,8 @@ export default defineComponent({
site,
getQtyWarnPreOrdered,
getQtyBookableAvailable,
listord,
sumval,
}
}
})

View File

@@ -109,12 +109,12 @@
<q-list>
<q-item
:clickable="tools.isManager()"
@click="tools.isManager() ? (openlistorders = true) : null"
@click="tools.isManager() ? (visuListDisponibili()) : null"
>
<q-item-section avatar>
<q-icon
:color="getQtyAvailable() >= 0 ? 'green' : 'blue'"
:name="getQtyAvailable() >= 0 ? 'fas fa-store' : 'fas fa-edit'"
color="green"
name="fas fa-store"
/>
</q-item-section>
@@ -146,9 +146,9 @@
</q-item-section>
</q-item>
<q-item
v-if="getQtyBookableAvailable() > 0"
v-if="getQtyBookableAvailable() > 0 || (myproduct.bookableQty > 0)"
:clickable="tools.isManager()"
@click="tools.isManager() ? (openlistorders = true) : null"
@click="tools.isManager() ? (visuListBookable()) : null"
>
<q-item-section avatar>
<q-icon color="blue" name="fas fa-edit" />
@@ -210,7 +210,6 @@
class="self-center no-outline"
tabindex="0"
>
Preord.: {{ myorder.quantitypreordered }}
</div>
</template>
</q-field>
@@ -298,7 +297,7 @@
<tbody>
<tr
v-for="(ordcart, index) of arrordersCart"
v-for="(ordcart, index) of listord"
:key="index"
class="listaev listaev__table"
>
@@ -347,7 +346,7 @@
<td class="text-center">
Totali:
<span class="totali">{{
products.getSumQtyOrderProductInOrdersCart(myproduct._id)
sumval
}}</span>
</td>
<td>&nbsp;</td>

View File

@@ -1,45 +1,89 @@
<template>
<div v-if="order && order.product" class="q-pa-xs q-gutter-xs">
<div v-if="order.product" class="row items-center justify-evenly no-wrap">
<div class="col-2 text-h6 ellipsis">
<q-img v-if="order.product && order.product.img" :src="`` + order.product.img" :alt="order.product.name"
:class="myimgclass">
<q-img
v-if="order.product && order.product.img"
:src="`` + order.product.img"
:alt="order.product.name"
:class="myimgclass"
>
</q-img>
</div>
<div class="col-4 q-ml-xs">
{{ order.product.name }}
<div v-if="showall">
<br><span class="text-grey">{{ order.product.description }}</span>
<br /><span class="text-grey">{{ order.product.description }}</span>
</div>
</div>
<div class="col-3">
<div class="row q-mb-xs no-wrap items-center centeritems">
<q-btn v-if="showall && !nomodif" round size="xs" text-color="grey" icon="fas fa-minus"
@click="addsubqty(false, true)"></q-btn>
<!--<q-field outlined dense style="width: 25px; height: 20px; " class="q-mx-xs text-subtitle4">
<template v-slot:control>
<div class="self-center no-outline" tabindex="0" >{{ order.quantity }}</div>
</template>
</q-field>-->
<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>
<q-btn
v-if="showall && !nomodif"
round
size="xs"
text-color="grey"
icon="fas fa-minus"
@click="addsubqty(false, true)"
></q-btn>
<div v-if="order.quantity > 0" :class="`q-mx-sm text-blue-14`">
{{ order.quantity }}
</div>
<div v-if="order.quantity > 0 && order.quantitypreordered > 0">
+ {{ $t('ecomm.preord') }}:
</div>
<div
v-if="order.quantitypreordered > 0"
:class="`q-mx-sm text-blue-14`"
>
{{ 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_short q-mr-sm">
<span :class="isApplicatoSconto() ? 'ordine_scontato_nuovo' : ''">&nbsp;{{ order.TotalPriceProduct ? order.TotalPriceProduct.toFixed(2) : 0 }}</span>
<span :class="isApplicatoSconto() ? 'ordine_scontato_nuovo' : ''"
>&nbsp;{{
order.TotalPriceProduct ? order.TotalPriceProduct.toFixed(2) : 0
}}</span
>
<span v-if="isApplicatoSconto()">
&nbsp;<span class="ordine_scontato">(<span class="barrato"> {{((order.price * order.quantity) + (order.price * order.quantitypreordered)).toFixed(2) }}</span>)</span>&nbsp;
&nbsp;<span class="ordine_scontato"
>(<span class="barrato"
>
{{
(
order.price * order.quantity +
order.price * order.quantitypreordered
).toFixed(2)
}}</span
>)</span
>&nbsp;
</span>
<span v-if="isApplicatoSconto()" class="ordine_scritta_sconto">{{ $t('ecomm.sconto_applicato', {risparmio: getRisparmio()}) }}</span>
<span v-if="isApplicatoSconto()" class="ordine_scritta_sconto">{{
$t('ecomm.sconto_applicato', { risparmio: getRisparmio() })
}}</span>
</div>
<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"
>
</q-btn>
</div>
</div>
</div>
</template>