Fixed things for WarehouseOrder

This commit is contained in:
Luca Haid
2025-03-11 17:47:00 +01:00
parent 8b989fd135
commit a6ab876bf0
6 changed files with 60 additions and 43 deletions

View File

@@ -14,6 +14,7 @@ Vue.component('change-status-modal', {
sendEmail: false,
sendEmailViewedPDF: false,
sendEmailMail: '',
submitLoading: false
};
},
async mounted() {
@@ -24,8 +25,6 @@ Vue.component('change-status-modal', {
window.notify('error', 'Bestellung wurde storniert');
}
this.order = response.data;
},
computed: {
availableStatuses() {
@@ -107,11 +106,14 @@ Vue.component('change-status-modal', {
},
removeFile: index => this.uploadedFiles.splice(index, 1),
async submit() {
this.submitLoading = true;
if (this.newStatus === 'accepted' && this.sendEmail && !this.sendEmailMail) {
window.notify('error', 'Bitte geben Sie eine E-Mail-Adresse ein');
this.submitLoading = false;
return;
} else if (this.newStatus === 'accepted' && this.sendEmail && !this.sendEmailViewedPDF) {
window.notify('error', 'Bitte öffnen Sie das PDF bevor Sie die E-Mail senden');
this.submitLoading = false;
return;
} else if (this.newStatus === 'accepted' && this.sendEmail && this.sendEmailMail) {
if (this.order.sendShippingNote > 0) {
@@ -135,6 +137,7 @@ Vue.component('change-status-modal', {
window.notify('error',
response.data.errors ? Object.values(response.data.errors).join('<br>') : response.data.message || 'Ein Fehler ist aufgetreten');
}
this.submitLoading = false;
},
async generateShippingNote() {
const positions = this.order.positions.map(position => ({
@@ -171,7 +174,7 @@ Vue.component('change-status-modal', {
}
},
template: `
<tt-modal :show="true" @submit="submit" @update:show="$emit('close')" title="Status ändern">
<tt-modal :show="true" @submit="submit" @update:show="$emit('close')" title="Status ändern" :save-loading="submitLoading">
<tt-loader :absolute="false" v-if="!order"/>
<template v-else>
<tt-select label="Neuer Status" v-model="newStatus" :options="availableStatuses" sm row/>
@@ -199,7 +202,7 @@ Vue.component('change-status-modal', {
</div>
<tt-textarea label="Bemerkung*" v-model="note" sm/>
<tt-textarea label="Bemerkung" v-model="note" sm/>
<div v-if="newStatus === 'partiallyDelivered' || newStatus === 'fullyDelivered'">
<h4>Positionen</h4>
@@ -256,7 +259,7 @@ Vue.component('warehouse-order-modal', {
<tt-modal :show="true"
@submit="submit"
@delete="deleteOrder"
:delete="id !== 'create'"
:delete="false"
:title="id === 'create' ? 'Bestellung erstellen' : \`Bestellung #\${id} bearbeiten\`"
@update:show="$emit('close')">
<div style="width: 99%">
@@ -550,7 +553,7 @@ Vue.component('warehouse-order', {
<tt-table-crud emit-edit
@openpdf="openPDF"
@changeStatus="changeStatusModalId = $event.id"
@edit="orderModalId = $event.id" ref="table">
@edit="orderModalId = $event.id; $refs.table.$refs.table.refreshTable()" ref="table">
<template v-slot:expandedRow="{ row }">
<warehouse-order-detail :id="row.id"/>
</template>
@@ -566,9 +569,12 @@ Vue.component('warehouse-order', {
if (JSON.parse(localStorage.getItem('WarehouseOrder_create'))) this.orderModalId = 'create';
},
methods: {
closeModal() {
async closeModal() {
console.log("hi");
this.orderModalId = null;
this.changeStatusModalId = null;
console.log("hi");
await new Promise(resolve => setTimeout(resolve, 250));
this.$refs.table.$refs.table.refreshTable();
},
calculateSum: positions => positions.reduce((sum, {amount, buyPrice}) => sum + amount * buyPrice, 0),