- aggiunto bottone per Confermare tutti gli ordini

- 1 bottone per Consegnare e Pagare
This commit is contained in:
Surya Paolo
2024-02-16 14:11:12 +01:00
parent a82e07b4ce
commit 26e17f3398
4 changed files with 140 additions and 26 deletions

View File

@@ -38,6 +38,8 @@ export default defineComponent({
const arrout = ref(<any[]>[])
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,
}
}
})