added confirmation email for eshop
This commit is contained in:
@@ -3,7 +3,9 @@ Vue.component('warehouse-e-shop-order', {
|
||||
//language=Vue
|
||||
template: `
|
||||
<tt-card>
|
||||
<tt-table-crud @openHistory="historyModal = true; historyModalId = $event.id" ref="table">
|
||||
<tt-table-crud @openHistory="historyModal = true; historyModalId = $event.id"
|
||||
@openSingleOrderEmail="openSingleOrderEmailModal = true; singleOrderEmailModalId = $event.id"
|
||||
ref="table">
|
||||
|
||||
<template v-slot:table-top-buttons>
|
||||
<button @click="createCSVExportAndMarkAsAccepted" type="button" class="btn btn-outline-success">
|
||||
@@ -28,10 +30,29 @@ Vue.component('warehouse-e-shop-order', {
|
||||
|
||||
</tt-table-crud>
|
||||
<warehouse-history-modal :show.sync="historyModal" :id="historyModalId"/>
|
||||
|
||||
<!-- add a tt-modal which just shows some text from the api to show a email for a single order-->
|
||||
<tt-modal :show.sync="openSingleOrderEmailModal"
|
||||
:title="'Email für Bestellung ' + singleOrderEmailModalId"
|
||||
@close="openSingleOrderEmailModal = false"
|
||||
save-text="E-Mail senden"
|
||||
@submit="sendSingleOrderEmail"
|
||||
:delete="false"
|
||||
>
|
||||
<div v-if="singleOrderEmailModalId && singleOrderEmailModalText">
|
||||
<p v-html="singleOrderEmailModalText.body.replaceAll('\\n', '<br>')"></p>
|
||||
</div>
|
||||
<!-- else show loader-->
|
||||
<div v-else>
|
||||
<tt-loader/>
|
||||
</div>
|
||||
</tt-modal>
|
||||
|
||||
|
||||
</tt-card>
|
||||
`, data() {
|
||||
return {
|
||||
window: window, historyModal: false, historyModalId: null, articleItems: null
|
||||
window: window, historyModal: false, historyModalId: null, articleItems: null, openSingleOrderEmailModal: false, singleOrderEmailModalId: null, singleOrderEmailModalText: null
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
@@ -40,11 +61,20 @@ Vue.component('warehouse-e-shop-order', {
|
||||
this.articleItems = response.data;
|
||||
},
|
||||
methods: {
|
||||
async sendSingleOrderEmail() {
|
||||
const response = await axios.get(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseEShopOrder/singleOrderEmail?id=${this.singleOrderEmailModalId}`);
|
||||
if (response.data.message) {
|
||||
window.notify(response.data.success === true ? 'success' : 'error', response.data.message);
|
||||
this.openSingleOrderEmailModal = false;
|
||||
} else {
|
||||
window.notify('error', 'Ein Fehler ist aufgetreten');
|
||||
}
|
||||
},
|
||||
async createCSVExportAndMarkAsAccepted() {
|
||||
const response = await axios.post(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseEShopOrder/CSVExportNewOrdersMarkAccepted`);
|
||||
|
||||
if (response.data.message) {
|
||||
window.notify('info', response.data.message);
|
||||
window.notify('success', response.data.message);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,5 +107,16 @@ Vue.component('warehouse-e-shop-order', {
|
||||
|
||||
await this.$refs.table.$refs.table.fetchData();
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
singleOrderEmailModalId() {
|
||||
this.openSingleOrderEmailModal = !!this.singleOrderEmailModalId;
|
||||
this.singleOrderEmailModalText = null;
|
||||
if (this.singleOrderEmailModalId) {
|
||||
axios.get(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseEShopOrder/singleOrderEmail?id=${this.singleOrderEmailModalId}&dryRun=true`)
|
||||
.then(response => this.singleOrderEmailModalText = response.data)
|
||||
.catch(error => window.notify('error', error.response?.data?.message || 'Ein Fehler ist aufgetreten'));
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user