Browse Source

上传控件bug修改及上传组件删除功能 读汉字写拼音去选项上传音频

秦鹏 3 years ago
parent
commit
a597b8ba9d

+ 1 - 1
src/components/Adult/common/SentenceModule.vue

@@ -181,7 +181,7 @@
     >
       <img src="../../../assets/adult/pro-plus.png" alt="" />
     </div>
-    <div class="adult-book-input-item">
+    <div class="adult-book-input-item" v-if="type != 'recordHZ_inputPY_chs'">
       <span class="adult-book-lable">音频:</span>
       <Upload
         :changeFillId="changeMp3"

+ 9 - 7
src/components/Adult/common/Upload.vue

@@ -14,6 +14,8 @@
       :on-success="handleSuccess"
       :on-change="handleChange"
       :file-list="fileList"
+      :before-remove="beforeRemove"
+      :on-remove="handleRemove"
     >
       <el-button size="mini" type="success">上传{{ fileTypeName }}</el-button>
       <div
@@ -142,13 +144,13 @@ export default {
         background: "rgba(0, 0, 0, 0.7)",
       });
     },
-    // handleRemove(file, fileList) {
-    //   this.changeFillId(fileList, "", this.index);
-    //   this.$message.success("移除成功");
-    // },
-    // beforeRemove(file, fileList) {
-    //   return this.$confirm(`确定移除 ${file.name}?`);
-    // },
+    handleRemove(file, fileList) {
+      this.changeFillId(fileList, "", this.index);
+      this.$message.success("移除成功");
+    },
+    beforeRemove(file, fileList) {
+      return this.$confirm(`确定移除 ${file.name}?`);
+    },
     handlePreview(file) {},
     handleExceed(files, fileList) {
       this.$message.warning(

+ 2 - 0
src/components/Adult/inputModules/ArticleTemChs/index.vue

@@ -280,6 +280,7 @@ export default {
           });
         } else {
           _this.$message.warning("请先上传音频");
+          _this.loading = false;
         }
       });
     },
@@ -496,6 +497,7 @@ export default {
           }
         } else {
           this.$message.warning("请先上传音频");
+          this.loading = false;
         }
       });
     },

+ 73 - 25
src/components/Adult/preview/UploadControlView.vue

@@ -6,7 +6,7 @@
       :style="{ display: type == 'upload_control_chs' ? 'flex' : 'block' }"
     >
       <div class="content">
-        <template v-if="curQue.Bookanswer&&type == 'upload_control_chs'">
+        <template v-if="curQue.Bookanswer && type == 'upload_control_chs'">
           <template
             v-if="
               curQue.Bookanswer.file_name.indexOf('png') != -1 ||
@@ -16,18 +16,28 @@
           >
             <img :src="curQue.Bookanswer.file_url" alt="" />
           </template>
-          <template v-else-if="curQue.Bookanswer.file_name.indexOf('pdf') != -1">
-            <pdf
+          <template
+            v-else-if="curQue.Bookanswer.file_name.indexOf('pdf') != -1"
+          >
+            <iframe
+              :src="curQue.Bookanswer.newpath"
+              id="ifm"
+              width="100%"
+              height="100%"
+            ></iframe>
+            <!-- <pdf
               ref="pdf"
               :src="curQue.Bookanswer.fileRelativePath"
               v-for="i in curQue.Bookanswer.numPages"
               :key="i"
               :page="i"
             >
-            </pdf>
+            </pdf> -->
           </template>
         </template>
-        <template v-else-if="curQue.data&&type == 'upload_control_preview_chs'">
+        <template
+          v-else-if="curQue.data && type == 'upload_control_preview_chs'"
+        >
           <template
             v-if="
               curQue.data.file_name.indexOf('png') != -1 ||
@@ -37,21 +47,29 @@
           >
             <img :src="curQue.data.file_url" alt="" />
           </template>
-          <template v-else-if="curQue.Bookanswer.file_name.indexOf('pdf') != -1">
-            <pdf
+          <template
+            v-else-if="curQue.Bookanswer.file_name.indexOf('pdf') != -1"
+          >
+            <iframe
+              :src="curQue.Bookanswer.newpath"
+              id="ifm"
+              width="100%"
+              height="100%"
+            ></iframe>
+            <!-- <pdf
               ref="pdf"
               :src="curQue.Bookanswer.fileRelativePath"
               v-for="i in curQue.Bookanswer.numPages"
               :key="i"
               :page="i"
             >
-            </pdf>
+            </pdf> -->
           </template>
         </template>
         <template v-else>
           <div
             style="display: flex; height: 40px"
