Browse Source

智能导入下载模板

dlt_manageScope_0428
mk 2 years ago
parent
commit
c5ab3fe351
  1. 58
      src/views/modules/base/smartImport/cpts/createdTask.vue

58
src/views/modules/base/smartImport/cpts/createdTask.vue

@ -418,51 +418,51 @@ export default {
},
//
async handelClickDownModule() {
let url = "/actual/base/intelligentImportData/autoGenerateExcelModule";
let url = "/actual/base/intelligentImportData/downloadImportModule";
let params = {
importCategory: this.form.importCategory,
};
await this.$http({
method: "POST",
url,
// responseType: "blob",
responseType: "blob",
data: params,
})
.then((res) => {
// if (res.status==200) {
if (res.status==200) {
// let fileName = window.decodeURI(
// res.headers["content-disposition"]
// .split(";")[1]
// .split("=")[1]
// );
// let fileName = `${
// this.$store.state.user.agencyName + this.categoryName
// }`;
// let blob = new Blob([res.data], {
// type: "application/vnd.ms-excel",
// });
// 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("");
let fileName = `${
let fileName = `${
this.$store.state.user.agencyName + this.categoryName
}导入模板`;
const url = res.data.data;
const aLink = document.createElement("a");
aLink.style.display = "none";
aLink.href = url;
aLink.setAttribute("download",`${fileName}.xlsx`);
document.body.appendChild(aLink);
aLink.click();
document.body.removeChild(aLink);
window.URL.revokeObjectURL(url);
let blob = new Blob([res.data], {
type: "application/vnd.ms-excel",
});
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("下载失败");
// let fileName = `${
// this.$store.state.user.agencyName + this.categoryName
// }`;
// const url = res.data.data;
// const aLink = document.createElement("a");
// aLink.style.display = "none";
// aLink.href = url;
// aLink.setAttribute("download",`${fileName}.xlsx`);
// document.body.appendChild(aLink);
// aLink.click();
// document.body.removeChild(aLink);
// window.URL.revokeObjectURL(url);
})
.catch((err) => {
console.log(err);

Loading…
Cancel
Save