HOTFIX: mana axios deacoplate #1489
|
@ -1,32 +1,26 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import axios from 'axios';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
import { toCurrency } from 'src/filters';
|
import { toCurrency } from 'src/filters';
|
||||||
import VnUsesMana from 'components/ui/VnUsesMana.vue';
|
import VnUsesMana from 'components/ui/VnUsesMana.vue';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
mana: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
newPrice: {
|
newPrice: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
usesMana: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
manaCode: {
|
|
||||||
type: String,
|
|
||||||
default: 'mana',
|
|
||||||
},
|
|
||||||
sale: {
|
sale: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const mana = ref(null);
|
||||||
|
const usesMana = ref(false);
|
||||||
|
|
||||||
const emit = defineEmits(['save', 'cancel']);
|
const emit = defineEmits(['save', 'cancel']);
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -38,36 +32,47 @@ const save = (sale = $props.sale) => {
|
||||||
QPopupProxyRef.value.hide();
|
QPopupProxyRef.value.hide();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getMana = async () => {
|
||||||
|
const { data } = await axios.get(`Tickets/${route.params.id}/getSalesPersonMana`);
|
||||||
|
mana.value = data;
|
||||||
|
await getUsesMana();
|
||||||
|
};
|
||||||
|
|
||||||
|
const getUsesMana = async () => {
|
||||||
|
const { data } = await axios.get('Sales/usesMana');
|
||||||
|
usesMana.value = data;
|
||||||
|
};
|
||||||
|
|
||||||
const cancel = () => {
|
const cancel = () => {
|
||||||
emit('cancel');
|
emit('cancel');
|
||||||
QPopupProxyRef.value.hide();
|
QPopupProxyRef.value.hide();
|
||||||
};
|
};
|
||||||
|
const hasMana = computed(() => typeof mana.value === 'number');
|
||||||
defineExpose({ save });
|
defineExpose({ save });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QPopupProxy ref="QPopupProxyRef" data-cy="ticketEditManaProxy">
|
<QPopupProxy
|
||||||
|
ref="QPopupProxyRef"
|
||||||
|
@before-show="getMana"
|
||||||
|
data-cy="ticketEditManaProxy"
|
||||||
|
>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<QSpinner
|
<div class="header">Mana: {{ toCurrency(mana) }}</div>
|
||||||
v-if="!(typeof mana === 'number' && mana >= 0)"
|
<QSpinner v-if="!hasMana" color="primary" size="md" />
|
||||||
color="primary"
|
<div class="q-pa-md" v-else>
|
||||||
size="md"
|
<slot :popup="QPopupProxyRef" />
|
||||||
/>
|
<div v-if="usesMana" class="column q-gutter-y-sm q-mt-sm">
|
||||||
<div v-else>
|
<VnUsesMana :mana-code="manaCode" />
|
||||||
<div class="header">Mana: {{ toCurrency(mana) }}</div>
|
</div>
|
||||||
<div class="q-pa-md">
|
<div v-if="newPrice" class="column items-center q-mt-lg">
|
||||||
<slot :popup="QPopupProxyRef" />
|
<span class="text-primary">{{ t('New price') }}</span>
|
||||||
<div v-if="usesMana" class="column q-gutter-y-sm q-mt-sm">
|
<span class="text-subtitle1">
|
||||||
<VnUsesMana :mana-code="manaCode" />
|
{{ toCurrency($props.newPrice) }}
|
||||||
</div>
|
</span>
|
||||||
<div v-if="newPrice" class="column items-center q-mt-lg">
|
|
||||||
<span class="text-primary">{{ t('New price') }}</span>
|
|
||||||
<span class="text-subtitle1">
|
|
||||||
{{ toCurrency($props.newPrice) }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<QBtn
|
<QBtn
|
||||||
color="primary"
|
color="primary"
|
||||||
|
|
|
@ -44,7 +44,6 @@ const isTicketEditable = ref(false);
|
||||||
const sales = ref([]);
|
const sales = ref([]);
|
||||||
const editableStatesOptions = ref([]);
|
const editableStatesOptions = ref([]);
|
||||||
const selectedSales = ref([]);
|
const selectedSales = ref([]);
|
||||||
const mana = ref(null);
|
|
||||||
const manaCode = ref('mana');
|
const manaCode = ref('mana');
|
||||||
const ticketState = computed(() => store.data?.ticketState?.state?.code);
|
const ticketState = computed(() => store.data?.ticketState?.state?.code);
|
||||||
const transfer = ref({
|
const transfer = ref({
|
||||||
|
@ -258,18 +257,6 @@ const DEFAULT_EDIT = {
|
||||||
oldQuantity: null,
|
oldQuantity: null,
|
||||||
};
|
};
|
||||||
const edit = ref({ ...DEFAULT_EDIT });
|
const edit = ref({ ...DEFAULT_EDIT });
|
||||||
const usesMana = ref(null);
|
|
||||||
|
|
||||||
const getUsesMana = async () => {
|
|
||||||
const { data } = await axios.get('Sales/usesMana');
|
|
||||||
usesMana.value = data;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getMana = async () => {
|
|
||||||
const { data } = await axios.get(`Tickets/${route.params.id}/getSalesPersonMana`);
|
|
||||||
mana.value = data;
|
|
||||||
await getUsesMana();
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectedValidSales = computed(() => {
|
const selectedValidSales = computed(() => {
|
||||||
if (!sales.value) return;
|
if (!sales.value) return;
|
||||||
|
@ -277,7 +264,6 @@ const selectedValidSales = computed(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const onOpenEditPricePopover = async (sale) => {
|
const onOpenEditPricePopover = async (sale) => {
|
||||||
await getMana();
|
|
||||||
edit.value = {
|
edit.value = {
|
||||||
sale: JSON.parse(JSON.stringify(sale)),
|
sale: JSON.parse(JSON.stringify(sale)),
|
||||||
price: sale.price,
|
price: sale.price,
|
||||||
|
@ -285,7 +271,6 @@ const onOpenEditPricePopover = async (sale) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onOpenEditDiscountPopover = async (sale) => {
|
const onOpenEditDiscountPopover = async (sale) => {
|
||||||
await getMana();
|
|
||||||
if (isLocked.value) return;
|
if (isLocked.value) return;
|
||||||
if (sale) {
|
if (sale) {
|
||||||
edit.value = {
|
edit.value = {
|
||||||
|
@ -306,7 +291,6 @@ const changePrice = async (sale) => {
|
||||||
await confirmUpdate(() => updatePrice(sale, newPrice));
|
await confirmUpdate(() => updatePrice(sale, newPrice));
|
||||||
} else updatePrice(sale, newPrice);
|
} else updatePrice(sale, newPrice);
|
||||||
}
|
}
|
||||||
await getMana();
|
|
||||||
};
|
};
|
||||||
const updatePrice = async (sale, newPrice) => {
|
const updatePrice = async (sale, newPrice) => {
|
||||||
await axios.post(`Sales/${sale.id}/updatePrice`, { newPrice });
|
await axios.post(`Sales/${sale.id}/updatePrice`, { newPrice });
|
||||||
|
@ -599,9 +583,7 @@ watch(
|
||||||
:is-ticket-editable="isTicketEditable"
|
:is-ticket-editable="isTicketEditable"
|
||||||
:sales="selectedValidSales"
|
:sales="selectedValidSales"
|
||||||
:disable="!hasSelectedRows"
|
:disable="!hasSelectedRows"
|
||||||
:mana="mana"
|
|
||||||
:ticket-config="ticketConfig"
|
:ticket-config="ticketConfig"
|
||||||
@get-mana="getMana()"
|
|
||||||
@update-discounts="updateDiscounts"
|
@update-discounts="updateDiscounts"
|
||||||
@refresh-table="resetChanges"
|
@refresh-table="resetChanges"
|
||||||
/>
|
/>
|
||||||
|
@ -829,7 +811,6 @@ watch(
|
||||||
</QBtn>
|
</QBtn>
|
||||||
<TicketEditManaProxy
|
<TicketEditManaProxy
|
||||||
ref="editPriceProxyRef"
|
ref="editPriceProxyRef"
|
||||||
:mana="mana"
|
|
||||||
:sale="row"
|
:sale="row"
|
||||||
:new-price="getNewPrice"
|
:new-price="getNewPrice"
|
||||||
@save="changePrice"
|
@save="changePrice"
|
||||||
|
@ -852,10 +833,8 @@ watch(
|
||||||
|
|
||||||
<TicketEditManaProxy
|
<TicketEditManaProxy
|
||||||
ref="editManaProxyRef"
|
ref="editManaProxyRef"
|
||||||
:mana="mana"
|
|
||||||
:sale="row"
|
:sale="row"
|
||||||
:new-price="getNewPrice"
|
:new-price="getNewPrice"
|
||||||
:uses-mana="usesMana"
|
|
||||||
:mana-code="manaCode"
|
:mana-code="manaCode"
|
||||||
@save="changeDiscount"
|
@save="changeDiscount"
|
||||||
>
|
>
|
||||||
|
|
|
@ -34,10 +34,6 @@ const props = defineProps({
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
mana: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
ticketConfig: {
|
ticketConfig: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
|
@ -220,7 +216,6 @@ const createRefund = async (withWarehouse) => {
|
||||||
<TicketEditManaProxy
|
<TicketEditManaProxy
|
||||||
ref="editManaProxyRef"
|
ref="editManaProxyRef"
|
||||||
:sale="row"
|
:sale="row"
|
||||||
:mana="props.mana"
|
|
||||||
@save="changeMultipleDiscount"
|
@save="changeMultipleDiscount"
|
||||||
>
|
>
|
||||||
<VnInput
|
<VnInput
|
||||||
|
|
Loading…
Reference in New Issue