0
0
Fork 0

Implement routes report

This commit is contained in:
Kevin Martinez 2024-01-24 06:51:52 -04:00
parent c146f77563
commit d0d57f71e0
1 changed files with 29 additions and 2 deletions

View File

@ -15,11 +15,13 @@ import RouteSearchbar from 'pages/Route/Card/RouteSearchbar.vue';
import RouteFilter from 'pages/Route/Card/RouteFilter.vue';
import { useQuasar } from 'quasar';
import RouteSummaryDialog from 'pages/Route/Card/RouteSummaryDialog.vue';
import {useSession} from "composables/useSession";
const stateStore = useStateStore();
const { t } = useI18n();
const { validate } = useValidator();
const quasar = useQuasar();
const session = useSession();
const to = Date.vnNew();
to.setDate(to.getDate() + 1);
@ -149,6 +151,23 @@ const cloneRoutes = () => {
startingDate.value = null;
};
const showRouteReport = () => {
const ids = selectedRows.value.map(row => row?.id)
const idString = ids.join(',')
let url;
if (selectedRows.value.length <= 1) {
url = `api/Routes/${idString}/driver-route-pdf?access_token=${session.getToken()}`;
} else {
const params = new URLSearchParams({
access_token: session.getToken(),
id: idString
})
url = `api/Routes/downloadZip?${params.toString()}`;
}
window.open(url, '_blank');
}
const markAsServed = () => {
selectedRows.value.forEach((row) => {
if (row?.id) {
@ -206,7 +225,6 @@ function previewRoute(id) {
autofocus
/>
</QCardSection>
<!-- TODO: Add report -->
<QCardActions align="right">
<QBtn flat :label="t('Cancel')" v-close-popup class="text-primary" />
<QBtn color="primary" v-close-popup @click="cloneRoutes">
@ -239,7 +257,15 @@ function previewRoute(id) {
>
<QTooltip>{{ t('Clone Selected Routes') }}</QTooltip>
</QBtn>
<QBtn
icon="cloud_download"
color="primary"
class="q-mr-sm"
:disable="!selectedRows?.length"
@click="showRouteReport"
>
<QTooltip>{{ t('Download selected routes as PDF') }}</QTooltip>
</QBtn>
<QBtn
icon="check"
color="primary"
@ -527,4 +553,5 @@ es:
Cancel: Cancelar
Clone: Clonar
Mark as served: Marcar como servidas
Download selected routes as PDF: Descargar rutas seleccionadas como PDF
</i18n>