[pricelist] receipt as list, fixed some merge issues

This commit is contained in:
Tim Gröger 2021-03-29 22:35:54 +02:00
parent 0d044b505a
commit d185b84823
7 changed files with 91 additions and 28 deletions

View File

@ -91,7 +91,7 @@ declare namespace FG {
type?: DrinkType; type?: DrinkType;
volumes: Array<DrinkPriceVolume>; volumes: Array<DrinkPriceVolume>;
uuid: string; uuid: string;
receipt?: string; receipt?: Array<string>;
} }
interface DrinkIngredient { interface DrinkIngredient {
id: number; id: number;

View File

@ -154,7 +154,7 @@
v-model="scope.value" v-model="scope.value"
:options="drinkTypes" :options="drinkTypes"
option-label="name" option-label="name"
option-value='id' option-value="id"
filled filled
dense dense
autofocus autofocus
@ -296,8 +296,12 @@
/> />
</q-td> </q-td>
<q-td key="receipt" :props="drinks_props"> <q-td key="receipt" :props="drinks_props">
{{drinks_props.row.receipt}} <build-manual
<q-popup-edit :steps="drinks_props.row.receipt"
@deleteStep="deleteStep($event, drinks_props.row)"
@addStep="addStep($event, drinks_props.row)"
/>
<!--<q-popup-edit
v-slot="scope" v-slot="scope"
v-model="drinks_props.row.receipt" v-model="drinks_props.row.receipt"
buttons buttons
@ -312,7 +316,7 @@
counter counter
@keyup.enter.stop @keyup.enter.stop
/> />
</q-popup-edit> </q-popup-edit>-->
</q-td> </q-td>
</q-tr> </q-tr>
</template> </template>
@ -326,6 +330,7 @@ import { useMainStore } from 'src/store';
import { Drink, usePricelistStore } from 'src/plugins/pricelist/store'; import { Drink, usePricelistStore } from 'src/plugins/pricelist/store';
import MinPriceSetting from 'src/plugins/pricelist/components/MinPriceSetting.vue'; import MinPriceSetting from 'src/plugins/pricelist/components/MinPriceSetting.vue';
import NewDrink from 'src/plugins/pricelist/components/CalculationTable/NewDrink.vue'; import NewDrink from 'src/plugins/pricelist/components/CalculationTable/NewDrink.vue';
import BuildManual from 'src/plugins/pricelist/components/CalculationTable/BuildManual.vue';
import { Notify } from 'quasar'; import { Notify } from 'quasar';
function sort(a: string | number, b: string | number) { function sort(a: string | number, b: string | number) {
@ -336,15 +341,15 @@ function sort(a: string | number, b: string | number) {
export default defineComponent({ export default defineComponent({
name: 'CalculationTable', name: 'CalculationTable',
components: { MinPriceSetting, DrinkPriceVolumesTable, NewDrink }, components: { BuildManual, MinPriceSetting, DrinkPriceVolumesTable, NewDrink },
setup() { setup() {
const mainStore = useMainStore(); const mainStore = useMainStore();
const store = usePricelistStore(); const store = usePricelistStore();
onBeforeMount(() => { onBeforeMount(() => {
void store.getDrinkTypes() void store.getDrinkTypes();
void store.getExtraIngredients() void store.getExtraIngredients();
void store.get_min_prices() void store.get_min_prices();
store.getPriceCalcColumn(user); store.getPriceCalcColumn(user);
}); });
@ -506,6 +511,18 @@ export default defineComponent({
void store.delete_drink_picture(drink); void store.delete_drink_picture(drink);
} }
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);
}
return { return {
drinks: computed(() => store.drinks), drinks: computed(() => store.drinks),
pagination, pagination,
@ -520,6 +537,8 @@ export default defineComponent({
drinkPic, drinkPic,
savePicture, savePicture,
deletePicture, deletePicture,
addStep,
deleteStep,
console, console,
}; };
}, },

View File

@ -0,0 +1,44 @@
<template>
<div v-for="(step, index) in steps" :key="index">
{{ step }}
<q-btn v-if="editable" icon="mdi-delete" @click="deleteStep(index)" />
</div>
<div v-if="editable" class="row q-gutter-sm">
<q-input v-model="newStep" />
<q-btn label="Schritt hinzufügen" @click="addStep" />
</div>
</template>
<script lang="ts">
import { PropType, defineComponent, ref } from 'vue';
export default defineComponent({
name: 'BuildManual',
props: {
steps: {
type: Array as PropType<Array<string>>,
required: true,
},
editable: {
type: Boolean,
default: true,
},
},
emits: {
deleteStep: (index: number) => true,
addStep: (val: string) => true,
},
setup(_, { emit }) {
const newStep = ref('');
function deleteStep(index: number) {
emit('deleteStep', index);
}
function addStep() {
emit('addStep', newStep.value);
newStep.value = '';
}
return { newStep, addStep, deleteStep };
},
});
</script>
<style scoped></style>

View File

@ -1,10 +1,5 @@
<template> <template>
<q-btn <q-btn color="positive" icon-right="add" label="Abgabe hinzufügen" size="xs">
color="positive"
icon-right="add"
label="Abgabe hinzufügen"
size="xs"
>
<q-menu anchor="center middle" self="center middle"> <q-menu anchor="center middle" self="center middle">
<div class="row justify-around q-pa-sm"> <div class="row justify-around q-pa-sm">
<q-input <q-input

View File

@ -32,8 +32,8 @@
filled filled
label="Inhalt in L/Gebinde" label="Inhalt in L/Gebinde"
type="number" type="number"
step='0.01' step="0.01"
min='0' min="0"
/> />
<q-input <q-input
v-model.number="newDrink.package_size" v-model.number="newDrink.package_size"
@ -48,8 +48,8 @@
filled filled
label="Preis Netto/Gebinde" label="Preis Netto/Gebinde"
type="number" type="number"
step='0.01' step="0.01"
min='0' min="0"
/> />
<q-input <q-input
v-model.number="cost_per_volume" v-model.number="cost_per_volume"
@ -57,9 +57,9 @@
filled filled
label="Preis mit 19%/Liter" label="Preis mit 19%/Liter"
:disable="calc_price_pro_volume" :disable="calc_price_pro_volume"
type='number' type="number"
step='0.01' step="0.01"
min='0' min="0"
/> />
<div class="row justify-between"> <div class="row justify-between">
<q-btn v-close-popup label="Abbrechen" type="reset" /> <q-btn v-close-popup label="Abbrechen" type="reset" />

View File

@ -15,10 +15,13 @@
<div class="text-h6">Zutaten</div> <div class="text-h6">Zutaten</div>
<div v-for="ingredient in drink.volumes[0].ingredients" :key="ingredient.id"> <div v-for="ingredient in drink.volumes[0].ingredients" :key="ingredient.id">
{{ {{
name(ingredient.drink_ingredient?.ingredient_id) || name(ingredient.drink_ingredient?.ingredient_id) || ingredient.extra_ingredient?.name
ingredient.extra_ingredient?.name }}
{{
ingredient.drink_ingredient?.volume
? `${ingredient.drink_ingredient?.volume * 100} cl`
: ''
}} }}
{{ ingredient.drink_ingredient?.volume ? `${ingredient.drink_ingredient?.volume * 100} cl` : '' }}
</div> </div>
</q-card-section> </q-card-section>
<q-card-section> <q-card-section>
@ -31,8 +34,8 @@
</q-card-section> </q-card-section>
<q-card-section> <q-card-section>
<div class="text-h6">Anleitung</div> <div class="text-h6">Anleitung</div>
{{drink.receipt}} <build-manual :steps="drink.receipt" :editable="false" />
</q-card-section> </q-card-section>
</q-card> </q-card>
</div> </div>
</template> </template>
@ -40,8 +43,10 @@
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, onBeforeMount } from 'vue'; import { computed, defineComponent, onBeforeMount } from 'vue';
import { usePricelistStore } from 'src/plugins/pricelist/store'; import { usePricelistStore } from 'src/plugins/pricelist/store';
import BuildManual from 'src/plugins/pricelist/components/CalculationTable/BuildManual.vue';
export default defineComponent({ export default defineComponent({
name: 'Reciepts', name: 'Reciepts',
components: { BuildManual },
setup() { setup() {
const store = usePricelistStore(); const store = usePricelistStore();
onBeforeMount(() => { onBeforeMount(() => {

View File

@ -83,7 +83,7 @@ class Drink {
this.type = type; this.type = type;
this.volumes = []; this.volumes = [];
this.uuid = uuid; this.uuid = uuid;
this.receipt = receipt; this.receipt = receipt || [];
} }
} }