added shipping notes for warehouse e shop
This commit is contained in:
@@ -5,6 +5,7 @@ Vue.component('warehouse-e-shop-order', {
|
||||
<tt-card>
|
||||
<tt-table-crud @openHistory="historyModal = true; historyModalId = $event.id"
|
||||
@openSingleOrderEmail="openSingleOrderEmailModal = true; singleOrderEmailModalId = $event.id"
|
||||
@createShippingNote="createShippingNote($event.id)"
|
||||
@showTrackingHistory="openTrackingHistoryModal = true; trackingHistoryModalId = $event.id"
|
||||
ref="table">
|
||||
|
||||
@@ -84,6 +85,14 @@ Vue.component('warehouse-e-shop-order', {
|
||||
const response = await axios.get(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseEShopOrder/getAllItemsPerOrder`);
|
||||
this.articleItems = response.data;
|
||||
}, methods: {
|
||||
async createShippingNote(id) {
|
||||
const response = await axios.get(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseEShopOrder/createShippingNote?id=${id}`);
|
||||
|
||||
window.notify(response.data.success === true ? 'success' : 'info', response.data.message);
|
||||
if (response.data.shippingNoteId) {
|
||||
window.open(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseShippingNote/createPDF?id=${response.data.shippingNoteId}&price=true`, '_blank');
|
||||
}
|
||||
},
|
||||
async sendSingleOrderEmail() {
|
||||
const response = await axios.get(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseEShopOrder/singleOrderEmail?id=${this.singleOrderEmailModalId}`);
|
||||
if (response.data.message) {
|
||||
|
||||
@@ -19,7 +19,7 @@ Vue.component('warehouse-shipping-note-positions', {
|
||||
positions: Array
|
||||
}, data() {
|
||||
return {
|
||||
articleData: {}, loading: false
|
||||
articleData: {}, loading: false, articlePacketData: {}
|
||||
}
|
||||
}, template: `
|
||||
<div>
|
||||
@@ -30,15 +30,20 @@ Vue.component('warehouse-shipping-note-positions', {
|
||||
|
||||
<ul v-if="!loading">
|
||||
<li v-for="position in positions">
|
||||
<span>{{ position.amount }}x {{ articleData[position.article]?.text }}</span>
|
||||
<span>{{ position.amount }}x {{ position.article ? articleData[position.article]?.text : articlePacketData[position.articlePacket]?.text }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
`, async mounted() {
|
||||
this.loading = true;
|
||||
for (const position of this.positions) {
|
||||
const response = await axios.get(window.TT_CONFIG["BASE_PATH"] + '/WarehouseArticle/autoComplete?searchedID=' + position.article);
|
||||
this.$set(this.articleData, position.article, response.data[0]);
|
||||
if (position.article) {
|
||||
const response = await axios.get(window.TT_CONFIG["BASE_PATH"] + '/WarehouseArticle/autoComplete?searchedID=' + position.article);
|
||||
this.$set(this.articleData, position.article, response.data[0]);
|
||||
} else if (position.articlePacket) {
|
||||
const response = await axios.get(window.TT_CONFIG["BASE_PATH"] + '/WarehouseArticlePacket/autoComplete?searchedID=' + position.articlePacket);
|
||||
this.$set(this.articlePacketData, position.articlePacket, response.data[0]);
|
||||
}
|
||||
}
|
||||
this.loading = false;
|
||||
}
|
||||
@@ -58,7 +63,9 @@ Vue.component('warehouse-shipping-note', {
|
||||
:api-url="window.TT_CONFIG['BASE_PATH'] + '/Address/Api?do=findAddress'"
|
||||
label="Rechnungsadresse" sm row/>
|
||||
|
||||
<tt-select v-model="crudModalSelectDeliveryAddressMode" :options="crudModalSelectDeliveryAddressModeItems" label="Lieferadresse Art" sm
|
||||
<tt-select
|
||||
v-if="crudModalId === 'create'"
|
||||
v-model="crudModalSelectDeliveryAddressMode" :options="crudModalSelectDeliveryAddressModeItems" label="Lieferadresse Art" sm
|
||||
row/>
|
||||
|
||||
<template v-if="crudModalSelectDeliveryAddressMode === 'existing'">
|
||||
@@ -109,7 +116,7 @@ Vue.component('warehouse-shipping-note', {
|
||||
<tbody>
|
||||
<tr v-for="(position, index) in crudModalData.positions">
|
||||
<td>{{ index + 1 }}</td>
|
||||
<td>{{ articleNames[position.article] }}</td>
|
||||
<td>{{ position.article ? articleNames[position.article] : articlePacketNames[position.articlePacket] }}</td>
|
||||
<td>{{ position.amount }}</td>
|
||||
<td>{{ (position.price?.toFixed(2)) }} €</td>
|
||||
<td>
|
||||
@@ -164,6 +171,7 @@ Vue.component('warehouse-shipping-note', {
|
||||
crudModalAddPositionAmount: '',
|
||||
crudModalAddPositionPrice: '',
|
||||
articleNames: {},
|
||||
articlePacketNames: {},
|
||||
textElements: [],
|
||||
}
|
||||
}, async mounted() {
|
||||
@@ -207,6 +215,7 @@ Vue.component('warehouse-shipping-note', {
|
||||
this.crudModalData = defaultCrudModalData
|
||||
this.crudModal = true
|
||||
} else {
|
||||
this.crudModalSelectDeliveryAddressMode = 'new';
|
||||
const disconnectedData = JSON.parse(JSON.stringify(data));
|
||||
|
||||
if (disconnectedData.status !== 'new') {
|
||||
@@ -217,7 +226,8 @@ Vue.component('warehouse-shipping-note', {
|
||||
disconnectedData.textElements = JSON.parse(disconnectedData.textElements);
|
||||
disconnectedData.positions = JSON.parse(disconnectedData.positions);
|
||||
for (const position of disconnectedData.positions) {
|
||||
await this.fetchArticleNames(position.article);
|
||||
if (position.article) await this.fetchArticleNames(position.article);
|
||||
if (position.articlePacket) await this.fetchArticlePacketNames(position.articlePacket);
|
||||
}
|
||||
this.crudModalId = 'update'
|
||||
this.crudModalData = disconnectedData
|
||||
@@ -254,6 +264,9 @@ Vue.component('warehouse-shipping-note', {
|
||||
}, async fetchArticleNames(articleId) {
|
||||
const response = await axios.get(window.TT_CONFIG["BASE_PATH"] + '/WarehouseArticle/autoComplete?searchedID=' + articleId);
|
||||
this.$set(this.articleNames, articleId, response.data[0].text);
|
||||
}, async fetchArticlePacketNames(articlePacketId) {
|
||||
const response = await axios.get(window.TT_CONFIG["BASE_PATH"] + '/WarehouseArticlePacket/autoComplete?searchedID=' + articlePacketId);
|
||||
this.$set(this.articlePacketNames, articlePacketId, response.data[0].text);
|
||||
}, async createOrUpdate() {
|
||||
const response = await axios.post(this.crudModalId === 'create' ? window['TT_CONFIG']['CREATE_URL'] : window['TT_CONFIG']['UPDATE_URL'],
|
||||
this.crudModalData);
|
||||
@@ -266,7 +279,7 @@ Vue.component('warehouse-shipping-note', {
|
||||
response.data.errors ? Object.values(response.data.errors).join('<br>') : response.data.message || 'Ein Fehler ist aufgetreten');
|
||||
}
|
||||
}, async fetchDeliveryAddresses() {
|
||||
if (!this.crudModalData.billingAddressId || this.crudModalSelectDeliveryAddressMode !== 'existing') return;
|
||||
if (!this.crudModalData.billingAddressId || this.crudModalSelectDeliveryAddressMode !== 'existing' && this.crudModalSelectDeliveryAddressMode !== 'billing') return;
|
||||
|
||||
if (this.crudModalSelectDeliveryAddressMode === 'billing') {
|
||||
const response = await axios.get(window.TT_CONFIG["BASE_PATH"] + '/Address/api?do=getAddress&id=' + this.crudModalData.billingAddressId);
|
||||
|
||||
Reference in New Issue
Block a user