Feature/add e shop
This commit is contained in:
@@ -63,13 +63,18 @@ Vue.component('warehouse-e-shop', {
|
||||
|
||||
<tt-table-crud>
|
||||
|
||||
<template v-slot:price="{ row }">
|
||||
<span v-if="row.hasOwnProperty('calculatedSellPrice')"> {{ row.calculatedSellPrice.toFixed(2) }} €</span>
|
||||
<span v-else>{{ JSON.parse(row.cheapestSellPrice).find(price => price.title === 'Energie Steiermark').price.toFixed(2) }} €</span>
|
||||
</template>
|
||||
|
||||
<template v-slot:amount="{ row }">
|
||||
<!-- this has no padding - add a full width full height tt-input with -->
|
||||
<tt-input type="number" style="width: 100%; height: 100%;margin:0 !important" v-model="itemAmounts[row.id]"/>
|
||||
<tt-input type="number" style="width: 100%; height: 100%;margin:0 !important" v-model="itemAmounts[row.hasOwnProperty('calculatedSellPrice') ? 'P-' + row.id : 'I-' + row.id]" sm/>
|
||||
</template>
|
||||
|
||||
<template v-slot:add="{ row }">
|
||||
<a style="cursor: pointer;" @click="addToCart(row)">
|
||||
<a style="cursor: pointer;" @click="addToCart(row, row.hasOwnProperty('calculatedSellPrice') ? 'P' : 'I')">
|
||||
<i class="fas fa-shopping-cart text-primary"></i>
|
||||
</a>
|
||||
</template>
|
||||
@@ -110,12 +115,16 @@ Vue.component('warehouse-e-shop', {
|
||||
'Ein Fehler ist aufgetreten');
|
||||
}
|
||||
},
|
||||
addToCart(row) {
|
||||
addToCart(row, type) {
|
||||
row = JSON.parse(JSON.stringify(row));
|
||||
row.id = `${type}-${row.id}`;
|
||||
if (!this.itemAmounts[row.id] || this.itemAmounts[row.id] === 0) {
|
||||
window.notify('error', 'Bitte geben Sie eine Menge ein.');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(this.shoppingCart, row)
|
||||
|
||||
// Check if Article is already in the shopping cart
|
||||
if (this.shoppingCart.some(item => item.itemId === row.id)) {
|
||||
window.notify('warning', `${row.title} ist bereits im Warenkorb.`);
|
||||
|
||||
Reference in New Issue
Block a user