- aggiunto bottone per Confermare tutti gli ordini
- 1 bottone per Consegnare e Pagare
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -146,6 +146,19 @@
|
||||
"
|
||||
class="q-pa-sm"
|
||||
>
|
||||
<q-btn
|
||||
v-if="
|
||||
taborders ===
|
||||
shared_consts.OrderStat.CONFERMATI.value
|
||||
"
|
||||
size="sm"
|
||||
dense
|
||||
color="green"
|
||||
icon="fas fa-people-carry"
|
||||
:label="t('ecomm.consegna')"
|
||||
@click="clickFunz(props.row, shared_consts.OrderStat.DELIVERED.value)"
|
||||
></q-btn>
|
||||
|
||||
<q-btn-dropdown rounded dense label="Azioni">
|
||||
<q-list class="text-primary">
|
||||
<q-item
|
||||
@@ -200,7 +213,7 @@
|
||||
<q-tr :props="props">
|
||||
<q-td key="ind" :props="props">
|
||||
<div class="q-pa-sm">
|
||||
{{index}}
|
||||
{{ index }}
|
||||
</div>
|
||||
</q-td>
|
||||
<q-td key="apri" :props="props">
|
||||
@@ -221,6 +234,19 @@
|
||||
v-if="tools.isManager() && props.row.user.name !== 'TOTALI'"
|
||||
class="q-pa-sm"
|
||||
>
|
||||
<q-btn
|
||||
v-if="
|
||||
taborders === shared_consts.OrderStat.CONFERMATI.value
|
||||
"
|
||||
size="sm"
|
||||
dense
|
||||
color="green"
|
||||
icon="fas fa-people-carry"
|
||||
class="q-mx-sm"
|
||||
:label="t('ecomm.consegna')"
|
||||
@click="clickFunz(props.row, shared_consts.OrderStat.DELIVERED.value)"
|
||||
></q-btn>
|
||||
|
||||
<q-btn-dropdown rounded dense label="Azioni">
|
||||
<q-list class="text-primary">
|
||||
<q-item
|
||||
@@ -332,6 +358,34 @@
|
||||
</q-table>
|
||||
</div>
|
||||
|
||||
<!-- Ordini IN CORSO -->
|
||||
<div
|
||||
v-if="
|
||||
tools.isManager() &&
|
||||
taborders === shared_consts.OrderStat.IN_CORSO.value
|
||||
"
|
||||
class="q-ma-sm q-pa-sm row justify-center"
|
||||
>
|
||||
<div>
|
||||
<q-toggle
|
||||
v-if="tools.isManager()"
|
||||
v-model="check_send_email"
|
||||
color="blue"
|
||||
class="row q-mx-md"
|
||||
icon="fas fa-envelope"
|
||||
:label="$t('orderscart.check_invia_email')"
|
||||
>
|
||||
</q-toggle>
|
||||
</div>
|
||||
|
||||
<q-btn
|
||||
color="positive"
|
||||
icon="mail"
|
||||
:label="t('orderscart.order_confirm')"
|
||||
@click="ConfermaOrdini"
|
||||
></q-btn>
|
||||
</div>
|
||||
|
||||
<!-- Emails -->
|
||||
|
||||
<div v-if="tools.isManager()" class="q-ma-sm q-pa-sm row">
|
||||
@@ -366,7 +420,7 @@
|
||||
<q-btn
|
||||
color="positive"
|
||||
icon="mail"
|
||||
:label="t('orderscart.sendmail')"
|
||||
:label="t('orderscart.sendmail', { count: arrout.length })"
|
||||
@click="sendMailToAll"
|
||||
></q-btn>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user