From 26e17f33988fbb01914b631f2975c101ea3c62e4 Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Fri, 16 Feb 2024 14:11:12 +0100 Subject: [PATCH] - aggiunto bottone per Confermare tutti gli ordini - 1 bottone per Consegnare e Pagare --- src/statics/lang/it.js | 6 +- src/store/Products.ts | 18 ++--- src/views/ecommerce/orderInfo/orderInfo.ts | 84 +++++++++++++++++---- src/views/ecommerce/orderInfo/orderInfo.vue | 58 +++++++++++++- 4 files changed, 140 insertions(+), 26 deletions(-) diff --git a/src/statics/lang/it.js b/src/statics/lang/it.js index e02e5e21..8fc79b6f 100755 --- a/src/statics/lang/it.js +++ b/src/statics/lang/it.js @@ -1730,6 +1730,8 @@ const msg_it = { totalPrice: 'Totale', carrello_utente: 'Carrello dell\'Utente', tutti: 'Tutti', + paga: 'Paga', + consegna: 'Consegna', }, gas: { name: 'Ordine Gas', @@ -1748,13 +1750,15 @@ const msg_it = { totalQtyPreordered: 'totalQty PreOrd', numero_ordine: 'Numero d\'Ordine', nome: 'Nominativo', - sendmail: 'Invia Email a Tutti', + sendmail: 'Invia Email a Tutti {count}', sendmail_test: 'Invia Email TEST', email_sent: '{inviate} email inviate !', email_not_send: 'Email non inviata', update_order: 'Aggiorna Ordine', update_TotalPrice: 'Aggiorna Totale', TotalPriceProduct: 'Prezzo Totale', + order_confirm: 'Conferma Ordini (aggiorna Qta magazzino)', + check_invia_email: 'Invia le email', }, cash: { creatorUserId: 'Creatore', diff --git a/src/store/Products.ts b/src/store/Products.ts index 564104b3..ff59407b 100755 --- a/src/store/Products.ts +++ b/src/store/Products.ts @@ -785,8 +785,10 @@ export const useProducts = defineStore('Products', { return ris }, - getOptions() { - return {} + getOptions(sendmail: boolean) { + return { + sendmail + } }, async CreateOrdersCart({ cart_id, status, note }: { cart_id: string, status: number, note: string }) { @@ -802,7 +804,7 @@ export const useProducts = defineStore('Products', { let ris = null - ris = await Api.SendReq('/cart/' + this.userActive._id + '/createorderscart', 'POST', { cart_id, status, note, options: this.getOptions() }) + ris = await Api.SendReq('/cart/' + this.userActive._id + '/createorderscart', 'POST', { cart_id, status, note, options: this.getOptions(true) }) .then((res) => { if (res.data.status === shared_consts.OrderStatus.CHECKOUT_SENT) { @@ -823,7 +825,7 @@ export const useProducts = defineStore('Products', { return ris }, - async UpdateStatusCart({ ordercart_id, status }: { ordercart_id: string, status: number }) { + /*async UpdateStatusCart({ ordercart_id, status }: { ordercart_id: string, status: number }) { const userStore = useUserStore() const globalStore = useGlobalStore() @@ -850,11 +852,9 @@ export const useProducts = defineStore('Products', { }) return ris - }, + },*/ - - - async UpdateOrderCartStatus({ order_id, status }: { order_id: string, status: number }) { + async UpdateOrderCartStatus({ order_id, status, sendmail }: { order_id: string, status: number, sendmail: boolean }) { const userStore = useUserStore() const globalStore = useGlobalStore() @@ -864,7 +864,7 @@ export const useProducts = defineStore('Products', { let ris = null - ris = await Api.SendReq('/cart/' + this.userActive._id + '/ordercartstatus', 'POST', { order_id, status, options: this.getOptions() }) + ris = await Api.SendReq('/cart/' + this.userActive._id + '/ordercartstatus', 'POST', { order_id, status, options: this.getOptions(sendmail) }) .then((res) => { this.updateDataProduct(res) diff --git a/src/views/ecommerce/orderInfo/orderInfo.ts b/src/views/ecommerce/orderInfo/orderInfo.ts index dc1de964..cb72369f 100755 --- a/src/views/ecommerce/orderInfo/orderInfo.ts +++ b/src/views/ecommerce/orderInfo/orderInfo.ts @@ -38,6 +38,8 @@ export default defineComponent({ const arrout = ref([]) + const check_send_email = ref(false) + const initialPagination = ref({ sortBy: 'desc', descending: false, @@ -365,40 +367,62 @@ export default defineComponent({ title: 'Ordine' }).onOk(async () => { - statusnow.value = await productStore.UpdateOrderCartStatus({ order_id: order._id, status }) + statusnow.value = await productStore.UpdateOrderCartStatus({ order_id: order._id, status, sendmail: check_send_email.value }) if (statusnow.value === status) { order.status = statusnow.value updateorders(true) tools.showPositiveNotif($q, 'Ordine ' + statusStr) } + + // Se l'ordine è stato PAGATO, controllo se è stato consegnato + if (status === shared_consts.OrderStatus.DELIVERED) { + if (!order.pagato) { + clickFunz(order, shared_consts.OrderStatus.PAYED) + } + } + // change_field('status') // change_field('status') }) } - async function sendMailToAll() { - const orders = getOrdersCartWithTotals() + function sendMailToAll() { + const orders = arrout.value let res = null let inviate = 0 - for (const ord of orders) { - res = await productStore.sendMailToTheBuyer(ord._id, templemail.value, false) - if (res && res.emailsend) - inviate++ - } + $q.dialog({ + message: 'Inviare la email ' + templemail.value + ' a tutti ?', + ok: { + label: t('dialog.yes'), + push: true + }, + cancel: { + label: t('dialog.cancel') + }, + title: 'Ordine' + }).onOk(async () => { - if (inviate > 0) { - tools.showPositiveNotif($q, t('orderscart.email_sent', { inviate })) - } else { - tools.showNegativeNotif($q, t('orderscart.email_not_send')) - } + + for (const ord of orders) { + res = await productStore.sendMailToTheBuyer(ord._id, templemail.value, false) + if (res && res.emailsend) + inviate++ + } + + if (inviate > 0) { + tools.showPositiveNotif($q, t('orderscart.email_sent', { inviate })) + } else { + tools.showNegativeNotif($q, t('orderscart.email_not_send')) + } + }) } async function sendMailTest() { - const orders = getOrdersCartWithTotals() + const orders = arrout.value if (orders && orders.length > 0) { const res = await productStore.sendMailToTheBuyer(orders[0]._id, templemail.value, true) @@ -412,6 +436,36 @@ export default defineComponent({ } + async function CambiaStatoaTutti(status: number) { + + for (const order of arrout.value) { + statusnow.value = await productStore.UpdateOrderCartStatus({ order_id: order._id, status, sendmail: check_send_email.value }) + } + + updateorders(true) + } + + function ConfermaOrdini() { + + let conemail = 'ed inviare le Email di Conferma' + if (!check_send_email.value) + conemail = 'senza inviare le Email di Conferma' + + $q.dialog({ + message: 'Confermare tutti gli Ordini ' + conemail + '?', + ok: { + label: t('dialog.yes'), + push: true + }, + cancel: { + label: t('dialog.cancel') + }, + title: 'Ordine' + }).onOk(async () => { + await CambiaStatoaTutti(shared_consts.OrderStatus.ORDER_CONFIRMED) + }) + } + onMounted(mounted) return { @@ -441,6 +495,8 @@ export default defineComponent({ fieldsTable, storeGasordine, arrout, + check_send_email, + ConfermaOrdini, } } }) diff --git a/src/views/ecommerce/orderInfo/orderInfo.vue b/src/views/ecommerce/orderInfo/orderInfo.vue index 76f573f9..353489dd 100755 --- a/src/views/ecommerce/orderInfo/orderInfo.vue +++ b/src/views/ecommerce/orderInfo/orderInfo.vue @@ -146,6 +146,19 @@ " class="q-pa-sm" > + +
- {{index}} + {{ index }}
@@ -221,6 +234,19 @@ v-if="tools.isManager() && props.row.user.name !== 'TOTALI'" class="q-pa-sm" > + + + +
+
+ + +
+ + +
+
@@ -366,7 +420,7 @@