Browse Source

Merge branch 'master' into seec

mjh 3 years ago
parent
commit
e6d306fda2

+ 3 - 1
src/global/register-element.js

@@ -40,6 +40,7 @@ import {
   ElContainer,ElHeader,ElMain,
   ElBadge, ElOptionGroup, ElTooltip,
   ElAlert,
+  ElProgress
 } from "element-plus";
 
 // NOTE 使用到的组件列表,请确保 import 和 component 的一致性
@@ -90,7 +91,8 @@ const components = [
   ElContainer,
   ElHeader,
   ElMain,
-  ElAlert
+  ElAlert,
+  ElProgress
 ];
 
 export default function (app) {

+ 0 - 5
src/router/index.js

@@ -135,11 +135,6 @@ const routes = [
     path: "/courseWare/:courseWareId/details",
     name: "courseWareDetails",
     component: ()=>import("../views/CourseWarePage/CourseWarePage")
-  },
-  {
-    path: "/empty/:courseWareId",
-    name: "empty",
-    component: ()=>import("../views/CourseWarePage/pdf/Empty")
   }
 ];
 

+ 20 - 41
src/views/CourseDetailPage/tabs/CoursewareTab.vue

@@ -8,7 +8,7 @@
                   plain>新建</el-button>
       </el-col>
       <el-col :span="15">
-          <span style="font-size: smaller; position: absolute; bottom: 25%">(支持拓展名:.pdf .jpg .jpeg .png .exe .zip)</span>
+          <span style="font-size: smaller; position: absolute; bottom: 25%">(支持拓展名:.pdf .jpg .jpeg .png .exe .zip,最大文件大小:100MB)</span>
       </el-col>
     </el-row>
     <el-dialog v-model="uploadDialogVisible" :before-close="handleCancelUpload" :width="700">
@@ -29,7 +29,8 @@
                   :auto-upload="false"
                   :show-file-list="false"
               >
-                  <el-button plain type="primary" class="tabs-function-button">上传文件</el-button>(仅支持上传单个文件)
+                  <el-button plain type="primary" class="tabs-function-button" size="small"
+                  >上传文件</el-button>(仅支持上传单个文件,最大文件大小:100MB)
               </el-upload>
               <el-tag
                       v-if="isNameUnique"
@@ -60,10 +61,12 @@
               <el-switch v-model="downloadValue" />
           </el-form-item>
         </el-form>
-        <div style="margin: auto;width: fit-content">
-          <el-button type="primary" @click="handleConfirmUpload">确定</el-button>
-          <el-button @click="handleCancelUpload">取消</el-button>
+        <div style="margin: auto; width: fit-content">
+          <el-button type="primary" @click="handleConfirmUpload" size="small">确定</el-button>
+          <el-button @click="handleCancelUpload" size="small">取消</el-button>
         </div>
+        <el-progress  v-if="percentageVisible" :indeterminate="true" :percentage="100" status="warning"
+                     style="width: 40%; margin-top: 20px; margin-left: 30%"></el-progress>
     </el-dialog>
 
       <el-table :data="fileEntryList" style="width: 100%">
@@ -222,7 +225,9 @@ export default {
       pdfName: "",
       downloadValue: true,
       canDownloadList: [],
-      courseWareNum: 0
+      courseWareNum: 0,
+      //percentage: 0,
+      percentageVisible: false
     };
   },
 
