0
0
Fork 0

fix: refs #8083 delete btn & redirect

This commit is contained in:
Jorge Penadés 2024-10-22 14:21:03 +02:00
parent f751408de2
commit b1a511ff6f
1 changed files with 14 additions and 33 deletions

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { onMounted, ref, computed, onUnmounted, watch } from 'vue'; import { onMounted, ref, computed, onUnmounted } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
@ -34,42 +34,15 @@ const selectedRows = ref([]);
const hasSelectedRows = computed(() => selectedRows.value.length > 0); const hasSelectedRows = computed(() => selectedRows.value.length > 0);
const expeditionStateTypes = ref([]); const expeditionStateTypes = ref([]);
const exprBuilder = (param, value) => {
switch (param) {
case 'expeditionFk':
return { id: value };
case 'packageItemName':
return { packagingItemFk: value };
}
};
const expeditionsFilter = computed(() => ({ const expeditionsFilter = computed(() => ({
where: { ticketFk: route.params.id }, where: { ticketFk: route.params.id },
order: ['created DESC'], order: ['created DESC'],
})); }));
const expeditionsArrayData = useArrayData('ticketExpeditions', {
url: 'Expeditions/filter',
filter: expeditionsFilter.value,
exprBuilder: exprBuilder,
});
const ticketArrayData = useArrayData('ticketData'); const ticketArrayData = useArrayData('ticketData');
const ticketStore = ticketArrayData.store; const ticketStore = ticketArrayData.store;
const ticketData = computed(() => ticketStore.data); const ticketData = computed(() => ticketStore.data);
const refetchExpeditions = async () => {
await expeditionsArrayData.applyFilter({
filter: expeditionsFilter.value,
});
};
watch(
() => route.params.id,
async () => await refetchExpeditions(),
{ immediate: true }
);
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
@ -191,12 +164,10 @@ const showNewTicketDialog = (withRoute = false) => {
const deleteExpedition = async () => { const deleteExpedition = async () => {
try { try {
const expeditionIds = selectedExpeditions.value.map( const expeditionIds = selectedRows.value.map((expedition) => expedition.id);
(expedition) => expedition.id
);
const params = { expeditionIds }; const params = { expeditionIds };
await axios.post('Expeditions/deleteExpeditions', params); await axios.post('Expeditions/deleteExpeditions', params);
await refetchExpeditions(); vnTableRef.value.reload();
selectedExpeditions.value = []; selectedExpeditions.value = [];
notify(t('expedition.expeditionRemoved'), 'positive'); notify(t('expedition.expeditionRemoved'), 'positive');
} catch (error) { } catch (error) {
@ -330,6 +301,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
ref="vnTableRef" ref="vnTableRef"
data-key="TicketExpedition" data-key="TicketExpedition"
url="Expeditions/filter" url="Expeditions/filter"
search-url="expeditions"
:columns="columns" :columns="columns"
:filter="expeditionsFilter" :filter="expeditionsFilter"
v-model:selected="selectedRows" v-model:selected="selectedRows"
@ -339,7 +311,16 @@ onUnmounted(() => (stateStore.rightDrawer = false));
}" }"
save-url="Expeditions/crud" save-url="Expeditions/crud"
auto-load auto-load
order="created DESC" :expr-builder="
(param, value) => {
switch (param) {
case 'expeditionFk':
return { id: value };
case 'packageItemName':
return { packagingItemFk: value };
}
}
"
> >
<template #column-packagingItemFk="{ row }"> <template #column-packagingItemFk="{ row }">
<span class="link" @click.stop> <span class="link" @click.stop>