natasha %!s(int64=3) %!d(string=hai) anos
pai
achega
4c96005291
Modificáronse 1 ficheiros con 60 adicións e 14 borrados
  1. 60 14
      src/views/courseList.vue

+ 60 - 14
src/views/courseList.vue

@@ -355,7 +355,7 @@
                         multiple
                         style="width: 500px"
                     >
-                        <el-button size="mini" type="success">上传视频</el-button>
+                        <el-button size="mini" type="success" :loading="uploadingVideo">上传视频</el-button>
                     </el-upload>
                   </el-form-item>
                   <el-form-item label="课文音频" label-width="90px" prop="fileListAudio">
@@ -373,7 +373,7 @@
                         multiple
                         style="width: 500px"
                     >
-                        <el-button size="mini" type="success">上传音频</el-button>
+                        <el-button size="mini" type="success" :loading="uploadingAudio">上传音频</el-button>
                     </el-upload>
                   </el-form-item>
                   <el-form-item label="其他音频" label-width="90px" prop="fileListOtheraudio">
@@ -381,7 +381,7 @@
                         :action="url"
                         :file-list="fileListOtheraudio"
                         :limit="100"
-                        :before-upload="beforeUploadAudio"
+                        :before-upload="beforeUploadOtherAudio"
                         :on-exceed="handleExceedVideo"
                         :on-remove="handleRemoveOtheraudio"
                         :on-success="handleSuccesOthersAudio"
@@ -391,7 +391,7 @@
                         multiple
                         style="width: 500px"
                     >
-                        <el-button size="mini" type="success">上传音频</el-button>
+                        <el-button size="mini" type="success" :loading="uploadingOtherAudio">上传音频</el-button>
                     </el-upload>
                   </el-form-item>
                   <el-form-item label="试读PDF" label-width="90px" prop="fileListDoc">
@@ -409,7 +409,7 @@
                         multiple
                         style="width: 500px"
                     >
-                        <el-button size="mini" type="success">上传PDF</el-button>
+                        <el-button size="mini" type="success" :loading="uploadingDoc">上传PDF</el-button>
                     </el-upload>
                   </el-form-item>
               </el-tab-pane>
@@ -540,6 +540,10 @@ export default {
         price: [{ required: true, validator: validatePrice }],
       },
       loading: false,
+      uploadingVideo: false,
+      uploadingAudio: false,
+      uploadingOtherAudio: false,
+      uploadingDoc: false,
       titleEdit: "新建教材",
       rowIndex: 0, // 记录编辑教材的index
       tableloading: true,
@@ -692,6 +696,10 @@ export default {
     // 新建教材提交
     submitCourse() {
       const _this = this;
+      if(this.uploadingVideo||this.uploadingAudio||this.uploadingOtherAudio||this.uploadingDoc){
+          this.$message.warning('有文件尚未上传成功,请耐心等待');
+          return false
+      }
       _this.$refs.formDialog.validate((valid) => {
         _this.formDialog.name = _this.formDialog.name.trim();
         _this.formDialog.author = _this.formDialog.author.trim();
@@ -852,6 +860,7 @@ export default {
       }
     },
     handleSuccessVideo(response, file, fileList) {
+      this.uploadingVideo = false
       if (response.status == 1) {
         this.$message.success("上传成功");
         this.formDialog.resource_file_id_list_video.push(response.file_info_list[0].file_id);
@@ -860,6 +869,7 @@ export default {
       }
     },
     handleSuccessAudio(response, file, fileList) {
+      this.uploadingAudio = false
       if (response.status == 1) {
         this.$message.success("上传成功");
         this.formDialog.resource_file_id_list_audio.push(response.file_info_list[0].file_id);
@@ -868,6 +878,7 @@ export default {
       }
     },
     handleSuccesOthersAudio(response, file, fileList) {
+      this.uploadingOtherAudio = false
       if (response.status == 1) {
         this.$message.success("上传成功");
         this.formDialog.resource_file_id_list_otheraudio.push(response.file_info_list[0].file_id);
@@ -876,6 +887,7 @@ export default {
       }
     },
     handleSuccessDoc(response, file, fileList) {
+      this.uploadingDoc = false
       if (response.status == 1) {
         this.$message.success("上传成功");
         this.formDialog.resource_file_id_list_doc.push(response.file_info_list[0].file_id);
@@ -925,21 +937,51 @@ export default {
         }
     },
     beforeUploadVideo(file) {
-        if (file.size > 500 * 1024 * 1024) {
-            this.$message.warning('上传视频大小不能超过500M');
-            return false   //必须返回false
+        if(this.uploadingVideo){
+            return false
+        }else{
+            this.uploadingVideo = true
+            if (file.size > 500 * 1024 * 1024) {
+                this.$message.warning('上传视频大小不能超过500M');
+                this.uploadingVideo = false
+                return false   //必须返回false
+            }
         }
     },
     beforeUploadAudio(file) {
-        if (file.size > 20 * 1024 * 1024) {
-            this.$message.warning('上传音频大小不能超过20M');
-            return false   //必须返回false
+        if(this.uploadingAudio){
+            return false
+        }else{
+            this.uploadingAudio = true
+            if (file.size > 20 * 1024 * 1024) {
+                this.$message.warning('上传音频大小不能超过20M');
+                this.uploadingAudio = false
+                return false   //必须返回false
+            }
+        }
+    },
+    beforeUploadOtherAudio(file){
+        if(this.uploadingOtherAudio){
+            return false
+        }else{
+            this.uploadingOtherAudio = true
+            if (file.size > 20 * 1024 * 1024) {
+                this.$message.warning('上传音频大小不能超过20M');
+                this.uploadingOtherAudio = false
+                return false   //必须返回false
+            }
         }
     },
     beforeUploadDoc(file) {
-        if (file.size > 20 * 1024 * 1024) {
-            this.$message.warning('上传文件大小不能超过20M');
-            return false   //必须返回false
+        if(this.uploadingDoc){
+            return false
+        }else{
+            this.uploadingDoc = true
+            if (file.size > 20 * 1024 * 1024) {
+                this.$message.warning('上传文件大小不能超过20M');
+                this.uploadingDoc = false
+                return false   //必须返回false
+            }
         }
     },
     handleExceed(files, fileList) {
@@ -950,6 +992,10 @@ export default {
       );
     },
     handleExceedVideo(files, fileList) {
+      this.uploadingVideo = false
+      this.uploadingAudio = false
+      this.uploadingOtherAudio = false
+      this.uploadingDoc = false
       this.$message.warning(
         `当前限制选择 100 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
           files.length + fileList.length