flaschengeist-frontend/src/plugins/pricelist/pages/CocktailBuilder.vue

66 lines
1.9 KiB
Vue
Raw Normal View History

2021-03-28 17:53:04 +00:00
<template>
<q-card>
<q-card-section>
<div class="q-table__title">Cocktailbuilder</div>
</q-card-section>
<q-card-section>
<ingredients
v-model="volume.ingredients"
2021-03-28 17:53:04 +00:00
class="q-pa-sm"
editable
@update:modelValue="update"
2021-03-28 17:53:04 +00:00
/>
</q-card-section>
<q-card-section>
<div class="q-table__title">Du solltest mindest sowiel verlangen oder bezahlen:</div>
<div class="full-width row q-gutter-sm justify-around">
<div v-for="min_price in volume.min_prices" :key="min_price.percentage">
<div>
<q-badge class="text-h6" color="primary"> {{ min_price.percentage }}% </q-badge>
</div>
<div>{{ min_price.price.toFixed(2) }}</div>
</div>
</div>
</q-card-section>
</q-card>
</template>
<script lang="ts">
2021-04-09 21:49:49 +00:00
import { defineComponent, onBeforeMount, ref } from 'vue';
2021-03-28 17:53:04 +00:00
import Ingredients from 'src/plugins/pricelist/components/CalculationTable/Ingredients.vue';
import { DrinkPriceVolume, usePricelistStore } from 'src/plugins/pricelist/store';
import { calc_min_prices } from '../utils/utils';
2021-03-28 17:53:04 +00:00
export default defineComponent({
name: 'CocktailBuilder',
components: { Ingredients },
setup() {
onBeforeMount(() => {
void store.get_min_prices().finally(() => {
volume.value.min_prices = calc_min_prices(volume.value, undefined, store.min_prices);
2021-03-28 17:53:04 +00:00
});
void store.getDrinks();
void store.getDrinkTypes();
void store.getExtraIngredients();
});
const store = usePricelistStore();
const emptyVolume: DrinkPriceVolume = {
id: -1,
_volume: 0,
min_prices: [],
prices: [],
ingredients: [],
};
const volume = ref(emptyVolume);
function update() {
volume.value.min_prices = calc_min_prices(volume.value, undefined, store.min_prices);
2021-03-28 17:53:04 +00:00
}
return { volume, update };
2021-03-28 17:53:04 +00:00
},
});
</script>
<style scoped></style>