This commit is contained in:
Taric Xin
2022-01-13 16:24:58 +08:00
parent 6fc033cc95
commit 45f0869f1f
4 changed files with 101 additions and 70 deletions

View File

@ -91,4 +91,26 @@ export class TicketService extends ShipperBaseService {
constructor(public injector: Injector, public eaCacheSrv: EACacheService) {
super(injector, eaCacheSrv);
}
reviewPDF(url: string) {
if (!url) {
return;
}
const uA = window.navigator.userAgent; // 判断浏览器内核
const isIE =
/msie\s|trident\/|edge\//i.test(uA) &&
!!('uniqueID' in document || 'documentMode' in document || 'ActiveXObject' in window || 'MSInputMethodContext' in window);
const objectUrl = url;
const a = document.createElement('a');
document.body.appendChild(a);
a.href = objectUrl;
a.download = '面单.pdf';
if (isIE) {
// 兼容IE11无法触发下载的问题
(navigator as any).msSaveBlob(url, a.download);
} else {
a.click();
}
a.remove();
}
}