diff --git a/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumeTable/NewVolume.vue b/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumeTable/NewVolume.vue index bcc703b..3855c19 100644 --- a/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumeTable/NewVolume.vue +++ b/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumeTable/NewVolume.vue @@ -1,6 +1,6 @@ - - + diff --git a/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumesTable.vue b/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumesTable.vue index 268d91e..7066419 100644 --- a/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumesTable.vue +++ b/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumesTable.vue @@ -49,13 +49,7 @@ label-set="Speichern" @save="updateVolume(props.row, drink)" > - + @@ -84,38 +78,39 @@ - + - - + diff --git a/src/plugins/pricelist/components/CalculationTable/Ingredients.vue b/src/plugins/pricelist/components/CalculationTable/Ingredients.vue index b7b42a4..bdb80f4 100644 --- a/src/plugins/pricelist/components/CalculationTable/Ingredients.vue +++ b/src/plugins/pricelist/components/CalculationTable/Ingredients.vue @@ -118,6 +118,7 @@ /> @@ -150,17 +150,6 @@ import { computed, defineComponent, PropType, ref } from 'vue'; import { DrinkPriceVolume, usePricelistStore } from '../../store'; -import {CompositionAPIEmit} from 'vue-typed-emit'; -import {SetupContext} from 'vue'; - -interface Events { - updateDrink: undefined -} - -interface ExtendedSetupContext extends Omit { - emit: CompositionAPIEmit -} - export default defineComponent({ name: 'Ingredients', props: { @@ -173,8 +162,8 @@ export default defineComponent({ required: true, }, }, - emits: ["updateDrink"], - setup(_:any, {emit}: ExtendedSetupContext) { + emits: { updateDrink: () => true }, + setup(_, { emit }) { const store = usePricelistStore(); const emptyIngredient: FG.Ingredient = { @@ -185,34 +174,29 @@ export default defineComponent({ const newIngredient = ref(); const newIngredientVolume = ref(0); function addIngredient(volume: DrinkPriceVolume) { - let ingredient : FG.Ingredient if ((newIngredient.value)?.volume && newIngredient.value) { - volume.ingredients.push( - { + volume.ingredients.push({ + id: -1, + drink_ingredient: { id: -1, - drink_ingredient: { - id: -1, - drink_ingredient_id: newIngredient.value.id, - volume: newIngredientVolume.value, - }, - extra_ingredient: undefined, + drink_ingredient_id: newIngredient.value.id, + volume: newIngredientVolume.value, }, - ); + extra_ingredient: undefined, + }); } else if (newIngredient.value) { - volume.ingredients.push( - { - id: -1, - drink_ingredient: undefined, - extra_ingredient: newIngredient.value, - }, - ); + volume.ingredients.push({ + id: -1, + drink_ingredient: undefined, + extra_ingredient: newIngredient.value, + }); } - updateDrink() + updateDrink(); cancelAddIngredient(); } function updateDrink() { - console.log("updateDrink from Ingredients") - emit("updateDrink") + console.log('updateDrink from Ingredients'); + emit('updateDrink'); } function cancelAddIngredient() { setTimeout(() => { @@ -224,7 +208,7 @@ export default defineComponent({ } const drinks = computed(() => store.drinks.filter((drink) => { - console.log("computed drinks", drink.name, drink.cost_price_pro_volume) + console.log('computed drinks', drink.name, drink.cost_price_pro_volume); return drink.cost_price_pro_volume; }) ); diff --git a/src/plugins/pricelist/components/CalculationTable/PriceTable.vue b/src/plugins/pricelist/components/CalculationTable/PriceTable.vue index e4afab6..13fcd3a 100644 --- a/src/plugins/pricelist/components/CalculationTable/PriceTable.vue +++ b/src/plugins/pricelist/components/CalculationTable/PriceTable.vue @@ -48,11 +48,7 @@ - + @@ -142,17 +138,6 @@ import { defineComponent, ref } from 'vue'; import { DrinkPriceVolume, usePricelistStore } from '../../store'; -import {CompositionAPIEmit} from 'vue-typed-emit'; -import {SetupContext} from 'vue'; - -interface Events { - updateDrink: undefined -} - -interface ExtendedSetupContext extends Omit { - emit: CompositionAPIEmit -} - export default defineComponent({ name: 'PriceTable', props: { @@ -173,8 +158,8 @@ export default defineComponent({ required: true, }, }, - emits: ["updateDrink"], - setup(props, {emit}: ExtendedSetupContext) { + emits: { updateDrink: () => true }, + setup(props, { emit }) { const store = usePricelistStore(); const emptyPrice: FG.DrinkPrice = { @@ -185,12 +170,12 @@ export default defineComponent({ }; const newPrice = ref(emptyPrice); function addPrice(volume: DrinkPriceVolume) { - volume.prices.push(newPrice.value) - updateDrink() + volume.prices.push(newPrice.value); + updateDrink(); cancelAddPrice(); } function updateDrink() { - emit("updateDrink") + emit('updateDrink'); } function cancelAddPrice() { setTimeout(() => { diff --git a/src/plugins/pricelist/store.ts b/src/plugins/pricelist/store.ts index e6ea2e8..26889fe 100644 --- a/src/plugins/pricelist/store.ts +++ b/src/plugins/pricelist/store.ts @@ -4,11 +4,11 @@ import { AxiosResponse } from 'axios'; import { computed, WritableComputedRef } from 'vue'; interface MinPrice extends Omit { - price: WritableComputedRef | null; + price?: WritableComputedRef; } interface DrinkPriceVolume extends Omit, 'min_prices'> { _volume: number; - volume: WritableComputedRef | null; + volume?: WritableComputedRef; min_prices: MinPrice[]; } interface Drink extends Omit, 'volumes'> { @@ -17,7 +17,7 @@ interface Drink extends Omit, 'volumes'> _cost_price_pro_volume?: number; } -class DrinkPriceVolume { +class DrinkPriceVolume implements DrinkPriceVolume { constructor({ id, volume, min_prices, prices, ingredients }: FG.DrinkPriceVolume, drink: Drink) { this.id = id; this._volume = volume;