update for warehouse
This commit is contained in:
@@ -250,11 +250,14 @@ Vue.component('warehouse-article', {
|
||||
//language=Vue
|
||||
template: `
|
||||
<tt-card>
|
||||
|
||||
<tt-table-crud ref="table"
|
||||
@openHistory="historyModal = true; historyModalId = $event.id"
|
||||
@editDistributorEntries="distributorModal = true; distributorModalId = $event.id"
|
||||
@editPricesEntries="priceModal = true; priceModalId = $event.id"
|
||||
@editThresholdEntries="thresholdModal = true; thresholdModalId = $event.id">
|
||||
@editThresholdEntries="thresholdModal = true; thresholdModalId = $event.id"
|
||||
@addToCart="addShoppingCartModal = true; addShoppingCartModalId = $event.id"
|
||||
>
|
||||
|
||||
<template v-slot:cheapestsellprice="{ row }">
|
||||
<template v-for="price in JSON.parse(row.cheapestSellPrice)">
|
||||
@@ -268,6 +271,38 @@ Vue.component('warehouse-article', {
|
||||
|
||||
</tt-table-crud>
|
||||
|
||||
<tt-expandable-shopping-cart :cart-items="shoppingCart" @submitOrder="prepareOrder"/>
|
||||
<tt-modal :show.sync="addShoppingCartModal" title="Artikel zur Bestellung hinzufügen" :delete="false" @submit="addToShoppingCart"
|
||||
@close="addShoppingCartModal = false">
|
||||
<tt-input v-model="addShoppingCartModalCount" placeholder="Menge" type="number" sm></tt-input>
|
||||
</tt-modal>
|
||||
|
||||
<tt-modal :show.sync="confirmOrderModal" title="Bestellung bestätigen" :delete="false"
|
||||
save-text="Bestätigen" @submit="createOrder"
|
||||
@close="confirmOrderModal = false; confirmOrderModalData = null">
|
||||
<span>
|
||||
Es werden Bestellungen an folgende Lieferanten gesendet:
|
||||
</span>
|
||||
<div v-for="(order, index) in confirmOrderModalData" :key="index">
|
||||
<h4>{{order.distributor[0].name}} - {{order.orderAmount}} €
|
||||
</h4>
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<th>Artikel</th>
|
||||
<th>Menge</th>
|
||||
<th>Preis</th>
|
||||
<th>Summe</th>
|
||||
</tr>
|
||||
<tr v-for="(item, index) in order.orders" :key="index">
|
||||
<td>{{item.title}}</td>
|
||||
<td>{{item.amount}}</td>
|
||||
<td>{{item.purchasePrice}} €</td>
|
||||
<td>{{item.sum.toFixed(2)}} €</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</tt-modal>
|
||||
|
||||
<warehouse-distributor-modal :show.sync="distributorModal" :id="distributorModalId" @doUpdate="refreshTable"/>
|
||||
<warehouse-threshold-modal :show.sync="thresholdModal" :id="thresholdModalId" @doUpdate="refreshTable"/>
|
||||
<warehouse-article-price-modal :show.sync="priceModal" :id="priceModalId" @doUpdate="refreshTable"/>
|
||||
@@ -275,19 +310,56 @@ Vue.component('warehouse-article', {
|
||||
</tt-card>
|
||||
`, data() {
|
||||
return {
|
||||
window: window,
|
||||
historyModal: false,
|
||||
historyModalId: null,
|
||||
distributorModal: false,
|
||||
distributorModalId: null,
|
||||
thresholdModal: false,
|
||||
thresholdModalId: null,
|
||||
priceModal: false,
|
||||
priceModalId: null
|
||||
window: window,
|
||||
historyModal: false,
|
||||
historyModalId: null,
|
||||
distributorModal: false,
|
||||
distributorModalId: null,
|
||||
thresholdModal: false,
|
||||
thresholdModalId: null,
|
||||
priceModal: false,
|
||||
priceModalId: null,
|
||||
shoppingCart: [],
|
||||
addShoppingCartModal: false,
|
||||
addShoppingCartModalId: null,
|
||||
addShoppingCartModalCount: '',
|
||||
confirmOrderModal: false,
|
||||
confirmOrderModalData: null,
|
||||
|
||||
}
|
||||
}, methods: {
|
||||
refreshTable() {
|
||||
this.$refs.table.$refs.table.refreshTable();
|
||||
}, async addToShoppingCart() {
|
||||
if (this.addShoppingCartModalCount < 1) { // Check if amount is set
|
||||
window.notify('error', 'Bitte geben Sie eine Menge ein.');
|
||||
return;
|
||||
}
|
||||
if (this.shoppingCart.some(item => item.itemId === this.addShoppingCartModalId)) { // Check if same article is already in cart
|
||||
window.notify('error', 'Artikel bereits im Warenkorb.');
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await axios.get(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseArticle/getById?id=${this.addShoppingCartModalId}`);
|
||||
this.shoppingCart.push({amount: parseInt(this.addShoppingCartModalCount), itemId: this.addShoppingCartModalId, title: response.data.title});
|
||||
this.addShoppingCartModal = false;
|
||||
this.addShoppingCartModalId = null;
|
||||
this.addShoppingCartModalCount = '';
|
||||
window.notify('success', 'Artikel erfolgreich hinzugefügt.');
|
||||
}, async prepareOrder() {
|
||||
const response = await axios.post(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseArticle/prepareOrder`, this.shoppingCart);
|
||||
this.confirmOrderModal = true;
|
||||
this.confirmOrderModalData = response.data;
|
||||
},
|
||||
async createOrder() {
|
||||
const response = await axios.post(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseOrder/createOrder`, this.confirmOrderModalData);
|
||||
this.confirmOrderModal = false;
|
||||
this.confirmOrderModalData = null;
|
||||
this.shoppingCart = [];
|
||||
window.notify(response.data.success ? 'success' : 'error', response.data.message);
|
||||
setTimeout(() => {
|
||||
window.location.href = `${window['TT_CONFIG']['BASE_PATH']}/WarehouseOrder`;
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user