2021-03-14 19:37:41 +00:00
|
|
|
<template>
|
2021-03-17 20:36:26 +00:00
|
|
|
<q-table
|
2021-03-19 15:33:27 +00:00
|
|
|
v-model:pagination="pagination"
|
2021-03-17 20:36:26 +00:00
|
|
|
title="Kalkulationstabelle"
|
|
|
|
:columns="columns"
|
2021-03-19 19:41:21 +00:00
|
|
|
:rows="drinks"
|
2021-03-17 20:36:26 +00:00
|
|
|
:visible-columns="visibleColumn"
|
|
|
|
:dense="$q.screen.lt.md"
|
|
|
|
row-key="id"
|
|
|
|
virtual-scroll
|
|
|
|
:rows-per-page-options="[0]"
|
2021-03-31 12:18:55 +00:00
|
|
|
:filter="search"
|
|
|
|
:filter-method="filter"
|
2021-03-17 20:36:26 +00:00
|
|
|
>
|
2021-03-19 15:33:27 +00:00
|
|
|
<template #header="props">
|
2021-03-17 20:36:26 +00:00
|
|
|
<q-tr :props="props">
|
|
|
|
<q-th auto-width />
|
|
|
|
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
|
|
|
{{ col.label }}
|
|
|
|
</q-th>
|
|
|
|
</q-tr>
|
|
|
|
</template>
|
2021-03-19 15:33:27 +00:00
|
|
|
<template #top-right>
|
2021-03-17 20:36:26 +00:00
|
|
|
<div class="row justify-end q-gutter-sm">
|
2021-04-02 17:32:08 +00:00
|
|
|
<search-input v-model="search" :keys="search_keys" />
|
2021-03-21 21:07:12 +00:00
|
|
|
<q-btn label="Aufpreise">
|
|
|
|
<q-menu anchor="center middle" self="center middle">
|
|
|
|
<min-price-setting />
|
|
|
|
</q-menu>
|
|
|
|
</q-btn>
|
2021-03-17 20:36:26 +00:00
|
|
|
<q-btn label="neues Getränk" color="positive" icon-right="add">
|
2021-03-31 13:17:43 +00:00
|
|
|
<q-menu v-model="showNewDrink" anchor="center middle" self="center middle" persistent>
|
2021-03-21 22:02:25 +00:00
|
|
|
<new-drink @close="showNewDrink = false" />
|
2021-03-17 20:36:26 +00:00
|
|
|
</q-menu>
|
|
|
|
</q-btn>
|
2021-03-14 19:37:41 +00:00
|
|
|
<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
|
|
|
|
/>
|
2021-03-17 20:36:26 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
2021-03-19 15:33:27 +00:00
|
|
|
<template #body="drinks_props">
|
2021-03-17 20:36:26 +00:00
|
|
|
<q-tr :props="drinks_props">
|
|
|
|
<q-td auto-width>
|
|
|
|
<q-btn
|
2021-03-19 15:33:27 +00:00
|
|
|
v-if="drinks_props.row.volumes.length === 0"
|
2021-03-17 20:36:26 +00:00
|
|
|
size="xs"
|
|
|
|
color="negative"
|
|
|
|
round
|
|
|
|
dense
|
|
|
|
icon="mdi-delete"
|
|
|
|
class="q-mx-sm"
|
|
|
|
@click="deleteDrink(drinks_props.row)"
|
|
|
|
/>
|
|
|
|
</q-td>
|
2021-03-25 22:14:49 +00:00
|
|
|
<q-td key="picture" :props="drinks_props" style="min-width: 256px">
|
2021-03-22 22:18:22 +00:00
|
|
|
<q-img
|
2021-03-28 11:40:41 +00:00
|
|
|
loading="lazy"
|
|
|
|
:src="
|
|
|
|
drinks_props.row.uuid
|
|
|
|
? `/api/pricelist/picture/${drinks_props.row.uuid}?size=256`
|
|
|
|
: 'no-image.svg'
|
|
|
|
"
|
|
|
|
placeholder-src="no-image.svg"
|
2021-03-28 09:34:36 +00:00
|
|
|
>
|
2021-03-28 11:40:41 +00:00
|
|
|
<template #error>
|
2021-03-28 09:34:36 +00:00
|
|
|
<div class="absolute-full flex flex-center bg-negative text-white">
|
|
|
|
Cannot load image
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</q-img>
|
2021-03-25 22:14:49 +00:00
|
|
|
<q-popup-edit v-model="drinkPic" @update:modelValue="savePicture(drinks_props.row)">
|
|
|
|
<template #default="scope">
|
|
|
|
<div class="full-width row">
|
|
|
|
<q-file v-model="scope.value" filled>
|
|
|
|
<template #prepend>
|
|
|
|
<q-icon name="attach_file" />
|
|
|
|
</template>
|
|
|
|
</q-file>
|
|
|
|
<div class="full-width row justify-between">
|
|
|
|
<q-btn label="Abbrechen" flat color="primary" @click="scope.cancel" />
|
|
|
|
<q-btn
|
|
|
|
label="Löschen"
|
|
|
|
flat
|
|
|
|
color="primary"
|
|
|
|
@click="
|
|
|
|
scope.cancel();
|
|
|
|
deletePicture(drinks_props.row);
|
|
|
|
"
|
|
|
|
/>
|
|
|
|
<q-btn label="Speichern" flat color="primary" @click="scope.set" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
2021-03-22 22:18:22 +00:00
|
|
|
</q-popup-edit>
|
|
|
|
</q-td>
|
2021-03-17 20:36:26 +00:00
|
|
|
<q-td key="name" :props="drinks_props">
|
|
|
|
{{ drinks_props.row.name }}
|
|
|
|
<q-popup-edit
|
2021-03-21 21:07:12 +00:00
|
|
|
v-slot="scope"
|
2021-03-17 20:36:26 +00:00
|
|
|
v-model="drinks_props.row.name"
|
|
|
|
buttons
|
|
|
|
label-cancel="Abbrechen"
|
|
|
|
label-set="Speichern"
|
2021-03-21 21:07:12 +00:00
|
|
|
@update:modelValue="updateDrink(drinks_props.row)"
|
2021-03-17 20:36:26 +00:00
|
|
|
>
|
2021-03-21 21:07:12 +00:00
|
|
|
<q-input
|
|
|
|
v-model="scope.value"
|
|
|
|
filled
|
|
|
|
dense
|
|
|
|
autofocus
|
|
|
|
clearable
|
|
|
|
@keyup.enter="scope.set"
|
|
|
|
/>
|
2021-03-17 20:36:26 +00:00
|
|
|
</q-popup-edit>
|
|
|
|
</q-td>
|
2021-04-01 20:39:54 +00:00
|
|
|
<q-td key="drink_type" :props="drinks_props">
|
|
|
|
{{ drinks_props.row.type.name }}
|
2021-03-17 20:36:26 +00:00
|
|
|
<q-popup-edit
|
2021-03-21 21:07:12 +00:00
|
|
|
v-slot="scope"
|
2021-04-01 20:39:54 +00:00
|
|
|
v-model="drinks_props.row.type"
|
2021-03-17 20:36:26 +00:00
|
|
|
buttons
|
|
|
|
label-cancel="Abbrechen"
|
|
|
|
label-set="Speichern"
|
2021-03-21 21:07:12 +00:00
|
|
|
@update:modelValue="updateDrink(drinks_props.row)"
|
2021-03-17 20:36:26 +00:00
|
|
|
>
|
2021-04-01 20:39:54 +00:00
|
|
|
<q-select
|
2021-03-21 21:07:12 +00:00
|
|
|
v-model="scope.value"
|
2021-04-01 20:39:54 +00:00
|
|
|
:options="drinkTypes"
|
|
|
|
option-label="name"
|
|
|
|
option-value="id"
|
2021-03-17 20:36:26 +00:00
|
|
|
filled
|
|
|
|
dense
|
|
|
|
autofocus
|
2021-03-21 21:07:12 +00:00
|
|
|
@keyup.enter="scope.set"
|
2021-03-17 20:36:26 +00:00
|
|
|
/>
|
|
|
|
</q-popup-edit>
|
|
|
|
</q-td>
|
2021-04-01 20:39:54 +00:00
|
|
|
<q-td key="tags" :props="drinks_props">
|
|
|
|
<q-badge
|
|
|
|
v-for="tag in drinks_props.row.tags"
|
|
|
|
:key="`${drinks_props.row.id}-${tag.id}`"
|
|
|
|
class="q-ma-xs"
|
|
|
|
rounded
|
|
|
|
:style="`background-color: ${tag.color}`"
|
|
|
|
>
|
|
|
|
{{ tag.name }}
|
|
|
|
</q-badge>
|
|
|
|
<q-popup-edit
|
|
|
|
v-model="drinks_props.row.tags"
|
|
|
|
buttons
|
|
|
|
label-cancel="Abbrechen"
|
|
|
|
label-set="Speichern"
|
|
|
|
@update:modelValue="updateDrink(drinks_props.row)"
|
|
|
|
>
|
|
|
|
<template #default="scope">
|
|
|
|
<q-select
|
|
|
|
v-model="scope.value"
|
|
|
|
multiple
|
|
|
|
:options="tags"
|
|
|
|
label="Tags"
|
|
|
|
option-label="name"
|
|
|
|
filled
|
|
|
|
>
|
|
|
|
<template #selected-item="item">
|
|
|
|
<q-chip
|
|
|
|
removable
|
|
|
|
:tabindex="item.tabindex"
|
|
|
|
:style="`background-color: ${item.opt.color}`"
|
|
|
|
@remove="item.removeAtIndex(item.index)"
|
|
|
|
>
|
|
|
|
{{ item.opt.name }}
|
|
|
|
</q-chip>
|
|
|
|
</template>
|
|
|
|
<template #option="item">
|
|
|
|
<q-item v-bind="item.itemProps" v-on="item.itemEvents">
|
|
|
|
<q-chip :style="`background-color: ${item.opt.color}`">
|
|
|
|
<q-avatar
|
|
|
|
v-if="item.selected"
|
|
|
|
icon="mdi-check"
|
|
|
|
color="positive"
|
|
|
|
text-color="white"
|
|
|
|
/>
|
|
|
|
{{ item.opt.name }}
|
|
|
|
</q-chip>
|
|
|
|
</q-item>
|
|
|
|
</template>
|
|
|
|
</q-select>
|
|
|
|
</template>
|
|
|
|
</q-popup-edit>
|
|
|
|
</q-td>
|
|
|
|
<q-td key="article_id" :props="drinks_props">
|
|
|
|
{{ drinks_props.row.article_id || 'o.A.' }}
|
2021-03-17 20:36:26 +00:00
|
|
|
<q-popup-edit
|
2021-03-21 21:07:12 +00:00
|
|
|
v-slot="scope"
|
2021-04-01 20:39:54 +00:00
|
|
|
v-model="drinks_props.row.article_id"
|
2021-03-17 20:36:26 +00:00
|
|
|
buttons
|
|
|
|
label-cancel="Abbrechen"
|
|
|
|
label-set="Speichern"
|
2021-03-21 21:07:12 +00:00
|
|
|
@update:modelValue="updateDrink(drinks_props.row)"
|
2021-03-17 20:36:26 +00:00
|
|
|
>
|
2021-04-01 20:39:54 +00:00
|
|
|
<q-input
|
2021-03-21 21:07:12 +00:00
|
|
|
v-model="scope.value"
|
|
|
|
filled
|
|
|
|
dense
|
|
|
|
autofocus
|
2021-04-01 20:39:54 +00:00
|
|
|
clearable
|
2021-03-21 21:07:12 +00:00
|
|
|
@keyup.enter="scope.set"
|
|
|
|
/>
|
2021-03-17 20:36:26 +00:00
|
|
|
</q-popup-edit>
|
|
|
|
</q-td>
|
|
|
|
<q-td key="volume_package" :props="drinks_props">
|
|
|
|
{{ drinks_props.row.volume ? `${drinks_props.row.volume} L` : 'o.A.' }}
|
|
|
|
<q-popup-edit
|
|
|
|
v-if="
|
2021-03-18 16:23:57 +00:00
|
|
|
!drinks_props.row.volumes.some((volume) =>
|
|
|
|
volume.ingredients.some((ingredient) => ingredient.drink_ingredient)
|
2021-03-17 20:36:26 +00:00
|
|
|
)
|
|
|
|
"
|
2021-03-21 21:07:12 +00:00
|
|
|
v-slot="scope"
|
2021-03-17 20:36:26 +00:00
|
|
|
v-model.number="drinks_props.row.volume"
|
|
|
|
buttons
|
|
|
|
label-cancel="Abbrechen"
|
|
|
|
label-set="Speichern"
|
2021-03-21 21:07:12 +00:00
|
|
|
@update:modelValue="updateDrink(drinks_props.row)"
|
2021-03-17 20:36:26 +00:00
|
|
|
>
|
|
|
|
<q-input
|
2021-03-21 21:07:12 +00:00
|
|
|
v-model.number="scope.value"
|
2021-03-17 20:36:26 +00:00
|
|
|
filled
|
|
|
|
dense
|
|
|
|
autofocus
|
|
|
|
type="number"
|
|
|
|
clearable
|
|
|
|
step="0.01"
|
|
|
|
min="0"
|
|
|
|
suffix="L"
|
2021-03-21 21:07:12 +00:00
|
|
|
@keyup.enter="scope.set"
|
2021-03-17 20:36:26 +00:00
|
|
|
/>
|
|
|
|
</q-popup-edit>
|
|
|
|
</q-td>
|
|
|
|
<q-td key="package_size" :props="drinks_props">
|
|
|
|
{{ drinks_props.row.package_size || 'o.A.' }}
|
|
|
|
<q-popup-edit
|
|
|
|
v-if="
|
2021-03-18 16:23:57 +00:00
|
|
|
!drinks_props.row.volumes.some((volume) =>
|
|
|
|
volume.ingredients.some((ingredient) => ingredient.drink_ingredient)
|
2021-03-17 20:36:26 +00:00
|
|
|
)
|
|
|
|
"
|
2021-03-21 21:07:12 +00:00
|
|
|
v-slot="scope"
|
2021-03-17 20:36:26 +00:00
|
|
|
v-model="drinks_props.row.package_size"
|
|
|
|
buttons
|
|
|
|
label-cancel="Abbrechen"
|
|
|
|
label-set="Speichern"
|
2021-03-21 21:07:12 +00:00
|
|
|
@update:modelValue="updateDrink(drinks_props.row)"
|
2021-03-17 20:36:26 +00:00
|
|
|
>
|
|
|
|
<q-input
|
2021-03-21 21:07:12 +00:00
|
|
|
v-model.number="scope.value"
|
2021-03-17 20:36:26 +00:00
|
|
|
filled
|
|
|
|
dense
|
|
|
|
autofocus
|
|
|
|
type="number"
|
|
|
|
min="0"
|
2021-03-21 21:07:12 +00:00
|
|
|
@keyup.enter="scope.set"
|
2021-03-17 20:36:26 +00:00
|
|
|
/>
|
|
|
|
</q-popup-edit>
|
|
|
|
</q-td>
|
2021-04-02 12:06:03 +00:00
|
|
|
<q-td key="cost_per_package" :props="drinks_props">
|
2021-03-17 20:36:26 +00:00
|
|
|
{{
|
2021-04-02 12:06:03 +00:00
|
|
|
drinks_props.row.cost_per_package
|
|
|
|
? `${drinks_props.row.cost_per_package.toFixed(2)}€`
|
2021-03-17 20:36:26 +00:00
|
|
|
: 'o.A.'
|
|
|
|
}}
|
|
|
|
<q-popup-edit
|
|
|
|
v-if="
|
2021-03-18 16:23:57 +00:00
|
|
|
!drinks_props.row.volumes.some((volume) =>
|
|
|
|
volume.ingredients.some((ingredient) => ingredient.drink_ingredient)
|
2021-03-17 20:36:26 +00:00
|
|
|
)
|
|
|
|
"
|
2021-03-21 21:07:12 +00:00
|
|
|
v-slot="scope"
|
2021-04-02 12:06:03 +00:00
|
|
|
v-model="drinks_props.row.cost_per_package"
|
2021-03-17 20:36:26 +00:00
|
|
|
buttons
|
|
|
|
label-cancel="Abbrechen"
|
|
|
|
label-set="Speichern"
|
2021-03-21 21:07:12 +00:00
|
|
|
@update:modelValue="updateDrink(drinks_props.row)"
|
2021-03-17 20:36:26 +00:00
|
|
|
>
|
|
|
|
<q-input
|
2021-03-21 21:07:12 +00:00
|
|
|
v-model.number="scope.value"
|
2021-03-17 20:36:26 +00:00
|
|
|
filled
|
|
|
|
dense
|
|
|
|
autofocus
|
|
|
|
type="number"
|
|
|
|
step="0.01"
|
|
|
|
min="0"
|
|
|
|
suffix="€"
|
2021-03-21 21:07:12 +00:00
|
|
|
@keyup.enter="scope.set"
|
2021-03-17 20:36:26 +00:00
|
|
|
/>
|
|
|
|
</q-popup-edit>
|
|
|
|
</q-td>
|
2021-04-02 12:06:03 +00:00
|
|
|
<q-td key="cost_per_volume" :props="drinks_props">
|
2021-03-17 20:36:26 +00:00
|
|
|
{{
|
2021-04-02 12:06:03 +00:00
|
|
|
drinks_props.row.cost_per_volume
|
|
|
|
? `${drinks_props.row.cost_per_volume.toFixed(3)}€`
|
2021-03-17 20:36:26 +00:00
|
|
|
: 'o.A.'
|
|
|
|
}}
|
|
|
|
<q-popup-edit
|
|
|
|
v-if="
|
|
|
|
!(
|
2021-04-02 12:06:03 +00:00
|
|
|
!!drinks_props.row.cost_per_package &&
|
2021-03-17 20:36:26 +00:00
|
|
|
!!drinks_props.row.volume &&
|
|
|
|
!!drinks_props.row.package_size
|
|
|
|
) &&
|
2021-03-18 16:23:57 +00:00
|
|
|
!drinks_props.row.volumes.some((volume) =>
|
|
|
|
volume.ingredients.some((ingredient) => ingredient.drink_ingredient)
|
|
|
|
)
|
2021-03-17 20:36:26 +00:00
|
|
|
"
|
2021-03-21 21:07:12 +00:00
|
|
|
v-slot="scope"
|
2021-04-02 12:06:03 +00:00
|
|
|
v-model="drinks_props.row.cost_per_volume"
|
2021-03-17 20:36:26 +00:00
|
|
|
buttons
|
|
|
|
label-cancel="Abbrechen"
|
|
|
|
label-set="Speichern"
|
2021-03-21 21:07:12 +00:00
|
|
|
@update:modelValue="updateDrink(drinks_props.row)"
|
2021-03-17 20:36:26 +00:00
|
|
|
>
|
|
|
|
<q-input
|
2021-03-21 21:07:12 +00:00
|
|
|
v-model.number="scope.value"
|
2021-03-17 20:36:26 +00:00
|
|
|
filled
|
|
|
|
dense
|
|
|
|
autofocus
|
|
|
|
type="number"
|
|
|
|
min="0"
|
|
|
|
step="0.1"
|
|
|
|
suffix="€"
|
2021-03-21 21:07:12 +00:00
|
|
|
@keyup.enter="scope.set"
|
2021-03-17 20:36:26 +00:00
|
|
|
/>
|
|
|
|
</q-popup-edit>
|
|
|
|
</q-td>
|
|
|
|
<q-td key="volumes" :props="drinks_props">
|
2021-03-21 21:07:12 +00:00
|
|
|
<drink-price-volumes-table
|
|
|
|
:rows="drinks_props.row.volumes"
|
|
|
|
:visible-columns="visibleColumn"
|
|
|
|
:columns="column_calc"
|
|
|
|
:drink="drinks_props.row"
|
|
|
|
@updateDrink="updateDrink(drinks_props.row)"
|
|
|
|
/>
|
2021-03-17 20:36:26 +00:00
|
|
|
</q-td>
|
2021-03-29 10:50:50 +00:00
|
|
|
<q-td key="receipt" :props="drinks_props">
|
2021-03-29 20:35:54 +00:00
|
|
|
<build-manual
|
|
|
|
:steps="drinks_props.row.receipt"
|
|
|
|
@deleteStep="deleteStep($event, drinks_props.row)"
|
|
|
|
@addStep="addStep($event, drinks_props.row)"
|
|
|
|
/>
|
|
|
|
<!--<q-popup-edit
|
2021-03-29 10:50:50 +00:00
|
|
|
v-slot="scope"
|
|
|
|
v-model="drinks_props.row.receipt"
|
|
|
|
buttons
|
|
|
|
label-cancel="Abbrechen"
|
|
|
|
label-set="Speichern"
|
|
|
|
@update:modelValue="updateDrink(drinks_props.row)"
|
|
|
|
>
|
|
|
|
<q-input
|
|
|
|
v-model="scope.value"
|
2021-03-29 19:29:04 +00:00
|
|
|
type="textarea"
|
2021-03-29 10:50:50 +00:00
|
|
|
autofocus
|
|
|
|
counter
|
|
|
|
@keyup.enter.stop
|
|
|
|
/>
|
2021-03-29 20:35:54 +00:00
|
|
|
</q-popup-edit>-->
|
2021-03-29 10:50:50 +00:00
|
|
|
</q-td>
|
2021-03-17 20:36:26 +00:00
|
|
|
</q-tr>
|
|
|
|
</template>
|
|
|
|
</q-table>
|
2021-03-14 19:37:41 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-03-28 11:40:41 +00:00
|
|
|
import { defineComponent, onBeforeMount, ComputedRef, computed, ref } from 'vue';
|
2021-03-20 13:59:55 +00:00
|
|
|
import DrinkPriceVolumesTable from 'src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumesTable.vue';
|
2021-03-29 22:28:18 +00:00
|
|
|
import { useMainStore } from 'src/stores';
|
2021-03-20 13:59:55 +00:00
|
|
|
import { Drink, usePricelistStore } from 'src/plugins/pricelist/store';
|
2021-03-21 21:07:12 +00:00
|
|
|
import MinPriceSetting from 'src/plugins/pricelist/components/MinPriceSetting.vue';
|
2021-03-21 22:02:25 +00:00
|
|
|
import NewDrink from 'src/plugins/pricelist/components/CalculationTable/NewDrink.vue';
|
2021-03-29 20:35:54 +00:00
|
|
|
import BuildManual from 'src/plugins/pricelist/components/CalculationTable/BuildManual.vue';
|
2021-03-31 12:18:55 +00:00
|
|
|
import SearchInput from './SearchInput.vue';
|
2021-04-01 09:15:21 +00:00
|
|
|
import { filter, Search } from '../utils/filter';
|
2021-03-22 22:18:22 +00:00
|
|
|
import { Notify } from 'quasar';
|
2021-04-01 09:15:21 +00:00
|
|
|
import { sort } from '../utils/sort';
|
2021-03-28 11:40:41 +00:00
|
|
|
|
2021-03-14 19:37:41 +00:00
|
|
|
export default defineComponent({
|
|
|
|
name: 'CalculationTable',
|
2021-03-31 12:18:55 +00:00
|
|
|
components: { SearchInput, BuildManual, MinPriceSetting, DrinkPriceVolumesTable, NewDrink },
|
2021-03-19 15:33:27 +00:00
|
|
|
setup() {
|
|
|
|
const mainStore = useMainStore();
|
2021-03-19 19:41:21 +00:00
|
|
|
const store = usePricelistStore();
|
2021-03-19 15:33:27 +00:00
|
|
|
|
2021-03-18 21:33:25 +00:00
|
|
|
onBeforeMount(() => {
|
2021-04-01 20:39:54 +00:00
|
|
|
void store.getDrinkTypes(true);
|
|
|
|
void store.getTags();
|
2021-03-29 20:35:54 +00:00
|
|
|
void store.getExtraIngredients();
|
|
|
|
void store.get_min_prices();
|
2021-03-19 19:41:21 +00:00
|
|
|
store.getPriceCalcColumn(user);
|
2021-03-18 21:33:25 +00:00
|
|
|
});
|
2021-03-19 15:33:27 +00:00
|
|
|
|
|
|
|
const user = mainStore.currentUser.userid;
|
|
|
|
|
2021-03-14 19:37:41 +00:00
|
|
|
const columns = [
|
2021-03-22 22:18:22 +00:00
|
|
|
{
|
|
|
|
name: 'picture',
|
|
|
|
label: 'Bild',
|
|
|
|
},
|
2021-03-14 19:37:41 +00:00
|
|
|
{
|
|
|
|
name: 'name',
|
2021-04-02 17:32:08 +00:00
|
|
|
label: 'Name',
|
2021-03-18 16:23:57 +00:00
|
|
|
field: 'name',
|
2021-03-18 20:10:54 +00:00
|
|
|
sortable: true,
|
|
|
|
sort,
|
2021-04-02 17:32:08 +00:00
|
|
|
filterable: true,
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
2021-04-01 20:39:54 +00:00
|
|
|
|
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-18 16:23:57 +00:00
|
|
|
format: (val: FG.DrinkType) => `${val.name}`,
|
2021-03-18 20:10:54 +00:00
|
|
|
sortable: true,
|
|
|
|
sort: (a: FG.DrinkType, b: FG.DrinkType) => sort(a.name, b.name),
|
2021-04-02 17:32:08 +00:00
|
|
|
filterable: true,
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
2021-04-01 20:39:54 +00:00
|
|
|
{
|
|
|
|
name: 'tags',
|
|
|
|
label: 'Tags',
|
|
|
|
field: 'tags',
|
|
|
|
format: (val: Array<FG.Tag>) => {
|
|
|
|
let retVal = '';
|
|
|
|
val.forEach((tag, index) => {
|
|
|
|
if (index > 0) {
|
|
|
|
retVal += ', ';
|
|
|
|
}
|
|
|
|
retVal += tag.name;
|
|
|
|
});
|
|
|
|
return retVal;
|
|
|
|
},
|
2021-04-02 17:32:08 +00:00
|
|
|
filterable: true,
|
2021-04-01 20:39:54 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'article_id',
|
|
|
|
label: 'Artikelnummer',
|
|
|
|
field: 'article_id',
|
|
|
|
sortable: true,
|
|
|
|
sort,
|
2021-04-02 17:32:08 +00:00
|
|
|
filterable: true,
|
2021-04-01 20:39:54 +00:00
|
|
|
},
|
2021-03-14 19:37:41 +00:00
|
|
|
{
|
|
|
|
name: 'volume_package',
|
|
|
|
label: 'Inhalt in l des Gebinde',
|
2021-03-18 16:23:57 +00:00
|
|
|
field: 'volume',
|
2021-03-18 20:10:54 +00:00
|
|
|
sortable: true,
|
|
|
|
sort,
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'package_size',
|
|
|
|
label: 'Gebindegröße',
|
2021-03-18 16:23:57 +00:00
|
|
|
field: 'package_size',
|
2021-03-18 20:10:54 +00:00
|
|
|
sortable: true,
|
|
|
|
sort,
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
2021-04-02 12:06:03 +00:00
|
|
|
name: 'cost_per_package',
|
2021-03-14 19:37:41 +00:00
|
|
|
label: 'Preis Netto/Gebinde',
|
2021-04-02 12:06:03 +00:00
|
|
|
field: 'cost_per_package',
|
2021-03-18 16:23:57 +00:00
|
|
|
format: (val: number | null) => (val ? `${val.toFixed(3)}€` : ''),
|
2021-03-18 20:10:54 +00:00
|
|
|
sortable: true,
|
|
|
|
sort,
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
2021-04-02 12:06:03 +00:00
|
|
|
name: 'cost_per_volume',
|
2021-03-14 19:37:41 +00:00
|
|
|
label: 'Preis mit 19%/Liter',
|
2021-04-02 12:06:03 +00:00
|
|
|
field: 'cost_per_volume',
|
2021-03-18 16:23:57 +00:00
|
|
|
format: (val: number | null) => (val ? `${val.toFixed(3)}€` : ''),
|
2021-03-18 20:10:54 +00:00
|
|
|
sortable: true,
|
|
|
|
sort: (a: ComputedRef, b: ComputedRef) => sort(a.value, b.value),
|
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-18 16:23:57 +00:00
|
|
|
field: 'volumes',
|
|
|
|
},
|
2021-03-29 10:50:50 +00:00
|
|
|
{
|
|
|
|
name: 'receipt',
|
|
|
|
label: 'Bauanleitung',
|
|
|
|
field: 'receipt',
|
2021-04-02 17:32:08 +00:00
|
|
|
filterable: true,
|
2021-03-29 10:50:50 +00:00
|
|
|
},
|
2021-03-14 19:37:41 +00:00
|
|
|
];
|
|
|
|
const column_calc = [
|
|
|
|
{
|
|
|
|
name: 'volume',
|
|
|
|
label: 'Abgabe in l',
|
|
|
|
field: 'volume',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'min_prices',
|
|
|
|
label: 'Minimal Preise',
|
2021-03-18 16:23:57 +00:00
|
|
|
field: 'min_prices',
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'prices',
|
|
|
|
label: 'Preise',
|
2021-03-18 16:23:57 +00:00
|
|
|
field: 'prices',
|
|
|
|
},
|
2021-03-14 19:37:41 +00:00
|
|
|
];
|
|
|
|
const column_prices = [
|
|
|
|
{
|
|
|
|
name: 'price',
|
|
|
|
label: 'Preis',
|
|
|
|
field: 'price',
|
2021-03-18 16:23:57 +00:00
|
|
|
format: (val: number) => `${val.toFixed(2)}€`,
|
2021-03-14 19:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'description',
|
|
|
|
label: 'Beschreibung',
|
2021-03-18 16:23:57 +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-18 16:23:57 +00:00
|
|
|
field: 'public',
|
|
|
|
},
|
2021-03-15 18:57:42 +00:00
|
|
|
];
|
2021-03-18 21:33:25 +00:00
|
|
|
const visibleColumn = computed({
|
2021-03-19 19:41:21 +00:00
|
|
|
get: () => store.pricecalc_columns,
|
2021-03-18 21:33:25 +00:00
|
|
|
set: (val) => {
|
2021-03-19 19:41:21 +00:00
|
|
|
store.updatePriceCalcColumn(user, val);
|
2021-03-18 21:33:25 +00:00
|
|
|
},
|
|
|
|
});
|
2021-03-14 19:37:41 +00:00
|
|
|
|
2021-04-02 17:32:08 +00:00
|
|
|
const search_keys = computed(() => columns.filter((column) => column.filterable));
|
|
|
|
|
2021-03-19 19:41:21 +00:00
|
|
|
// eslint-disable-next-line vue/return-in-computed-property
|
2021-03-17 20:36:26 +00:00
|
|
|
const pagination = computed(() => {
|
2021-03-19 19:41:21 +00:00
|
|
|
rowsPerPage: store.drinks.length;
|
2021-03-17 20:36:26 +00:00
|
|
|
});
|
|
|
|
|
2021-03-19 19:41:21 +00:00
|
|
|
const drinkTypes = computed(() => store.drinkTypes);
|
2021-03-17 20:36:26 +00:00
|
|
|
|
|
|
|
function updateDrink(drink: Drink) {
|
2021-03-21 21:07:12 +00:00
|
|
|
void store.updateDrink(drink);
|
2021-03-17 20:36:26 +00:00
|
|
|
}
|
2021-03-28 11:40:41 +00:00
|
|
|
|
2021-03-17 20:36:26 +00:00
|
|
|
function deleteDrink(drink: Drink) {
|
2021-03-19 19:41:21 +00:00
|
|
|
store.deleteDrink(drink);
|
2021-03-14 19:37:41 +00:00
|
|
|
}
|
|
|
|
|
2021-03-21 22:02:25 +00:00
|
|
|
const showNewDrink = ref(false);
|
|
|
|
|
2021-03-22 22:18:22 +00:00
|
|
|
const drinkPic = ref<File>();
|
|
|
|
|
|
|
|
function onPictureRejected() {
|
|
|
|
Notify.create({
|
|
|
|
group: false,
|
|
|
|
type: 'negative',
|
|
|
|
message: 'Datei zu groß oder keine gültige Bilddatei.',
|
|
|
|
timeout: 10000,
|
|
|
|
progress: true,
|
|
|
|
actions: [{ icon: 'mdi-close', color: 'white' }],
|
|
|
|
});
|
|
|
|
drinkPic.value = undefined;
|
|
|
|
}
|
2021-03-28 11:40:41 +00:00
|
|
|
|
2021-03-22 22:18:22 +00:00
|
|
|
function savePicture(drink: Drink) {
|
|
|
|
console.log('hier bin ich!!!', drinkPic.value);
|
2021-03-25 22:14:49 +00:00
|
|
|
if (drinkPic.value && drinkPic.value instanceof File) {
|
2021-03-28 11:40:41 +00:00
|
|
|
store.upload_drink_picture(drink, drinkPic.value).catch((response: Response) => {
|
|
|
|
if (response && response.status == 400) {
|
|
|
|
onPictureRejected();
|
|
|
|
}
|
|
|
|
});
|
2021-03-25 22:14:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-28 09:34:36 +00:00
|
|
|
function deletePicture(drink: Drink) {
|
2021-03-28 11:40:41 +00:00
|
|
|
void store.delete_drink_picture(drink);
|
2021-03-22 22:18:22 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 20:35:54 +00:00
|
|
|
function addStep(event: string, drink: Drink) {
|
|
|
|
console.log(event, drink.receipt);
|
|
|
|
drink.receipt?.push(event);
|
|
|
|
updateDrink(drink);
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteStep(event: number, drink: Drink) {
|
|
|
|
console.log(event, drink.receipt);
|
|
|
|
drink.receipt?.splice(event, 1);
|
|
|
|
updateDrink(drink);
|
|
|
|
}
|
|
|
|
|
2021-04-01 09:15:21 +00:00
|
|
|
const search = ref<Search>({
|
2021-03-31 12:18:55 +00:00
|
|
|
value: '',
|
|
|
|
key: '',
|
|
|
|
label: '',
|
|
|
|
});
|
2021-03-14 19:37:41 +00:00
|
|
|
return {
|
2021-03-19 19:41:21 +00:00
|
|
|
drinks: computed(() => store.drinks),
|
2021-03-17 20:36:26 +00:00
|
|
|
pagination,
|
2021-03-14 19:37:41 +00:00
|
|
|
columns,
|
|
|
|
column_calc,
|
|
|
|
column_prices,
|
|
|
|
visibleColumn,
|
2021-03-17 20:36:26 +00:00
|
|
|
drinkTypes,
|
|
|
|
updateDrink,
|
|
|
|
deleteDrink,
|
2021-03-21 22:02:25 +00:00
|
|
|
showNewDrink,
|
2021-03-22 22:18:22 +00:00
|
|
|
drinkPic,
|
|
|
|
savePicture,
|
2021-03-25 22:14:49 +00:00
|
|
|
deletePicture,
|
2021-03-29 20:35:54 +00:00
|
|
|
addStep,
|
|
|
|
deleteStep,
|
2021-03-18 16:23:57 +00:00
|
|
|
console,
|
2021-03-31 12:18:55 +00:00
|
|
|
search,
|
|
|
|
filter,
|
2021-04-02 17:32:08 +00:00
|
|
|
search_keys,
|
2021-04-01 20:39:54 +00:00
|
|
|
tags: computed(() => store.tags),
|
2021-03-19 19:41:21 +00:00
|
|
|
};
|
2021-03-18 16:23:57 +00:00
|
|
|
},
|
2021-03-14 19:37:41 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped></style>
|