Просмотр исходного кода

Revert "课表列表导出修改"

This reverts commit af0c473886ac15386a52b709ea5acc97c5a72e01.
mo 4 лет назад
Родитель
Сommit
e4463f3159
1 измененных файлов с 23 добавлено и 25 удалено
  1. 23 25
      src/views/teamDetail/teamCourseList.vue

+ 23 - 25
src/views/teamDetail/teamCourseList.vue

@@ -1099,40 +1099,38 @@ export default {
         },
         },
         params: this.getSearchForm(),
         params: this.getSearchForm(),
         url,
         url,
-        // responseType: "blob",
+        responseType: "blob",
       };
       };
       this.$confirm("您确定导出报表", "提示", {
       this.$confirm("您确定导出报表", "提示", {
         confirmButtonText: "确定",
         confirmButtonText: "确定",
         cancelButtonText: "取消",
         cancelButtonText: "取消",
         type: "warning",
         type: "warning",
       })
       })
-        .then((data) => {
+        .then(() => {
           load.startLoading();
           load.startLoading();
           axios(options)
           axios(options)
             .then((res) => {
             .then((res) => {
-              console.log(res)
-              this.$message.success(res.data.data)
-              // let blob = new Blob([res.data], {
-              //   // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
-              //   type: "application/vnd.ms-excel;charset=utf-8",
-              //   //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
-              // });
-              // let text = new Response(blob).text();
-              // text.then((res) => {
-              //   // 判断是否报错
-              //   if (res.indexOf("code") != -1) {
-              //     let json = JSON.parse(res);
-              //     this.$message.error(json.msg);
-              //   } else {
-              //     let objectUrl = URL.createObjectURL(blob);
-              //     let link = document.createElement("a");
-              //     let fname = "课表列表" + new Date().getTime() + ".xls"; //下载文件的名字
-              //     link.href = objectUrl;
-              //     link.setAttribute("download", fname);
-              //     document.body.appendChild(link);
-              //     link.click();
-              //   }
-              // });
+              let blob = new Blob([res.data], {
+                // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
+                type: "application/vnd.ms-excel;charset=utf-8",
+                //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
+              });
+              let text = new Response(blob).text();
+              text.then((res) => {
+                // 判断是否报错
+                if (res.indexOf("code") != -1) {
+                  let json = JSON.parse(res);
+                  this.$message.error(json.msg);
+                } else {
+                  let objectUrl = URL.createObjectURL(blob);
+                  let link = document.createElement("a");
+                  let fname = "课表列表" + new Date().getTime() + ".xls"; //下载文件的名字
+                  link.href = objectUrl;
+                  link.setAttribute("download", fname);
+                  document.body.appendChild(link);
+                  link.click();
+                }
+              });
               load.endLoading();
               load.endLoading();
             })
             })
             .catch((error) => {
             .catch((error) => {