- Categorie

- ProductInfo
This commit is contained in:
Surya Paolo
2023-12-27 02:58:23 +01:00
parent c27c293fbf
commit 6be8ccc906
30 changed files with 612 additions and 198 deletions

View File

@@ -16,6 +16,7 @@
.prod_disp {
font-size: 1.2rem;
font-size: 1.2rem;
}

View File

@@ -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,
}
}
})

View File

@@ -2,10 +2,14 @@
<div class="q-pa-md row items-start q-gutter-md">
<q-spinner v-if="!endload" color="primary" size="3em" :thickness="2" />
<q-card :class="getmycardcl()" v-if="!!myproduct && endload" bordered>
<q-card
:class="getmycardcl()"
v-if="!!myproduct && endload && !!myproduct.productInfo"
bordered
>
<q-img
:src="`` + myproduct.img"
:alt="myproduct.name"
:src="`` + myproduct.productInfo.img"
:alt="myproduct.productInfo.name"
:class="getclimgproduct()"
></q-img>
@@ -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"
/>
<div class="row items-center centeritems">
<div class="text-h7 boldhigh">
{{ myproduct.name }}
{{ myproduct.productInfo.name }}
</div>
<div class="product_code">
&nbsp; {{ $t('ecomm.codice') }}: {{ myproduct.code }}
&nbsp; {{ t('ecomm.codice') }}: {{ myproduct.productInfo.code }}
</div>
</div>
</q-item>
<q-item v-if="complete">
<q-item v-if="complete && myproduct.productInfo.description">
<div class="row items-center">
<div class="text-title text-grey-9">
<span class="text-grey-7" v-html="myproduct.description"></span>
<span
class="text-grey-7"
v-html="myproduct.productInfo.description"
></span>
</div>
</div>
</q-item>
@@ -66,20 +73,25 @@
</div>
</q-item-label>
</q-item-section>
<q-item-section avatar v-if="myproduct.weight">
<q-item-section avatar v-if="myproduct.productInfo.weight">
<q-icon
name="fas fa-balance-scale"
style="padding-right: 16px !important"
/>
</q-item-section>
<q-item-section v-if="myproduct.weight">
<q-item-section v-if="myproduct.productInfo.weight">
<q-item-label>
{{ t('products.weight') }}
</q-item-label>
<q-item-label>
<span class="text-black q-ml-xs text-h8" v-if="myproduct.unit">
{{ myproduct.weight }}
{{ tools.getUnitsMeasure(myproduct.unit, true) }}</span
<span
class="text-black q-ml-xs text-h8"
v-if="myproduct.productInfo.unit"
>
{{ myproduct.productInfo.weight }}
{{
tools.getUnitsMeasure(myproduct.productInfo.unit, true)
}}</span
>
</q-item-label>
</q-item-section>
@@ -93,8 +105,14 @@
<q-item-label>
{{ t('products.gasordine') }}
</q-item-label>
<q-item-label
v-if="(tools.isArray(myproduct.gasordines) && myproduct.gasordines.length > 1) && (!myorder.idGasordine || ((myorder.quantity + myorder.quantitypreordered) === 0 ))">
<q-item-label
v-if="
tools.isArray(myproduct.gasordines) &&
myproduct.gasordines.length > 1 &&
(!myorder.idGasordine ||
myorder.quantity + myorder.quantitypreordered === 0)
"
>
<q-select
:behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
outlined
@@ -171,7 +189,7 @@
"
>
{{
$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)"
>
</q-btn>
@@ -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)"
>
</q-btn>
@@ -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"
></q-btn>
@@ -306,7 +324,7 @@
<q-card class="dialog_card">
<q-toolbar class="bg-primary text-white">
<q-toolbar-title>
{{ t('ecomm.listaord') }} - {{ myproduct.name }}
{{ t('ecomm.listaord') }} - {{ myproduct.productInfo.name }}
</q-toolbar-title>
<q-btn flat round color="white" icon="close" v-close-popup></q-btn>
</q-toolbar>

View File

@@ -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,
}
},
})

View File

@@ -3,9 +3,9 @@
<div v-if="order.product" class="row items-center justify-evenly no-wrap">
<div class="col-2 text-h6 ellipsis">
<q-img
v-if="order.product && order.product.img"
:src="`` + order.product.img"
:alt="order.product.name"
v-if="order.product && order.product.productInfo.img"
:src="`` + order.product.productInfo.img"
:alt="order.product.productInfo.name"
:class="myimgclass"
>
</q-img>
@@ -14,7 +14,7 @@
<div v-if="order.idGasordine" class="gasordine">
{{ products.getSingleGasordine(order, true) }}<br>
</div>
{{ order.product.name }}
{{ order.product.productInfo.name }}
<!--<div v-if="showalle">
<br /><span class="text-grey">{{ order.product.description }}</span>
@@ -35,7 +35,7 @@
{{ order.quantity }}
</div>
<div v-if="order.quantity > 0 && order.quantitypreordered > 0">
+ {{ $t('ecomm.preord') }}:
+ {{ t('ecomm.preord') }}:
</div>
<div
@@ -55,10 +55,10 @@
</div>
<div
class="text-black q-ml-xs text-h8 text-center"
v-if="order.product.unit"
v-if="order.product.productInfo.unit"
>
{{ tools.getWeightTotalByOrder(order) }}
{{ tools.getUnitsMeasure(order.product.unit, true) }}
{{ tools.getUnitsMeasure(order.product.productInfo.unit, true) }}
</div>
</div>
<div class="col-2 no-wrap text-subtitle3_short q-mr-sm">