- 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>