-            v-if="type == 'upload_control_chs'&&TaskModel!='ANSWER'"
+            v-if="type == 'upload_control_chs' && TaskModel != 'ANSWER'"
           >
             <UploadView
               :changeFillId="changeFillId"
@@ -76,7 +94,12 @@
         下载
       </div>
       <div class="dv" v-if="curQue.Bookanswer">
-        <div v-if="type == 'upload_control_chs'" class="remove" :class="[TaskModel == 'ANSWER'?'notAllow':'']" @click="remove">
+        <div
+          v-if="type == 'upload_control_chs'"
+          class="remove"
+          :class="[TaskModel == 'ANSWER' ? 'notAllow' : '']"
+          @click="remove"
+        >
           <img src="../../../assets/adult/red_remove.png" alt="" />
         </div>
       </div>
@@ -88,6 +111,7 @@
 import UploadView from "../common/UploadView.vue";
 import pdf from "vue-pdf";
 import { getToken } from "../../../utils/auth";
+const Base64 = require("js-base64").Base64;
 
 export default {
   components: {
@@ -144,15 +168,15 @@ export default {
         `/GCLSFileServer/WebFileDownload?UserCode=${data.UserCode}&UserType=${data.UserType}&SessionID=${data.SessionID}&FileID=${data.FileID}`;
     },
     remove() {
-        if(!this.TaskModel||this.TaskModel!='ANSWER'){
-            if (this.curQue.Bookanswer) {
-                this.data = null;
-                this.curQue.Bookanswer = null;
-                this.curQue.fileList = [];
-                this.$message.success("删除成功");
-                this.$forceUpdate()
-            }
+      if (!this.TaskModel || this.TaskModel != "ANSWER") {
+        if (this.curQue.Bookanswer) {
+          this.data = null;
+          this.curQue.Bookanswer = null;
+          this.curQue.fileList = [];
+          this.$message.success("删除成功");
+          this.$forceUpdate();
         }
+      }
     },
     changeFillId(fileList, item, index) {
       this.curQue.fileList = fileList;
@@ -161,9 +185,14 @@ export default {
       this.curQue.Bookanswer = fileList[0].response.file_info_list[0];
       if (this.curQue.Bookanswer.file_name.indexOf("pdf") != -1) {
         this.curQue.Bookanswer = fileList[0].response.file_info_list[0];
-        this.curQue.Bookanswer.fileRelativePath =
-          process.env.VUE_APP_BASE_API + this.curQue.Bookanswer.file_relative_path;
-        this.getNumPages();
+        let path =
+          `http://docpreview.utschool.cn/onlinePreview?url=` +
+          Base64.encode(this.curQue.Bookanswer.file_url);
+        this.curQue.Bookanswer.newpath = path;
+        // this.curQue.Bookanswer.fileRelativePath =
+        //   process.env.VUE_APP_BASE_API +
+        //   this.curQue.Bookanswer.file_relative_path;
+        // this.getNumPages();
       }
       this.$forceUpdate();
     },
@@ -187,9 +216,28 @@ export default {
       let data = JSON.parse(JSON.stringify(this.data_structure));
       this.changeCurQue(data);
     },
+    handleData() {
+      let _this = this;
+      let single = null;
+      if (this.curQue.data) {
+        let path =
+          `http://docpreview.utschool.cn/onlinePreview?url=` +
+          Base64.encode(this.curQue.data.file_url);
+        this.curQue.data.newpath = path;
+        single = JSON.parse(JSON.stringify(this.curQue.data));
+      } else {
+        single = null;
+      }
+
+      if (!this.curQue.Bookanswer) {
+        this.$set(this.curQue, "Bookanswer", single);
+      }
+    },
   },
   //生命周期 - 创建完成(可以访问当前this实例)
-  created() {},
+  created() {
+    this.handleData();
+  },
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {},
   beforeCreate() {}, //生命周期 - 创建之前
@@ -223,8 +271,8 @@ export default {
       justify-content: center;
       margin-left: 32px;
       cursor: pointer;
-      &.notAllow{
-          cursor: not-allowed;
+      &.notAllow {
+        cursor: not-allowed;
       }
       img {
         width: 24px;
@@ -270,7 +318,7 @@ export default {
       border-radius: 4px;
       box-sizing: border-box;
       background: linear-gradient(0deg, #ebebeb, #ebebeb);
-      overflow-y: scroll;
+      // overflow-y: scroll;
       display: flex;
       justify-content: center;
       align-items: center;