fix: changes in sale and summary

This commit is contained in:
Jon Elias 2024-10-07 13:29:43 +02:00
parent bd3de77cbd
commit afc52f6cea
5 changed files with 110 additions and 27 deletions

View File

@ -3,7 +3,7 @@ import axios from 'axios';
import { ref, toRefs } from 'vue';
import { useQuasar } from 'quasar';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import { useRoute, useRouter } from 'vue-router';
import { usePrintService } from 'composables/usePrintService';
import SendEmailDialog from 'components/common/SendEmailDialog.vue';
import VnConfirm from 'components/ui/VnConfirm.vue';
@ -23,6 +23,7 @@ const props = defineProps({
required: true,
},
});
const route = useRoute();
const { push, currentRoute } = useRouter();
const { dialog, notify } = useQuasar();
@ -334,7 +335,11 @@ async function handleInvoiceOutData() {
</script>
<template>
<FetchData
:url="`Tickets/${ticketId}/isEditable`"
:url="
route.path.startsWith('/ticket')
? `Tickets/${ticketId}/isEditable`
: `Tickets/${ticket}/isEditable`
"
auto-load
@on-fetch="handleFetchData"
/>

View File

@ -13,12 +13,21 @@ const $props = defineProps({
type: Number,
default: 0,
},
usesMana: {
type: Boolean,
default: false,
},
manaCode: {
type: String,
default: 'mana',
},
});
const emit = defineEmits(['save', 'cancel']);
const { t } = useI18n();
const QPopupProxyRef = ref(null);
const manaCode = ref($props.manaCode);
const save = () => {
emit('save');
@ -47,6 +56,23 @@ const cancel = () => {
</div>
</div>
</div>
<div v-if="usesMana" class="column q-gutter-y-sm q-mt-sm">
<QRadio
v-model="manaCode"
dense
val="mana"
:label="t('Promotion mana')"
:dark="true"
/>
<QRadio
v-model="manaCode"
dense
val="manaClaim"
:label="t('Claim mana')"
:dark="true"
class="q-mb-sm"
/>
</div>
<div class="row">
<QBtn
color="primary"

View File

@ -761,6 +761,8 @@ watch(
<TicketEditManaProxy
:mana="mana"
:new-price="getNewPrice"
:uses-mana="usesMana"
:mana-code="manaCode"
@save="changeDiscount(row)"
>
<VnInput
@ -768,6 +770,23 @@ watch(
:label="t('ticketSale.discount')"
type="number"
/>
<div v-if="usesMana" class="column q-gutter-y-sm q-mt-sm">
<QRadio
v-model="edit.manaCode"
dense
val="mana"
:label="t('Promotion mana')"
:dark="true"
/>
<QRadio
v-model="edit.manaCode"
dense
val="manaClaim"
:label="t('Claim mana')"
:dark="true"
class="q-mb-sm"
/>
</div>
</TicketEditManaProxy>
</template>
<span v-else>{{ toPercentage(row.discount / 100) }}</span>

View File

@ -19,6 +19,7 @@ import VnTitle from 'src/components/common/VnTitle.vue';
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import TicketDescriptorMenu from './TicketDescriptorMenu.vue';
const route = useRoute();
const { notify } = useNotify();
@ -68,7 +69,7 @@ function isEditable() {
async function changeState(value) {
try {
stateBtnDropdownRef.value.hide();
stateBtnDropdownRef.value?.hide();
const formData = {
ticketFk: entityId.value,
code: value,
@ -108,6 +109,10 @@ function getNoteValue(description) {
function toTicketUrl(section) {
return '#/ticket/' + entityId.value + '/' + section;
}
function isOnTicketCard() {
const currentPath = route.path;
return currentPath.startsWith('/ticket');
}
</script>
<template>
@ -122,6 +127,16 @@ function toTicketUrl(section) {
:url="`Tickets/${entityId}/summary`"
data-key="TicketSummary"
>
<template #header-left>
<router-link
v-if="route?.name !== 'TicketSummary'"
:to="{ name: 'TicketSummary', params: { id: entityId } }"
class="header link"
:href="entryUrl"
>
<QIcon name="open_in_new" color="white" size="sm" />
</router-link>
</template>
<template #header="{ entity }">
<div>
Ticket #{{ entity.id }} - {{ entity.client?.name }} ({{
@ -131,23 +146,43 @@ function toTicketUrl(section) {
</div>
</template>
<template #header-right>
<QBtnDropdown
ref="stateBtnDropdownRef"
color="black"
text-color="white"
:label="t('ticket.summary.changeState')"
:disable="!isEditable()"
>
<VnSelect
:options="editableStates"
hide-selected
option-label="name"
option-value="code"
hide-dropdown-icon
focus-on-mount
@update:model-value="changeState"
/>
</QBtnDropdown>
<div class="flex items-end">
<QBtnDropdown
ref="stateBtnDropdownRef"
color="black"
text-color="white"
:label="t('ticket.summary.changeState')"
:disable="!isEditable()"
>
<VnSelect
:options="editableStates"
hide-selected
option-label="name"
option-value="code"
hide-dropdown-icon
focus-on-mount
@update:model-value="changeState"
/>
</QBtnDropdown>
<QBtn
v-if="!isOnTicketCard()"
icon="more_vert"
round
size="md"
flat
color="white"
>
<QMenu>
<QList>
<QItem>
<QItemSection>
<TicketDescriptorMenu :ticket="entityId" />
</QItemSection>
</QItem>
</QList>
</QMenu>
</QBtn>
</div>
</template>
<template #body="{ entity }">
<QCard class="vn-one">

View File

@ -20,18 +20,16 @@ const provinces = ref([]);
const states = ref([]);
const agencies = ref([]);
const warehouses = ref([]);
const alertLevels = ref([]);
const groupedStates = ref([]);
const getGroupedStates = () => {
for (const state of alertLevels.value) {
const getGroupedStates = (data) => {
for (const state of data) {
groupedStates.value.push({
id: state.id,
name: t(`${state.code}`),
code: state.code,
});
}
console.log(groupedStates.value);
};
</script>
@ -42,7 +40,7 @@ const getGroupedStates = () => {
url="AlertLevels"
@on-fetch="
(data) => {
(alertLevels = data), getGroupedStates();
getGroupedStates(data);
}
"
auto-load
@ -130,10 +128,10 @@ const getGroupedStates = () => {
</QItemSection>
</QItem>
<QItem>
<QItemSection v-if="!alertLevels">
<QItemSection v-if="!groupedStates">
<QSkeleton type="QInput" class="full-width" />
</QItemSection>
<QItemSection v-if="alertLevels">
<QItemSection v-if="groupedStates">
<QSelect
:label="t('Grouped state')"
v-model="params.groupedStates"