[pricelist] add useroption for pricelist_view
This commit is contained in:
parent
8ee5c891a5
commit
f7a6f3fbe1
|
@ -7,6 +7,7 @@
|
||||||
:filter="search"
|
:filter="search"
|
||||||
:filter-method="filter"
|
:filter-method="filter"
|
||||||
dense
|
dense
|
||||||
|
:pagination="pagination"
|
||||||
>
|
>
|
||||||
<template #top-right>
|
<template #top-right>
|
||||||
<div class="row justify-end q-gutter-sm">
|
<div class="row justify-end q-gutter-sm">
|
||||||
|
@ -75,6 +76,7 @@ export default defineComponent({
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
if (!props.public) {
|
if (!props.public) {
|
||||||
user.value = useMainStore().currentUser.userid;
|
user.value = useMainStore().currentUser.userid;
|
||||||
|
void store.getDrinks();
|
||||||
void store.getPriceCalcColumn(user.value);
|
void store.getPriceCalcColumn(user.value);
|
||||||
} else {
|
} else {
|
||||||
user.value = '';
|
user.value = '';
|
||||||
|
@ -191,6 +193,11 @@ export default defineComponent({
|
||||||
label: '',
|
label: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const pagination = ref({
|
||||||
|
sortBy: 'name',
|
||||||
|
rowsPerPage: 10,
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
drinks: computed(() => store.pricelist),
|
drinks: computed(() => store.pricelist),
|
||||||
columns,
|
columns,
|
||||||
|
@ -198,6 +205,7 @@ export default defineComponent({
|
||||||
options: _options,
|
options: _options,
|
||||||
search,
|
search,
|
||||||
filter,
|
filter,
|
||||||
|
pagination,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,21 +11,27 @@
|
||||||
</pricelist>
|
</pricelist>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, onBeforeMount, ref } from 'vue';
|
import { defineComponent, onBeforeMount, computed } from 'vue';
|
||||||
import CalculationTable from '../components/CalculationTable.vue';
|
import CalculationTable from '../components/CalculationTable.vue';
|
||||||
import Pricelist from 'src/plugins/pricelist/components/Pricelist.vue';
|
import Pricelist from 'src/plugins/pricelist/components/Pricelist.vue';
|
||||||
import { usePricelistStore } from 'src/plugins/pricelist/store';
|
import { usePricelistStore } from 'src/plugins/pricelist/store';
|
||||||
|
import { useMainStore } from 'src/stores';
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'InnerPricelist',
|
name: 'InnerPricelist',
|
||||||
components: { Pricelist, CalculationTable },
|
components: { Pricelist, CalculationTable },
|
||||||
setup() {
|
setup() {
|
||||||
const store = usePricelistStore();
|
const store = usePricelistStore();
|
||||||
|
const mainStore = useMainStore();
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
void store.getDrinks();
|
void store.getDrinks();
|
||||||
|
void store.getPriceListView(mainStore.currentUser.userid);
|
||||||
});
|
});
|
||||||
|
|
||||||
const list = ref(false);
|
const list = computed({
|
||||||
|
get: () => store.pricelist_view,
|
||||||
|
set: (val: boolean) => store.updatePriceListView(mainStore.currentUser.userid, val),
|
||||||
|
});
|
||||||
return { list };
|
return { list };
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -78,6 +78,7 @@ export const usePricelistStore = defineStore({
|
||||||
min_prices: [] as Array<number>,
|
min_prices: [] as Array<number>,
|
||||||
tags: [] as Array<FG.Tag>,
|
tags: [] as Array<FG.Tag>,
|
||||||
pricecalc_columns: [] as Array<string>,
|
pricecalc_columns: [] as Array<string>,
|
||||||
|
pricelist_view: false as boolean,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -263,6 +264,14 @@ export const usePricelistStore = defineStore({
|
||||||
await api.put<Array<string>>(`pricelist/users/${userid}/pricecalc_columns`, data);
|
await api.put<Array<string>>(`pricelist/users/${userid}/pricecalc_columns`, data);
|
||||||
this.pricecalc_columns = data;
|
this.pricecalc_columns = data;
|
||||||
},
|
},
|
||||||
|
async getPriceListView(userid: string) {
|
||||||
|
const { data } = await api.get<{ value: boolean }>(`pricelist/users/${userid}/pricelist`);
|
||||||
|
this.pricelist_view = data.value;
|
||||||
|
},
|
||||||
|
async updatePriceListView(userid: string, data: boolean) {
|
||||||
|
await api.put<Array<string>>(`pricelist/users/${userid}/pricelist`, { value: data });
|
||||||
|
this.pricelist_view = data;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
pricelist() {
|
pricelist() {
|
||||||
|
@ -282,6 +291,7 @@ export const usePricelistStore = defineStore({
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
console.log(retVal);
|
||||||
return retVal;
|
return retVal;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -56,15 +56,17 @@ function calc_min_prices(
|
||||||
) {
|
) {
|
||||||
const retVal: Array<FG.MinPrices> = [];
|
const retVal: Array<FG.MinPrices> = [];
|
||||||
volume.min_prices = [];
|
volume.min_prices = [];
|
||||||
min_prices.forEach((min_price) => {
|
if (min_prices) {
|
||||||
let computedMinPrice: number;
|
min_prices.forEach((min_price) => {
|
||||||
if (cost_per_volume) {
|
let computedMinPrice: number;
|
||||||
computedMinPrice = (cost_per_volume * <number>volume.volume * min_price) / 100;
|
if (cost_per_volume) {
|
||||||
} else {
|
computedMinPrice = (cost_per_volume * <number>volume.volume * min_price) / 100;
|
||||||
computedMinPrice = helper(volume, min_price);
|
} else {
|
||||||
}
|
computedMinPrice = helper(volume, min_price);
|
||||||
retVal.push({ percentage: min_price, price: computedMinPrice });
|
}
|
||||||
});
|
retVal.push({ percentage: min_price, price: computedMinPrice });
|
||||||
|
});
|
||||||
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue