Carrello con scontistica aggiornata

This commit is contained in:
Surya Paolo
2023-12-18 12:11:22 +01:00
parent 265c8f4d9e
commit c1d60a7260
8 changed files with 41 additions and 13 deletions

View File

@@ -87,7 +87,6 @@ export default defineComponent({
return false return false
} }
products.addToCart({ product: myproduct.value, order: myorder, addqty: add }).then((ris) => { products.addToCart({ product: myproduct.value, order: myorder, addqty: add }).then((ris) => {
let strprod = t('ecomm.prodotto') let strprod = t('ecomm.prodotto')
@@ -226,7 +225,7 @@ export default defineComponent({
} }
function enableAddQty() { function enableAddQty() {
if (site.value.ecomm!.enablePreOrders) { if (site.value.ecomm && site.value.ecomm.enablePreOrders) {
return true return true
} else { } else {
return getQtyAvailable() > 0 return getQtyAvailable() > 0

View File

@@ -18,4 +18,13 @@
.ordine_scontato_barrato{ .ordine_scontato_barrato{
text-decoration: line-through; text-decoration: line-through;
color: gray; color: gray;
}
.ordine_scontato_nuovo{
font-size: 1.1rem;
font-weight: bold;
}
.ordine_scritta_sconto{
font-style: italic;
color: green;
font-weight: bold;
} }

View File

@@ -62,8 +62,8 @@ export default defineComponent({
} }
function isApplicatoSconto() { function isApplicatoSconto() {
const totalipotetico = order.value.price! * order.value.quantity const totalipotetico = order.value.price * order.value.quantity
if (totalipotetico > order.value.TotalPriceProduct!) { if (totalipotetico > order.value.TotalPriceProduct) {
return true return true
} }
return false return false

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class="q-pa-xs q-gutter-xs"> <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 v-if="order.product" class="row items-center justify-evenly no-wrap">
<div class="col-2 text-h6 ellipsis"> <div class="col-2 text-h6 ellipsis">
@@ -31,7 +31,8 @@
<div v-if="isApplicatoSconto()"> <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).toFixed(2) }}</span>
</div> </div>
&nbsp;{{ order.TotalPriceProduct ? order.TotalPriceProduct.toFixed(2) : 0 }} <span v-if="isApplicatoSconto()" class="ordine_scritta_sconto">{{ $t('ecomm.sconto_applicato') }}</span>
<span :class="isApplicatoSconto() ? 'ordine_scontato_nuovo' : ''">&nbsp;{{ order.TotalPriceProduct ? order.TotalPriceProduct.toFixed(2) : 0 }}</span>
</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

@@ -45,12 +45,11 @@ export default function () {
return '' return ''
} }
function getnumItemsCart(): any { function getnumItemsCart(): number {
const products = useProducts() const products = useProducts()
const arrcart = products.cart const arrcart = products.cart
if (!!arrcart) { if (!!arrcart) {
if (!!arrcart.items) { if (!!arrcart.items) {
// @ts-ignore
const total = arrcart.items.reduce((sum, item) => sum + item.order.quantity, 0) const total = arrcart.items.reduce((sum, item) => sum + item.order.quantity, 0)
return total return total
} }

View File

@@ -256,6 +256,9 @@ const msg_it = {
}, },
db: { db: {
recupdated: 'Record Aggiornato', recupdated: 'Record Aggiornato',
records_imported: '{num} Record Importati',
records_updated: '{num} Record Aggiornati',
records_errors: '{num} Record con Errori',
recfailed: 'Errore durante aggiornamento Record', recfailed: 'Errore durante aggiornamento Record',
reccanceled: 'Annullato Aggiornamento. Ripristinato valore precendente', reccanceled: 'Annullato Aggiornamento. Ripristinato valore precendente',
deleterecord: 'Elimina Record', deleterecord: 'Elimina Record',
@@ -1661,6 +1664,7 @@ const msg_it = {
carrello: 'Carrello', carrello: 'Carrello',
settings: 'Impostazioni', settings: 'Impostazioni',
qta_in_attesa: '(Ordinati In attesa {qty})', qta_in_attesa: '(Ordinati In attesa {qty})',
sconto_applicato: 'Sconto!',
}, },
}, },

View File

@@ -415,11 +415,13 @@ export const useProducts = defineStore('Products', {
if (order.quantity === 0) if (order.quantity === 0)
order.quantity = 1 order.quantity = 1
neworder = this.createOrderByProduct(product, order) if (order.idStorehouse) {
neworder = this.createOrderByProduct(product, order)
}
} }
if (neworder && !neworder.idStorehouse) // if (neworder && !neworder.idStorehouse)
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, 'Nessuno Store') // return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, 'Nessuno Store')
console.log('addToCart', 'userid=', userStore.my._id, neworder) console.log('addToCart', 'userid=', userStore.my._id, neworder)

View File

@@ -1754,9 +1754,23 @@ export const useUserStore = defineStore('UserStore', {
async importToServerCmd($q: any, t: any, cmd: number, data: any) { async importToServerCmd($q: any, t: any, cmd: number, data: any) {
return Api.SendReq('/admin/import', 'POST', { cmd, data }) return Api.SendReq('/admin/import', 'POST', { cmd, data })
.then((res) => { .then((res: any) => {
if (res) { if (res) {
tools.showPositiveNotif($q, t('db.recupdated')) let msg = ''
if (res.data.imported) {
msg += ' ' + t('db.records_imported', {num: res.data.imported})
}
if (res.data.errors) {
msg += ' ' + t('db.records_errors', {num: res.data.errors})
}
if (res.data.updated) {
msg += ' ' + t('db.records_updated', {num: res.data.updated})
}
if (!msg) {
msg = t('db.recupdated')
}
tools.showPositiveNotif($q, msg)
} }
}).catch((error) => { }).catch((error) => {
tools.showNegativeNotif($q, t('db.recfailed')) tools.showNegativeNotif($q, t('db.recfailed'))