- Categorie
- ProductInfo
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user