This commit is contained in:
wangshiming
2022-03-02 09:53:31 +08:00
parent 803e3f3f77
commit 8344c23453
2 changed files with 33 additions and 9 deletions

View File

@ -4,7 +4,7 @@
* @Author : Shiming
* @Date : 2022-03-01 15:13:03
* @LastEditors : Shiming
* @LastEditTime : 2022-03-01 16:18:58
* @LastEditTime : 2022-03-02 09:52:53
* @FilePath : \\tms-obc-web\\src\\app\\routes\\supply-management\\model\\import-supply\\import-supply.component.ts
* Copyright (C) 2022 huzhenhong. All rights reserved.
*/
@ -184,12 +184,36 @@ export class SupplyManagementImportSupplyComponent implements OnInit {
});
};
downFile() {
this.service.request(this.service.$api_exportGoodsResourceOperateTemplate).subscribe((res: any)=> {
console.log(res)
if(res) {
this.status = false
}
})
console.log('78')
// this.service.request(this.service.$api_exportGoodsResourceOperateTemplate).subscribe((res: any)=> {
// console.log('66')
// console.log(res)
// let aLink = document.createElement('a');
// const content = res;
// let blob = this.base64ToBlob(content); //new Blob([content]);
// let evt = document.createEvent("HTMLEvents");
// evt.initEvent("click", true, true);//initEvent 不加后两个参数在IE下会报错 事件类型,是否冒泡,是否阻止浏览器的默认行为
// aLink.download = '模板';
// aLink.href = URL.createObjectURL(blob);
// // aLink.dispatchEvent(evt);
// aLink.click();
// this.status = false
// })
this.service.downloadFile(this.service.$api_exportGoodsResourceOperateTemplate);
// window.location.href('')
}
//base64转blob
base64ToBlob(code: any) {
let parts = code.split(';base64,');
let contentType = parts[0].split(':')[1];
let raw = window.atob(parts[1]);
let rawLength = raw.length;
let uInt8Array = new Uint8Array(rawLength);
for (let i = 0; i < rawLength; ++i) {
uInt8Array[i] = raw.charCodeAt(i);
}
return new Blob([uInt8Array], { type: contentType });
}
}