diff --git a/src/plugins/pricelist/components/CalculationTable.vue b/src/plugins/pricelist/components/CalculationTable.vue index 854f22b..b80fa8b 100644 --- a/src/plugins/pricelist/components/CalculationTable.vue +++ b/src/plugins/pricelist/components/CalculationTable.vue @@ -8,9 +8,7 @@ dense :filter="search" :filter-method="filter" - :grid="grid" - :style="grid ? '' : 'max-height: 80vh;'" - :virtual-scroll="!grid" + grid :rows-per-page-options="[0]" > - @@ -482,6 +471,7 @@ import DrinkModify from './DrinkModify.vue'; import { filter, Search } from '../utils/filter'; import { Notify } from 'quasar'; import { sort } from '../utils/sort'; +import { DeleteObjects } from 'src/plugins/pricelist/utils/utils'; export default defineComponent({ name: 'CalculationTable', @@ -489,8 +479,6 @@ export default defineComponent({ SearchInput, MinPriceSetting, NewDrink, - BuildManual, - DrinkPriceVolumesTable, DrinkPriceVolumes, DrinkModify, }, @@ -710,25 +698,36 @@ export default defineComponent({ 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); - } - const search = ref({ value: '', key: '', label: '', }); - const grid = ref(true); const editDrink = ref(); + + async function editing_drink(drink: Drink, toDeleteObjects: DeleteObjects) { + notLoading.value = false; + for (const ingredient of toDeleteObjects.ingredients) { + await store.deleteIngredient(ingredient); + } + for (const price of toDeleteObjects.prices) { + await store.deletePrice(price); + } + for (const volume of toDeleteObjects.volumes) { + await store.deleteVolume(volume, drink); + } + console.log(drink); + await store.updateDrink(drink); + editDrink.value = undefined; + notLoading.value = true; + } + + function get_volumes(drink_id: number) { + return store.drinks.find((a) => a.id === drink_id)?.volumes; + } + + const notLoading = ref(true); + return { drinks: computed(() => store.drinks), pagination, @@ -743,15 +742,15 @@ export default defineComponent({ drinkPic, savePicture, deletePicture, - addStep, - deleteStep, console, search, filter, search_keys, - grid, tags: computed(() => store.tags), editDrink, + editing_drink, + get_volumes, + notLoading, }; }, }); diff --git a/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue b/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue index 0df25e2..b5b046b 100644 --- a/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue +++ b/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue @@ -6,24 +6,30 @@ animated swipeable control-color="primary" - navigation arrows > - +
+ +
+ + Abgabe entfernen + +
+
{{ min_price.percentage }}% @@ -33,13 +39,11 @@
-
- {{ price.price.toFixed(2) }}€ -
+
{{ price.price.toFixed(2) }}€
-
+
-
+
{{ price.description }}
+
+ + Preis entfernen + +
+
+ + Preis hinzufügen + + + + +
- +
+
+ +
+
+ + Abgabe hinzufügen + +
+
diff --git a/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumesTable.vue b/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumesTable.vue index 07666d4..f196c2a 100644 --- a/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumesTable.vue +++ b/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumesTable.vue @@ -67,13 +67,13 @@
- + />--> @@ -108,8 +108,7 @@ + + diff --git a/src/plugins/pricelist/components/CalculationTable/PriceTable.vue b/src/plugins/pricelist/components/CalculationTable/PriceTable.vue deleted file mode 100644 index d17dcf0..0000000 --- a/src/plugins/pricelist/components/CalculationTable/PriceTable.vue +++ /dev/null @@ -1,218 +0,0 @@ - - - - - diff --git a/src/plugins/pricelist/components/DrinkModify.vue b/src/plugins/pricelist/components/DrinkModify.vue index 16060ef..75fce9a 100644 --- a/src/plugins/pricelist/components/DrinkModify.vue +++ b/src/plugins/pricelist/components/DrinkModify.vue @@ -3,6 +3,36 @@
Getränk Bearbeiten
+ + + + + +
+ + + @@ -60,37 +96,90 @@ diff --git a/src/plugins/pricelist/store.ts b/src/plugins/pricelist/store.ts index 28dde0b..d9cc121 100644 --- a/src/plugins/pricelist/store.ts +++ b/src/plugins/pricelist/store.ts @@ -146,8 +146,8 @@ export const usePricelistStore = defineStore({ return 0; }); }, - deletePrice(price: FG.DrinkPrice, volume: FG.DrinkPriceVolume) { - api + async deletePrice(price: FG.DrinkPrice) { + /*api .delete(`pricelist/prices/${price.id}`) .then(() => { const index = volume.prices.findIndex((a) => a.id == price.id); @@ -155,21 +155,18 @@ export const usePricelistStore = defineStore({ volume.prices.splice(index, 1); } }) - .catch((err) => console.warn(err)); + .catch((err) => console.warn(err));*/ + await api.delete(`pricelist/prices/${price.id}`); }, - deleteVolume(volume: FG.DrinkPriceVolume, drink: FG.Drink) { - api - .delete(`pricelist/volumes/${volume.id}`) - .then(() => { - const index = drink.volumes.findIndex((a) => a.id === volume.id); - if (index > -1) { - drink.volumes.splice(index, 1); - } - }) - .catch((err) => console.warn(err)); + async deleteVolume(volume: DrinkPriceVolume, drink: Drink) { + await api.delete(`pricelist/volumes/${volume.id}`); + const index = drink.volumes.findIndex((a) => a.id === volume.id); + if (index > -1) { + drink.volumes.splice(index, 1); + } }, - deleteIngredient(ingredient: FG.Ingredient, volume: DrinkPriceVolume) { - api + async deleteIngredient(ingredient: FG.Ingredient) { + /*api .delete(`pricelist/ingredients/${ingredient.id}`) .then(() => { const index = volume.ingredients.findIndex((a) => a.id === ingredient.id); @@ -178,6 +175,8 @@ export const usePricelistStore = defineStore({ } }) .catch((err) => console.warn(err)); + */ + await api.delete(`pricelist/ingredients/${ingredient.id}`); }, async setDrink(drink: FG.Drink) { const { data } = await api.post('pricelist/drinks', { @@ -192,10 +191,8 @@ export const usePricelistStore = defineStore({ calc_all_min_prices(this.drinks, this.min_prices); }, async updateDrink(drink: Drink) { - console.log(drink); const { data } = await api.put(`pricelist/drinks/${drink.id}`, { ...drink, - cost_per_volume: drink._cost_per_volume, }); const index = this.drinks.findIndex((a) => a.id === data.id); if (index > -1) { diff --git a/src/plugins/pricelist/utils/utils.ts b/src/plugins/pricelist/utils/utils.ts index 8c24234..7db2ec4 100644 --- a/src/plugins/pricelist/utils/utils.ts +++ b/src/plugins/pricelist/utils/utils.ts @@ -72,4 +72,11 @@ function clone(o: T): T { return JSON.parse(JSON.stringify(o)); } +interface DeleteObjects { + prices: Array; + volumes: Array; + ingredients: Array; +} +export { DeleteObjects }; + export { calc_volume, calc_cost_per_volume, calc_all_min_prices, calc_min_prices, clone };