forked from verdnatura/hedera-web
Apply multimedia token and change openReport method
This commit is contained in:
parent
b669adab5a
commit
c9812cd320
|
@ -5,8 +5,7 @@ import { useQuasar } from 'quasar';
|
||||||
|
|
||||||
export function usePrintService() {
|
export function usePrintService() {
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const userStore = useUserStore();
|
const { getTokenMultimedia } = useUserStore();
|
||||||
const token = userStore.token;
|
|
||||||
|
|
||||||
function sendEmail(path, params) {
|
function sendEmail(path, params) {
|
||||||
return axios.post(path, params).then(() =>
|
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(
|
params = Object.assign(
|
||||||
{
|
{
|
||||||
access_token: token
|
access_token: getTokenMultimedia()
|
||||||
},
|
},
|
||||||
params
|
params
|
||||||
);
|
);
|
||||||
|
|
||||||
const query = new URLSearchParams(params).toString();
|
const query = new URLSearchParams(params).toString();
|
||||||
|
window.open(`api/${path}?${query}`, isNewTab);
|
||||||
window.open(`api/${path}?${query}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -5,17 +5,16 @@ import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
import TicketDetails from 'src/pages/Ecomerce/TicketDetails.vue';
|
import TicketDetails from 'src/pages/Ecomerce/TicketDetails.vue';
|
||||||
|
|
||||||
import { useUserStore } from 'stores/user';
|
|
||||||
import { useAppStore } from 'stores/app';
|
import { useAppStore } from 'stores/app';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { usePrintService } from 'src/composables/usePrintService';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const jApi = inject('jApi');
|
const jApi = inject('jApi');
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const userStore = useUserStore();
|
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
const { isHeaderMounted } = storeToRefs(appStore);
|
const { isHeaderMounted } = storeToRefs(appStore);
|
||||||
const { user, token } = storeToRefs(userStore);
|
const { openReport } = usePrintService();
|
||||||
|
|
||||||
const ticket = ref({});
|
const ticket = ref({});
|
||||||
const rows = ref([]);
|
const rows = ref([]);
|
||||||
|
@ -38,16 +37,8 @@ onMounted(async () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const onPrintClick = () => {
|
const onPrintClick = () =>
|
||||||
const params = new URLSearchParams({
|
openReport(`Tickets/${ticket.value.id}/delivery-note-pdf`, {}, '_blank');
|
||||||
access_token: token.value,
|
|
||||||
recipientId: user.value.id,
|
|
||||||
type: 'deliveryNote'
|
|
||||||
});
|
|
||||||
window.open(
|
|
||||||
`/api/Tickets/${ticket.value.id}/delivery-note-pdf?${params.toString()}`
|
|
||||||
);
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -311,6 +311,7 @@ export const useUserStore = defineStore('user', () => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
token,
|
token,
|
||||||
|
tokenMultimedia,
|
||||||
isGuest,
|
isGuest,
|
||||||
user,
|
user,
|
||||||
supplantedUser,
|
supplantedUser,
|
||||||
|
|
Loading…
Reference in New Issue