Browse Source

zip下载

V1.0
zhangyuan 3 years ago
parent
commit
db47c28148
  1. 51
      src/views/modules/base/smartImport.vue

51
src/views/modules/base/smartImport.vue

@ -285,27 +285,36 @@ export default {
data: params, data: params,
}) })
.then((res) => { .then((res) => {
// this.download(res.data, title + '.xls') const url = window.URL.createObjectURL(new Blob([res.data]))
if (res.headers["content-disposition"]) { const aLink = document.createElement('a')
let fileName = window.decodeURI( aLink.style.display = 'none'
res.headers["content-disposition"] aLink.href = url
.split(";")[1] aLink.setAttribute('download', '人员导入模板.zip')
.split("=")[1] document.body.appendChild(aLink)
); aLink.click()
console.log("filename", fileName); document.body.removeChild(aLink)
let blob = new Blob([res.data], { window.URL.revokeObjectURL(url)
type: "application/vnd.ms-excel", // // this.download(res.data, title + '.xls')
}); // if (res.headers["content-disposition"]) {
var url = window.URL.createObjectURL(blob); // let fileName = window.decodeURI(
var aLink = document.createElement("a"); // res.headers["content-disposition"]
aLink.style.display = "none"; // .split(";")[1]
aLink.href = url; // .split("=")[1]
aLink.setAttribute("download", fileName); // );
document.body.appendChild(aLink); // console.log("filename", fileName);
aLink.click(); // let blob = new Blob([res.data], {
document.body.removeChild(aLink); // // type: "application/vnd.ms-excel",
window.URL.revokeObjectURL(url); //blob // });
} else this.$message.error("下载失败"); // var url = window.URL.createObjectURL(blob);
// var aLink = document.createElement("a");
// aLink.style.display = "none";
// aLink.href = url;
// aLink.setAttribute("download", fileName);
// document.body.appendChild(aLink);
// aLink.click();
// document.body.removeChild(aLink); //
// window.URL.revokeObjectURL(url); //blob
// } else this.$message.error("");
}) })
.catch((err) => { .catch((err) => {
console.log("err", err); console.log("err", err);

Loading…
Cancel
Save