added csv export for triotronik for e shop orders

This commit is contained in:
2024-08-02 10:28:19 +02:00
parent e31c240f76
commit 2c0ee7e83e
3 changed files with 95 additions and 11 deletions
@@ -3,7 +3,14 @@ Vue.component('warehouse-e-shop-order', {
//language=Vue
template: `
<tt-card>
<tt-table-crud @openHistory="historyModal = true; historyModalId = $event.id">
<tt-table-crud @openHistory="historyModal = true; historyModalId = $event.id" ref="table">
<template v-slot:table-top-buttons>
<button @click="createCSVExportAndMarkAsAccepted" type="button" class="btn btn-outline-success">
<i class="fas fa-file-excel"></i>
CSV Export für neue Bestellungen
</button>
</template>
<template v-slot:create="{ row }">
{{ window.moment(row.create * 1000).format('DD.MM.YYYY HH:mm:ss') }}
@@ -31,6 +38,28 @@ Vue.component('warehouse-e-shop-order', {
const response = await axios.get(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseEShopOrder/getAllItemsPerOrder`);
console.log(response.data);
this.articleItems = response.data;
},
methods: {
async createCSVExportAndMarkAsAccepted() {
const response = await axios.post(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseEShopOrder/CSVExportNewOrdersMarkAccepted`);
if (response.data.message) {
window.notify('info', response.data.message);
return;
}
const blob = new Blob([response.data], {type: 'text/csv charset=utf-8;'});
const url = window.URL.createObjectURL(blob);
const link = document.createElement("a");
link.setAttribute("href", url);
link.setAttribute("download", "Export.csv");
document.body.appendChild(link); // Required for FF
link.click(); // This will download the data file named "my_data.csv".
link.remove();
await this.$refs.table.$refs.table.fetchData();
}
}
})