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

View File

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

View File

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