feat: refs #7936 enhance downloadFile function to support opening in a new tab
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
a33cec4a34
commit
ad9063704c
|
@ -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);
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue