fix : correction du téléchargement du bon de réception pour Chrome
This commit is contained in:
@@ -5,7 +5,7 @@ export const usePdfPrinter = () => {
|
||||
const receptionStore = useReceptionStore()
|
||||
const currentReception = receptionStore.current
|
||||
|
||||
const printPdf = async (url: string): Promise<void> => {
|
||||
const printPdf = async (url: string, previewWindow?: Window | null): Promise<void> => {
|
||||
const blob = await api.getBlob(url);
|
||||
|
||||
const pdfBlob = blob.type === 'application/pdf'
|
||||
@@ -16,15 +16,17 @@ export const usePdfPrinter = () => {
|
||||
|
||||
const filename = `${currentReception.identificationNumber}_${currentReception.supplier.name}_${currentReception.licensePlate}.pdf`;
|
||||
|
||||
const a = document.createElement('a');
|
||||
a.href = blobUrl;
|
||||
a.download = filename;
|
||||
a.style.display = 'none';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
if (previewWindow) {
|
||||
previewWindow.location.replace(blobUrl)
|
||||
}
|
||||
|
||||
// L'ouverture dans un nouvel onglet déclenche un 2e PDF sans le nom personnalisé.
|
||||
const a = document.createElement('a')
|
||||
a.href = blobUrl
|
||||
a.download = filename
|
||||
a.style.display = 'none'
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
a.remove()
|
||||
setTimeout(() => URL.revokeObjectURL(blobUrl), 60_000);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user