From 4ac6cacf199ea7a782d1f14f17f7735d6b675ca0 Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Mon, 11 Dec 2023 16:51:51 +0100 Subject: [PATCH] aa1 --- src/components/CProductCard/CProductCard.scss | 13 ++ src/components/CProductCard/CProductCard.ts | 38 +++- src/components/CProductCard/CProductCard.vue | 191 ++++++++---------- src/css/app.scss | 15 ++ src/layouts/menuone/menuOne.scss | 2 +- src/model/Products.ts | 4 +- src/statics/lang/it.js | 2 + 7 files changed, 154 insertions(+), 111 deletions(-) diff --git a/src/components/CProductCard/CProductCard.scss b/src/components/CProductCard/CProductCard.scss index f1663553..3239f26e 100755 --- a/src/components/CProductCard/CProductCard.scss +++ b/src/components/CProductCard/CProductCard.scss @@ -10,3 +10,16 @@ place-content: center; } +.prod_price{ + font-size: 1.25rem; +} + +.prod_disp{ + font-size: 1.2rem; +} + +.prod_qtywarn{ + padding-left: 10px; + font-size: 1rem; + color: grey; +} \ No newline at end of file diff --git a/src/components/CProductCard/CProductCard.ts b/src/components/CProductCard/CProductCard.ts index 80b9b6a3..3e67641b 100755 --- a/src/components/CProductCard/CProductCard.ts +++ b/src/components/CProductCard/CProductCard.ts @@ -115,11 +115,15 @@ export default defineComponent({ } function getSingleStorehouse() { - const mystore = myproduct.value.storehouses[0] - if (mystore) - return mystore.name + ' (' + mystore.city + ')' - else + try { + const mystore = myproduct.value.storehouses[0] + if (mystore) + return mystore.name + ' (' + mystore.city + ')' + else + return '' + } catch (e) { return '' + } } function getStorehouses() { @@ -145,6 +149,23 @@ export default defineComponent({ return !myorder.value.idStorehouse } + function updateQtyAvailable() { + myproduct.value.quantityAvailable = myproduct.value.stockQty - myorder.value.quantity + } + + function getQtyAvailable() { + updateQtyAvailable() + let qty = myproduct.value.quantityAvailable + return qty + } + + function getQtyWarn() { + if (myorder.value.quantity > 0){ + return t('ecomm.di_cui_x_in_carrello', {qty: myorder.value.quantity}) + } + return '' + } + watch(() => props.code, (newval, oldval) => { console.log('change code') load() @@ -179,7 +200,7 @@ export default defineComponent({ } function getmycardcl() { - return (props.complete) ? 'my-card-big' : 'my-card' + return (props.complete) ? 'my-card-big' : 'my-card-prod' } function getclimg() { @@ -190,6 +211,10 @@ export default defineComponent({ return myorder.value ? myorder.value.quantity > 0 : true } + function enableAddQty() { + return getQtyAvailable() > 0 + } + onMounted(load) return { @@ -209,6 +234,9 @@ export default defineComponent({ t, storeSelected, enableSubQty, + enableAddQty, + getQtyAvailable, + getQtyWarn, } } }) diff --git a/src/components/CProductCard/CProductCard.vue b/src/components/CProductCard/CProductCard.vue index 82378323..7c1ba4b1 100755 --- a/src/components/CProductCard/CProductCard.vue +++ b/src/components/CProductCard/CProductCard.vue @@ -1,79 +1,100 @@