0
1
Fork 0

Apply multimedia token and change openReport method

This commit is contained in:
William Buezas 2024-10-07 09:33:17 -03:00
parent b669adab5a
commit c9812cd320
3 changed files with 10 additions and 19 deletions

View File

@ -5,8 +5,7 @@ import { useQuasar } from 'quasar';
export function usePrintService() {
const quasar = useQuasar();
const userStore = useUserStore();
const token = userStore.token;
const { getTokenMultimedia } = useUserStore();
function sendEmail(path, params) {
return axios.post(path, params).then(() =>
@ -18,17 +17,17 @@ export function usePrintService() {
);
}
function openReport(path, params) {
function openReport(path, params, isNewTab = '_self') {
if (typeof params === 'string') params = JSON.parse(params);
params = Object.assign(
{
access_token: token
access_token: getTokenMultimedia()
},
params
);
const query = new URLSearchParams(params).toString();
window.open(`api/${path}?${query}`);
window.open(`api/${path}?${query}`, isNewTab);
}
return {

View File

@ -5,17 +5,16 @@ import { useI18n } from 'vue-i18n';
import TicketDetails from 'src/pages/Ecomerce/TicketDetails.vue';
import { useUserStore } from 'stores/user';
import { useAppStore } from 'stores/app';
import { storeToRefs } from 'pinia';
import { usePrintService } from 'src/composables/usePrintService';
const { t } = useI18n();
const jApi = inject('jApi');
const route = useRoute();
const userStore = useUserStore();
const appStore = useAppStore();
const { isHeaderMounted } = storeToRefs(appStore);
const { user, token } = storeToRefs(userStore);
const { openReport } = usePrintService();
const ticket = ref({});
const rows = ref([]);
@ -38,16 +37,8 @@ onMounted(async () => {
);
});
const onPrintClick = () => {
const params = new URLSearchParams({
access_token: token.value,
recipientId: user.value.id,
type: 'deliveryNote'
});
window.open(
`/api/Tickets/${ticket.value.id}/delivery-note-pdf?${params.toString()}`
);
};
const onPrintClick = () =>
openReport(`Tickets/${ticket.value.id}/delivery-note-pdf`, {}, '_blank');
</script>
<template>

View File

@ -311,6 +311,7 @@ export const useUserStore = defineStore('user', () => {
return {
token,
tokenMultimedia,
isGuest,
user,
supplantedUser,