@@ -93,7 +95,7 @@
) => val,
@@ -179,10 +181,8 @@ export default defineComponent({
});
function updateVolume(_volume: DrinkPriceVolume) {
- console.log('updateVolume', _volume);
const index = volumes.value.findIndex((a) => a.id === _volume.id);
if (index > -1) {
- console.log('updateVolume old', volumes.value[index]);
volumes.value[index].volume = calc_volume(_volume);
}
change();
diff --git a/src/plugins/pricelist/components/DrinkModify.vue b/src/plugins/pricelist/components/DrinkModify.vue
index c155f4a..fb3fcb4 100644
--- a/src/plugins/pricelist/components/DrinkModify.vue
+++ b/src/plugins/pricelist/components/DrinkModify.vue
@@ -122,9 +122,9 @@
/>
-
+
{
//edit_drink.value = JSON.parse(JSON.stringify(props.drink));
edit_drink.value = clone(props.drink);
+ edit_volumes.value = clone(props.drink.volumes);
});
+ const key = ref(0);
+
const store = usePricelistStore();
const toDeleteObjects = ref({
@@ -183,7 +186,9 @@ export default defineComponent({
});
const edit_drink = ref();
+ const edit_volumes = ref>([]);
function save() {
+ (edit_drink.value).volumes = edit_volumes.value;
emit('save', edit_drink.value, toDeleteObjects.value, drinkPic.value, deletePic.value);
}
@@ -191,15 +196,25 @@ export default defineComponent({
emit('cancel');
}
function updateVolume(index: number) {
- if (index > -1 && edit_drink.value) {
- edit_drink.value.volumes[index].min_prices = calc_min_prices(
- edit_drink.value.volumes[index],
- edit_drink.value.cost_per_volume,
+ if (index > -1 && edit_volumes.value) {
+ edit_volumes.value[index].min_prices = calc_min_prices(
+ edit_volumes.value[index],
+ //edit_drink.value.cost_per_volume,
+ cost_per_volume.value,
store.min_prices
);
}
}
+ function updateVolumes() {
+ setTimeout(() => {
+ edit_volumes.value?.forEach((_, index) => {
+ updateVolume(index);
+ });
+ key.value++;
+ }, 50);
+ }
+
function deletePrice(price: FG.DrinkPrice) {
toDeleteObjects.value.prices.push(price);
}
@@ -287,10 +302,14 @@ export default defineComponent({
const cost_per_volume = computed({
get: () => {
+ let retVal: number;
if (auto_cost_per_volume.value) {
- return calc_cost_per_volume(edit_drink.value);
+ retVal = calc_cost_per_volume(edit_drink.value);
+ } else {
+ retVal = (edit_drink.value).cost_per_volume;
}
- return (edit_drink.value).cost_per_volume;
+ updateVolumes();
+ return retVal;
},
set: (val: number) => ((edit_drink.value).cost_per_volume = val),
});
@@ -316,6 +335,8 @@ export default defineComponent({
delete_drink,
auto_cost_per_volume,
cost_per_volume,
+ edit_volumes,
+ key,
};
},
});
diff --git a/src/plugins/pricelist/pages/InnerPricelist.vue b/src/plugins/pricelist/pages/InnerPricelist.vue
index 0699258..4e5f324 100644
--- a/src/plugins/pricelist/pages/InnerPricelist.vue
+++ b/src/plugins/pricelist/pages/InnerPricelist.vue
@@ -6,7 +6,7 @@ import { defineComponent } from 'vue';
import CalculationTable from '../components/CalculationTable.vue';
export default defineComponent({
name: 'InnerPricelist',
- components: {CalculationTable},
+ components: { CalculationTable },
setup() {
return {};
},