WarehouseOffer fixed bugs
This commit is contained in:
@@ -1,53 +1,53 @@
|
||||
Vue.component('warehouse-e-shop', {
|
||||
//language=Vue
|
||||
template: `
|
||||
<tt-card>
|
||||
<tt-expandable-shopping-cart :cart-items="shoppingCart" @submitOrder="openOrderDialog"/>
|
||||
<tt-card>
|
||||
<tt-expandable-shopping-cart :cart-items="shoppingCart" @submitOrder="openOrderDialog"/>
|
||||
|
||||
<tt-modal :show.sync="createOrderDialog"
|
||||
:delete="false"
|
||||
title="Bestellung abschicken"
|
||||
@submit="submitOrder">
|
||||
|
||||
<tt-select v-model="createOrderDialogData.deliveryMode" label="Adresse" :options="[
|
||||
<tt-modal :show.sync="createOrderDialog"
|
||||
:delete="false"
|
||||
title="Bestellung abschicken"
|
||||
@submit="submitOrder">
|
||||
|
||||
<tt-select v-model="createOrderDialogData.deliveryMode" label="Adresse" :options="[
|
||||
{text: 'Einzelne Adresse', value: 'singleAddress'},
|
||||
// {text: 'Mehrere Adressen', value: 'multipleAddresses'},
|
||||
]" sm row/>
|
||||
<tt-input v-model="createOrderDialogData.extRef" label="Externe Referenz" sm row/>
|
||||
]" sm row/>
|
||||
<tt-input v-model="createOrderDialogData.extRef" label="Externe Referenz" sm row/>
|
||||
|
||||
<tt-input v-model="createOrderDialogData.deliveryAddressName" label="Name" sm row/>
|
||||
<tt-input v-model="createOrderDialogData.deliveryAddressMail" label="E-Mail" sm row/>
|
||||
<tt-input v-model="createOrderDialogData.deliveryAddressPhone" label="Nummer" sm row/>
|
||||
<tt-input v-model="createOrderDialogData.deliveryAddressAdditional" label="Anschriftenzusatz" sm row/>
|
||||
<tt-input v-model="createOrderDialogData.deliveryAddressLine" label="Straße" sm row/>
|
||||
<tt-input v-model="createOrderDialogData.deliveryAddressPLZ" label="PLZ" sm row/>
|
||||
<tt-input v-model="createOrderDialogData.deliveryAddressCity" label="Stadt" sm row/>
|
||||
|
||||
</tt-modal>
|
||||
<tt-input v-model="createOrderDialogData.deliveryAddressName" label="Name" sm row/>
|
||||
<tt-input v-model="createOrderDialogData.deliveryAddressMail" label="E-Mail" sm row/>
|
||||
<tt-input v-model="createOrderDialogData.deliveryAddressPhone" label="Nummer" sm row/>
|
||||
<tt-input v-model="createOrderDialogData.deliveryAddressAdditional" label="Anschriftenzusatz" sm row/>
|
||||
<tt-input v-model="createOrderDialogData.deliveryAddressLine" label="Straße" sm row/>
|
||||
<tt-input v-model="createOrderDialogData.deliveryAddressPLZ" label="PLZ" sm row/>
|
||||
<tt-input v-model="createOrderDialogData.deliveryAddressCity" label="Stadt" sm row/>
|
||||
|
||||
<tt-table-crud>
|
||||
</tt-modal>
|
||||
|
||||
<template v-slot:price="{ row }">
|
||||
<span v-if="row.hasOwnProperty('calculatedSellPrice')"> {{ row.calculatedSellPrice.toFixed(2) }} €</span>
|
||||
<span v-else>{{
|
||||
Array.isArray(JSON.parse(row.cheapestSellPrice)) ? JSON.parse(row.cheapestSellPrice).find(price => price.title === 'Energie Steiermark').price.toFixed(2) :
|
||||
Object.values(JSON.parse(row.cheapestSellPrice)).find(price => price.title === 'Energie Steiermark').price.toFixed(2) }} €</span>
|
||||
</template>
|
||||
<tt-table-crud>
|
||||
|
||||
<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.hasOwnProperty('calculatedSellPrice') ? 'P-' + row.id : 'I-' + row.id]" sm/>
|
||||
</template>
|
||||
|
||||
<template v-slot:add="{ row }">
|
||||
<a style="cursor: pointer;" @click="addToCart(row, row.hasOwnProperty('calculatedSellPrice') ? 'P' : 'I')">
|
||||
<i class="fas fa-shopping-cart text-primary"></i>
|
||||
</a>
|
||||
</template>
|
||||
|
||||
</tt-table-crud>
|
||||
</tt-card>
|
||||
`, data() {
|
||||
<template v-slot:price="{ row }">
|
||||
<span v-if="row.hasOwnProperty('calculatedSellPrice')"> {{ row.calculatedSellPrice.toFixed(2) }} €</span>
|
||||
<span v-else>
|
||||
{{ getArticlePrice(row).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.hasOwnProperty('calculatedSellPrice') ? 'P-' + row.id : 'I-' + row.id]" sm/>
|
||||
</template>
|
||||
|
||||
<template v-slot:add="{ row }">
|
||||
<a style="cursor: pointer;" @click="addToCart(row, row.hasOwnProperty('calculatedSellPrice') ? 'P' : 'I')">
|
||||
<i class="fas fa-shopping-cart text-primary"></i>
|
||||
</a>
|
||||
</template>
|
||||
|
||||
</tt-table-crud>
|
||||
</tt-card>
|
||||
`, data() {
|
||||
return {
|
||||
window: window, itemAmounts: {}, shoppingCart: [], createOrderDialog: false, createOrderDialogData: {
|
||||
deliveryMode: 'singleAddress',
|
||||
@@ -59,9 +59,29 @@ Vue.component('warehouse-e-shop', {
|
||||
deliveryAddressPLZ: '',
|
||||
deliveryAddressCity: '',
|
||||
},
|
||||
userAddressId: window['TT_CONFIG']['userAddressId'] || null, // Get user's address ID from PHP
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getArticlePrice(row) {
|
||||
const cheapestSellPrice = JSON.parse(row.cheapestSellPrice);
|
||||
let priceTitle = '';
|
||||
|
||||
if (this.userAddressId === 209) {
|
||||
priceTitle = 'Energie Steiermark';
|
||||
} else if (this.userAddressId === 9633) {
|
||||
priceTitle = 'SBIDI';
|
||||
} else {
|
||||
// Default or error handling if addressId is not recognized
|
||||
return 0;
|
||||
}
|
||||
|
||||
const foundPrice = Array.isArray(cheapestSellPrice)
|
||||
? cheapestSellPrice.find(price => price.title === priceTitle)
|
||||
: Object.values(cheapestSellPrice).find(price => price.title === priceTitle);
|
||||
|
||||
return foundPrice ? foundPrice.price : 0;
|
||||
},
|
||||
async openOrderDialog() {
|
||||
this.createOrderDialog = true;
|
||||
},
|
||||
@@ -81,6 +101,7 @@ Vue.component('warehouse-e-shop', {
|
||||
if (response.data.success) {
|
||||
this.window.notify('success', response.data.message || 'Erfolgreich gespeichert');
|
||||
this.shoppingCart = [];
|
||||
this.itemAmounts = {}; // Clear item amounts after successful order
|
||||
this.createOrderDialogData = {
|
||||
deliveryMode: 'singleAddress',
|
||||
extRef: '',
|
||||
|
||||
Reference in New Issue
Block a user