forked from verdnatura/salix-front
Fix card searchbar routing
This commit is contained in:
parent
acc899b851
commit
c31e865faa
|
@ -1,17 +1,29 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
import VnCard from 'components/common/VnCard.vue';
|
import VnCard from 'components/common/VnCard.vue';
|
||||||
import TicketDescriptor from './TicketDescriptor.vue';
|
import TicketDescriptor from './TicketDescriptor.vue';
|
||||||
import TicketFilter from '../TicketFilter.vue';
|
import TicketFilter from '../TicketFilter.vue';
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
const routeName = computed(() => route.name);
|
||||||
|
const searchBarDataKeys = {
|
||||||
|
TicketSummary: 'TicketSummary',
|
||||||
|
TicketSale: 'TicketSale',
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnCard
|
<VnCard
|
||||||
data-key="Ticket"
|
data-key="Ticket"
|
||||||
base-url="Tickets"
|
|
||||||
:descriptor="TicketDescriptor"
|
|
||||||
:filter-panel="TicketFilter"
|
:filter-panel="TicketFilter"
|
||||||
search-data-key="TicketList"
|
:descriptor="TicketDescriptor"
|
||||||
search-url="Tickets/filter"
|
:search-data-key="searchBarDataKeys[routeName]"
|
||||||
searchbar-label="Search ticket"
|
:search-custom-route-redirect="routeName"
|
||||||
searchbar-info="You can search by ticket id or alias"
|
:searchbar-label="t('card.search')"
|
||||||
|
:searchbar-info="t('card.searchInfo')"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref, computed, onUnmounted } from 'vue';
|
import { onMounted, ref, computed, onUnmounted, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter, useRoute } from 'vue-router';
|
import { useRouter, useRoute } from 'vue-router';
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ const stateStore = useStateStore();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const { openConfirmationModal } = useVnConfirm();
|
const { openConfirmationModal } = useVnConfirm();
|
||||||
const salesDataRef = ref(null);
|
|
||||||
const editPriceProxyRef = ref(null);
|
const editPriceProxyRef = ref(null);
|
||||||
const stateBtnDropdownRef = ref(null);
|
const stateBtnDropdownRef = ref(null);
|
||||||
|
|
||||||
|
@ -53,6 +52,11 @@ const transfer = ref({
|
||||||
sales: [],
|
sales: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => route.params.id,
|
||||||
|
async () => await getSales()
|
||||||
|
);
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
label: '',
|
label: '',
|
||||||
|
@ -139,11 +143,29 @@ const columns = computed(() => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const getConfig = async () => {
|
const getConfig = async () => {
|
||||||
let filter = {
|
try {
|
||||||
fields: ['daysForWarningClaim'],
|
let filter = {
|
||||||
};
|
fields: ['daysForWarningClaim'],
|
||||||
const { data } = await axios.get(`TicketConfigs`, { filter });
|
};
|
||||||
ticketConfig.value = data;
|
const { data } = await axios.get(`TicketConfigs`, { filter });
|
||||||
|
ticketConfig.value = data;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error getting ticket config', err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onSalesFetched = (salesData) => {
|
||||||
|
sales.value = salesData;
|
||||||
|
for (let sale of salesData) sale.amount = getSaleTotal(sale);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getSales = async () => {
|
||||||
|
try {
|
||||||
|
const { data } = await axios.get(`Tickets/${route.params.id}/getSales`);
|
||||||
|
onSalesFetched(data);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching sales', err);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSaleTotal = (sale) => {
|
const getSaleTotal = (sale) => {
|
||||||
|
@ -155,14 +177,9 @@ const getSaleTotal = (sale) => {
|
||||||
return price - discount;
|
return price - discount;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSalesFetched = (salesData) => {
|
|
||||||
sales.value = salesData;
|
|
||||||
for (let sale of salesData) sale.amount = getSaleTotal(sale);
|
|
||||||
};
|
|
||||||
|
|
||||||
const resetChanges = async () => {
|
const resetChanges = async () => {
|
||||||
arrayData.fetch({ append: false });
|
arrayData.fetch({ append: false });
|
||||||
salesDataRef.value.fetch();
|
getSales();
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateQuantity = async (sale) => {
|
const updateQuantity = async (sale) => {
|
||||||
|
@ -398,7 +415,8 @@ const setTransferParams = async () => {
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
stateStore.rightDrawer = true;
|
stateStore.rightDrawer = true;
|
||||||
await getConfig();
|
getConfig();
|
||||||
|
getSales();
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => (stateStore.rightDrawer = false));
|
onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
|
@ -415,12 +433,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
auto-load
|
auto-load
|
||||||
@on-fetch="(data) => (isLocked = data)"
|
@on-fetch="(data) => (isLocked = data)"
|
||||||
/>
|
/>
|
||||||
<FetchData
|
|
||||||
ref="salesDataRef"
|
|
||||||
:url="`Tickets/${route.params.id}/getSales`"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="(data) => onSalesFetched(data)"
|
|
||||||
/>
|
|
||||||
<FetchData
|
<FetchData
|
||||||
url="Items/withName"
|
url="Items/withName"
|
||||||
:filter="{ fields: ['id', 'name'], order: 'id DESC' }"
|
:filter="{ fields: ['id', 'name'], order: 'id DESC' }"
|
||||||
|
|
|
@ -22,3 +22,6 @@ ticketSale:
|
||||||
shipped: Shipped
|
shipped: Shipped
|
||||||
agency: Agency
|
agency: Agency
|
||||||
address: Address
|
address: Address
|
||||||
|
card:
|
||||||
|
search: Search tickets
|
||||||
|
searchInfo: You can search by ticket id or alias
|
||||||
|
|
|
@ -24,3 +24,6 @@ ticketSale:
|
||||||
shipped: F. Envío
|
shipped: F. Envío
|
||||||
agency: Agencia
|
agency: Agencia
|
||||||
address: Consignatario
|
address: Consignatario
|
||||||
|
card:
|
||||||
|
search: Buscar tickets
|
||||||
|
searchInfo: Buscar tickets por identificador o alias
|
||||||
|
|
|
@ -22,6 +22,7 @@ const searchBarDataKeys = {
|
||||||
ZoneEvents: 'ZoneEvents',
|
ZoneEvents: 'ZoneEvents',
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnCard
|
<VnCard
|
||||||
data-key="Zone"
|
data-key="Zone"
|
||||||
|
|
Loading…
Reference in New Issue