- Esporta Lista Carrello (Totale)
- Sconto Applicato
This commit is contained in:
467
_LIMBO/esempio.htm
Normal file
467
_LIMBO/esempio.htm
Normal file
@@ -0,0 +1,467 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Carrello Prodotti - Design Moderno</title>
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.cart-container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
backdrop-filter: blur(20px);
|
||||
border-radius: 24px;
|
||||
padding: 32px;
|
||||
box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.cart-header {
|
||||
text-align: center;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.cart-title {
|
||||
font-size: 2.5rem;
|
||||
font-weight: 700;
|
||||
background: linear-gradient(135deg, #667eea, #764ba2);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.cart-subtitle {
|
||||
color: #6b7280;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.product-card {
|
||||
background: #ffffff;
|
||||
border-radius: 20px;
|
||||
padding: 24px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
|
||||
border: 1px solid rgba(0, 0, 0, 0.05);
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.product-card:hover {
|
||||
transform: translateY(-4px);
|
||||
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.product-card.removing {
|
||||
opacity: 0;
|
||||
transform: translateX(100px);
|
||||
transition: all 0.5s ease;
|
||||
}
|
||||
|
||||
.product-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.product-image {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
border-radius: 16px;
|
||||
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 2rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.product-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.product-name {
|
||||
font-size: 1.3rem;
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.product-price {
|
||||
font-size: 1.1rem;
|
||||
color: #6b7280;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.product-total {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 700;
|
||||
color: #059669;
|
||||
}
|
||||
|
||||
.quantity-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.quantity-btn {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
background: linear-gradient(135deg, #667eea, #764ba2);
|
||||
color: white;
|
||||
font-size: 1.2rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
|
||||
}
|
||||
|
||||
.quantity-btn:hover:not(:disabled) {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
|
||||
}
|
||||
|
||||
.quantity-btn:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.quantity-btn:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.quantity-display {
|
||||
min-width: 60px;
|
||||
text-align: center;
|
||||
font-size: 1.4rem;
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
background: #f8fafc;
|
||||
border-radius: 12px;
|
||||
padding: 12px 16px;
|
||||
border: 2px solid #e2e8f0;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.quantity-display.updating {
|
||||
transform: scale(1.1);
|
||||
border-color: #667eea;
|
||||
background: #eff6ff;
|
||||
}
|
||||
|
||||
.remove-btn {
|
||||
background: linear-gradient(135deg, #ef4444, #dc2626);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
padding: 12px 20px;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.remove-btn:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
|
||||
}
|
||||
|
||||
.cart-summary {
|
||||
background: linear-gradient(135deg, #667eea, #764ba2);
|
||||
color: white;
|
||||
border-radius: 20px;
|
||||
padding: 24px;
|
||||
margin-top: 32px;
|
||||
text-align: center;
|
||||
opacity: 1;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.cart-summary.hidden {
|
||||
opacity: 0;
|
||||
transform: translateY(20px);
|
||||
}
|
||||
|
||||
.total-amount {
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.total-items {
|
||||
opacity: 0.9;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.checkout-btn {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border: 2px solid rgba(255, 255, 255, 0.3);
|
||||
color: white;
|
||||
padding: 16px 32px;
|
||||
border-radius: 12px;
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.checkout-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.empty-cart {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
color: #6b7280;
|
||||
opacity: 0;
|
||||
transition: opacity 0.5s ease;
|
||||
}
|
||||
|
||||
.empty-cart.show {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.empty-cart i {
|
||||
font-size: 4rem;
|
||||
margin-bottom: 20px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { transform: scale(1); }
|
||||
50% { transform: scale(1.05); }
|
||||
}
|
||||
|
||||
.pulse {
|
||||
animation: pulse 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
@keyframes fadeInUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(30px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.fade-in {
|
||||
animation: fadeInUp 0.5s ease forwards;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.product-content {
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.quantity-controls {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.remove-btn {
|
||||
margin: 16px auto 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="cart-container">
|
||||
<div class="cart-header">
|
||||
<h1 class="cart-title">
|
||||
<i class="fas fa-shopping-cart"></i>
|
||||
Il Tuo Carrello
|
||||
</h1>
|
||||
<p class="cart-subtitle">Gestisci i tuoi prodotti preferiti</p>
|
||||
</div>
|
||||
|
||||
<div id="empty-cart" class="empty-cart">
|
||||
<i class="fas fa-shopping-bag"></i>
|
||||
<h3>Il tuo carrello è vuoto</h3>
|
||||
<p>Aggiungi alcuni prodotti per iniziare!</p>
|
||||
</div>
|
||||
|
||||
<div id="cart-items"></div>
|
||||
|
||||
<div id="cart-summary" class="cart-summary">
|
||||
<div class="total-amount" id="total-amount">€0.00</div>
|
||||
<p class="total-items" id="total-items">0 articoli nel carrello</p>
|
||||
<button class="checkout-btn" onclick="checkout()">
|
||||
<i class="fas fa-credit-card"></i>
|
||||
Procedi al Checkout
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Dati del carrello
|
||||
let cartItems = [
|
||||
{ id: 1, name: 'iPhone 15 Pro', price: 1199.99, quantity: 1, emoji: '📱' },
|
||||
{ id: 2, name: 'MacBook Air M3', price: 1299.99, quantity: 2, emoji: '💻' },
|
||||
{ id: 3, name: 'AirPods Pro', price: 279.99, quantity: 1, emoji: '🎧' },
|
||||
{ id: 4, name: 'Apple Watch', price: 399.99, quantity: 1, emoji: '⌚' }
|
||||
];
|
||||
|
||||
// Elementi DOM
|
||||
const cartItemsContainer = document.getElementById('cart-items');
|
||||
const emptyCartDiv = document.getElementById('empty-cart');
|
||||
const cartSummaryDiv = document.getElementById('cart-summary');
|
||||
const totalAmountSpan = document.getElementById('total-amount');
|
||||
const totalItemsSpan = document.getElementById('total-items');
|
||||
|
||||
// Funzioni di calcolo
|
||||
function calculateTotal() {
|
||||
return cartItems.reduce((total, item) => total + (item.price * item.quantity), 0);
|
||||
}
|
||||
|
||||
function calculateTotalItems() {
|
||||
return cartItems.reduce((total, item) => total + item.quantity, 0);
|
||||
}
|
||||
|
||||
// Funzione per creare HTML di un prodotto
|
||||
function createProductHTML(item) {
|
||||
return `
|
||||
<div class="product-card fade-in" data-id="${item.id}">
|
||||
<div class="product-content">
|
||||
<div class="product-image">
|
||||
${item.emoji}
|
||||
</div>
|
||||
<div class="product-info">
|
||||
<h3 class="product-name">${item.name}</h3>
|
||||
<p class="product-price">€${item.price.toFixed(2)} / unità</p>
|
||||
<p class="product-total">Totale: €${(item.price * item.quantity).toFixed(2)}</p>
|
||||
|
||||
<div class="quantity-controls">
|
||||
<button
|
||||
class="quantity-btn"
|
||||
onclick="decreaseQuantity(${item.id})"
|
||||
${item.quantity <= 1 ? 'disabled' : ''}
|
||||
>
|
||||
<i class="fas fa-minus"></i>
|
||||
</button>
|
||||
|
||||
<div class="quantity-display" id="qty-${item.id}">
|
||||
${item.quantity}
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="quantity-btn"
|
||||
onclick="increaseQuantity(${item.id})"
|
||||
>
|
||||
<i class="fas fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="remove-btn"
|
||||
onclick="removeItem(${item.id})"
|
||||
>
|
||||
<i class="fas fa-trash"></i>
|
||||
Rimuovi
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
// Funzione per aggiornare l'interfaccia
|
||||
function updateUI() {
|
||||
// Aggiorna contenuto carrello
|
||||
if (cartItems.length === 0) {
|
||||
cartItemsContainer.innerHTML = '';
|
||||
emptyCartDiv.classList.add('show');
|
||||
cartSummaryDiv.classList.add('hidden');
|
||||
} else {
|
||||
emptyCartDiv.classList.remove('show');
|
||||
cartSummaryDiv.classList.remove('hidden');
|
||||
cartItemsContainer.innerHTML = cartItems.map(createProductHTML).join('');
|
||||
}
|
||||
|
||||
// Aggiorna totali
|
||||
const total = calculateTotal();
|
||||
const totalItems = calculateTotalItems();
|
||||
|
||||
totalAmountSpan.textContent = `€${total.toFixed(2)}`;
|
||||
totalItemsSpan.textContent = `${totalItems} ${totalItems === 1 ? 'articolo' : 'articoli'} nel carrello`;
|
||||
}
|
||||
|
||||
// Funzioni per gestire quantità
|
||||
function increaseQuantity(itemId) {
|
||||
const item = cartItems.find(item => item.id === itemId);
|
||||
if (item) {
|
||||
item.quantity++;
|
||||
|
||||
// Animazione feedback
|
||||
const qtyDisplay = document.getElementById(`qty-${itemId}`);
|
||||
qtyDisplay.classList.add('updating');
|
||||
setTimeout(() => qtyDisplay.classList.remove('updating'), 300);
|
||||
|
||||
updateUI();
|
||||
}
|
||||
}
|
||||
|
||||
function decreaseQuantity(itemId) {
|
||||
const item = cartItems.find(item => item.id === itemId);
|
||||
if (item && item.quantity > 1) {
|
||||
item.quantity--;
|
||||
|
||||
// Animazione feedback
|
||||
const qtyDisplay = document.getElementById(`qty-${itemId}`);
|
||||
qtyDisplay.classList.add('updating');
|
||||
setTimeout(() => qtyDisplay.classList.remove('updating'), 300);
|
||||
|
||||
updateUI();
|
||||
}
|
||||
}
|
||||
|
||||
// Funzione per rimuovere prodotto
|
||||
function removeItem(itemId) {
|
||||
const productCard = document.querySelector(`[data-id="${itemId}"]`);
|
||||
productCard.classList.add('removing');
|
||||
|
||||
setTimeout(() => {
|
||||
cartItems = cartItems.filter(item => item.id !== itemId);
|
||||
updateUI();
|
||||
}, 500);
|
||||
}
|
||||
|
||||
// Funzione checkout
|
||||
function checkout() {
|
||||
const total = calculateTotal();
|
||||
const totalItems = calculateTotalItems();
|
||||
alert(`Checkout per €${total.toFixed(2)} - ${totalItems} articoli`);
|
||||
}
|
||||
|
||||
// Inizializza l'interfaccia
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
updateUI();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -2533,6 +2533,11 @@ export const shared_consts = {
|
||||
WEB: 1,
|
||||
STAMPA: 2,
|
||||
},
|
||||
PUNTI_PER_POLLICE: 96
|
||||
PUNTI_PER_POLLICE: 96,
|
||||
|
||||
SCONTI_APPLICA: {
|
||||
NESSUNO: 0,
|
||||
A_TUTTI: 1,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import { defineComponent, onMounted, ref, computed, watch } from 'vue'
|
||||
import { tools } from '@tools'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { useProducts } from '@store/Products'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { toolsext } from '@store/Modules/toolsext'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { costanti } from '@costanti'
|
||||
import { defineComponent, onMounted, ref, computed, watch } from 'vue';
|
||||
import { tools } from '@tools';
|
||||
import { useUserStore } from '@store/UserStore';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useGlobalStore } from '@store/globalStore';
|
||||
import { useProducts } from '@store/Products';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { toolsext } from '@store/Modules/toolsext';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { costanti } from '@costanti';
|
||||
import type { ICart, IOrder, IOrderCart, IProduct } from '@src/model/Products';
|
||||
import { IShareWithUs } from '@src/model/Products'
|
||||
import { IShareWithUs } from '@src/model/Products';
|
||||
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
import { shared_consts } from '@src/common/shared_vuejs';
|
||||
|
||||
import { CSingleCart } from '../CSingleCart'
|
||||
import { CTitleBanner } from '@src/components/CTitleBanner'
|
||||
import { CSelectUserActive } from '@src/components/CSelectUserActive'
|
||||
import { CSingleCart } from '../CSingleCart';
|
||||
import { CTitleBanner } from '@src/components/CTitleBanner';
|
||||
import { CSelectUserActive } from '@src/components/CSelectUserActive';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CCart',
|
||||
@@ -30,148 +30,160 @@ export default defineComponent({
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
|
||||
},
|
||||
components: { CSingleCart, CTitleBanner, CSelectUserActive },
|
||||
setup(props) {
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
const productStore = useProducts()
|
||||
const $router = useRouter()
|
||||
const $q = useQuasar()
|
||||
const userStore = useUserStore();
|
||||
const globalStore = useGlobalStore();
|
||||
const productStore = useProducts();
|
||||
const $router = useRouter();
|
||||
const $q = useQuasar();
|
||||
const { t } = useI18n();
|
||||
|
||||
const mycart = ref(<ICart>{})
|
||||
const myrec = ref(<any[string]>[])
|
||||
const oldrec = ref(<any[string]>[])
|
||||
const note = ref('')
|
||||
const endload = ref(false)
|
||||
const recOrderCart = ref(<IOrderCart>{})
|
||||
const mycart = ref(<ICart>{});
|
||||
const myrec = ref(<any[string]>[]);
|
||||
const oldrec = ref(<any[string]>[]);
|
||||
const note = ref('');
|
||||
const codice_sconto = ref('');
|
||||
const endload = ref(false);
|
||||
const caricamentodati = ref(false);
|
||||
const recOrderCart = ref(<IOrderCart>{});
|
||||
|
||||
const search = ref('')
|
||||
const search = ref('');
|
||||
|
||||
const isfinishLoading = computed(() => globalStore.finishLoading)
|
||||
const isfinishLoading = computed(() => globalStore.finishLoading);
|
||||
|
||||
watch(() => isfinishLoading.value, (newval: boolean, oldval: boolean) => {
|
||||
if (isfinishLoading.value) {
|
||||
load()
|
||||
watch(
|
||||
() => isfinishLoading.value,
|
||||
(newval: boolean, oldval: boolean) => {
|
||||
if (isfinishLoading.value) {
|
||||
load();
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
const statusnow = computed(() => (): number => {
|
||||
if (recOrderCart.value) {
|
||||
return recOrderCart.value.status
|
||||
return recOrderCart.value.status;
|
||||
}
|
||||
return 0
|
||||
})
|
||||
return 0;
|
||||
});
|
||||
|
||||
function mounted() {
|
||||
// Inizializza
|
||||
load()
|
||||
load();
|
||||
}
|
||||
|
||||
function getOrdersCart() {
|
||||
if (props.iscash) {
|
||||
return productStore.getOrdersCartById(props.idOrdersCart)
|
||||
return productStore.getOrdersCartById(props.idOrdersCart);
|
||||
} else {
|
||||
return productStore.getCart()
|
||||
return productStore.getCart();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getItemsCart() {
|
||||
const cart = getOrdersCart()
|
||||
return cart.items || null
|
||||
const cart = getOrdersCart();
|
||||
return cart.items || null;
|
||||
}
|
||||
|
||||
function getNumItems(): number {
|
||||
const cart = getOrdersCart()
|
||||
if (cart.items)
|
||||
return cart.items.length || 0
|
||||
else
|
||||
return 0
|
||||
const cart = getOrdersCart();
|
||||
if (cart.items) return cart.items.length || 0;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
function getCart(): ICart {
|
||||
return getOrdersCart()
|
||||
return getOrdersCart();
|
||||
}
|
||||
|
||||
function getNote() {
|
||||
const cart = getOrdersCart()
|
||||
return cart.note
|
||||
const cart = getOrdersCart();
|
||||
return cart.note;
|
||||
}
|
||||
|
||||
function change_field(fieldname: string) {
|
||||
if (myrec.value[fieldname] !== oldrec.value[fieldname]) {
|
||||
myrec.value[fieldname] = oldrec.value[fieldname]
|
||||
myrec.value[fieldname] = oldrec.value[fieldname];
|
||||
|
||||
const mydata = {
|
||||
[fieldname]: myrec.value[fieldname]
|
||||
}
|
||||
[fieldname]: myrec.value[fieldname],
|
||||
};
|
||||
|
||||
const aggiorna = fieldname !== 'status'
|
||||
tools.saveFieldToServer($q, 'carts', mycart.value._id, mydata, aggiorna)
|
||||
oldrec.value[fieldname] = myrec.value[fieldname]
|
||||
const aggiorna = fieldname !== 'status';
|
||||
tools.saveFieldToServer($q, 'carts', mycart.value._id, mydata, aggiorna);
|
||||
oldrec.value[fieldname] = myrec.value[fieldname];
|
||||
}
|
||||
}
|
||||
|
||||
function myTotalPrice(): string {
|
||||
if (productStore.cart && productStore.cart.totalPrice) {
|
||||
return productStore.cart.totalPrice.toFixed(2)
|
||||
return productStore.cart.totalPrice.toFixed(2);
|
||||
} else {
|
||||
return '0'
|
||||
return '0';
|
||||
}
|
||||
}
|
||||
|
||||
function myTotalQty(): number {
|
||||
if (productStore.cart) {
|
||||
return productStore.cart.totalQty!
|
||||
return productStore.cart.totalQty!;
|
||||
} else {
|
||||
return 0
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
async function aggiornaCarrello() {
|
||||
if (mycart.value) {
|
||||
recOrderCart.value = await productStore.CreateOrdersCart({
|
||||
cart_id: mycart.value._id,
|
||||
status: 0,
|
||||
note: note.value,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
if (isfinishLoading.value) {
|
||||
console.log('Load CCART')
|
||||
mycart.value = getCart()
|
||||
myrec.value = Object.keys(mycart)
|
||||
oldrec.value = myrec.value
|
||||
note.value = mycart.value.note!
|
||||
console.log('Load CCART');
|
||||
mycart.value = getCart();
|
||||
myrec.value = Object.keys(mycart);
|
||||
oldrec.value = myrec.value;
|
||||
note.value = mycart.value.note!;
|
||||
// codice_sconto.value = mycart.value.codice_sconto!;
|
||||
|
||||
const options = {};
|
||||
|
||||
if (mycart.value) {
|
||||
recOrderCart.value = await productStore.CreateOrdersCart({ cart_id: mycart.value._id, status: 0, note: note.value })
|
||||
}
|
||||
aggiornaCarrello();
|
||||
|
||||
// console.log('myrec', myrec.value)
|
||||
|
||||
endload.value = true
|
||||
endload.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
function CanBeShipped() {
|
||||
return productStore.cart.items ? productStore.cart.items.filter((rec: any) => rec.order.product.canBeShipped).length : false
|
||||
return productStore.cart.items
|
||||
? productStore.cart.items.filter((rec: any) => rec.order.product.canBeShipped)
|
||||
.length
|
||||
: false;
|
||||
}
|
||||
|
||||
function CanBeBuyOnline() {
|
||||
return productStore.cart.items ? productStore.cart.items.filter((rec: any) => rec.order.product.canBeBuyOnline).length : false
|
||||
return productStore.cart.items
|
||||
? productStore.cart.items.filter((rec: any) => rec.order.product.canBeBuyOnline)
|
||||
.length
|
||||
: false;
|
||||
}
|
||||
|
||||
function getnumsteps() {
|
||||
let numsteps = 1
|
||||
let numsteps = 1;
|
||||
|
||||
if (CanBeShipped())
|
||||
numsteps++
|
||||
if (CanBeBuyOnline())
|
||||
numsteps++
|
||||
if (CanBeShipped()) numsteps++;
|
||||
if (CanBeBuyOnline()) numsteps++;
|
||||
|
||||
return numsteps
|
||||
return numsteps;
|
||||
}
|
||||
|
||||
function docheckout() {
|
||||
|
||||
// Può essere spedito?
|
||||
|
||||
if (CanBeShipped()) {
|
||||
@@ -188,40 +200,53 @@ export default defineComponent({
|
||||
message: t('ecomm.conferma_acq', { qty: myTotalQty() }),
|
||||
ok: {
|
||||
label: t('dialog.yes'),
|
||||
push: true
|
||||
push: true,
|
||||
},
|
||||
cancel: {
|
||||
label: t('dialog.cancel')
|
||||
label: t('dialog.cancel'),
|
||||
},
|
||||
title: t('ecomm.order')
|
||||
title: t('ecomm.order'),
|
||||
}).onOk(async () => {
|
||||
const status = shared_consts.OrderStatus.CHECKOUT_SENT
|
||||
const status = shared_consts.OrderStatus.CHECKOUT_SENT;
|
||||
|
||||
recOrderCart.value = await productStore.CreateOrdersCart({ cart_id: mycart.value._id, status, note: note.value })
|
||||
try {
|
||||
caricamentodati.value = true;
|
||||
|
||||
// statusnow.value = myordercart ? myordercart.status : 0
|
||||
recOrderCart.value = await productStore.CreateOrdersCart({
|
||||
cart_id: mycart.value._id,
|
||||
status,
|
||||
note: note.value,
|
||||
codice_sconto: codice_sconto.value,
|
||||
});
|
||||
|
||||
if (recOrderCart.value.status === status) {
|
||||
tools.showPositiveNotif($q, t('ecomm.ord_confirmed'))
|
||||
setTimeout(() => {
|
||||
$router.push('/orderinfo')
|
||||
}, 2000)
|
||||
} else {
|
||||
tools.showNegativeNotif($q, t('ecomm.ord_not_confirmed'))
|
||||
// statusnow.value = myordercart ? myordercart.status : 0
|
||||
|
||||
if (recOrderCart.value.status === status) {
|
||||
tools.showPositiveNotif($q, t('ecomm.ord_confirmed'));
|
||||
setTimeout(() => {
|
||||
$router.push('/orderinfo');
|
||||
}, 2000);
|
||||
} else {
|
||||
tools.showNegativeNotif($q, t('ecomm.ord_not_confirmed'));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
} finally {
|
||||
caricamentodati.value = false;
|
||||
}
|
||||
// change_field('status')
|
||||
// change_field('status')
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function getActualIdStorehouse(myprod: IProduct) {
|
||||
// Ottieni il negozio attualmente selezionato:
|
||||
// Se ce n'è solo 1 allora prendi quello !
|
||||
if (myprod.storehouses.length === 1) {
|
||||
return myprod.storehouses[0]._id
|
||||
return myprod.storehouses[0]._id;
|
||||
} else {
|
||||
// Ottieni il negozio attualmente scelto !
|
||||
return ''
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,10 +254,10 @@ export default defineComponent({
|
||||
// Ottieni il negozio attualmente selezionato:
|
||||
// Se ce n'è solo 1 allora prendi quello !
|
||||
if (myprod.gasordine) {
|
||||
return myprod.gasordine._id
|
||||
return myprod.gasordine._id;
|
||||
} else {
|
||||
// Ottieni il gasordine attualmente scelto !
|
||||
return ''
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,18 +267,111 @@ export default defineComponent({
|
||||
const myprod = productStore.getProductByCode(lowerSearchText);
|
||||
if (myprod && myprod.active) {
|
||||
const myorder: IOrder = {
|
||||
quantity: 1, quantitypreordered: 0,
|
||||
TotalPriceProduct: 0, TotalPriceProductCalc: 0, price: 0,
|
||||
quantity: 1,
|
||||
quantitypreordered: 0,
|
||||
TotalPriceProduct: 0,
|
||||
TotalPriceProductCalc: 0,
|
||||
price: 0,
|
||||
idStorehouse: getActualIdStorehouse(myprod),
|
||||
idGasordine: getActualGasordine(myprod),
|
||||
}
|
||||
await productStore.addtoCartBase({ $q, t, id: myprod._id, order: myorder, addqty: true })
|
||||
search.value = ''
|
||||
load()
|
||||
};
|
||||
await productStore.addtoCartBase({
|
||||
$q,
|
||||
t,
|
||||
id: myprod._id,
|
||||
order: myorder,
|
||||
addqty: true,
|
||||
});
|
||||
search.value = '';
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
function esportaCsv() {
|
||||
const csvRows: string[] = [];
|
||||
const sep = '|';
|
||||
const headers = `Num${sep}Codice${sep}Titolo${sep}Quantità${sep}Prezzo${sep}Totale\n`;
|
||||
csvRows.push(headers);
|
||||
|
||||
let index = 1
|
||||
for (const itemorder of getItemsCart()) {
|
||||
const productCode = itemorder.order.product?.productInfo.code || '';
|
||||
const productName = itemorder.order.product?.productInfo.name || '';
|
||||
const quantity = itemorder.order.quantity + itemorder.order.quantitypreordered;
|
||||
const price = Number(itemorder.order.price).toFixed(2);
|
||||
const totalPrice = (price * quantity).toFixed(2);
|
||||
|
||||
const row = `${index}${sep}${productCode}${sep}${productName}${sep}${quantity}${sep}${price}${sep}${totalPrice}\n`;
|
||||
csvRows.push(row);
|
||||
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 totalRow = `${sep}${sep}Totale${sep}${totalQuantity}${sep}${sep}${totalAmount.toFixed(2)}\n`;
|
||||
csvRows.push(totalRow);
|
||||
|
||||
|
||||
console.log('csvRows', csvRows)
|
||||
|
||||
const csvContent = csvRows.join('').trim();
|
||||
|
||||
const today = new Date();
|
||||
tools.createAndDownloadCSVFromData(
|
||||
csvContent,
|
||||
`ordine_${today.getFullYear()}-${today.getMonth() + 1}-${today.getDate()}`
|
||||
);
|
||||
}
|
||||
|
||||
async function applicaSconto(codice: string) {
|
||||
try {
|
||||
caricamentodati.value = true;
|
||||
const rissconto = await productStore.ApplicaSconto({
|
||||
cart_id: mycart.value._id,
|
||||
codice_sconto: codice,
|
||||
});
|
||||
|
||||
if (rissconto) {
|
||||
if (rissconto.msg) {
|
||||
tools.showNeutralNotif($q, `${rissconto.msg}`);
|
||||
} else if (rissconto.valido && rissconto.mycart) {
|
||||
tools.showPositiveNotif($q, 'Sconto Applicato!');
|
||||
} else {
|
||||
tools.showNegativeNotif($q, `${rissconto.errmsg}`);
|
||||
}
|
||||
codice_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 = '';
|
||||
} finally {
|
||||
caricamentodati.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function confermaCodiceSconto() {
|
||||
await applicaSconto(codice_sconto.value);
|
||||
}
|
||||
|
||||
async function rimuoviCodiceSconto() {
|
||||
$q.dialog({
|
||||
message: `Vuoi rimuovere il codice sconto "${recOrderCart.value.codice_sconto}"?`,
|
||||
ok: {
|
||||
label: 'Si',
|
||||
push: true,
|
||||
},
|
||||
cancel: {
|
||||
label: 'No',
|
||||
},
|
||||
}).onOk(async () => {
|
||||
await applicaSconto('RIMUOVI');
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(mounted);
|
||||
|
||||
return {
|
||||
userStore,
|
||||
@@ -277,6 +395,11 @@ export default defineComponent({
|
||||
insertArticolo,
|
||||
globalStore,
|
||||
isfinishLoading,
|
||||
}
|
||||
}
|
||||
})
|
||||
esportaCsv,
|
||||
codice_sconto,
|
||||
confermaCodiceSconto,
|
||||
rimuoviCodiceSconto,
|
||||
caricamentodati,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,107 +1,204 @@
|
||||
<template>
|
||||
<q-spinner v-if="!endload" color="primary" size="3em" :thickness="2" />
|
||||
<div v-if="isfinishLoading && endload">
|
||||
<CSelectUserActive></CSelectUserActive>
|
||||
<div v-if="recOrderCart" class="panel">
|
||||
<div>
|
||||
<div class="container">
|
||||
<div
|
||||
style="min-height: 100vh; display: flex; justify-content: center; align-items: center"
|
||||
>
|
||||
<q-spinner
|
||||
v-if="!endload"
|
||||
color="primary"
|
||||
size="3em"
|
||||
:thickness="2"
|
||||
/>
|
||||
<div v-if="isfinishLoading && endload">
|
||||
<CSelectUserActive></CSelectUserActive>
|
||||
<div
|
||||
v-if="recOrderCart"
|
||||
class="panel"
|
||||
>
|
||||
<div>
|
||||
<div class="container">
|
||||
<div
|
||||
class="q-pa-sm col items-start q-gutter-xs"
|
||||
v-for="(itemorder, index) in getItemsCart()"
|
||||
:key="index"
|
||||
>
|
||||
<CSingleCart
|
||||
:order="itemorder.order"
|
||||
:idOrdersCart="recOrderCart._id"
|
||||
:showall="true"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<q-separator></q-separator>
|
||||
<div
|
||||
class="q-pa-sm col items-start q-gutter-xs"
|
||||
v-for="(itemorder, index) in getItemsCart()"
|
||||
:key="index"
|
||||
class="col-6 q-mr-sm"
|
||||
style="text-align: right"
|
||||
>
|
||||
<CSingleCart
|
||||
:order="itemorder.order"
|
||||
:idOrdersCart="recOrderCart._id"
|
||||
:showall="true"
|
||||
/>
|
||||
<span class="text-grey q-mr-xs">{{ $t('ecomm.totale') }}:</span>
|
||||
<span class="text-subtitle1 q-mr-sm">€ {{ myTotalPrice() }}</span>
|
||||
</div>
|
||||
|
||||
<q-separator />
|
||||
|
||||
<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"
|
||||
/>-->
|
||||
</div>
|
||||
|
||||
<q-input
|
||||
v-if="getNumItems() > 0"
|
||||
v-model="note"
|
||||
style="min-width: 400px"
|
||||
class="q-mt-md"
|
||||
:label="$t('ecomm.note')"
|
||||
filled
|
||||
dense
|
||||
debounce="1000"
|
||||
autogrow
|
||||
@input="change_field('note')"
|
||||
>
|
||||
</q-input>
|
||||
|
||||
<div
|
||||
v-if="recOrderCart.note_ordine_gas"
|
||||
class="note_ordine_gas"
|
||||
v-html="recOrderCart.note_ordine_gas"
|
||||
></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 &&
|
||||
recOrderCart.status < shared_consts.OrderStatus.CHECKOUT_SENT
|
||||
"
|
||||
rounded
|
||||
icon="fas fa-shopping-cart"
|
||||
color="green"
|
||||
:label="$t('ecomm.completa_ord')"
|
||||
class="q-mb-sm"
|
||||
:disabled="myTotalQty() < 1"
|
||||
@click="completeOrder()"
|
||||
></q-btn>
|
||||
</div>
|
||||
<div class="center-text">
|
||||
<br />
|
||||
|
||||
<div
|
||||
class="q-ma-sm q-pa-sm text-h8 text-grey"
|
||||
v-if="globalStore && globalStore.site.ecomm.NoteExtraOnCart"
|
||||
>
|
||||
{{ globalStore.site.ecomm.NoteExtraOnCart }}
|
||||
</div>
|
||||
</div>
|
||||
<q-separator></q-separator>
|
||||
<div class="col-6 q-mr-sm" style="text-align: right">
|
||||
<span class="text-grey q-mr-xs">{{ $t('ecomm.totale') }}:</span>
|
||||
<span class="text-subtitle1 q-mr-sm">€ {{ myTotalPrice() }}</span>
|
||||
</div>
|
||||
|
||||
<q-input
|
||||
v-if="getNumItems() > 0"
|
||||
v-model="note"
|
||||
style="max-width: 400px"
|
||||
:label="$t('ecomm.note')"
|
||||
filled
|
||||
dense
|
||||
debounce="1000"
|
||||
autogrow
|
||||
@input="change_field('note')"
|
||||
>
|
||||
</q-input>
|
||||
|
||||
<div
|
||||
v-if="recOrderCart.note_ordine_gas"
|
||||
class="note_ordine_gas"
|
||||
v-html="recOrderCart.note_ordine_gas"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<q-btn
|
||||
v-if="
|
||||
recOrderCart &&
|
||||
recOrderCart.status < shared_consts.OrderStatus.CHECKOUT_SENT
|
||||
"
|
||||
rounded
|
||||
icon="fas fa-shopping-cart"
|
||||
color="green"
|
||||
:label="$t('ecomm.completa_ord')"
|
||||
class="q-mb-sm"
|
||||
:disabled="myTotalQty() < 1"
|
||||
@click="completeOrder()"
|
||||
></q-btn>
|
||||
</div>
|
||||
<div class="center-text">
|
||||
<br />
|
||||
|
||||
<div
|
||||
class="q-ma-sm q-pa-sm text-h8 text-grey"
|
||||
v-if="globalStore && globalStore.site.ecomm.NoteExtraOnCart"
|
||||
>
|
||||
{{ globalStore.site.ecomm.NoteExtraOnCart }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else style="text-align: center" class="text-grey">
|
||||
{{ $t('ecomm.carrello_vuoto') }}
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<div
|
||||
class="q-gutter-y-md column text-center q-mx-auto"
|
||||
style="width: 350px; max-width: 100%"
|
||||
>
|
||||
<q-input
|
||||
filled
|
||||
stack-label
|
||||
dense
|
||||
:label="$t('ecomm.code_add_to_cart')"
|
||||
v-model="search"
|
||||
class="q-ml-md"
|
||||
@keyup.enter="insertArticolo()"
|
||||
<div
|
||||
v-else
|
||||
style="text-align: center"
|
||||
class="text-grey"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon
|
||||
class="insert"
|
||||
name="fas fa-shopping-cart"
|
||||
color="green"
|
||||
@click="insertArticolo()"
|
||||
/>
|
||||
</template>
|
||||
</q-input>
|
||||
{{ $t('ecomm.carrello_vuoto') }}
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<div
|
||||
class="q-gutter-y-md column text-center q-mx-auto"
|
||||
style="width: 350px; max-width: 100%"
|
||||
>
|
||||
<q-input
|
||||
filled
|
||||
stack-label
|
||||
dense
|
||||
:label="$t('ecomm.code_add_to_cart')"
|
||||
v-model="search"
|
||||
class="q-ml-md"
|
||||
@keyup.enter="insertArticolo()"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon
|
||||
class="insert"
|
||||
name="fas fa-shopping-cart"
|
||||
color="green"
|
||||
@click="insertArticolo()"
|
||||
/>
|
||||
</template>
|
||||
</q-input>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="caricamentodati"
|
||||
class="overlay"
|
||||
>
|
||||
<q-spinner-hourglass
|
||||
color="primary"
|
||||
size="50px"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" src="./CCart.ts">
|
||||
</script>
|
||||
<script lang="ts" src="./CCart.ts"></script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import './CCart';
|
||||
|
||||
@@ -44,6 +44,7 @@ export default defineComponent({
|
||||
const myrec = ref(<any[string]>[])
|
||||
const oldrec = ref(<any[string]>[])
|
||||
const note = ref('')
|
||||
const codice_sconto = ref('')
|
||||
const note_per_gestore = ref('')
|
||||
const note_per_admin = ref('')
|
||||
const endload = ref(false)
|
||||
@@ -129,6 +130,7 @@ export default defineComponent({
|
||||
if (recOrderCart.value) {
|
||||
oldrec.value = recOrderCart.value
|
||||
myrec.value.note = recOrderCart.value.note!
|
||||
myrec.value.codice_sconto = recOrderCart.value.codice_sconto!
|
||||
myrec.value.note_per_gestore = recOrderCart.value.note_per_gestore!
|
||||
myrec.value.note_per_admin = recOrderCart.value.note_per_admin!
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@
|
||||
<div v-else>
|
||||
<q-field> Note: {{ myrec.note }} </q-field>
|
||||
<q-field color="red"> Note per il Gestore: {{ myrec.note_per_gestore }} </q-field>
|
||||
<q-field color="blue"> Codice Sconto: {{ myrec.codice_sconto }} </q-field>
|
||||
</div>
|
||||
|
||||
<q-input
|
||||
@@ -111,6 +112,18 @@
|
||||
@update:model-value="change_field('note_per_gestore')"
|
||||
>
|
||||
</q-input>
|
||||
<q-input
|
||||
v-if="editOn && tools.isManager() && getNumItems() > 0"
|
||||
v-model="myrec.codice_sconto"
|
||||
style="max-width: 400px"
|
||||
:label="t('ecomm.codice_sconto')"
|
||||
filled
|
||||
dense
|
||||
debounce="1000"
|
||||
autogrow
|
||||
@update:model-value="change_field('codice_sconto')"
|
||||
>
|
||||
</q-input>
|
||||
<q-input
|
||||
v-if="editOn && tools.isAdmin() && getNumItems() > 0"
|
||||
v-model="myrec.note_per_admin"
|
||||
|
||||
@@ -828,6 +828,7 @@ export default defineComponent({
|
||||
: [
|
||||
'pos',
|
||||
'image',
|
||||
'addtocart',
|
||||
'name',
|
||||
'authors',
|
||||
'isbn',
|
||||
@@ -835,7 +836,6 @@ export default defineComponent({
|
||||
'stato',
|
||||
'date_pub',
|
||||
'pagine',
|
||||
// 'trafiletto',
|
||||
'quantity',
|
||||
'prezzo',
|
||||
]
|
||||
|
||||
@@ -47,7 +47,198 @@
|
||||
.qta{
|
||||
font-size: 1.15rem;
|
||||
font-weight: bold;
|
||||
border-radius: 12px;
|
||||
padding: 8px;
|
||||
}
|
||||
.autori{
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.elimina-btn{
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
background: linear-gradient(135deg, #ff3860, #e61e4d); /*negative gradient */
|
||||
color: white;
|
||||
font-size: 1.2rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
|
||||
}
|
||||
|
||||
.quantity-btn {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
background: linear-gradient(135deg, #34c759, #2ecc71); /*positive gradient */
|
||||
&[data-gradiente="negative"] {
|
||||
background: linear-gradient(135deg, #ff3860, #e61e4d); /*negative gradient */
|
||||
}
|
||||
color: white;
|
||||
font-size: 1.2rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
|
||||
}
|
||||
|
||||
.quantity-btn:hover:not(:disabled) {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
|
||||
}
|
||||
|
||||
.quantity-btn:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.quantity-btn:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.quantity-display {
|
||||
min-width: 60px;
|
||||
text-align: center;
|
||||
font-size: 1.4rem;
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
background: #f8fafc;
|
||||
border-radius: 12px;
|
||||
padding: 12px 16px;
|
||||
border: 2px solid #e2e8f0;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.quantity-display.updating {
|
||||
transform: scale(1.1);
|
||||
border-color: #667eea;
|
||||
background: #eff6ff;
|
||||
}
|
||||
|
||||
.remove-btn {
|
||||
background: linear-gradient(135deg, #ef4444, #dc2626);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
padding: 12px 20px;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.remove-btn:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
|
||||
}
|
||||
|
||||
.cart-summary {
|
||||
background: linear-gradient(135deg, #667eea, #764ba2);
|
||||
color: white;
|
||||
border-radius: 20px;
|
||||
padding: 24px;
|
||||
margin-top: 32px;
|
||||
text-align: center;
|
||||
opacity: 1;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.cart-summary.hidden {
|
||||
opacity: 0;
|
||||
transform: translateY(20px);
|
||||
}
|
||||
|
||||
.total-amount {
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.total-items {
|
||||
opacity: 0.9;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.checkout-btn {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border: 2px solid rgba(255, 255, 255, 0.3);
|
||||
color: white;
|
||||
padding: 16px 32px;
|
||||
border-radius: 12px;
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.checkout-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.empty-cart {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
color: #6b7280;
|
||||
opacity: 0;
|
||||
transition: opacity 0.5s ease;
|
||||
}
|
||||
|
||||
.empty-cart.show {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.empty-cart i {
|
||||
font-size: 4rem;
|
||||
margin-bottom: 20px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { transform: scale(1); }
|
||||
50% { transform: scale(1.05); }
|
||||
}
|
||||
|
||||
.pulse {
|
||||
animation: pulse 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
@keyframes fadeInUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(30px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.fade-in {
|
||||
animation: fadeInUp 0.5s ease forwards;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.product-content {
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.quantity-controls {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.remove-btn {
|
||||
margin: 16px auto 0;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
import { tools } from '../../store/Modules/tools'
|
||||
import { CCardState } from '../CCardState'
|
||||
import { CCopyBtn } from '../CCopyBtn'
|
||||
import { tools } from '../../store/Modules/tools';
|
||||
import { CCardState } from '../CCardState';
|
||||
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 { CTitleBanner } from '@src/components/CTitleBanner'
|
||||
import { useProducts } from '@store/Products'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { loadRouteLocation } from 'vue-router'
|
||||
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 { CTitleBanner } from '@src/components/CTitleBanner';
|
||||
import { useProducts } from '@store/Products';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { loadRouteLocation } from 'vue-router';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CSingleCart',
|
||||
@@ -42,11 +42,11 @@ export default defineComponent({
|
||||
},
|
||||
components: { CTitleBanner, CCardState, CCopyBtn },
|
||||
setup(props, { emit }) {
|
||||
const products = useProducts()
|
||||
const order = toRef(props, 'order')
|
||||
const { t } = useI18n()
|
||||
const products = useProducts();
|
||||
const order = toRef(props, 'order');
|
||||
const { t } = useI18n();
|
||||
|
||||
const $q = useQuasar()
|
||||
const $q = useQuasar();
|
||||
|
||||
const orderQuantity = ref(<number | undefined>undefined);
|
||||
const weight = ref(<number | undefined>undefined);
|
||||
@@ -54,161 +54,179 @@ export default defineComponent({
|
||||
const orderQuantityPreordered = ref(<number | undefined>undefined);
|
||||
const orderTotalPriceProduct = ref(<number | undefined>undefined);
|
||||
|
||||
const enableQty = ref(false)
|
||||
const endload = ref(false)
|
||||
const enableQtyPreordered = ref(false)
|
||||
const enableChangeTotalPrice = ref(false)
|
||||
const enableQty = ref(false);
|
||||
const endload = ref(false);
|
||||
const enableQtyPreordered = ref(false);
|
||||
const enableChangeTotalPrice = ref(false);
|
||||
|
||||
watch(orderQuantity, (newValue: any) => {
|
||||
if (!newValue)
|
||||
order.value.quantity = 0
|
||||
else
|
||||
order.value.quantity = parseFloat(newValue);
|
||||
if (!newValue) order.value.quantity = 0;
|
||||
else order.value.quantity = parseFloat(newValue);
|
||||
|
||||
enableChangeTotalPrice.value = false
|
||||
enableChangeTotalPrice.value = false;
|
||||
});
|
||||
|
||||
watch(weight, (newValue: any) => {
|
||||
if (order.value.product) {
|
||||
if (!newValue)
|
||||
order.value.product.productInfo.weight = 0
|
||||
else
|
||||
order.value.product.productInfo.weight = parseFloat(newValue);
|
||||
if (!newValue) order.value.product.productInfo.weight = 0;
|
||||
else order.value.product.productInfo.weight = parseFloat(newValue);
|
||||
}
|
||||
enableChangeTotalPrice.value = false
|
||||
enableChangeTotalPrice.value = false;
|
||||
});
|
||||
|
||||
watch(price, (newValue: any) => {
|
||||
if (order.value) {
|
||||
if (!newValue)
|
||||
order.value.price = 0
|
||||
else
|
||||
order.value.price = parseFloat(newValue);
|
||||
if (!newValue) order.value.price = 0;
|
||||
else order.value.price = parseFloat(newValue);
|
||||
}
|
||||
enableChangeTotalPrice.value = false
|
||||
enableChangeTotalPrice.value = false;
|
||||
});
|
||||
|
||||
watch(orderQuantityPreordered, (newValue: any) => {
|
||||
if (!newValue)
|
||||
order.value.quantitypreordered = 0
|
||||
else
|
||||
order.value.quantitypreordered = parseFloat(newValue);
|
||||
if (!newValue) order.value.quantitypreordered = 0;
|
||||
else order.value.quantitypreordered = parseFloat(newValue);
|
||||
|
||||
enableChangeTotalPrice.value = false
|
||||
enableChangeTotalPrice.value = false;
|
||||
});
|
||||
|
||||
watch(orderTotalPriceProduct, (newValue: any) => {
|
||||
if (!newValue)
|
||||
order.value.TotalPriceProduct = 0
|
||||
else
|
||||
order.value.TotalPriceProduct = parseFloat(newValue);
|
||||
if (!newValue) order.value.TotalPriceProduct = 0;
|
||||
else order.value.TotalPriceProduct = parseFloat(newValue);
|
||||
});
|
||||
|
||||
watch(() => props.order.TotalPriceProduct, (newValue: any) => {
|
||||
if (!newValue)
|
||||
orderTotalPriceProduct.value = 0
|
||||
else
|
||||
orderTotalPriceProduct.value = parseFloat(newValue);
|
||||
});
|
||||
watch(
|
||||
() => props.order.TotalPriceProduct,
|
||||
(newValue: any) => {
|
||||
if (!newValue) orderTotalPriceProduct.value = 0;
|
||||
else orderTotalPriceProduct.value = parseFloat(newValue);
|
||||
}
|
||||
);
|
||||
|
||||
function myimgclass() {
|
||||
if (props.showall) {
|
||||
return 'imgNormal'
|
||||
return 'imgNormal';
|
||||
} else {
|
||||
return 'imgSmall'
|
||||
return 'imgSmall';
|
||||
}
|
||||
}
|
||||
|
||||
function qtyInCart() {
|
||||
return props.order.quantity + props.order.quantitypreordered;
|
||||
}
|
||||
|
||||
async function addsubqty(addqty: boolean, subqty: boolean) {
|
||||
if (products.isQtyAvailableByOrder(props.order)) {
|
||||
if (addqty) {
|
||||
if (props.order.quantity >= 100)
|
||||
return false
|
||||
if (props.order.quantity >= 100) return false;
|
||||
}
|
||||
|
||||
if (subqty) {
|
||||
if (props.order.quantity === 0)
|
||||
return false
|
||||
if (props.order.quantity === 0) return false;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (products.isInPreorderByOrder(props.order)) {
|
||||
if (addqty) {
|
||||
if (props.order.quantitypreordered >= 100)
|
||||
return false
|
||||
if (props.order.quantitypreordered >= 100) return false;
|
||||
}
|
||||
|
||||
if (subqty) {
|
||||
if (props.order.quantitypreordered === 0)
|
||||
return false
|
||||
if (props.order.quantitypreordered === 0) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return await products.addSubQtyToItem({
|
||||
addqty,
|
||||
subqty,
|
||||
order: props.order,
|
||||
}).then((res: any) => {
|
||||
if (res.risult) {
|
||||
if (res.myord) {
|
||||
order.value.quantity = res.myord.quantity
|
||||
order.value.quantitypreordered = res.myord.quantitypreordered
|
||||
return await products
|
||||
.addSubQtyToItem({
|
||||
addqty,
|
||||
subqty,
|
||||
order: props.order,
|
||||
})
|
||||
.then((res: any) => {
|
||||
if (res.risult) {
|
||||
if (res.myord) {
|
||||
order.value.quantity = res.myord.quantity;
|
||||
order.value.quantitypreordered = res.myord.quantitypreordered;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function isApplicatoSconto() {
|
||||
const totalipotetico = order.value.product!.price * (order.value.quantity + order.value.quantitypreordered)
|
||||
const totalipotetico =
|
||||
order.value.product!.price *
|
||||
(order.value.quantity + order.value.quantitypreordered);
|
||||
if (totalipotetico.toFixed(2) > order.value.TotalPriceProduct.toFixed(2)) {
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
|
||||
function removeFromCard() {
|
||||
products.removeFromCart({ order: order.value })
|
||||
|
||||
$q.dialog({
|
||||
title: order.value.product.productInfo.name,
|
||||
message: 'Sicuro di voler rimuovere il prodotto dal carrello?',
|
||||
ok: {
|
||||
label: 'Rimuovi',
|
||||
color: 'negative',
|
||||
rounded: true,
|
||||
},
|
||||
cancel: {
|
||||
label: 'Annulla',
|
||||
color: 'primary',
|
||||
rounded: true,
|
||||
},
|
||||
}).onOk(() => {
|
||||
products.removeFromCart({ order: order.value });
|
||||
});
|
||||
}
|
||||
|
||||
async function updateOrder(paramstoupdate: any) {
|
||||
endload.value = false
|
||||
endload.value = false;
|
||||
if (enableChangeTotalPrice.value) {
|
||||
paramstoupdate = { ...paramstoupdate, TotalPriceProduct: order.value.TotalPriceProduct }
|
||||
paramstoupdate = {
|
||||
...paramstoupdate,
|
||||
TotalPriceProduct: order.value.TotalPriceProduct,
|
||||
};
|
||||
}
|
||||
const myOrdersCart = await products.updateOrderByOrder(props.idOrdersCart, order.value._id, paramstoupdate)
|
||||
emit('update')
|
||||
mounted()
|
||||
const myOrdersCart = await products.updateOrderByOrder(
|
||||
props.idOrdersCart,
|
||||
order.value._id,
|
||||
paramstoupdate
|
||||
);
|
||||
emit('update');
|
||||
mounted();
|
||||
}
|
||||
|
||||
function getRisparmio(): string {
|
||||
return ((order.value.product!.price * order.value.quantity) - order.value.TotalPriceProduct).toFixed(2)
|
||||
return (
|
||||
order.value.product!.price * order.value.quantity -
|
||||
order.value.TotalPriceProduct
|
||||
).toFixed(2);
|
||||
}
|
||||
|
||||
function mounted() {
|
||||
endload.value = false
|
||||
weight.value = props.order.product?.productInfo.weight
|
||||
price.value = props.order.price
|
||||
endload.value = false;
|
||||
weight.value = props.order.product?.productInfo.weight;
|
||||
price.value = props.order.price;
|
||||
if (props.order.quantity !== 0) {
|
||||
orderQuantity.value = props.order.quantity
|
||||
enableQty.value = true
|
||||
orderQuantity.value = props.order.quantity;
|
||||
enableQty.value = true;
|
||||
}
|
||||
if (props.order.quantitypreordered !== 0) {
|
||||
orderQuantityPreordered.value = props.order.quantitypreordered
|
||||
enableQtyPreordered.value = true
|
||||
orderQuantityPreordered.value = props.order.quantitypreordered;
|
||||
enableQtyPreordered.value = true;
|
||||
}
|
||||
|
||||
orderTotalPriceProduct.value = props.order.TotalPriceProduct
|
||||
endload.value = true
|
||||
orderTotalPriceProduct.value = props.order.TotalPriceProduct;
|
||||
endload.value = true;
|
||||
}
|
||||
|
||||
function changeTotalPrice() {
|
||||
console.log('changeTotalPrice')
|
||||
enableChangeTotalPrice.value = true
|
||||
console.log('changeTotalPrice');
|
||||
enableChangeTotalPrice.value = true;
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
onMounted(mounted);
|
||||
|
||||
return {
|
||||
myimgclass,
|
||||
@@ -229,6 +247,7 @@ export default defineComponent({
|
||||
changeTotalPrice,
|
||||
orderTotalPriceProduct,
|
||||
endload,
|
||||
}
|
||||
qtyInCart,
|
||||
};
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
@@ -86,26 +86,30 @@
|
||||
<div class="row q-mb-xs no-wrap items-center centeritems">
|
||||
<q-btn
|
||||
v-if="showall && !nomodif && products.CanDeleteIfSub(order)"
|
||||
icon="fas fa-trash"
|
||||
color="negative"
|
||||
icon="fas fa-trash-alt"
|
||||
round
|
||||
size="xs"
|
||||
size="sm"
|
||||
class="elimina-btn"
|
||||
@click="removeFromCard"
|
||||
>
|
||||
</q-btn>
|
||||
<q-btn
|
||||
v-else-if="showall && !nomodif"
|
||||
:disable="!products.enableSubQty(order)"
|
||||
size="sm"
|
||||
icon="fas fa-cart-arrow-down"
|
||||
:color="products.enableSubQty(order) ? 'negative' : 'grey'"
|
||||
@click="addsubqty(false, true)"
|
||||
rounded
|
||||
:label="
|
||||
<!--
|
||||
:label="
|
||||
t('products.subcart', {
|
||||
qta: products.qtaNextSub(order, order.product),
|
||||
})
|
||||
"
|
||||
-->
|
||||
<q-btn
|
||||
v-else-if="!nomodif"
|
||||
:disable="!products.enableSubQty(order)"
|
||||
size="sm"
|
||||
class="quantity-btn"
|
||||
data-gradiente="negative"
|
||||
:icon="qtyInCart() === 1 ? 'fas fa-trash': 'fas fa-minus'"
|
||||
:color="products.enableSubQty(order) ? undefined : 'grey'"
|
||||
@click="qtyInCart() === 1 ? removeFromCard(): addsubqty(false, true)"
|
||||
rounded
|
||||
></q-btn>
|
||||
<div v-if="editmode">
|
||||
<q-input
|
||||
@@ -115,6 +119,7 @@
|
||||
debounce="500"
|
||||
borderless
|
||||
rounded
|
||||
class="quantity-display"
|
||||
dense
|
||||
:label="t('products.quantity')"
|
||||
></q-input>
|
||||
@@ -124,6 +129,7 @@
|
||||
autofocus
|
||||
debounce="500"
|
||||
borderless
|
||||
class="quantity-display"
|
||||
rounded
|
||||
densep
|
||||
:label="t('ecomm.preord')"
|
||||
@@ -159,24 +165,25 @@
|
||||
</q-btn>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="showall"
|
||||
v-else
|
||||
:class="`q-mx-sm text-blue-14 qta`"
|
||||
>
|
||||
{{ order.quantity + order.quantitypreordered }}
|
||||
</div>
|
||||
|
||||
<q-btn
|
||||
v-if="showall && !nomodif"
|
||||
icon-right="fas fa-cart-plus"
|
||||
color="positive"
|
||||
:disable="!products.enableAddQty(order, order.product)"
|
||||
rounded
|
||||
size="sm"
|
||||
:label="
|
||||
<!-- :label="
|
||||
t('products.addcart', {
|
||||
qta: products.qtaNextAdd(order, order.product),
|
||||
})
|
||||
"
|
||||
-->
|
||||
<q-btn
|
||||
v-if="!nomodif"
|
||||
icon-right="fas fa-plus"
|
||||
class="quantity-btn"
|
||||
:disable="!products.enableAddQty(order, order.product)"
|
||||
rounded
|
||||
size="sm"
|
||||
@click="addsubqty(true, false)"
|
||||
>
|
||||
</q-btn>
|
||||
@@ -229,7 +236,7 @@
|
||||
</div>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<!--<q-item-section side>
|
||||
<q-item-label>
|
||||
<div class="col-2">
|
||||
<q-btn
|
||||
@@ -243,7 +250,7 @@
|
||||
</q-btn>
|
||||
</div>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item-section>-->
|
||||
|
||||
<!--<q-item-section side top>
|
||||
<q-item-label caption>meta</q-item-label>
|
||||
|
||||
@@ -2597,3 +2597,16 @@ body.body--dark {
|
||||
font-size: 12px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(255, 255, 255, 0.7); /* Sfondo semi-trasparente */
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 9999;
|
||||
}
|
||||
@@ -187,7 +187,8 @@ export interface IOrder {
|
||||
date_payment?: Date
|
||||
date_shipping?: Date
|
||||
date_delivered?: Date
|
||||
notes?: string
|
||||
note?: string
|
||||
codice_sconto?: string
|
||||
modify_at?: Date
|
||||
}
|
||||
|
||||
@@ -382,6 +383,7 @@ export interface IScontistica {
|
||||
qta: number,
|
||||
perc_sconto: number,
|
||||
price: number,
|
||||
applica: number,
|
||||
comulativo: boolean,
|
||||
}
|
||||
|
||||
@@ -439,6 +441,7 @@ export interface IOrderCart {
|
||||
date_ricevuto?: Date
|
||||
created_at?: Date
|
||||
note: string
|
||||
codice_sconto?: string
|
||||
note_per_gestore: string
|
||||
note_per_admin: string
|
||||
note_ordine_gas: string
|
||||
|
||||
@@ -137,6 +137,7 @@ const msg_it = {
|
||||
price: 'Prezzo',
|
||||
qta: 'Quantita',
|
||||
comulativo: 'Cumulativo',
|
||||
applica: 'Applica',
|
||||
},
|
||||
otherpages: {
|
||||
myactivities: 'Attività',
|
||||
@@ -1871,12 +1872,17 @@ const msg_it = {
|
||||
ecomm: {
|
||||
already_in_cart: 'Questo prodotto è stato già aggiunto al Carrello',
|
||||
area_personale: 'Per poter fare un Ordine occorre essere Registrati ed accedere con le proprie credenziali (username e password)',
|
||||
codice_sconto: 'Aggiungi il Codice Sconto',
|
||||
applica_sconto: 'Applica',
|
||||
rimuovi_sconto: 'Rimuovi',
|
||||
sconto_appl: 'Sconto Applicato',
|
||||
prodotto: 'prodotto',
|
||||
prodotti: 'prodotti',
|
||||
prod_sul_carrello: '{qty} {strprod} sul Carrello (Totale: {tot})',
|
||||
prodotto_tolto: 'Il prodotto è stato tolto dal Carrello',
|
||||
error_cart: 'Errore durante l\'inserimento del prodotto sul carrello, riprovare.',
|
||||
completa_ord: 'Invia l\'Ordine',
|
||||
esporta_csv:'Esporta Lista',
|
||||
conferma_acq: 'Confermare l\'ordine di acquisto di {qty} prodotti ?',
|
||||
order: 'Ordine',
|
||||
ord_confirmed: 'Ordine Confermato',
|
||||
|
||||
@@ -696,6 +696,7 @@ export const getcolorderscart = [
|
||||
AddCol({ name: 'items', label_trans: 'order.items' }),
|
||||
AddCol({ name: 'userId', label_trans: 'order.users', fieldtype: costanti.FieldType.select, jointable: 'users' }),
|
||||
AddCol({ name: 'note', label_trans: 'order.note' }),
|
||||
AddCol({ name: 'codice_sconto', label_trans: 'order.codice_sconto' }),
|
||||
AddCol({ name: 'confermato', label_trans: 'order.confermato', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'date_confermato', label_trans: 'order.date_confermato', fieldtype: costanti.FieldType.date }),
|
||||
AddCol({ name: 'consegnato', label_trans: 'order.consegnato', fieldtype: costanti.FieldType.boolean }),
|
||||
@@ -892,6 +893,7 @@ export const colTableScontistica = [
|
||||
AddCol({ name: 'qta', label_trans: 'scontistica.qta', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'perc_sconto', label_trans: 'scontistica.perc_sconto', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'price', label_trans: 'products.price', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'applica', label_trans: 'products.applica', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'comulativo', label_trans: 'products.comulativo', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol(DeleteRec),
|
||||
AddCol(DuplicateRec),
|
||||
|
||||
@@ -61,6 +61,7 @@ function getRecordOrdersCartEmpty(): IOrderCart {
|
||||
ricevuto: false,
|
||||
note: '',
|
||||
note_per_gestore: '',
|
||||
codice_sconto:'',
|
||||
note_per_admin: '',
|
||||
note_ordine_gas: '',
|
||||
};
|
||||
@@ -1374,10 +1375,12 @@ export const useProducts = defineStore('Products', {
|
||||
cart_id,
|
||||
status,
|
||||
note,
|
||||
codice_sconto,
|
||||
}: {
|
||||
cart_id: string;
|
||||
status: number;
|
||||
note: string;
|
||||
codice_sconto: string;
|
||||
}) {
|
||||
const userStore = useUserStore();
|
||||
const globalStore = useGlobalStore();
|
||||
@@ -1395,6 +1398,7 @@ export const useProducts = defineStore('Products', {
|
||||
cart_id,
|
||||
status,
|
||||
note,
|
||||
codice_sconto,
|
||||
options: this.getOptions(true),
|
||||
}
|
||||
)
|
||||
@@ -1494,6 +1498,49 @@ export const useProducts = defineStore('Products', {
|
||||
|
||||
return ris;
|
||||
},
|
||||
|
||||
async ApplicaSconto({
|
||||
cart_id,
|
||||
codice_sconto,
|
||||
}: {
|
||||
cart_id: string;
|
||||
codice_sconto: number;
|
||||
}) {
|
||||
const userStore = useUserStore();
|
||||
const globalStore = useGlobalStore();
|
||||
|
||||
if (!globalStore.site.confpages.enableEcommerce) return null;
|
||||
|
||||
let ris = null;
|
||||
|
||||
ris = await Api.SendReq(
|
||||
'/cart/' + this.userActive._id + '/app_sc',
|
||||
'POST',
|
||||
{
|
||||
cart_id,
|
||||
code: codice_sconto,
|
||||
}
|
||||
)
|
||||
.then((res) => {
|
||||
this.updateDataProduct(res);
|
||||
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error ApplicaSconto', error);
|
||||
userStore.setErrorCatch(error);
|
||||
return new Types.AxiosError(
|
||||
serv_constants.RIS_CODE_ERR,
|
||||
null,
|
||||
toolsext.ERR_GENERICO,
|
||||
error
|
||||
);
|
||||
});
|
||||
|
||||
return ris;
|
||||
},
|
||||
|
||||
|
||||
async addtoCartBase({
|
||||
$q,
|
||||
t,
|
||||
|
||||
@@ -674,11 +674,11 @@ export default defineComponent({
|
||||
// console.log('row', serverData.value)
|
||||
// console.log('mycolumns.value', mycolumns.value)
|
||||
// naive encoding to csv format
|
||||
const content = [columns_listafiltrati.value.map((col: any) => (col.label))].concat(
|
||||
listatotali.value.map((row: any) => columns_listafiltrati.value.map((col: any) => (
|
||||
row[col.field]
|
||||
)).join(','))
|
||||
).join('\r\n')
|
||||
const headers = columns_listafiltrati.value.map((col: any) => col.label);
|
||||
const rows = listatotali.value.map((row: any) =>
|
||||
columns_listafiltrati.value.map((col: any) => row[col.field]).join(',')
|
||||
);
|
||||
const content = [headers.join(',')].concat(rows).join('\r\n');
|
||||
|
||||
const status = exportFile(
|
||||
'lista-totali-' + productStore.getGasordineNameById(storeGasordine.value) + '_' + tools.getstrYYMMDDDate(tools.getDateNow()) + '.csv',
|
||||
|
||||
@@ -447,6 +447,9 @@
|
||||
<div v-if="props.row.note" class="note">
|
||||
Note: {{ props.row.note }}
|
||||
</div>
|
||||
<div v-if="props.row.codice_sconto" class="codice_sconto">
|
||||
Codice Sconto: {{ props.row.codice_sconto }}
|
||||
</div>
|
||||
<div v-if="props.row.note_per_gestore" class="note">
|
||||
Note per Gestore: {{ props.row.note_per_gestore }}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user