diff --git a/src/composables/downloadFile.js b/src/composables/downloadFile.js index 4588265a2..8c9e21a4f 100644 --- a/src/composables/downloadFile.js +++ b/src/composables/downloadFile.js @@ -2,16 +2,25 @@ import { useSession } from 'src/composables/useSession'; import { getUrl } from './getUrl'; import axios from 'axios'; import { exportFile } from 'quasar'; +import useOpenURL from './useOpenURL'; const { getTokenMultimedia } = useSession(); const token = getTokenMultimedia(); -export async function downloadFile(id, model = 'dms', urlPath = '/downloadFile', url) { +export async function downloadFile( + id, + model = 'dms', + urlPath = '/downloadFile', + url, + newTab = true +) { const appUrl = (await getUrl('', 'lilium')).replace('/#/', ''); - const response = await axios.get( - url ?? `${appUrl}/api/${model}/${id}${urlPath}?access_token=${token}`, - { responseType: 'blob' } - ); + const targetUrl = + url ?? `${appUrl}/api/${model}/${id}${urlPath}?access_token=${token}`; + + if (newTab) return useOpenURL(targetUrl); + + const response = await axios.get(targetUrl, { responseType: 'blob' }); const contentDisposition = response.headers['content-disposition']; const matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(contentDisposition); diff --git a/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue b/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue index f2c6f93ef..cb8a45833 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue @@ -206,7 +206,8 @@ const isAgricultural = () => { }; function showPdfInvoice() { - if (isAgricultural()) openReport(`InvoiceIns/${entityId.value}/invoice-in-pdf`); + if (isAgricultural()) + openReport(`InvoiceIns/${entityId.value}/invoice-in-pdf`, null, '_blank'); } function sendPdfInvoiceConfirmation() {