2021-03-14 19:37:41 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<q-table
|
|
|
|
title="Kalkulationstabelle"
|
|
|
|
:columns="columns"
|
2021-03-15 18:57:42 +00:00
|
|
|
:data="drinks"
|
2021-03-14 19:37:41 +00:00
|
|
|
:visible-columns="visibleColumn"
|
|
|
|
:dense="$q.screen.lt.md"
|
|
|
|
>
|
|
|
|
<template v-slot:top-right>
|
|
|
|
<q-select
|
|
|
|
v-model="visibleColumn"
|
|
|
|
multiple
|
|
|
|
filled
|
|
|
|
dense
|
|
|
|
options-dense
|
|
|
|
display-value="Sichtbarkeit"
|
|
|
|
emit-value
|
|
|
|
map-options
|
|
|
|
:options="[...columns, ...column_calc, ...column_prices]"
|
|
|
|
option-value="name"
|
|
|
|
options-cover
|
|
|
|
/>
|
|
|
|
</template>
|
2021-03-15 18:57:42 +00:00
|
|
|
<template v-slot:body-cell-volumes="volumes">
|
2021-03-14 19:37:41 +00:00
|
|
|
<q-table
|
|
|
|
:columns="column_calc"
|
2021-03-15 18:57:42 +00:00
|
|
|
:data="volumes.value"
|
2021-03-14 19:37:41 +00:00
|
|
|
dense
|
|
|
|
:visible-columns="visibleColumn"
|
|
|
|
row-key="id"
|
|
|
|
flat
|
|
|
|
>
|
|
|
|
<template v-slot:header="props">
|
|
|
|
<q-tr :props="props">
|
|
|
|
<q-th auto-width />
|
2021-03-15 18:57:42 +00:00
|
|
|
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
|
|
|
{{ col.label }}
|
2021-03-14 19:37:41 +00:00
|
|
|
</q-th>
|
|
|
|
</q-tr>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-slot:body="props">
|
|
|
|
<q-tr :props="props">
|
|
|
|
<q-td auto-width>
|
|
|
|
<q-btn
|
|
|
|
size="sm"
|
|
|
|
color="accent"
|
|
|
|
round
|
|
|
|
dense
|
2021-03-15 22:52:40 +00:00
|
|
|
@click="
|
|
|
|
props.expand = !props.expand;
|
|
|
|
console.log(volumes);
|
|
|
|
"
|
2021-03-14 19:37:41 +00:00
|
|
|
:icon="props.expand ? 'mdi-chevron-up' : 'mdi-chevron-down'"
|
2021-03-15 22:52:40 +00:00
|
|
|
v-if="volumes.row.cost_price_pro_volume == null"
|
2021-03-14 19:37:41 +00:00
|
|
|
/>
|
2021-03-16 17:10:37 +00:00
|
|
|
<q-btn
|
|
|
|
size="xs"
|
|
|
|
color="negative"
|
|
|
|
round
|
|
|
|
dense
|
|
|
|
icon="mdi-delete"
|
|
|
|
class="q-mx-sm"
|
|
|
|
v-if="props.row.ingredients.length === 0 && props.row.prices.length === 0"
|
|
|
|
@click="deleteVolume(props.row, volumes.row)"
|
|
|
|
/>
|
2021-03-14 19:37:41 +00:00
|
|
|
</q-td>
|
2021-03-15 22:52:40 +00:00
|
|
|
<q-td key="volume" :props="props">
|
2021-03-16 17:10:37 +00:00
|
|
|
{{ parseFloat(props.row.volume.value).toFixed(3) }}L
|
|
|
|
<!--{{ props.row.volume }}-->
|
2021-03-15 22:52:40 +00:00
|
|
|
<q-popup-edit
|
|
|
|
buttons
|
|
|
|
label-cancel="Abbrechen"
|
|
|
|
label-set="Speichern"
|
2021-03-16 17:10:37 +00:00
|
|
|
v-model="props.row.volume.value"
|
|
|
|
v-if="volumes.row.cost_price_pro_volume"
|
2021-03-15 22:52:40 +00:00
|
|
|
@save="updateVolume(props.row, volumes.row)"
|
|
|
|
>
|
|
|
|
<q-input
|
2021-03-14 19:37:41 +00:00
|
|
|
dense
|
2021-03-15 22:52:40 +00:00
|
|
|
filled
|
2021-03-16 17:10:37 +00:00
|
|
|
v-model.number="props.row.volume.value"
|
2021-03-15 22:52:40 +00:00
|
|
|
type="number"
|
|
|
|
suffix="L"
|
|
|
|
/>
|
|
|
|
</q-popup-edit>
|
|
|
|
</q-td>
|
|
|
|
<q-td key="min_prices" :props="props">
|
|
|
|
<div
|
|
|
|
v-for="(min_price, index) in props.row.min_prices"
|
|
|
|
:key="`min_prices` + index"
|
|
|
|
class="row justify-between"
|
|
|
|
>
|
|
|
|
<div class="col">
|
|
|
|
<q-badge color="primary">{{ min_price.percentage }}%</q-badge>
|
|
|
|
</div>
|
|
|
|
<div class="col" style="text-align: end">
|
2021-03-16 17:10:37 +00:00
|
|
|
<!--{{ parseFloat(min_price.price).toFixed(3) }}€-->
|
|
|
|
{{ min_price.price.value.toFixed(3) }}€
|
2021-03-15 22:52:40 +00:00
|
|
|
</div>
|
2021-03-14 19:37:41 +00:00
|
|
|
</div>
|
|
|
|
</q-td>
|
2021-03-15 22:52:40 +00:00
|
|
|
<q-td key="prices" :props="props">
|
|
|
|
<price-table
|
|
|
|
:columns="column_prices"
|
|
|
|
:data="props.row.prices"
|
|
|
|
:row="props.row"
|
|
|
|
:visible-columns="visibleColumn"
|
|
|
|
/>
|
|
|
|
</q-td>
|
2021-03-14 19:37:41 +00:00
|
|
|
</q-tr>
|
|
|
|
<q-tr v-show="props.expand" :props="props">
|
|
|
|
<q-td colspan="100%">
|
|
|
|
<div
|
2021-03-15 18:57:42 +00:00
|
|
|
v-for="ingredient in props.row.ingredients"
|
|
|
|
:key="`volume:${props.row.id},ingredient:${ingredient.id}`"
|
2021-03-14 19:37:41 +00:00
|
|
|
class="full-width row justify-evenly q-py-xs"
|
|
|
|
>
|
2021-03-15 18:57:42 +00:00
|
|
|
<div
|
|
|
|
class="full-width row justify-evenly q-py-xs"
|
|
|
|
v-if="ingredient.drink_ingredient"
|
|
|
|
>
|
|
|
|
<q-select
|
|
|
|
class="col q-px-sm"
|
|
|
|
label="Getränk"
|
|
|
|
filled
|
|
|
|
dense
|
|
|
|
:options="drinks"
|
|
|
|
option-label="name"
|
|
|
|
v-model="ingredient.drink_ingredient"
|
|
|
|
/>
|
|
|
|
<q-input
|
|
|
|
class="col q-px-sm"
|
|
|
|
label="Volume in L"
|
|
|
|
type="number"
|
|
|
|
filled
|
|
|
|
dense
|
|
|
|
v-model.number="ingredient.volume"
|
|
|
|
step="0.01"
|
|
|
|
min="0"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div v-else-if="ingredient.name">
|
|
|
|
{{ ingredient.name }} {{ ingredient.price }}
|
|
|
|
</div>
|
2021-03-14 19:37:41 +00:00
|
|
|
</div>
|
|
|
|
<div class="full-width row justify-end q-py-xs">
|
|
|
|
<q-btn
|
|
|
|
size="sm"
|
|
|
|
icon-right="add"
|
|
|
|
color="positive"
|
|
|
|
label="Zutat hinzufügen"
|
2021-03-15 18:57:42 +00:00
|
|
|
@click="addIngredient(props.row.ingredients, props.row.id)"
|
2021-03-14 19:37:41 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</q-td>
|
|
|
|
</q-tr>
|
|
|
|
</template>
|
|
|
|
<template v-slot:bottom>
|
|
|
|
<div class="full-width row justify-end">
|
|
|
|
<q-btn
|
|
|
|
color="positive"
|
|
|
|
icon-right="add"
|
|
|
|
label="Abgabe hinzufügen"
|
|
|
|
size="xs"
|
2021-03-15 22:52:40 +00:00
|
|
|
v-if="volumes.row.cost_price_pro_volume"
|
|
|
|
>
|
|
|
|
<q-menu anchor="center middle" self="center middle">
|
|
|
|
<div class="row justify-around q-pa-sm">
|
|
|
|
<q-input dense label="Liter" type="number" v-model.number="newVolume.volume" />
|
|
|
|
</div>
|
|
|
|
<div class="row justify-between q-pa-sm">
|
|
|
|
<q-btn label="Abbrechen" @click="cancelAddVolume" v-close-popup />
|
|
|
|
<q-btn
|
|
|
|
label="Speichern"
|
|
|
|
color="primary"
|
|
|
|
@click="addVolume(volumes.row)"
|
|
|
|
v-close-popup
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</q-menu>
|
|
|
|
</q-btn>
|
2021-03-14 19:37:41 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</q-table>
|
|
|
|
</template>
|
|
|
|
</q-table>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-03-16 17:10:37 +00:00
|
|
|
import {
|
|
|
|
defineComponent,
|
|
|
|
onBeforeMount,
|
|
|
|
ref,
|
|
|
|
computed,
|
|
|
|
WritableComputedRef
|
|
|
|
} from '@vue/composition-api';
|
2021-03-14 19:37:41 +00:00
|
|
|
import { v4 } from 'uuid';
|
2021-03-16 17:10:37 +00:00
|
|
|
import store, { create_volume, DrinkPriceVolume, Drink } from '../store/altStore';
|
2021-03-15 22:52:40 +00:00
|
|
|
import PriceTable from 'src/plugins/pricelist/components/CalculationTable/PriceTable.vue';
|
2021-03-14 19:37:41 +00:00
|
|
|
export default defineComponent({
|
|
|
|
name: 'CalculationTable',
|
2021-03-15 22:52:40 +00:00
|
|
|
components: { PriceTable },
|
2021-03-14 19:37:41 +00:00
|
|
|
setup(_, { root }) {
|
|
|
|
onBeforeMount(() => {
|
2021-03-15 18:57:42 +00:00
|
|
|
store.actions.getDrinks();
|
2021-03-14 19:37:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const columns = [
|
|
|
|
{
|
|
|
|
name: 'name',
|
|
|
|
label: 'Getränkename',
|
2021-03-15 22:52:40 +00:00
|
|
|
field: 'name'
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'article_id',
|
|
|
|
label: 'Artikelnummer',
|
2021-03-15 22:52:40 +00:00
|
|
|
field: 'article_id'
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
2021-03-15 18:57:42 +00:00
|
|
|
name: 'drink_type',
|
2021-03-14 19:37:41 +00:00
|
|
|
label: 'Kategorie',
|
2021-03-15 18:57:42 +00:00
|
|
|
field: 'type',
|
2021-03-15 22:52:40 +00:00
|
|
|
format: (val: FG.DrinkType) => `${val.name}`
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'volume_package',
|
|
|
|
label: 'Inhalt in l des Gebinde',
|
2021-03-15 22:52:40 +00:00
|
|
|
field: 'volume'
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'package_size',
|
|
|
|
label: 'Gebindegröße',
|
2021-03-15 22:52:40 +00:00
|
|
|
field: 'package_size'
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'cost_price_package_netto',
|
|
|
|
label: 'Preis Netto/Gebinde',
|
|
|
|
field: 'cost_price_package_netto',
|
2021-03-15 22:52:40 +00:00
|
|
|
format: (val: number | null) => (val ? `${val.toFixed(3)}€` : '')
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'cost_price_pro_volume',
|
|
|
|
label: 'Preis mit 19%/Liter',
|
|
|
|
field: 'cost_price_pro_volume',
|
2021-03-15 22:52:40 +00:00
|
|
|
format: (val: number | null) => (val ? `${val.toFixed(3)}€` : '')
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
2021-03-15 18:57:42 +00:00
|
|
|
name: 'volumes',
|
2021-03-14 19:37:41 +00:00
|
|
|
label: 'Preiskalkulation',
|
2021-03-15 22:52:40 +00:00
|
|
|
field: 'volumes'
|
|
|
|
}
|
2021-03-14 19:37:41 +00:00
|
|
|
];
|
|
|
|
const column_calc = [
|
|
|
|
{
|
|
|
|
name: 'volume',
|
|
|
|
label: 'Abgabe in l',
|
|
|
|
field: 'volume',
|
2021-03-15 22:52:40 +00:00
|
|
|
format: (val: number) => `${val} L`
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'min_prices',
|
|
|
|
label: 'Minimal Preise',
|
2021-03-15 22:52:40 +00:00
|
|
|
field: 'min_prices'
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'prices',
|
|
|
|
label: 'Preise',
|
2021-03-15 22:52:40 +00:00
|
|
|
field: 'prices'
|
|
|
|
}
|
2021-03-14 19:37:41 +00:00
|
|
|
];
|
|
|
|
const column_prices = [
|
|
|
|
{
|
|
|
|
name: 'price',
|
|
|
|
label: 'Preis',
|
|
|
|
field: 'price',
|
2021-03-15 22:52:40 +00:00
|
|
|
format: (val: number) => `${val.toFixed(2)}€`
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'description',
|
|
|
|
label: 'Beschreibung',
|
2021-03-15 22:52:40 +00:00
|
|
|
field: 'description'
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
2021-03-15 18:57:42 +00:00
|
|
|
name: 'public',
|
|
|
|
label: 'Öffentlich',
|
2021-03-15 22:52:40 +00:00
|
|
|
field: 'public'
|
|
|
|
}
|
2021-03-15 18:57:42 +00:00
|
|
|
];
|
2021-03-14 19:37:41 +00:00
|
|
|
const visibleColumn = ref([
|
|
|
|
'name',
|
|
|
|
'drink_kind',
|
|
|
|
'cost_price_pro_volumne',
|
2021-03-15 18:57:42 +00:00
|
|
|
'volumes',
|
2021-03-14 19:37:41 +00:00
|
|
|
'volume',
|
|
|
|
'min_prices',
|
|
|
|
'prices',
|
|
|
|
'price',
|
2021-03-15 18:57:42 +00:00
|
|
|
'description',
|
2021-03-15 22:52:40 +00:00
|
|
|
'public'
|
2021-03-14 19:37:41 +00:00
|
|
|
]);
|
2021-03-16 17:10:37 +00:00
|
|
|
const emptyVolume: DrinkPriceVolume = {
|
2021-03-15 22:52:40 +00:00
|
|
|
id: -1,
|
2021-03-16 17:10:37 +00:00
|
|
|
_volume: 0,
|
|
|
|
volume: null,
|
2021-03-15 22:52:40 +00:00
|
|
|
min_prices: [
|
2021-03-16 17:10:37 +00:00
|
|
|
{ percentage: 100, price: null },
|
|
|
|
{ percentage: 250, price: null },
|
|
|
|
{ percentage: 300, price: null }
|
2021-03-15 22:52:40 +00:00
|
|
|
],
|
|
|
|
prices: [],
|
|
|
|
ingredients: []
|
2021-03-15 18:57:42 +00:00
|
|
|
};
|
2021-03-16 17:10:37 +00:00
|
|
|
const newVolume = ref<DrinkPriceVolume>(emptyVolume);
|
|
|
|
function addVolume(drink: Drink) {
|
|
|
|
store.actions.setVolume(<DrinkPriceVolume>newVolume.value, drink);
|
2021-03-15 22:52:40 +00:00
|
|
|
cancelAddVolume();
|
2021-03-15 18:57:42 +00:00
|
|
|
}
|
2021-03-15 22:52:40 +00:00
|
|
|
function cancelAddVolume() {
|
2021-03-15 18:57:42 +00:00
|
|
|
setTimeout(() => {
|
2021-03-16 17:10:37 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
// @ts-ignore
|
2021-03-15 22:52:40 +00:00
|
|
|
newVolume.value = emptyVolume;
|
2021-03-15 18:57:42 +00:00
|
|
|
}, 200);
|
|
|
|
}
|
2021-03-16 17:10:37 +00:00
|
|
|
function updateVolume(volume: DrinkPriceVolume, drink: Drink) {
|
2021-03-15 22:52:40 +00:00
|
|
|
console.log(volume);
|
|
|
|
store.actions.updateVolume(volume, drink);
|
2021-03-14 19:37:41 +00:00
|
|
|
}
|
2021-03-16 17:10:37 +00:00
|
|
|
function deleteVolume(volume: FG.DrinkPriceVolume, drink: FG.Drink) {
|
|
|
|
store.actions.deleteVolume(volume, drink);
|
|
|
|
}
|
2021-03-14 19:37:41 +00:00
|
|
|
|
2021-03-15 18:57:42 +00:00
|
|
|
function addIngredient(ingredients: FG.Ingredient[]) {
|
|
|
|
ingredients.push({ id: -1, volume_id: 0, drink_ingredient: null, extra_ingredient: null });
|
2021-03-14 19:37:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2021-03-15 22:52:40 +00:00
|
|
|
drinks: computed(() => store.state.drinks),
|
2021-03-14 19:37:41 +00:00
|
|
|
columns,
|
|
|
|
column_calc,
|
|
|
|
column_prices,
|
|
|
|
visibleColumn,
|
|
|
|
addVolume,
|
2021-03-15 22:52:40 +00:00
|
|
|
cancelAddVolume,
|
|
|
|
newVolume,
|
|
|
|
updateVolume,
|
2021-03-16 17:10:37 +00:00
|
|
|
deleteVolume,
|
2021-03-14 19:37:41 +00:00
|
|
|
addIngredient,
|
2021-03-15 22:52:40 +00:00
|
|
|
console
|
2021-03-14 19:37:41 +00:00
|
|
|
};
|
2021-03-15 22:52:40 +00:00
|
|
|
}
|
2021-03-14 19:37:41 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped></style>
|