lsc 2 rokov pred
rodič
commit
78c2846ff1
1 zmenil súbory, kde vykonal 38 pridanie a 1 odobranie
  1. 38 1
      src/components/studyStudent.vue

+ 38 - 1
src/components/studyStudent.vue

@@ -555,6 +555,9 @@
                   @click="checkFileFull(showType, pptImgUrl1)"
                   >全屏查看</el-button
                 >
+                <el-button type="primary" @click="downloadFile(pptImgUrl1)"
+                  >文件下载</el-button
+                >
                 <el-button
                   v-if="isClickNav.indexOf('line') != -1"
                   type="primary"
@@ -7383,7 +7386,7 @@ export default {
           a = this.evalCount;
           this.toolsCount(a, t);
         }
-        this.eScore = { eBzText: "", eStar: [] }
+        this.eScore = { eBzText: "", eStar: [] };
         if (this.worksStudent[i].length) {
           for (var k = 0; k < this.worksStudent[i].length; k++) {
             if (this.userid == this.worksStudent[i][k].userid) {
@@ -7547,6 +7550,40 @@ export default {
       this.fulltype = type;
       this.fullUrl = url;
     },
+    downloadFile(url) {
+      let _url = "";
+      if (
+        url.indexOf("https://view.officeapps.live.com/op/view.aspx?src=") != -1
+      ) {
+        _url = url.split(
+          "https://view.officeapps.live.com/op/view.aspx?src="
+        )[1];
+      } else {
+        _url = url;
+      }
+      const x = new XMLHttpRequest();
+      x.open("GET", _url, true);
+      x.responseType = "blob";
+      x.onload = function (e) {
+        // const url = window.URL.createObjectURL(x.response);
+        // const a = document.createElement("a");
+        // a.href = url;
+        // a.target = "_blank";
+        // a.download = url;
+        // a.click();
+        // a.remove();
+        let content = x.response;
+        let elink = document.createElement("a");
+        elink.download = decodeURI(_url.split("https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/")[1]);
+        elink.style.display = "none";
+        let blob = new Blob([content]);
+        elink.href = URL.createObjectURL(blob);
+        document.body.appendChild(elink);
+        elink.click();
+        document.body.removeChild(elink);
+      };
+      x.send();
+    },
     openLine(url) {
       window.open(url);
     },