forked from verdnatura/salix-front
Mejoras y cosas faltantes
This commit is contained in:
parent
7eda82bf82
commit
6096123c6e
|
@ -1047,7 +1047,9 @@ export default {
|
|||
entries: 'Entries',
|
||||
cloneShipping: 'Clone travel',
|
||||
CloneTravelAndEntries: 'Clone travel and his entries',
|
||||
deleteTravel: 'Delete travel',
|
||||
AddEntry: 'Add entry',
|
||||
thermographs: 'Thermographs',
|
||||
},
|
||||
variables: {
|
||||
search: 'Id/Reference',
|
||||
|
|
|
@ -1047,7 +1047,9 @@ export default {
|
|||
entries: 'Entradas',
|
||||
cloneShipping: 'Clonar envío',
|
||||
CloneTravelAndEntries: 'Clonar travel y sus entradas',
|
||||
deleteTravel: 'Eliminar envío',
|
||||
AddEntry: 'Añadir entrada',
|
||||
thermographs: 'Termógrafos',
|
||||
},
|
||||
variables: {
|
||||
search: 'Id/Referencia',
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
import FormModel from 'components/FormModel.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
|
@ -9,20 +9,27 @@ import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
|
|||
import FetchData from 'components/FetchData.vue';
|
||||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||
|
||||
import { useState } from 'src/composables/useState';
|
||||
import { toDate } from 'src/filters';
|
||||
|
||||
const state = useState();
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const user = state.getUser();
|
||||
const newEntryForm = reactive({
|
||||
supplierFk: null,
|
||||
travelFk: route.query?.travelFk || null,
|
||||
companyFk: null,
|
||||
companyFk: user.value.companyFk || null,
|
||||
});
|
||||
|
||||
const suppliersOptions = ref([]);
|
||||
const travelsOptionsOptions = ref([]);
|
||||
const companiesOptions = ref([]);
|
||||
|
||||
const redirectToEntryBasicData = (_, { id }) => {
|
||||
router.push({ name: 'EntryBasicData', params: { id } });
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -48,12 +55,14 @@ const companiesOptions = ref([]);
|
|||
@on-fetch="(data) => (companiesOptions = data)"
|
||||
auto-load
|
||||
/>
|
||||
|
||||
<!-- Agregar searchbar de entries -->
|
||||
|
||||
<QPage>
|
||||
<VnSubToolbar />
|
||||
<FormModel url-create="Entries" model="entry" :form-initial-data="newEntryForm">
|
||||
<FormModel
|
||||
url-create="Entries"
|
||||
model="entry"
|
||||
:form-initial-data="newEntryForm"
|
||||
@on-data-saved="redirectToEntryBasicData"
|
||||
>
|
||||
<template #form="{ data, validate }">
|
||||
<VnRow class="row q-gutter-md q-mb-md">
|
||||
<VnSelectFilter
|
||||
|
|
|
@ -2,10 +2,13 @@
|
|||
import { ref, computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { toDate } from 'src/filters';
|
||||
|
||||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import TravelDescriptorMenuItems from './TravelDescriptorMenuItems.vue';
|
||||
|
||||
import useCardDescription from 'src/composables/useCardDescription';
|
||||
import { toDate } from 'src/filters';
|
||||
|
||||
const $props = defineProps({
|
||||
id: {
|
||||
|
@ -28,6 +31,7 @@ const filter = {
|
|||
'warehouseInFk',
|
||||
'warehouseOutFk',
|
||||
'cargoSupplierFk',
|
||||
'agencyModeFk',
|
||||
],
|
||||
include: [
|
||||
{
|
||||
|
@ -82,6 +86,9 @@ const setData = (entity) => {
|
|||
</QTooltip>
|
||||
</QBtn>
|
||||
</template>
|
||||
<template #menu="{ entity }">
|
||||
<TravelDescriptorMenuItems :travel="entity" />
|
||||
</template>
|
||||
<template #body="{ entity }">
|
||||
<VnLv :label="t('globals.wareHouseIn')" :value="entity.warehouseIn.name" />
|
||||
<VnLv :label="t('globals.wareHouseOut')" :value="entity.warehouseOut.name" />
|
||||
|
@ -89,10 +96,32 @@ const setData = (entity) => {
|
|||
<VnLv :label="t('globals.landed')" :value="toDate(entity.landed)" />
|
||||
<VnLv :label="t('globals.totalEntries')" :value="entity.totalEntries" />
|
||||
</template>
|
||||
<template #actions="{ entity }">
|
||||
<QCardActions>
|
||||
<QBtn
|
||||
:to="{
|
||||
name: 'TravelList',
|
||||
query: {
|
||||
params: JSON.stringify({
|
||||
agencyModeFk: entity.agencyModeFk,
|
||||
}),
|
||||
},
|
||||
}"
|
||||
size="md"
|
||||
icon="local_airport"
|
||||
color="primary"
|
||||
>
|
||||
<QTooltip>{{ t('All travels with current agency') }}</QTooltip>
|
||||
</QBtn>
|
||||
</QCardActions>
|
||||
</template>
|
||||
</CardDescriptor>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
Go to module index: Ir al índice del módulo
|
||||
The travel will be deleted: El envío será eliminado
|
||||
Do you want to delete this travel?: ¿Quieres eliminar este envío?
|
||||
All travels with current agency: Todos los envíos con la agencia actual
|
||||
</i18n>
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import { useRole } from 'src/composables/useRole';
|
||||
|
||||
const $props = defineProps({
|
||||
travel: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
const quasar = useQuasar();
|
||||
const { notify } = useNotify();
|
||||
const role = useRole();
|
||||
|
||||
const redirectToCreateView = (queryParams) => {
|
||||
router.push({ name: 'TravelCreate', query: { travelData: queryParams } });
|
||||
};
|
||||
|
||||
const cloneTravel = () => {
|
||||
const stringifiedTravelData = JSON.stringify($props.travel);
|
||||
redirectToCreateView(stringifiedTravelData);
|
||||
};
|
||||
|
||||
const cloneTravelWithEntries = () => {
|
||||
try {
|
||||
axios.post(`Travels/${$props.travel.id}/cloneWithEntries`);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
} catch (err) {
|
||||
console.err('Error cloning travel with entries');
|
||||
}
|
||||
};
|
||||
|
||||
const isBuyer = computed(() => {
|
||||
return role.hasAny(['buyer']);
|
||||
});
|
||||
|
||||
const openDeleteEntryDialog = (id) => {
|
||||
quasar
|
||||
.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('The travel will be deleted'),
|
||||
message: t('Do you want to delete this travel?'),
|
||||
},
|
||||
})
|
||||
.onOk(async () => {
|
||||
await deleteTravel(id);
|
||||
});
|
||||
};
|
||||
|
||||
const deleteTravel = async (id) => {
|
||||
try {
|
||||
await axios.delete(`Travels/${id}`);
|
||||
router.push({ name: 'TravelList' });
|
||||
notify('globals.dataDeleted', 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error deleting travel');
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QItem v-ripple clickable @click="cloneTravel(travel)">
|
||||
<QItemSection>{{ t('travel.summary.cloneShipping') }}</QItemSection>
|
||||
</QItem>
|
||||
<QItem v-ripple clickable @click="cloneTravelWithEntries()">
|
||||
<QItemSection>
|
||||
{{ t('travel.summary.CloneTravelAndEntries') }}
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem
|
||||
v-if="isBuyer && travel.totalEntries === 0"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="openDeleteEntryDialog(travel.id)"
|
||||
>
|
||||
<QItemSection>
|
||||
{{ t('travel.summary.deleteTravel') }}
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem v-ripple clickable>
|
||||
<QItemSection>
|
||||
<RouterLink
|
||||
:to="{ name: 'EntryCreate', query: { travelFk: travel.id } }"
|
||||
class="color-vn-text"
|
||||
>
|
||||
{{ t('travel.summary.AddEntry') }}
|
||||
</RouterLink>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
The travel will be deleted: El envío será eliminado
|
||||
Do you want to delete this travel?: ¿Quieres eliminar este envío?
|
||||
</i18n>
|
|
@ -1,23 +1,20 @@
|
|||
<script setup>
|
||||
import { onMounted, ref, computed, onUpdated } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { QCheckbox, QIcon } from 'quasar';
|
||||
import CardSummary from 'components/ui/CardSummary.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import EntryDescriptorProxy from 'src/pages/Entry/Card/EntryDescriptorProxy.vue';
|
||||
import FetchData from 'src/components/FetchData.vue';
|
||||
import TravelDescriptorMenuItems from './TravelDescriptorMenuItems.vue';
|
||||
|
||||
import travelService from 'src/services/travel.service';
|
||||
import { toDate, toCurrency } from 'src/filters';
|
||||
import { getUrl } from 'src/composables/getUrl';
|
||||
import axios from 'axios';
|
||||
|
||||
onUpdated(() => summaryRef.value.fetch());
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
|
||||
const $props = defineProps({
|
||||
id: {
|
||||
type: Number,
|
||||
|
@ -26,36 +23,21 @@ const $props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
|
||||
const entityId = computed(() => $props.id || route.params.id);
|
||||
const entries = ref([]);
|
||||
const summaryRef = ref();
|
||||
const travel = ref();
|
||||
const travelUrl = ref();
|
||||
const travel = ref();
|
||||
const entries = ref([]);
|
||||
const thermographs = ref([]);
|
||||
const warehouses = ref([]);
|
||||
|
||||
onMounted(async () => {
|
||||
travelUrl.value = (await getUrl('travel/')) + entityId.value;
|
||||
});
|
||||
|
||||
const cloneTravel = () => {
|
||||
const stringifiedTravelData = JSON.stringify(travel.value);
|
||||
redirectToCreateView(stringifiedTravelData);
|
||||
};
|
||||
|
||||
const cloneTravelWithEntries = () => {
|
||||
try {
|
||||
axios.post(`Travels/${$props.id}/cloneWithEntries`);
|
||||
} catch (err) {
|
||||
console.err('Error cloning travel with entries');
|
||||
}
|
||||
};
|
||||
|
||||
const headerMenuOptions = [
|
||||
{ name: t('travel.summary.cloneShipping'), action: cloneTravel },
|
||||
{ name: t('travel.summary.CloneTravelAndEntries'), action: cloneTravelWithEntries },
|
||||
{ name: t('travel.summary.AddEntry'), action: null },
|
||||
];
|
||||
|
||||
const entriesTableColumns = computed(() => {
|
||||
return [
|
||||
{
|
||||
|
@ -126,25 +108,122 @@ const entriesTableColumns = computed(() => {
|
|||
];
|
||||
});
|
||||
|
||||
const thermographsTableColumns = computed(() => {
|
||||
return [
|
||||
{
|
||||
label: t('travel.thermographs.code'),
|
||||
field: 'thermographFk',
|
||||
name: 'thermographFk',
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
label: t('travel.thermographs.temperature'),
|
||||
field: 'temperatureFk',
|
||||
name: 'temperatureFk',
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
label: t('travel.thermographs.state'),
|
||||
field: 'result',
|
||||
name: 'result',
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
label: t('travel.thermographs.destination'),
|
||||
field: 'warehouseFk',
|
||||
name: 'destination',
|
||||
align: 'left',
|
||||
format: (val) =>
|
||||
warehouses.value.find((warehouse) => warehouse.id === val).name,
|
||||
},
|
||||
{
|
||||
label: t('travel.thermographs.created'),
|
||||
field: 'created',
|
||||
name: 'created',
|
||||
align: 'left',
|
||||
format: (val) => toDate(val),
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
const entriesTableRows = computed(() => {
|
||||
if (!entries.value && !entries.value.length > 0) return [];
|
||||
return entries.value;
|
||||
});
|
||||
|
||||
async function setTravelData(data) {
|
||||
if (data) {
|
||||
travel.value = data;
|
||||
const entriesResponse = await travelService.getTravelEntries(travel.value.id);
|
||||
if (entriesResponse.data) entries.value = entriesResponse.data;
|
||||
}
|
||||
}
|
||||
const entriesTotalHb = computed(() => {
|
||||
return entriesTableRows.value.reduce((acc, { hb }) => acc + hb, 0);
|
||||
});
|
||||
|
||||
const redirectToCreateView = (queryParams) => {
|
||||
router.push({ name: 'TravelCreate', query: { travelData: queryParams } });
|
||||
const entriesTotalFreight = computed(() => {
|
||||
return toCurrency(
|
||||
entriesTableRows.value.reduce((acc, { freightValue }) => acc + freightValue, 0)
|
||||
);
|
||||
});
|
||||
|
||||
const entriesTotalCc = computed(() => {
|
||||
return entriesTableRows.value.reduce((acc, { cc }) => acc + cc, 0);
|
||||
});
|
||||
|
||||
const entriesTotalPallet = computed(() => {
|
||||
return entriesTableRows.value.reduce((acc, { pallet }) => acc + pallet, 0);
|
||||
});
|
||||
|
||||
const entriesTotalM3 = computed(() => {
|
||||
return entriesTableRows.value.reduce((acc, { m3 }) => acc + m3, 0);
|
||||
});
|
||||
|
||||
const getTravelEntries = async (id) => {
|
||||
try {
|
||||
const { data } = await axios.get(`Travels/${id}/getEntries`);
|
||||
entries.value = data;
|
||||
} catch (err) {
|
||||
console.error('Error fetching travel entries');
|
||||
}
|
||||
};
|
||||
|
||||
const getTravelThermographs = async (id) => {
|
||||
try {
|
||||
const filter = {
|
||||
include: {
|
||||
relation: 'warehouse',
|
||||
scope: {
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
},
|
||||
where: { travelFk: id },
|
||||
};
|
||||
|
||||
const { data } = await axios.get('TravelThermographs', {
|
||||
params: { filter: JSON.parse(JSON.stringify(filter)) },
|
||||
});
|
||||
thermographs.value = data;
|
||||
} catch (err) {
|
||||
console.error('Error fetching travel thermographs');
|
||||
}
|
||||
};
|
||||
|
||||
async function setTravelData(travelData) {
|
||||
try {
|
||||
if (travelData) {
|
||||
travel.value = travelData;
|
||||
await getTravelEntries(travel.value.id);
|
||||
await getTravelThermographs(travel.value.id);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Error setting travel data`, err);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
url="Warehouses"
|
||||
:filter="{ fields: ['id', 'name'] }"
|
||||
order="name"
|
||||
@on-fetch="(data) => (warehouses = data)"
|
||||
auto-load
|
||||
/>
|
||||
<CardSummary
|
||||
ref="summaryRef"
|
||||
:url="`Travels/${entityId}/getTravel`"
|
||||
|
@ -165,10 +244,8 @@ const redirectToCreateView = (queryParams) => {
|
|||
{{ t('components.cardDescriptor.moreOptions') }}
|
||||
</QTooltip>
|
||||
<QMenu>
|
||||
<QList dense v-for="option in headerMenuOptions" :key="option">
|
||||
<QItem v-ripple clickable @click="option.action">
|
||||
{{ option.name }}
|
||||
</QItem>
|
||||
<QList>
|
||||
<TravelDescriptorMenuItems :travel="travel" />
|
||||
</QList>
|
||||
</QMenu>
|
||||
</QBtn>
|
||||
|
@ -214,10 +291,9 @@ const redirectToCreateView = (queryParams) => {
|
|||
<VnLv :label="t('globals.totalEntries')" :value="travel.m3" />
|
||||
</QCard>
|
||||
<QCard class="full-width" v-if="entriesTableRows.length > 0">
|
||||
<a class="header" :href="travelUrl + 'entry'">
|
||||
<span class="header">
|
||||
{{ t('travel.summary.entries') }}
|
||||
<QIcon name="open_in_new" color="primary" />
|
||||
</a>
|
||||
</span>
|
||||
<QTable
|
||||
:rows="entriesTableRows"
|
||||
:columns="entriesTableColumns"
|
||||
|
@ -225,69 +301,71 @@ const redirectToCreateView = (queryParams) => {
|
|||
row-key="id"
|
||||
class="full-width q-mt-md"
|
||||
>
|
||||
<!-- <template #body-cell-isConfirmed="{ row }">
|
||||
<QTd auto-width>
|
||||
<template #header="props">
|
||||
<QTr :props="props" class="bg">
|
||||
<QTh v-for="col in props.cols" :key="col.name" :props="props">
|
||||
{{ t(col.label) }}
|
||||
</QTh>
|
||||
</QTr>
|
||||
</template>
|
||||
<template #body-cell-isConfirmed="{ col, value }">
|
||||
<QTd>
|
||||
<QIcon
|
||||
:name="row.isConfirmed ? 'check' : 'close'"
|
||||
:color="row.isConfirmed ? 'positive' : 'negative'"
|
||||
v-if="col.name === 'isConfirmed'"
|
||||
:name="value ? 'check' : 'close'"
|
||||
:color="value ? 'positive' : 'negative'"
|
||||
size="sm"
|
||||
/>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-id="{ row }">
|
||||
<QTd auto-width>
|
||||
<QBtn flat color="blue">
|
||||
{{ row.id }}
|
||||
<EntryDescriptorProxy :id="row.id" />
|
||||
<template #body-cell-id="{ col, value }">
|
||||
<QTd>
|
||||
<QBtn v-if="col.name === 'id'" flat color="blue" dense>
|
||||
{{ value }}
|
||||
<EntryDescriptorProxy :id="value" />
|
||||
</QBtn>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-observation="{ row }">
|
||||
<QTd auto-width>
|
||||
<QIcon
|
||||
v-if="row.observation"
|
||||
name="insert_drive_file"
|
||||
color="primary"
|
||||
size="sm"
|
||||
/>
|
||||
<template #body-cell-observation="{ value }">
|
||||
<QTd>
|
||||
<QIcon name="insert_drive_file" color="primary" size="24px">
|
||||
<QTooltip>{{ value }}</QTooltip>
|
||||
</QIcon>
|
||||
</QTd>
|
||||
</template> -->
|
||||
<!-- <template #body="props">
|
||||
<QTr :props="props" :key="`m_${props.row.index}`">
|
||||
<QTd v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<template v-if="col.showValue">{{ col.value }}</template>
|
||||
</QTd>
|
||||
</QTr>
|
||||
<QTr
|
||||
:props="props"
|
||||
:key="`e_${props.row.index}`"
|
||||
class="q-virtual-scroll--with-prev"
|
||||
>
|
||||
<QTd colspan="100%">
|
||||
<div class="text-left">
|
||||
This is the second row generated from the same data:
|
||||
</div>
|
||||
</QTd>
|
||||
</QTr>
|
||||
</template> -->
|
||||
<template #body-cell="props">
|
||||
<QTd :props="props">
|
||||
<QTr :props="props" :key="`m_${props.row.index}`">
|
||||
<template v-if="props.col.showValue">
|
||||
{{ props.value }}
|
||||
</template>
|
||||
</QTr>
|
||||
</QTd>
|
||||
<QTd :props="props">
|
||||
<QTr :props="props" :key="`m_${props.row.index}`">
|
||||
<template v-if="props.col.showValue">
|
||||
{{ props.value }}
|
||||
</template>
|
||||
</QTr>
|
||||
</QTd>
|
||||
<template #bottom-row>
|
||||
<QTd></QTd>
|
||||
<QTd></QTd>
|
||||
<QTd></QTd>
|
||||
<QTd></QTd>
|
||||
<QTd class="text-bold">{{ entriesTotalHb }}</QTd>
|
||||
<QTd class="text-bold">{{ entriesTotalFreight }}</QTd>
|
||||
<QTd class="text-bold">{{ entriesTotalCc }}</QTd>
|
||||
<QTd class="text-bold">{{ entriesTotalPallet }}</QTd>
|
||||
<QTd class="text-bold">{{ entriesTotalM3 }}</QTd>
|
||||
</template>
|
||||
</QTable>
|
||||
</QCard>
|
||||
|
||||
<QCard class="full-width" v-if="thermographs.length > 0">
|
||||
<RouterLink
|
||||
class="header"
|
||||
:to="{
|
||||
name: 'TravelThermographsIndex',
|
||||
params: { id: travel.id },
|
||||
}"
|
||||
>
|
||||
{{ t('travel.summary.thermographs') }}
|
||||
<QIcon name="open_in_new" color="primary" />
|
||||
</RouterLink>
|
||||
<QTable
|
||||
:rows="thermographs"
|
||||
:columns="thermographsTableColumns"
|
||||
hide-bottom
|
||||
row-key="id"
|
||||
class="full-width q-mt-md"
|
||||
/>
|
||||
</QCard>
|
||||
</template>
|
||||
</CardSummary>
|
||||
</template>
|
||||
|
|
|
@ -16,7 +16,7 @@ import { toCurrency } from 'src/filters';
|
|||
import { useArrayData } from 'composables/useArrayData';
|
||||
import { toDate } from 'src/filters';
|
||||
import { usePrintService } from 'composables/usePrintService';
|
||||
import travelService from 'src/services/travel.service';
|
||||
import axios from 'axios';
|
||||
|
||||
const router = useRouter();
|
||||
const stateStore = useStateStore();
|
||||
|
@ -222,9 +222,13 @@ const openReportPdf = () => {
|
|||
};
|
||||
|
||||
const saveFieldValue = async (val, field, index) => {
|
||||
try {
|
||||
const id = rows.value[index].id;
|
||||
const params = { [field]: val };
|
||||
await travelService.updateTravel(id, params);
|
||||
await axios.patch(`Travels/${id}`, params);
|
||||
} catch (err) {
|
||||
console.error('Error updating travel');
|
||||
}
|
||||
};
|
||||
|
||||
const navigateToTravelId = (id) => {
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
import axios from 'axios';
|
||||
|
||||
const travelService = {
|
||||
getTravelEntries: async (param) => {
|
||||
try {
|
||||
return await axios.get(`Travels/${param}/getEntries`);
|
||||
} catch (err) {
|
||||
console.error(`Error fetching travel entries`, err);
|
||||
return err.response;
|
||||
}
|
||||
},
|
||||
|
||||
updateTravel: async (id, params) => {
|
||||
try {
|
||||
return await axios.patch(`Travels/${id}`, params);
|
||||
} catch (err) {
|
||||
console.error(`Error updating travel`, err);
|
||||
return err.response;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default travelService;
|
Loading…
Reference in New Issue