fix : correction du téléchargement du bon de réception pour Chrome
All checks were successful
Auto Tag Develop / tag (push) Successful in 6s
Build Release Artefact / build (push) Successful in 1m17s

This commit is contained in:
2026-02-02 08:05:00 +01:00
parent 1ce6357c1d
commit 086279f962
4 changed files with 70 additions and 42 deletions

View File

@@ -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);
}