|
@@ -104,6 +104,7 @@ import {
|
|
|
modifySingleTemplate,
|
|
|
deleteSingleTemplate,
|
|
|
deleteMultipleTemplates,
|
|
|
+ downloadTemplate,
|
|
|
} from "@/api/data/template";
|
|
|
export default {
|
|
|
components: { page, templatePopup },
|
|
@@ -195,9 +196,23 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- downloadTemplate(data) {
|
|
|
- // 调用下载接口
|
|
|
- console.log(data);
|
|
|
+ downloadTemplate(fileName) {
|
|
|
+ downloadTemplate(fileName)
|
|
|
+ .then((res) => {
|
|
|
+ const data = res.data;
|
|
|
+ if (data.type === "application/octet-stream") {
|
|
|
+ const blob = new Blob([data], { type: data.type });
|
|
|
+ const url = window.URL.createObjectURL(blob);
|
|
|
+ const link = document.createElement("a");
|
|
|
+ link.href = url;
|
|
|
+ link.download = fileName;
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ this.$message.error("文件下载失败,请重新下载!");
|
|
|
+ });
|
|
|
},
|
|
|
handleSizeChange(val) {
|
|
|
this.currentPageSize = val;
|
|
@@ -261,18 +276,17 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
confirmEvent(data) {
|
|
|
- console.log(data, "传回的模板参数");
|
|
|
if (this.templateTitle === "添加模板") {
|
|
|
let options = {
|
|
|
templateName: data.name,
|
|
|
templateFormat: data.format,
|
|
|
introduction: data.introduction,
|
|
|
templateType: 0,
|
|
|
- file:data.file
|
|
|
+ file: data.file,
|
|
|
};
|
|
|
addReportTemplate(options).then((res) => {
|
|
|
if (res.data.code === -1) {
|
|
|
- this.$message.info("模板已存在,请修改重新添加!");
|
|
|
+ this.$message.info("添加失败,请修改重新添加!");
|
|
|
}
|
|
|
if (res.data.code === 0) {
|
|
|
this.$message.success("模板添加成功!");
|
|
@@ -288,7 +302,7 @@ export default {
|
|
|
templateFormat: data.format,
|
|
|
introduction: data.introduction,
|
|
|
templateType: 0,
|
|
|
- file:data.file
|
|
|
+ file: data.file,
|
|
|
};
|
|
|
modifySingleTemplate(options).then((res) => {
|
|
|
if (res.data.code === -1) {
|