Преглед на файлове

fix:调整课件上传时的加载进度条

chillqi преди 3 години
родител
ревизия
3793472ea1
променени са 2 файла, в които са добавени 23 реда и са изтрити 42 реда
  1. 3 1
      src/global/register-element.js
  2. 20 41
      src/views/CourseDetailPage/tabs/CoursewareTab.vue

+ 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) {

+ 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>