diff --git a/src/components/CProductCard/CProductCard.scss b/src/components/CProductCard/CProductCard.scss index 1d173abc..5a25d607 100755 --- a/src/components/CProductCard/CProductCard.scss +++ b/src/components/CProductCard/CProductCard.scss @@ -16,6 +16,7 @@ .prod_disp { font-size: 1.2rem; + font-size: 1.2rem; } diff --git a/src/components/CProductCard/CProductCard.ts b/src/components/CProductCard/CProductCard.ts index 9975d1da..edaa2af5 100755 --- a/src/components/CProductCard/CProductCard.ts +++ b/src/components/CProductCard/CProductCard.ts @@ -24,7 +24,7 @@ export default defineComponent({ required: false, default: null, }, - code: { + id: { type: String, required: false, default: '', @@ -58,7 +58,9 @@ export default defineComponent({ quantity: 0, quantitypreordered: 0, idStorehouse: '', - idProvider: '' + idGasordine: '', + storehouse: {}, + gasordine: {}, }) const storeSelected = ref('') @@ -97,7 +99,7 @@ export default defineComponent({ return false } - const ris = await products.addtoCartBase({ $q, t, code: myproduct.value.code!, order: myorder, addqty: add }) + const ris = await products.addtoCartBase({ $q, t, id: myproduct.value._id, order: myorder, addqty: add }) updateproduct() if (ris && ris.myord) { @@ -140,7 +142,7 @@ export default defineComponent({ } function updateproduct() { - myproduct.value = products.getProductByCode(props.code) + myproduct.value = products.getProductById(props.id) // products.updateQuantityAvailable(myproduct.value._id) } @@ -214,8 +216,8 @@ export default defineComponent({ return '' } - watch(() => props.code, (newval, oldval) => { - console.log('change code') + watch(() => props.id, (newval, oldval) => { + // console.log('change code') load() }) @@ -236,6 +238,7 @@ export default defineComponent({ if (!!myproduct.value) { if (myproduct.value.storehouses && myproduct.value.storehouses.length === 1) { + // Se solo 1 presente, metto fisso l'unico negozio ! myorder.idStorehouse = myproduct.value.storehouses[0]._id } @@ -252,6 +255,10 @@ export default defineComponent({ if (ord.idGasordine) gasordineSelected.value = ord.idGasordine! + // Seleziona il Negozio che avevo già scelto nell'ordine ! + if (ord.idStorehouse) + storeSelected.value = ord.idStorehouse + } } @@ -274,13 +281,49 @@ export default defineComponent({ function enableAddQty() { if (site.value.ecomm && site.value.ecomm.enablePreOrders) { - return getQtyBookableAvailable() > 0 || getQtyAvailable() > 0 + return (getQtyBookableAvailable() > 0 + && (myproduct.value.maxBookableQty === 0 + || (myorder.quantitypreordered + 1 < myproduct.value.maxBookableQty)) + ) + || (getQtyAvailable() > 0) + && (myproduct.value.maxBookableQty === 0 + || (myorder.quantity + 1 < myproduct.value.maxBookableQty )) + } else { - return getQtyAvailable() > 0 + return (getQtyAvailable() > 0) + && (myproduct.value.maxBookableQty === 0 + || (myorder.quantity + 1 < myproduct.value.maxBookableQty )) } } + function qtaNextAdd() { + let step = 1 + if (getQtyAvailable() > 0) { + if (myorder.quantity === 0) + step = myproduct.value.minBuyQty | 1 + } else { + if (myorder.quantitypreordered === 0) + step = myproduct.value.minBuyQty | 1 + } + + return step + } + + function qtaNextSub() { + let step = 1 + let minqta = myproduct.value.minBuyQty | 1 + if (getQtyAvailable() > 0) { + if (myorder.quantity === minqta) + step = minqta + } else { + if (myorder.quantitypreordered === minqta) + step = minqta + } + + return step + } + function visuListDisponibili() { openlistorders.value = true sumval.value = products.getSumQtyOrderProductInOrdersCart(myproduct.value._id) @@ -336,6 +379,8 @@ export default defineComponent({ listord, sumval, getGasordines, + qtaNextAdd, + qtaNextSub, } } }) diff --git a/src/components/CProductCard/CProductCard.vue b/src/components/CProductCard/CProductCard.vue index 56b44ce0..a49af567 100755 --- a/src/components/CProductCard/CProductCard.vue +++ b/src/components/CProductCard/CProductCard.vue @@ -2,10 +2,14 @@
- + @@ -18,22 +22,25 @@ icon="fas fa-info" class="absolute semi-transparent" style="top: 0; right: 12px; transform: translateY(-50%)" - :to="`/product/` + myproduct.code" + :to="`/product/` + myproduct._id + '/' + cosa" />
- {{ myproduct.name }} + {{ myproduct.productInfo.name }}
-   {{ $t('ecomm.codice') }}: {{ myproduct.code }} +   {{ t('ecomm.codice') }}: {{ myproduct.productInfo.code }}
- +
- +
@@ -66,20 +73,25 @@
- + - + {{ t('products.weight') }} - - {{ myproduct.weight }} - {{ tools.getUnitsMeasure(myproduct.unit, true) }} + {{ myproduct.productInfo.weight }} + {{ + tools.getUnitsMeasure(myproduct.productInfo.unit, true) + }} @@ -93,8 +105,14 @@ {{ t('products.gasordine') }} - + {{ - $t('ecomm.qta_in_attesa', { + t('ecomm.qta_in_attesa', { qty: myproduct.QuantitaOrdinateInAttesa, }) }} @@ -209,7 +227,7 @@ " > {{ - $t('ecomm.qta_prenotate_in_attesa', { + t('ecomm.qta_prenotate_in_attesa', { qty: myproduct.QuantitaPrenotateInAttesa, }) }} @@ -255,7 +273,7 @@ :disable="checkifCartDisable() || !enableSubQty()" rounded size="md" - :label="t('products.subcart', { qta: 1 })" + :label="t('products.subcart', { qta: qtaNextSub() })" @click="addtoCart(false)" > @@ -279,7 +297,7 @@ :disable="checkifCartDisable() || !enableAddQty()" rounded size="md" - :label="t('products.addcart', { qta: 1 })" + :label="t('products.addcart', { qta: qtaNextAdd() })" @click="addtoCart(true)" > @@ -291,7 +309,7 @@ rounded icon="fas fa-shopping-cart" color="primary" - :label="$t('ecomm.btn_cassa')" + :label="t('ecomm.btn_cassa')" class="q-mb-sm" to="/checkout" > @@ -306,7 +324,7 @@ - {{ t('ecomm.listaord') }} - {{ myproduct.name }} + {{ t('ecomm.listaord') }} - {{ myproduct.productInfo.name }} diff --git a/src/components/CSingleCart/CSingleCart.ts b/src/components/CSingleCart/CSingleCart.ts index 4dc56e03..569091ed 100755 --- a/src/components/CSingleCart/CSingleCart.ts +++ b/src/components/CSingleCart/CSingleCart.ts @@ -6,6 +6,8 @@ import { IOperators, IOrder, IProduct } from '@src/model' import { defineComponent, PropType, toRef } from 'vue' import { CTitleBanner } from '@src/components/CTitleBanner' import { useProducts } from '@store/Products' +import { useI18n } from '@src/boot/i18n' +import { useQuasar } from 'quasar' export default defineComponent({ @@ -30,6 +32,9 @@ export default defineComponent({ setup(props) { const products = useProducts() const order = toRef(props, 'order') + const { t } = useI18n() + + const $q = useQuasar() function myimgclass() { if (props.showall) { @@ -71,14 +76,16 @@ export default defineComponent({ order: props.order, }).then((res: any) => { if (res.risult) { - order.value.quantity = res.myord.quantity - order.value.quantitypreordered = res.myord.quantitypreordered + if (res.myord) { + order.value.quantity = res.myord.quantity + order.value.quantitypreordered = res.myord.quantitypreordered + } } }) } function isApplicatoSconto() { - const totalipotetico = order.value.price * (order.value.quantity + order.value.quantitypreordered) + const totalipotetico = order.value.product!.price * (order.value.quantity + order.value.quantitypreordered) if (totalipotetico > order.value.TotalPriceProduct) { return true } @@ -89,8 +96,8 @@ export default defineComponent({ products.removeFromCart({ order: order.value }) } - function getRisparmio(): string { - return ((order.value.price * order.value.quantity) - order.value.TotalPriceProduct).toFixed(2) + function getRisparmio(): string { + return ((order.value.product!.price * order.value.quantity) - order.value.TotalPriceProduct).toFixed(2) } return { @@ -101,6 +108,7 @@ export default defineComponent({ getRisparmio, tools, products, + t, } }, }) diff --git a/src/components/CSingleCart/CSingleCart.vue b/src/components/CSingleCart/CSingleCart.vue index 70973f2b..d9344c49 100755 --- a/src/components/CSingleCart/CSingleCart.vue +++ b/src/components/CSingleCart/CSingleCart.vue @@ -3,9 +3,9 @@
@@ -14,7 +14,7 @@
{{ products.getSingleGasordine(order, true) }}
- {{ order.product.name }} + {{ order.product.productInfo.name }}