0
0
Fork 0

Ticket expedition

This commit is contained in:
William Buezas 2024-06-28 08:27:21 -03:00
parent 053059997a
commit fe67f21206
3 changed files with 32 additions and 15 deletions

View File

@ -1,5 +1,5 @@
<script setup>
import { onMounted, ref, computed, onUnmounted, reactive } from 'vue';
import { onMounted, ref, computed, onUnmounted, reactive, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
@ -28,7 +28,6 @@ const { notify } = useNotify();
const { openConfirmationModal } = useVnConfirm();
const editPriceProxyRef = ref(null);
const newTicketDialogRef = ref(null);
const expeditionsFetchDataRef = ref(null);
const logsTableDialogRef = ref(null);
const expeditionsLogsData = ref([]);
@ -47,18 +46,34 @@ const exprBuilder = (param, value) => {
}
};
const arrayData = useArrayData('ticketExpeditions', {
const expeditionsFilter = computed(() => ({
where: { ticketFk: route.params.id },
order: ['created DESC'],
}));
const expeditionsArrayData = useArrayData('ticketExpeditions', {
url: 'Expeditions/filter',
filter: { where: { ticketFk: route.params.id }, order: ['created DESC'] },
filter: expeditionsFilter.value,
exprBuilder: exprBuilder,
});
const { store } = arrayData;
const ticketExpeditions = computed(() => store.data);
const expeditionsStore = expeditionsArrayData.store;
const ticketExpeditions = computed(() => expeditionsStore.data);
// watch(
// () => route.params.id,
// async () => await getSales()
// );
const ticketArrayData = useArrayData('ticketData');
const ticketStore = ticketArrayData.store;
const ticketData = computed(() => ticketStore.data);
const refetchExpeditions = async () => {
await expeditionsArrayData.applyFilter({
params: { filter: JSON.stringify(expeditionsFilter.value) },
});
};
watch(
() => route.params.id,
async () => await refetchExpeditions(),
{ immediate: true }
);
const params = reactive({});
@ -66,7 +81,7 @@ const applyColumnFilter = async (col) => {
try {
const paramKey = col.columnFilter?.filterParamKey || col.field;
params[paramKey] = col.columnFilter.filterValue;
await arrayData.addFilter({ params });
await expeditionsArrayData.addFilter({ params });
} catch (err) {
console.error('Error applying column filter', err);
}
@ -220,7 +235,7 @@ const deleteExpedition = async () => {
);
const params = { expeditionIds };
await axios.post('Expeditions/deleteExpeditions', params);
expeditionsFetchDataRef.value.fetch();
await refetchExpeditions();
selectedExpeditions.value = [];
notify(t('expedition.expeditionRemoved'), 'positive');
} catch (error) {
@ -253,7 +268,7 @@ onMounted(async () => {
stateStore.rightDrawer = true;
const filteredColumns = columns.value.filter((col) => col.name !== 'history');
allColumnNames.value = filteredColumns.map((col) => col.name);
await arrayData.fetch({ append: false });
// await expeditionsArrayData.fetch({ append: false });
});
onUnmounted(() => (stateStore.rightDrawer = false));
@ -280,7 +295,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<QBtnDropdown
ref="btnDropdownRef"
color="primary"
:label="t('ticketSale.more')"
:label="t('expedition.move')"
:disable="!selectedExpeditions.length"
>
<template #label>
@ -435,7 +450,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</QTable>
<QDialog ref="newTicketDialogRef" transition-show="scale" transition-hide="scale">
<ExpeditionNewTicket
:ticket="ticketExpeditions"
:ticket="ticketData"
:with-route="newTicketWithRoute"
:selected-expeditions="selectedExpeditions"
/>

View File

@ -98,3 +98,4 @@ expedition:
expeditionRemoved: Expedition removed
removeExpeditionSubtitle: Are you sure you want to delete this expedition?
worker: Worker
move: Move

View File

@ -97,6 +97,7 @@ expedition:
expeditionRemoved: Expedición eliminada
removeExpeditionSubtitle: ¿Está seguro de eliminar esta expedición?
worker: Trabajador
move: Mover
card:
search: Buscar tickets
searchInfo: Buscar tickets por identificador o alias