aggiornamento product

This commit is contained in:
Surya Paolo
2023-12-10 15:15:27 +01:00
parent 59c03f28f2
commit 1ce6d765ee
10 changed files with 169 additions and 108 deletions

View File

@@ -1,4 +1,4 @@
import { defineComponent, ref, toRef, computed, PropType, watch } from 'vue'
import { defineComponent, ref, toRef, computed, PropType, watch, onMounted } from 'vue'
import { useI18n } from '@src/boot/i18n'
import { useUserStore } from '@store/UserStore'
import { useGlobalStore } from '@store/globalStore'
@@ -42,7 +42,7 @@ export default defineComponent({
const myorder = ref(<IOrder>{
idapp: process.env.APP_ID,
quantity: 1,
quantity: 0,
idStorehouse: ''
})
@@ -50,6 +50,12 @@ export default defineComponent({
const storeSelected = ref('')
const valoriopt = computed(() => (item: any, addall: boolean, addnone: boolean) => {
// console.log('valoriopt', item.table)
return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter)
})
function iconWhishlist(order: IProduct) {
if (true) {
return 'far fa-heart'
@@ -98,105 +104,111 @@ export default defineComponent({
else
tools.showPositiveNotif($q, msg)
})
})
}
function getnumstore() {
if (myproduct.value.storehouses)
return myproduct.value.storehouses.length
else
return 0
}
function getnumstore() {
if (myproduct.value.storehouses)
return myproduct.value.storehouses.length
else
return 0
}
function getSingleStorehouse() {
const mystore = myproduct.value.storehouses[0]
if (mystore)
return mystore.name + ' (' + mystore.city + ')'
else
return ''
}
function getSingleStorehouse() {
const mystore = myproduct.value.storehouses[0]
if (mystore)
return mystore.name + ' (' + mystore.city + ')'
else
return ''
}
function getStorehouses() {
function getStorehouses() {
const myarr: any = []
let ind = 1
myproduct.value.storehouses.forEach((store) => {
myarr.push(
{
id: ind,
label: store.name + ' (' + store.city + ')',
value: store._id
const myarr: any = []
let ind = 1
myproduct.value.storehouses.forEach((store) => {
myarr.push(
{
id: ind,
label: store.name + ' (' + store.city + ')',
value: store._id
})
ind++
})
ind++
})
// console.log('arraystore', myarr)
return myarr
}
// console.log('arraystore', myarr)
return myarr
}
function checkifCartDisable() {
return !myorder.value.idStorehouse
}
function checkifCartDisable() {
return !myorder.value.idStorehouse
}
watch(() => props.code, (newval, oldval) => {
console.log('change code')
load()
})
watch(() => props.code, (newval, oldval) => {
console.log('change code')
load()
})
watch(() => storeSelected.value, (newval, oldval) => {
myorder.value.idStorehouse = newval
})
watch(() => storeSelected.value, (newval, oldval) => {
myorder.value.idStorehouse = newval
})
async function load() {
// console.log('created Cproductcard', code)
if (props.code) {
myproduct.value = await products.loadProduct({ code: props.code })
} else {
// @ts-ignore
myproduct.value = props.product
}
async function load() {
// console.log('created Cproductcard', code)
if (props.code) {
myproduct.value = await products.loadProduct({ code: props.code })
} else {
// @ts-ignore
myproduct.value = props.product
}
console.log('myproduct', myproduct, 'product', props.product)
console.log('myproduct', myproduct, 'product', props.product)
if (!!myproduct.value) {
if (myproduct.value.storehouses.length === 1) {
myorder.value.idStorehouse = myproduct.value.storehouses[0]._id
}
}
if (!!myproduct.value) {
if (myproduct.value.storehouses.length === 1) {
myorder.value.idStorehouse = myproduct.value.storehouses[0]._id
const ord = products.getOrderProductInCart(myproduct.value._id)
if (ord) {
myorder.value.quantity = ord.quantity
}
}
function getmycardcl() {
return (props.complete) ? 'my-card-big' : 'my-card'
}
function getclimg() {
return (props.complete) ? 'myimgtitle centermydiv' : 'centermydiv'
}
function enableSubQty() {
return myorder.value ? myorder.value.quantity > 0 : true
}
onMounted(load)
return {
decqty,
addqty,
addtoCart,
iconWhishlist,
getmycardcl,
getclimg,
getnumstore,
getSingleStorehouse,
getStorehouses,
checkifCartDisable,
myproduct,
myorder,
tools,
t,
storeSelected,
enableSubQty,
}
}
}
function getmycardcl() {
return (props.complete) ? 'my-card-big' : 'my-card'
}
function getclimg() {
return (props.complete) ? 'myimgtitle centermydiv' : 'centermydiv'
}
function enableSubQty() {
return myorder.value ? myorder.value.quantity > 0 : true
}
load()
return {
decqty,
addqty,
addtoCart,
iconWhishlist,
getmycardcl,
getclimg,
getnumstore,
getSingleStorehouse,
getStorehouses,
checkifCartDisable,
myproduct,
myorder,
tools,
t,
storeSelected,
enableSubQty,
}
}
})