瀏覽代碼

删除提示

natasha 1 周之前
父節點
當前提交
65cdb10046
共有 1 個文件被更改,包括 17 次插入7 次删除
  1. 17 7
      src/views/book/courseware/preview/components/upload_control/UploadControlPreview.vue

+ 17 - 7
src/views/book/courseware/preview/components/upload_control/UploadControlPreview.vue

@@ -79,17 +79,27 @@ export default {
   },
   methods: {
     changeFillId(fileList) {
-      this.data.answer.answer_list = [fileList[0].response.file_info_list[0]];
-      let path = `${this.file_preview_url}onlinePreview?url=${Base64.encode(fileList[0].response.file_info_list[0].file_url)}`;
-      this.data.answer.answer_list[0].newpath = path;
-      this.$forceUpdate();
+      if (fileList.length > 0) {
+        this.data.answer.answer_list = [fileList[0].response.file_info_list[0]];
+        let path = `${this.file_preview_url}onlinePreview?url=${Base64.encode(fileList[0].response.file_info_list[0].file_url)}`;
+        this.data.answer.answer_list[0].newpath = path;
+        this.$forceUpdate();
+      }
     },
     remove() {
       if (!this.isJudgingRightWrong) {
         if (this.data.answer.answer_list.length > 0) {
-          this.data.answer.answer_list = [];
-          this.$message.success('删除成功');
-          this.$forceUpdate();
+          this.$confirm('确定要删除此文件吗?', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning',
+          })
+            .then(() => {
+              this.data.answer.answer_list = [];
+              this.$message.success('删除成功');
+              this.$forceUpdate();
+            })
+            .catch(() => {});
         }
       }
     },