2021-02-13 13:11:25 +00:00
|
|
|
<template>
|
2021-03-18 16:23:57 +00:00
|
|
|
<div>
|
|
|
|
<q-table title="Getränke" :columns="columns" :data="drinks" row-key="name">
|
2021-03-14 12:52:58 +00:00
|
|
|
<template #body-cell-prices="{ row: { prices } }">
|
2021-02-13 13:11:25 +00:00
|
|
|
<q-td>
|
2021-03-18 16:23:57 +00:00
|
|
|
<div v-for="price in prices" :key="price.id" class="row">
|
|
|
|
<div class="col">
|
2021-03-14 12:52:58 +00:00
|
|
|
{{ setVolume(price.volume) }}
|
2021-03-18 16:23:57 +00:00
|
|
|
</div>
|
|
|
|
<div class="col">
|
2021-03-14 12:52:58 +00:00
|
|
|
{{ setCurrency(price.price) }}
|
2021-03-18 16:23:57 +00:00
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
{{ price.description }}
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-02-13 13:11:25 +00:00
|
|
|
</q-td>
|
2021-03-18 16:23:57 +00:00
|
|
|
</template>
|
2021-02-13 13:11:25 +00:00
|
|
|
</q-table>
|
2021-03-18 16:23:57 +00:00
|
|
|
</div>
|
2021-02-13 13:11:25 +00:00
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
2021-03-14 12:52:58 +00:00
|
|
|
import { defineComponent, onBeforeMount, ref } from 'vue';
|
2021-03-18 16:23:57 +00:00
|
|
|
import { StateInterface } from 'src/store';
|
|
|
|
import { DrinkInterface } from '../store/drinks';
|
2021-03-14 12:52:58 +00:00
|
|
|
import { useStore } from 'vuex';
|
|
|
|
|
2021-02-13 13:11:25 +00:00
|
|
|
export default defineComponent({
|
2021-03-18 16:23:57 +00:00
|
|
|
name: 'Pricelist',
|
|
|
|
filters: {
|
2021-02-13 13:11:25 +00:00
|
|
|
setVolume(volume: number) {
|
2021-03-18 16:23:57 +00:00
|
|
|
if (volume * 10 > 1) {
|
|
|
|
return `${volume}l`;
|
|
|
|
}
|
|
|
|
return `${volume * 100}cl`;
|
2021-02-13 13:11:25 +00:00
|
|
|
},
|
|
|
|
setCurrency(price: number) {
|
2021-03-18 16:23:57 +00:00
|
|
|
return `${price.toFixed(2)}€`;
|
2021-02-13 13:11:25 +00:00
|
|
|
},
|
2021-03-18 16:23:57 +00:00
|
|
|
},
|
2021-03-14 12:52:58 +00:00
|
|
|
setup() {
|
|
|
|
const store = useStore();
|
2021-03-18 16:23:57 +00:00
|
|
|
const state = <DrinkInterface>store.state.drink;
|
|
|
|
const drinks = ref(state.drinks);
|
|
|
|
onBeforeMount(() => {
|
|
|
|
void store.dispatch('drink/getDrinks');
|
|
|
|
});
|
|
|
|
const columns = [
|
|
|
|
{
|
|
|
|
name: 'name',
|
|
|
|
label: 'Getränk',
|
|
|
|
field: 'name',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'prices',
|
|
|
|
label: 'Preise',
|
|
|
|
field: 'prices',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
return { columns, drinks };
|
|
|
|
},
|
|
|
|
});
|
2021-02-13 13:11:25 +00:00
|
|
|
</script>
|