edit
This commit is contained in:
@ -64,7 +64,7 @@ export class PrintOrderModalComponent implements OnInit {
|
||||
delete this.data.scontactInfo.id;
|
||||
this.service.request(this.service.$api_get_order_summary, params).subscribe(res => {
|
||||
if (res?.length > 0) {
|
||||
this.reviewPDF(res);
|
||||
this.service.reviewPDF(res);
|
||||
} else {
|
||||
this.service.msgSrv.warning('请到快递信息页面打印');
|
||||
this.modal.destroy(true);
|
||||
@ -78,7 +78,7 @@ export class PrintOrderModalComponent implements OnInit {
|
||||
if (res?.pdfUrl) {
|
||||
this.service.msgSrv.success('操作成功');
|
||||
this.modal.destroy(true);
|
||||
this.reviewPDF(res.pdfUrl);
|
||||
this.service.reviewPDF(res.pdfUrl);
|
||||
} else {
|
||||
this.service.msgSrv.warning('下载失败');
|
||||
this.modal.destroy(true);
|
||||
@ -86,27 +86,7 @@ export class PrintOrderModalComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
close() {
|
||||
this.modal.destroy();
|
||||
|
||||
Reference in New Issue
Block a user