aggiornamento visualizzazione Ordini e Carrello
This commit is contained in:
@@ -27,12 +27,12 @@ export default defineComponent({
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n();
|
||||
|
||||
const mycart = ref(<ICart>{})
|
||||
const mycart = ref(<ICart>{})
|
||||
const myrec = ref(<any[string]>[])
|
||||
const oldrec = ref(<any[string]>[])
|
||||
const note = ref('')
|
||||
const statusnow = ref(shared_consts.OrderStatus.NONE)
|
||||
|
||||
|
||||
function mounted() {
|
||||
// Inizializza
|
||||
load()
|
||||
@@ -42,7 +42,7 @@ export default defineComponent({
|
||||
const cart = productStore.getCart()
|
||||
return cart.items || null
|
||||
}
|
||||
|
||||
|
||||
function getNumItems(): number {
|
||||
const cart = productStore.getCart()
|
||||
if (!!cart.items)
|
||||
@@ -50,30 +50,30 @@ export default defineComponent({
|
||||
else
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
function getCart(): ICart {
|
||||
return productStore.getCart()
|
||||
}
|
||||
|
||||
|
||||
function getNote() {
|
||||
const cart = productStore.getCart()
|
||||
return cart.note
|
||||
}
|
||||
|
||||
|
||||
function change_field(fieldname: string) {
|
||||
if (myrec.value[fieldname] !== oldrec.value[fieldname]) {
|
||||
myrec.value[fieldname] = oldrec.value[fieldname]
|
||||
|
||||
|
||||
const mydata = {
|
||||
[fieldname]: myrec.value[fieldname]
|
||||
}
|
||||
|
||||
|
||||
const aggiorna = fieldname !== 'status'
|
||||
tools.saveFieldToServer($q, 'carts', mycart.value._id, mydata, aggiorna)
|
||||
oldrec.value[fieldname] = myrec.value[fieldname]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function myTotalPrice(): string {
|
||||
if (productStore.cart && productStore.cart.totalPrice) {
|
||||
return productStore.cart.totalPrice.toFixed(2)
|
||||
@@ -81,7 +81,7 @@ export default defineComponent({
|
||||
return '0'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function myTotalQty(): number {
|
||||
if (productStore.cart) {
|
||||
return productStore.cart.totalQty!
|
||||
@@ -89,7 +89,7 @@ export default defineComponent({
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function load() {
|
||||
mycart.value = getCart()
|
||||
myrec.value = Object.keys(mycart)
|
||||
@@ -98,45 +98,45 @@ export default defineComponent({
|
||||
|
||||
if (mycart.value)
|
||||
statusnow.value = await productStore.UpdateStatusCart({ cart_id: mycart.value._id, status: 0 })
|
||||
|
||||
|
||||
console.log('myrec', myrec.value)
|
||||
}
|
||||
|
||||
|
||||
function CanBeShipped() {
|
||||
return productStore.cart.items ? productStore.cart.items.filter((rec: any) => rec.order.product.canBeShipped).length : false
|
||||
}
|
||||
|
||||
|
||||
function CanBeBuyOnline() {
|
||||
return productStore.cart.items ? productStore.cart.items.filter((rec: any) => rec.order.product.canBeBuyOnline).length : false
|
||||
}
|
||||
|
||||
|
||||
function getnumsteps() {
|
||||
let numsteps = 1
|
||||
|
||||
|
||||
if (CanBeShipped())
|
||||
numsteps++
|
||||
if (CanBeBuyOnline())
|
||||
numsteps++
|
||||
|
||||
|
||||
return numsteps
|
||||
}
|
||||
|
||||
|
||||
function docheckout() {
|
||||
|
||||
|
||||
// Può essere spedito?
|
||||
|
||||
|
||||
if (CanBeShipped()) {
|
||||
// mostra form di spedizione
|
||||
}
|
||||
|
||||
|
||||
if (CanBeBuyOnline()) {
|
||||
// mostra form di acquisto Online
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function completeOrder() {
|
||||
$q.dialog({
|
||||
message: 'Confermare l\'ordine di acquisto di ' + myTotalQty() + ' prodotti ?',
|
||||
message: t('ecomm.conferma_acq', { qty: myTotalQty() }),
|
||||
ok: {
|
||||
label: t('dialog.yes'),
|
||||
push: true
|
||||
@@ -144,13 +144,13 @@ export default defineComponent({
|
||||
cancel: {
|
||||
label: t('dialog.cancel')
|
||||
},
|
||||
title: 'Ordine'
|
||||
title: t('ecomm.order')
|
||||
}).onOk(async () => {
|
||||
const status = shared_consts.OrderStatus.CHECKOUT_SENT
|
||||
statusnow.value = await productStore.UpdateStatusCart({ cart_id: mycart.value._id, status })
|
||||
|
||||
|
||||
if (statusnow.value === status) {
|
||||
tools.showPositiveNotif($q, 'Ordine Confermato')
|
||||
tools.showPositiveNotif($q, t('ecomm.ord_confirmed'))
|
||||
setTimeout(() => {
|
||||
$router.push('/orderinfo')
|
||||
}, 2000)
|
||||
@@ -159,7 +159,7 @@ export default defineComponent({
|
||||
// change_field('status')
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user