@@ -377,6 +382,8 @@ export default {
                     });
                     this.newName = null;
                 } else {
+                    //this.percentage= 0;
+                    this.percentageVisible = true;
                     this.$apis.uploadCourseWareFile(this.courseId + "/" + this.newName + this.nameAppend, this.file.raw)
                         .then(res => {
                             const fileUrl = res.data.data;
@@ -390,7 +397,7 @@ export default {
                                 useMethod: this.form.useMethod,
                                 fileUrl: fileUrl,
                             }).then(res => {
-                                console.log(res.data.data.id);
+                                //this.percentage= 100;
                                 this.$apis.setCanDownloadById(res.data.data.id, this.downloadValue);
                                 this.$apis.getCourseWaresByCourseId(this.courseId)
                                     .then(res => {
@@ -408,6 +415,7 @@ export default {
                                         this.nameAppend = null;
                                         this.file = null;
                                         this.fileType = null;
+                                        this.percentageVisible = false;
                                     });
                             });
                         });
@@ -422,6 +430,8 @@ export default {
               this.nameAppend = null;
         }
         else {
+            //this.percentage= 0;
+            this.percentageVisible = true;
             this.$message({
                 message: "上传中,请稍候",
                 type: "warning",
@@ -440,6 +450,7 @@ export default {
                         useMethod: this.form.useMethod,
                         fileUrl: fileUrl,
                     }).then(res => {
+                        //this.percentage= 100;
                         this.$apis.setCanDownloadById(res.data.data.id, this.downloadValue);
                         this.$apis.getCourseWaresByCourseId(this.courseId)
                             .then(res => {
@@ -455,6 +466,7 @@ export default {
                                 this.fileNum = 0;
                                 this.file = null;
                                 this.fileType = null;
+                                this.percentageVisible = false;
                             });
                     });
                 });
@@ -476,6 +488,7 @@ export default {
           this.newName = null;
           this.nameAppend = null;
           this.fileType = null;
+          this.percentageVisible = false;
           this.clearForm();
           // Zhurui修改,关闭dialog
           done();
@@ -578,41 +591,7 @@ export default {
             .then(() => {
                 this.picturePreviewDialogVisible = false;
             });
-      },
-
-      // getCanDownloadById(id) {
-      //     this.$apis.getCanDownloadById(id).then(res => {
-      //         console.log(res.data.data);
-      //         return res.data.data;
-      //     });
-      // },
-
-      async getCanDownloadById(id) {
-          const canDownload = (await this.$apis.getCanDownloadById(id)).data.data;
-          //console.log(id + ": " + canDownload);
-          return canDownload === true;
-      },
-
-      checkDownloadButton(id, name){
-          this.$apis.getCanDownloadById(id).then(res => {
-              const canDownload = res.data.data;
-              const isPdf = this.isPdfOrPicture(name);
-              if ((isPdf === "PDF") && (canDownload.toString() === "true")) {
-                  return "1";
-              } else {
-                  return "0";
-              }
-          });
-          // const isPdf = this.isPdfOrPicture(name);
-          // const canDownload = (await this.$apis.getCanDownloadById(id)).data.data;
-          // if ((isPdf === "PDF") && (canDownload.toString() === "true")) {
-          //     return "1";
-          // } else {
-          //     return "0";
-          // }
-          //return "1";
       }
-
   }
 };
 </script>

+ 9 - 1
src/views/CourseWarePage/CourseWarePage.vue

@@ -12,7 +12,8 @@
                 </el-card>
             </el-col>
             <el-col :span="20">
-                <pdf-viewer></pdf-viewer>
+                <div>
+                    <pdf-viewer v-if="renderComponent"></pdf-viewer></div>
             </el-col>
         </el-row>
     </div>
@@ -37,6 +38,7 @@
         },
         data() {
             return {
+                renderComponent: true,
                 //fileUrl: "https://seec-portal.oss-cn-hangzhou.aliyuncs.com/1/07-%E9%9C%80%E6%B1%82%E6%96%87%E6%A1%A3%E5%8C%96%E4%B8%8E%E9%AA%8C%E8%AF%81.pdf",
             };
         },
@@ -117,6 +119,12 @@
                     let href = URL.createObjectURL(blob);
                     console.log(href);
                     this.$store.commit(SET_SRC, { src: href });
+                    this.renderComponent = false;
+                    this.$nextTick(() => {
+                        // 在 DOM 中添加 my-component 组件
+                        console.log(1);
+                        this.renderComponent = true;
+                    });
                 });
             });
         },

+ 0 - 17
src/views/CourseWarePage/pdf/Empty.vue

@@ -1,17 +0,0 @@
-<template>
-    <div></div>
-</template>
-
-<script>
-    export default {
-        name: "Empty",
-        created(){
-            console.log(this.$route.params.courseWareId);
-            //this.$router.replace({ path: "/courseWare/" + this.$route.params.courseWareId + "/details" });
-        }
-    };
-</script>
-
-<style scoped>
-
-</style>

+ 1 - 1
src/views/CourseWarePage/pdf/Pdf.vue

@@ -22,6 +22,7 @@
             };
         },
         mounted() {
+            console.log(this.src);
             this.loading = true;
             this._canvas = document.getElementById("pdf-canvas");
             this._context = this._canvas.getContext("2d");
@@ -29,7 +30,6 @@
             // Default size
             this._canvas.height = 450;
             this._canvas.width = 700;
-            console.log(this.src);
 
             if (this.src) {
                 this.load(this.src);