- corretto la gestione degli Sconti
- Duplicare un Catalogo
This commit is contained in:
@@ -22,4 +22,34 @@ $heightBtn: 100%;
|
||||
.strong {
|
||||
color: #d9534f; /* Rosso */
|
||||
font-weight: bold; /* Testo in grassetto */
|
||||
}
|
||||
}
|
||||
|
||||
.sconto-label{
|
||||
font-weight: bold;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.sconto-text{
|
||||
font-weight: bold;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.table {
|
||||
margin: auto;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.table td {
|
||||
padding: 8px;
|
||||
text-align: right;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.value {
|
||||
font-size: 1.2em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ export default defineComponent({
|
||||
const oldrec = ref(<any[string]>[]);
|
||||
const note = ref('');
|
||||
const codice_sconto = ref('');
|
||||
const descr_sconto = ref('');
|
||||
const endload = ref(false);
|
||||
const caricamentodati = ref(false);
|
||||
const recOrderCart = ref(<IOrderCart>{});
|
||||
@@ -82,16 +83,16 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
function getItemsCart() {
|
||||
const getItemsCart = computed(() => {
|
||||
const cart = getOrdersCart();
|
||||
return cart.items || null;
|
||||
}
|
||||
});
|
||||
|
||||
function getNumItems(): number {
|
||||
const getNumItems = computed((): number => {
|
||||
const cart = getOrdersCart();
|
||||
if (cart.items) return cart.items.length || 0;
|
||||
else return 0;
|
||||
}
|
||||
});
|
||||
|
||||
function getCart(): ICart {
|
||||
return getOrdersCart();
|
||||
@@ -116,21 +117,37 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
function myTotalPrice(): string {
|
||||
const myTotalPrice = computed((): string => {
|
||||
if (productStore.cart && productStore.cart.totalPrice) {
|
||||
return productStore.cart.totalPrice.toFixed(2);
|
||||
} else {
|
||||
return '0';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function myTotalQty(): number {
|
||||
const myTotalPriceCalc = computed((): string => {
|
||||
if (productStore.cart && productStore.cart.totalPriceCalc) {
|
||||
return productStore.cart.totalPriceCalc.toFixed(2);
|
||||
} else {
|
||||
return '0';
|
||||
}
|
||||
});
|
||||
const totalPriceIntero = computed((): string => {
|
||||
if (productStore.cart && productStore.cart.totalPriceIntero) {
|
||||
return productStore.cart.totalPriceIntero.toFixed(2);
|
||||
} else {
|
||||
return '0';
|
||||
}
|
||||
});
|
||||
|
||||
const myTotalQty = computed((): number => {
|
||||
if (productStore.cart) {
|
||||
return productStore.cart.totalQty!;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async function aggiornaCarrello() {
|
||||
if (mycart.value) {
|
||||
recOrderCart.value = await productStore.CreateOrdersCart({
|
||||
@@ -197,7 +214,7 @@ export default defineComponent({
|
||||
|
||||
function completeOrder() {
|
||||
$q.dialog({
|
||||
message: t('ecomm.conferma_acq', { qty: myTotalQty() }),
|
||||
message: t('ecomm.conferma_acq', { qty: myTotalQty }),
|
||||
ok: {
|
||||
label: t('dialog.yes'),
|
||||
push: true,
|
||||
@@ -294,7 +311,7 @@ export default defineComponent({
|
||||
csvRows.push(headers);
|
||||
|
||||
let index = 1
|
||||
for (const itemorder of getItemsCart()) {
|
||||
for (const itemorder of getItemsCart.value) {
|
||||
const productCode = itemorder.order.product?.productInfo.code || '';
|
||||
const productName = itemorder.order.product?.productInfo.name || '';
|
||||
const quantity = itemorder.order.quantity + itemorder.order.quantitypreordered;
|
||||
@@ -306,8 +323,8 @@ export default defineComponent({
|
||||
index++;
|
||||
}
|
||||
|
||||
const totalQuantity = getItemsCart().reduce((sum, itemorder) => sum + itemorder.order.quantity + itemorder.order.quantitypreordered, 0);
|
||||
const totalAmount = getItemsCart().reduce((sum, itemorder) => sum + parseFloat((itemorder.order.price * (itemorder.order.quantity + itemorder.order.quantitypreordered)).toFixed(2)), 0);
|
||||
const totalQuantity = getItemsCart.value.reduce((sum, itemorder) => sum + itemorder.order.quantity + itemorder.order.quantitypreordered, 0);
|
||||
const totalAmount = getItemsCart.value.reduce((sum, itemorder) => sum + parseFloat((itemorder.order.price * (itemorder.order.quantity + itemorder.order.quantitypreordered)).toFixed(2)), 0);
|
||||
|
||||
const totalRow = `${sep}${sep}Totale${sep}${totalQuantity}${sep}${sep}${totalAmount.toFixed(2)}\n`;
|
||||
csvRows.push(totalRow);
|
||||
@@ -341,12 +358,16 @@ export default defineComponent({
|
||||
tools.showNegativeNotif($q, `${rissconto.errmsg}`);
|
||||
}
|
||||
codice_sconto.value = '';
|
||||
if (rissconto.mycart) recOrderCart.value = rissconto.mycart;
|
||||
descr_sconto.value = '';
|
||||
if (rissconto.mycart) {
|
||||
recOrderCart.value = rissconto.mycart
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('error ApplicaSconto', error);
|
||||
tools.showNegativeNotif($q, `Sconto Non Applicato! ${error.message}`);
|
||||
codice_sconto.value = '';
|
||||
descr_sconto.value = '';
|
||||
} finally {
|
||||
caricamentodati.value = false;
|
||||
}
|
||||
@@ -381,6 +402,8 @@ export default defineComponent({
|
||||
completeOrder,
|
||||
getNumItems,
|
||||
myTotalPrice,
|
||||
myTotalPriceCalc,
|
||||
totalPriceIntero,
|
||||
getItemsCart,
|
||||
getNote,
|
||||
change_field,
|
||||
@@ -397,6 +420,7 @@ export default defineComponent({
|
||||
isfinishLoading,
|
||||
esportaCsv,
|
||||
codice_sconto,
|
||||
descr_sconto,
|
||||
confermaCodiceSconto,
|
||||
rimuoviCodiceSconto,
|
||||
caricamentodati,
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<div class="container">
|
||||
<div
|
||||
class="q-pa-sm col items-start q-gutter-xs"
|
||||
v-for="(itemorder, index) in getItemsCart()"
|
||||
v-for="(itemorder, index) in getItemsCart"
|
||||
:key="index"
|
||||
>
|
||||
<CSingleCart
|
||||
@@ -30,73 +30,77 @@
|
||||
</div>
|
||||
<q-separator></q-separator>
|
||||
<div
|
||||
class="col-6 q-mr-sm"
|
||||
style="text-align: right"
|
||||
v-if="totalPriceIntero"
|
||||
class="q-mr-sm"
|
||||
>
|
||||
<span class="text-grey q-mr-xs">{{ $t('ecomm.totale') }}:</span>
|
||||
<span class="text-subtitle1 q-mr-sm">€ {{ myTotalPrice() }}</span>
|
||||
</div>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="label">{{ $t('ecomm.prezzointero') }}:</td>
|
||||
<td
|
||||
class="value text-subtitle1"
|
||||
:class="{ 'text-strike': myTotalPrice !== totalPriceIntero }"
|
||||
>
|
||||
€ {{ totalPriceIntero }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="recOrderCart.codice_sconto">
|
||||
<td class="label">{{ $t('ecomm.sconto_appl') }}:</td>
|
||||
<td>
|
||||
<div class="column items-center">
|
||||
<q-chip
|
||||
square
|
||||
color="orange"
|
||||
text-color="white"
|
||||
size="md"
|
||||
icon="fas fa-tag"
|
||||
>
|
||||
<span class="sconto-text">{{ recOrderCart.descr_sconto }}</span>
|
||||
</q-chip>
|
||||
<q-btn
|
||||
dense
|
||||
flat
|
||||
icon="fas fa-times"
|
||||
color="negative"
|
||||
@click="rimuoviCodiceSconto"
|
||||
>Rimuovi</q-btn
|
||||
>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<q-separator />
|
||||
<tr v-if="!recOrderCart.codice_sconto">
|
||||
<td class="label">{{ $t('ecomm.codice_sconto') }}:</td>
|
||||
<td>
|
||||
<q-input
|
||||
v-model="codice_sconto"
|
||||
:label="$t('ecomm.codice_sconto')"
|
||||
style="width: 200px"
|
||||
filled
|
||||
dense
|
||||
@keyup.enter="confermaCodiceSconto"
|
||||
/>
|
||||
<q-btn
|
||||
:disabled="!codice_sconto || codice_sconto.trim() === ''"
|
||||
:label="$t('ecomm.applica_sconto')"
|
||||
icon="fas fa-check-circle"
|
||||
color="primary"
|
||||
class="q-mt-sm self-center"
|
||||
@click="confermaCodiceSconto"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<div
|
||||
v-if="getNumItems() > 0"
|
||||
style="max-width: 500px"
|
||||
class="row items-center q-gutter-x-xs"
|
||||
>
|
||||
<div class="column items-center q-gutter-x-xs">
|
||||
<div
|
||||
v-if="recOrderCart.codice_sconto"
|
||||
class="row items-center q-gutter-x-xs"
|
||||
>
|
||||
<div
|
||||
class="text-subtitle1 q-mr-sm q-pa-xs"
|
||||
style="background-color: #f0f0f0; border-radius: 4px"
|
||||
>
|
||||
{{ $t('ecomm.sconto_appl') }}
|
||||
</div>
|
||||
|
||||
<q-btn
|
||||
dense
|
||||
flat
|
||||
icon="fas fa-times"
|
||||
color="negative"
|
||||
@click="rimuoviCodiceSconto"
|
||||
>
|
||||
Rimuovi {{ recOrderCart.codice_sconto }}
|
||||
</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!recOrderCart.codice_sconto" class="row">
|
||||
<q-input
|
||||
v-model="codice_sconto"
|
||||
:label="$t('ecomm.codice_sconto')"
|
||||
style="width: 200px"
|
||||
filled
|
||||
dense
|
||||
@keyup.enter="confermaCodiceSconto"
|
||||
/>
|
||||
<q-btn
|
||||
:disabled="!codice_sconto || codice_sconto.trim() === ''"
|
||||
:label="$t('ecomm.applica_sconto')"
|
||||
icon="fas fa-check-circle"
|
||||
color="primary"
|
||||
class="q-mt-sm"
|
||||
@click="confermaCodiceSconto"
|
||||
/>
|
||||
</div>
|
||||
<!--<q-btn
|
||||
v-if="recOrderCart.codice_sconto"
|
||||
:label="$t('ecomm.rimuovi_sconto')"
|
||||
icon="fas fa-times-circle"
|
||||
color="negative"
|
||||
class="q-mt-sm"
|
||||
@click="rimuoviCodiceSconto"
|
||||
/>-->
|
||||
<tr>
|
||||
<td class="label">{{ $t('ecomm.totale_scontato') }}:</td>
|
||||
<td class="ordine_scontato_nuovo">€ {{ myTotalPrice }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<q-input
|
||||
v-if="getNumItems() > 0"
|
||||
v-if="getNumItems > 0"
|
||||
v-model="note"
|
||||
style="min-width: 400px"
|
||||
class="q-mt-md"
|
||||
@@ -116,18 +120,6 @@
|
||||
></div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<q-btn
|
||||
v-if="
|
||||
recOrderCart &&
|
||||
recOrderCart.status < shared_consts.OrderStatus.CHECKOUT_SENT
|
||||
"
|
||||
icon="fas fa-file-csv"
|
||||
flat
|
||||
filled
|
||||
:label="$t('ecomm.esporta_csv')"
|
||||
class="q-mb-sm"
|
||||
@click="esportaCsv()"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-if="
|
||||
recOrderCart &&
|
||||
@@ -138,10 +130,11 @@
|
||||
color="green"
|
||||
:label="$t('ecomm.completa_ord')"
|
||||
class="q-mb-sm"
|
||||
:disabled="myTotalQty() < 1"
|
||||
:disabled="myTotalQty < 1"
|
||||
@click="completeOrder()"
|
||||
></q-btn>
|
||||
</div>
|
||||
<q-separator />
|
||||
<div class="center-text">
|
||||
<br />
|
||||
|
||||
@@ -152,6 +145,20 @@
|
||||
{{ globalStore.site.ecomm.NoteExtraOnCart }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="q-mt-md row justify-center">
|
||||
<q-btn
|
||||
v-if="
|
||||
recOrderCart &&
|
||||
recOrderCart.status < shared_consts.OrderStatus.CHECKOUT_SENT
|
||||
"
|
||||
icon="fas fa-file-csv"
|
||||
flat
|
||||
filled
|
||||
:label="$t('ecomm.esporta_csv')"
|
||||
class="q-mb-sm"
|
||||
@click="esportaCsv()"
|
||||
></q-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
|
||||
@@ -2506,6 +2506,12 @@ export default defineComponent({
|
||||
|
||||
if (cmd === costanti.CMD_CLONE) {
|
||||
const myarr = serverData.value.find((rec: any) => rec._id === id)
|
||||
if (myarr) {
|
||||
mycolumns.value.forEach((col: IColGridTable) => {
|
||||
if (col.dont_clone)
|
||||
delete myarr[col.name]
|
||||
})
|
||||
}
|
||||
newRecord.value = myarr
|
||||
newRecord.value._id = 0
|
||||
newRecordBool.value = true
|
||||
|
||||
@@ -48,8 +48,9 @@
|
||||
<q-btn
|
||||
v-if="existsOrders()"
|
||||
rounded
|
||||
outline
|
||||
icon="fas fa-clipboard-list"
|
||||
color="positive"
|
||||
style="color: green;"
|
||||
:label="t('ecomm.btn_ordini')"
|
||||
class="q-mb-sm"
|
||||
@click="globalStore.rightCartOpen = false"
|
||||
|
||||
@@ -207,13 +207,13 @@
|
||||
:label="$t('reg.elimina')"
|
||||
icon="fas fa-trash-alt"
|
||||
/>
|
||||
<!--<q-fab-action
|
||||
v-if="tools.canModifyThisRec(myrec, table) || tools.isManager() || editOn"
|
||||
@click="cmdExt(costanti.CMD_CLONE, myrec._id, null)"
|
||||
color="accent"
|
||||
:label="$t('event.duplicate')"
|
||||
icon="fas fa-copy"
|
||||
/>-->
|
||||
<q-fab-action
|
||||
v-if="tools.canModifyThisRec(myrec, table) || tools.isManager() || editOn"
|
||||
@click="cmdExt(costanti.CMD_CLONE, myrec._id, null)"
|
||||
color="accent"
|
||||
:label="$t('event.duplicate')"
|
||||
icon="fas fa-copy"
|
||||
/>
|
||||
<q-fab-action
|
||||
v-if="tools.canModifyThisRec(myrec, table) || editOn"
|
||||
:disable="!pagina_collegata"
|
||||
|
||||
@@ -22,15 +22,7 @@
|
||||
.barrato {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
.ordine_scontato_nuovo{
|
||||
font-size: 1.1rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
.ordine_scritta_sconto{
|
||||
font-style: italic;
|
||||
color: green;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.gasordine {
|
||||
font-style: italic;
|
||||
color: blue;
|
||||
@@ -105,14 +97,15 @@
|
||||
}
|
||||
|
||||
.quantity-display {
|
||||
min-width: 60px;
|
||||
width: 80px;
|
||||
text-align: center;
|
||||
font-size: 1.4rem;
|
||||
font-size: 1.2rem;
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
background: #f8fafc;
|
||||
border-radius: 12px;
|
||||
padding: 12px 16px;
|
||||
padding: 4px 8px;
|
||||
margin: 4px;
|
||||
border: 2px solid #e2e8f0;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
@@ -241,4 +234,17 @@
|
||||
.remove-btn {
|
||||
margin: 16px auto 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.myval_sconto{
|
||||
font-size: 1.2em;
|
||||
font-weight: bold;
|
||||
color: green;
|
||||
}
|
||||
|
||||
.myperc_sconto{
|
||||
font-size: 1.2em;
|
||||
font-weight: bold;
|
||||
color: green;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { CCopyBtn } from '../CCopyBtn';
|
||||
import type { IOrder } from '@src/model';
|
||||
import { IOperators, IProduct } from '@src/model';
|
||||
import type { PropType } from 'vue';
|
||||
import { defineComponent, toRef, ref, watch, onMounted } from 'vue';
|
||||
import { defineComponent, toRef, ref, watch, onMounted, computed } from 'vue';
|
||||
import { CTitleBanner } from '@src/components/CTitleBanner';
|
||||
import { useProducts } from '@store/Products';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
@@ -59,6 +59,10 @@ export default defineComponent({
|
||||
const enableQtyPreordered = ref(false);
|
||||
const enableChangeTotalPrice = ref(false);
|
||||
|
||||
watch(props.order, (newVal: any) => {
|
||||
order.value = { ...newVal };
|
||||
});
|
||||
|
||||
watch(orderQuantity, (newValue: any) => {
|
||||
if (!newValue) order.value.quantity = 0;
|
||||
else order.value.quantity = parseFloat(newValue);
|
||||
@@ -151,15 +155,17 @@ export default defineComponent({
|
||||
});
|
||||
}
|
||||
|
||||
function isApplicatoSconto() {
|
||||
const isApplicatoSconto = computed(() => {
|
||||
const totalipotetico =
|
||||
order.value.product!.price *
|
||||
(order.value.quantity + order.value.quantitypreordered);
|
||||
if (totalipotetico.toFixed(2) > order.value.TotalPriceProduct.toFixed(2)) {
|
||||
const totalipoteticoNum = parseFloat(totalipotetico.toFixed(2));
|
||||
const totalpriceNum = parseFloat(order.value.TotalPriceProduct.toFixed(2));
|
||||
if (totalipoteticoNum > totalpriceNum) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
function removeFromCard() {
|
||||
$q.dialog({
|
||||
@@ -197,12 +203,21 @@ export default defineComponent({
|
||||
mounted();
|
||||
}
|
||||
|
||||
function getRisparmio(): string {
|
||||
const getRisparmio = computed((): string => {
|
||||
return (
|
||||
order.value.product!.price * order.value.quantity -
|
||||
order.value.TotalPriceProduct
|
||||
).toFixed(2);
|
||||
}
|
||||
});
|
||||
const getRispPerc = computed((): string => {
|
||||
const risparmioPerc = parseFloat(
|
||||
(
|
||||
(getRisparmio.value / (order.value.product!.price * order.value.quantity)) *
|
||||
100
|
||||
).toFixed(2)
|
||||
);
|
||||
return risparmioPerc.toFixed(0);
|
||||
});
|
||||
|
||||
function mounted() {
|
||||
endload.value = false;
|
||||
@@ -248,6 +263,7 @@ export default defineComponent({
|
||||
orderTotalPriceProduct,
|
||||
endload,
|
||||
qtyInCart,
|
||||
getRispPerc,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -106,9 +106,9 @@
|
||||
size="sm"
|
||||
class="quantity-btn"
|
||||
data-gradiente="negative"
|
||||
:icon="qtyInCart() === 1 ? 'fas fa-trash': 'fas fa-minus'"
|
||||
:icon="qtyInCart() === 1 ? 'fas fa-trash' : 'fas fa-minus'"
|
||||
:color="products.enableSubQty(order) ? undefined : 'grey'"
|
||||
@click="qtyInCart() === 1 ? removeFromCard(): addsubqty(false, true)"
|
||||
@click="qtyInCart() === 1 ? removeFromCard() : addsubqty(false, true)"
|
||||
rounded
|
||||
></q-btn>
|
||||
<div v-if="editmode">
|
||||
@@ -195,27 +195,12 @@
|
||||
{{ order.quantity + order.quantitypreordered }} x €
|
||||
{{ order.price ? order.price : 0 }}
|
||||
</span>
|
||||
<span :class="isApplicatoSconto() ? 'ordine_scontato_nuovo' : ''">
|
||||
= €
|
||||
=
|
||||
<span :class="isApplicatoSconto ? 'ordine_scontato_nuovo' : ''">
|
||||
€
|
||||
{{ order.TotalPriceProduct ? order.TotalPriceProduct.toFixed(2) : 0 }}
|
||||
</span>
|
||||
<span
|
||||
v-if="
|
||||
tools.isManager() &&
|
||||
order.TotalPriceProduct.toFixed(2) !==
|
||||
order.TotalPriceProductCalc.toFixed(2)
|
||||
"
|
||||
:class="isApplicatoSconto() ? 'ordine_scontato_nuovo' : ''"
|
||||
>
|
||||
(Calc: €
|
||||
{{
|
||||
order.TotalPriceProductCalc
|
||||
? order.TotalPriceProductCalc.toFixed(2)
|
||||
: 0
|
||||
}})
|
||||
</span>
|
||||
|
||||
<span v-if="isApplicatoSconto()">
|
||||
<span v-if="isApplicatoSconto">
|
||||
<span class="ordine_scontato"
|
||||
>(<span class="barrato"
|
||||
>€
|
||||
@@ -228,11 +213,17 @@
|
||||
>)</span
|
||||
>
|
||||
</span>
|
||||
<span
|
||||
v-if="isApplicatoSconto() && !editmode"
|
||||
<div
|
||||
v-if="isApplicatoSconto && !editmode"
|
||||
class="ordine_scritta_sconto"
|
||||
>{{ $t('ecomm.sconto_applicato', { risparmio: getRisparmio() }) }}</span
|
||||
v-html="
|
||||
$t('ecomm.sconto_applicato', {
|
||||
risparmio: getRisparmio,
|
||||
perc: getRispPerc,
|
||||
})
|
||||
"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
|
||||
Reference in New Issue
Block a user