forked from verdnatura/salix-front
fix: refs #8083 delete btn & redirect
This commit is contained in:
parent
f751408de2
commit
b1a511ff6f
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { onMounted, ref, computed, onUnmounted, watch } from 'vue';
|
||||
import { onMounted, ref, computed, onUnmounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
|
@ -34,42 +34,15 @@ const selectedRows = ref([]);
|
|||
const hasSelectedRows = computed(() => selectedRows.value.length > 0);
|
||||
const expeditionStateTypes = ref([]);
|
||||
|
||||
const exprBuilder = (param, value) => {
|
||||
switch (param) {
|
||||
case 'expeditionFk':
|
||||
return { id: value };
|
||||
case 'packageItemName':
|
||||
return { packagingItemFk: value };
|
||||
}
|
||||
};
|
||||
|
||||
const expeditionsFilter = computed(() => ({
|
||||
where: { ticketFk: route.params.id },
|
||||
order: ['created DESC'],
|
||||
}));
|
||||
|
||||
const expeditionsArrayData = useArrayData('ticketExpeditions', {
|
||||
url: 'Expeditions/filter',
|
||||
filter: expeditionsFilter.value,
|
||||
exprBuilder: exprBuilder,
|
||||
});
|
||||
|
||||
const ticketArrayData = useArrayData('ticketData');
|
||||
const ticketStore = ticketArrayData.store;
|
||||
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(() => [
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -191,12 +164,10 @@ const showNewTicketDialog = (withRoute = false) => {
|
|||
|
||||
const deleteExpedition = async () => {
|
||||
try {
|
||||
const expeditionIds = selectedExpeditions.value.map(
|
||||
(expedition) => expedition.id
|
||||
);
|
||||
const expeditionIds = selectedRows.value.map((expedition) => expedition.id);
|
||||
const params = { expeditionIds };
|
||||
await axios.post('Expeditions/deleteExpeditions', params);
|
||||
await refetchExpeditions();
|
||||
vnTableRef.value.reload();
|
||||
selectedExpeditions.value = [];
|
||||
notify(t('expedition.expeditionRemoved'), 'positive');
|
||||
} catch (error) {
|
||||
|
@ -330,6 +301,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
ref="vnTableRef"
|
||||
data-key="TicketExpedition"
|
||||
url="Expeditions/filter"
|
||||
search-url="expeditions"
|
||||
:columns="columns"
|
||||
:filter="expeditionsFilter"
|
||||
v-model:selected="selectedRows"
|
||||
|
@ -339,7 +311,16 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
}"
|
||||
save-url="Expeditions/crud"
|
||||
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 }">
|
||||
<span class="link" @click.stop>
|
||||
|
|
Loading…
Reference in New Issue