Просмотр исходного кода

去掉预览页面重新获取URL

natasha 1 месяц назад
Родитель
Сommit
0c88ac98bc

+ 3 - 3
src/views/book/courseware/create/components/question/article/NewWord.vue

@@ -115,7 +115,7 @@
         </div>
         <div class="table-item" style="width: 200px">
           <UploadPicture
-            :file-id="item.file_list[0]"
+            :file-info="item.file_list[0]"
             :item-index="i"
             :show-upload="!item.file_list[0]"
             @upload="uploadPic"
@@ -458,9 +458,9 @@ export default {
       this.data.new_word_list[index].mp3_list = '';
       this.data.file_id_list = this.data.file_id_list.filter((item) => item !== file_id);
     },
-    uploadPic(file_id, index) {
-      this.data.new_word_list[index].file_list[0] = file_id;
+    uploadPic(file_id, index, file) {
       this.data.file_id_list.push(file_id);
+      this.$set(this.data.new_word_list[index], 'file_list', [file]);
     },
     deletePic(file_id, index) {
       this.data.new_word_list[index].file_list[0] = '';

+ 12 - 12
src/views/book/courseware/create/components/question/character_structure/CharacterStructure.vue

@@ -180,19 +180,19 @@ export default {
           file_id_list.push(item.file_id);
         }
       });
-      GetFileURLMap({ file_id_list: file_id_list }).then(({ url_map }) => {
-        file_id_list.forEach((id) => {
-          let items = this.data.structure_img_list.find((p) => p.file_id === id);
-          if (items) {
-            items.value = url_map[id];
-          }
+      // GetFileURLMap({ file_id_list: file_id_list }).then(({ url_map }) => {
+      //   file_id_list.forEach((id) => {
+      //     let items = this.data.structure_img_list.find((p) => p.file_id === id);
+      //     if (items) {
+      //       items.value = url_map[id];
+      //     }
 
-          let item = this.data.structure_select_list.find((p) => p.file_id === id);
-          if (item) {
-            item.value = url_map[id];
-          }
-        });
-      });
+      //     let item = this.data.structure_select_list.find((p) => p.file_id === id);
+      //     if (item) {
+      //       item.value = url_map[id];
+      //     }
+      //   });
+      // });
     },
   },
 };

+ 6 - 6
src/views/book/courseware/create/components/question/drawing/Drawing.vue

@@ -135,12 +135,12 @@ export default {
     },
 
     handleData() {
-      this.data.image_list.forEach((item) => {
-        GetFileURLMap({ file_id_list: [item.file_id] }).then(({ url_map }) => {
-          this.file_url = url_map[item.file_id];
-          // this.$set(item, 'file_url', url_map[item.file_id]);
-        });
-      });
+      // this.data.image_list.forEach((item) => {
+      //   GetFileURLMap({ file_id_list: [item.file_id] }).then(({ url_map }) => {
+      //     this.file_url = url_map[item.file_id];
+      //     // this.$set(item, 'file_url', url_map[item.file_id]);
+      //   });
+      // });
       this.handleMindMap();
     },
     handleMindMap() {

+ 5 - 5
src/views/book/courseware/create/components/question/image_text/ImageText.vue

@@ -319,11 +319,11 @@ export default {
       }
     },
     handleData() {
-      this.data.image_list.forEach((item) => {
-        GetFileURLMap({ file_id_list: [item.file_id] }).then(({ url_map }) => {
-          this.$set(item, 'file_url', url_map[item.file_id]);
-        });
-      });
+      // this.data.image_list.forEach((item) => {
+      //   GetFileURLMap({ file_id_list: [item.file_id] }).then(({ url_map }) => {
+      //     this.$set(item, 'file_url', url_map[item.file_id]);
+      //   });
+      // });
     },
     // 删除文本框热区
     deletehotspots(index) {

+ 3 - 3
src/views/book/courseware/create/components/question/new_word/NewWord.vue

@@ -263,7 +263,7 @@
           </div>
           <div class="table-item" style="width: 200px">
             <UploadPicture
-              :file-id="item.file_list[0]"
+              :file-info="item.file_list[0]"
               :item-index="i"
               :show-upload="!item.file_list[0]"
               @upload="uploadPic"
@@ -571,9 +571,9 @@ export default {
       this.data.new_word_list[index].mp3_list = '';
       this.data.file_id_list = this.data.file_id_list.filter((item) => item !== file_id);
     },
-    uploadPic(file_id, index) {
-      this.data.new_word_list[index].file_list[0] = file_id;
+    uploadPic(file_id, index, file) {
       this.data.file_id_list.push(file_id);
+      this.$set(this.data.new_word_list[index], 'file_list', [file]);
     },
     deletePic(file_id, index) {
       this.data.new_word_list[index].file_list[0] = '';

+ 19 - 22
src/views/book/courseware/create/components/question/new_word/components/UploadPicture.vue

@@ -28,37 +28,33 @@ import { fileUpload, GetFileStoreInfo } from '@/api/app';
 
 export default {
   name: 'UploadAudio',
-  props: {
-    fileId: {
-      type: String,
-      default: '',
-    },
-    showUpload: {
-      type: Boolean,
-      default: true,
-    },
-    itemIndex: {
-      type: Number,
-      default: null,
-    },
-  },
+  props: ['fileInfo', 'itemIndex'],
+
   data() {
     return {
       progress: 0,
       file_id: '',
       file_url: '',
       file_name: '',
+      showUpload: true,
     };
   },
   watch: {
-    fileId: {
+    fileInfo: {
       handler(val) {
-        if (!val) return;
-        GetFileStoreInfo({ file_id: val }).then(({ file_id, file_url, file_name }) => {
-          this.file_id = file_id;
-          this.file_url = file_url;
-          this.file_name = file_name;
-        });
+        if (!val) {
+          this.showUpload = true;
+          return;
+        }
+        this.file_id = val.file_id;
+        this.file_url = val.file_url;
+        this.file_name = val.file_name;
+        this.showUpload = false;
+        // GetFileStoreInfo({ file_id: val }).then(({ file_id, file_url, file_name }) => {
+        //   this.file_id = file_id;
+        //   this.file_url = file_url;
+        //   this.file_name = file_name;
+        // });
       },
       immediate: true,
     },
@@ -83,7 +79,7 @@ export default {
           this.file_id = file_id;
           this.file_url = file_url;
           this.file_name = file_name;
-          this.$emit('upload', file_id, this.itemIndex);
+          this.$emit('upload', file_id, this.itemIndex, file_info_list[0]);
         }
       });
     },
@@ -102,6 +98,7 @@ export default {
           this.file_url = '';
           this.file_name = '';
           this.progress = 0;
+          this.showUpload = true;
           this.$refs.upload.clearFiles();
         })
         .catch(() => {});

+ 3 - 3
src/views/book/courseware/create/components/question/notes/Notes.vue

@@ -71,7 +71,7 @@
         <el-table-column prop="img_list" label="图片" width="300">
           <template slot-scope="scope">
             <UploadPicture
-              :file-id="scope.row.file_list[0]"
+              :file-info="scope.row.file_list[0]"
               :item-index="scope.$index"
               :show-upload="!scope.row.file_list[0]"
               @upload="uploadPic"
@@ -254,8 +254,8 @@ export default {
       if (pinyin) this.data.paragraph_list[i][j][k].pinyin = pinyin;
       if (activeTextStyle) this.data.paragraph_list[i][j][k].activeTextStyle = activeTextStyle;
     },
-    uploadPic(file_id, index) {
-      this.data.option[index].file_list[0] = file_id;
+    uploadPic(file_id, index, file) {
+      this.data.option[index].file_list[0] = file;
       this.data.file_id_list.push(file_id);
       this.refreshKey = Math.random();
     },

+ 4 - 3
src/views/book/courseware/preview/components/article/index.vue

@@ -506,9 +506,10 @@ export default {
         });
       }
       if (this.data.mp3_list && this.data.mp3_list.length > 0) {
-        GetFileURLMap({ file_id_list: [this.data.mp3_list[0].file_id] }).then(({ url_map }) => {
-          this.data.mp3_list[0].url = url_map[this.data.mp3_list[0].file_id];
-        });
+        this.data.mp3_list[0].url = this.data.mp3_list[0].temporary_url;
+        // GetFileURLMap({ file_id_list: [this.data.mp3_list[0].file_id] }).then(({ url_map }) => {
+        //   this.data.mp3_list[0].url = url_map[this.data.mp3_list[0].file_id];
+        // });
       }
       this.NNPENewWordList = (
         this.data.new_word_list_other_component_input ? this.data.new_word_list_other_component_input : []

+ 4 - 3
src/views/book/courseware/preview/components/dialogue_article/index.vue

@@ -501,9 +501,10 @@ export default {
       let userAnswer = JSON.parse(JSON.stringify(this.userAnswer));
       this.$set(this.data, 'Bookanswer', userAnswer);
       if (this.data.mp3_list && this.data.mp3_list.length > 0) {
-        GetFileURLMap({ file_id_list: [this.data.mp3_list[0].file_id] }).then(({ url_map }) => {
-          this.data.mp3_list[0].url = url_map[this.data.mp3_list[0].file_id];
-        });
+        this.data.mp3_list[0].url = this.data.mp3_list[0].temporary_url;
+        // GetFileURLMap({ file_id_list: [this.data.mp3_list[0].file_id] }).then(({ url_map }) => {
+        //   this.data.mp3_list[0].url = url_map[this.data.mp3_list[0].file_id];
+        // });
       }
       this.NNPENewWordList = (
         this.data.new_word_list_other_component_input ? this.data.new_word_list_other_component_input : []

+ 4 - 3
src/views/book/courseware/preview/components/drawing/DrawingPreview.vue

@@ -163,9 +163,10 @@ export default {
       }
 
       this.data.image_list.forEach((item) => {
-        GetFileURLMap({ file_id_list: [item.file_id] }).then(({ url_map }) => {
-          this.image_url = url_map[item.file_id];
-        });
+        this.image_url = item.file_url;
+        // GetFileURLMap({ file_id_list: [item.file_id] }).then(({ url_map }) => {
+        //   this.image_url = url_map[item.file_id];
+        // });
       });
     },
     // 保存图片

+ 8 - 6
src/views/book/courseware/preview/components/image_text/ImageTextPreview.vue

@@ -178,14 +178,16 @@ export default {
       }
 
       this.data.image_list.forEach((item) => {
-        GetFileURLMap({ file_id_list: [item.file_id] }).then(({ url_map }) => {
-          this.image_url = url_map[item.file_id];
-        });
+        this.image_url = item.file_url;
+        // GetFileURLMap({ file_id_list: [item.file_id] }).then(({ url_map }) => {
+        //   this.image_url = url_map[item.file_id];
+        // });
       });
       this.data.mp3_list.forEach((item) => {
-        GetFileURLMap({ file_id_list: [item.file_id] }).then(({ url_map }) => {
-          this.mp3_url = url_map[item.file_id];
-        });
+        this.mp3_url = item.temporary_url;
+        // GetFileURLMap({ file_id_list: [item.file_id] }).then(({ url_map }) => {
+        //   this.mp3_url = url_map[item.file_id];
+        // });
       });
     },
     /**

+ 12 - 9
src/views/book/courseware/preview/components/new_word/NewWordPreview.vue

@@ -1,7 +1,10 @@
 <!-- eslint-disable vue/no-v-html -->
 <template>
   <div ref="previewContainer" class="newWord-preview" :style="getAreaStyle()">
-    <SerialNumberPosition v-if="isEnable(data.property.sn_display_mode)" :property="data.property" />
+    <SerialNumberPosition
+      v-if="isEnable(data.property.hasOwnProperty('sn_display_mode') ? data.property.sn_display_mode : 'false')"
+      :property="data.property"
+    />
 
     <main v-if="data" ref="newWordMain" class="main">
       <div class="NPC-zhedie" :style="{ width: width }">
@@ -481,8 +484,8 @@
                                 ? '180px'
                                 : '160px',
                         }"
-                        :src="item.pic_url"
-                        :preview-src-list="[item.pic_url]"
+                        :src="item.file_list[0].file_url"
+                        :preview-src-list="[item.file_list[0].file_url]"
                         fit="contain"
                       />
                     </div>
@@ -794,7 +797,7 @@ export default {
               oldVal.new_word_list[0].new_word &&
               val.new_word_list[0].new_word !== oldVal.new_word_list[0].new_word) ||
             (val && val.new_word_list[0].new_word && !oldVal) ||
-            (val && val.hasOwn('unified_attrib') && oldVal && !oldVal.hasOwn('unified_attrib'))
+            (val && val.hasOwnProperty('unified_attrib') && oldVal && !oldVal.hasOwnProperty('unified_attrib'))
           ) {
             // this.wordShow = isEnable(this.data.property.is_word_show);
             this.initData();
@@ -951,11 +954,11 @@ export default {
             this.$set(item, 'mp3_list_url', url_map[item.mp3_list]);
           });
         }
-        if (item.file_list && item.file_list[0]) {
-          GetFileURLMap({ file_id_list: item.file_list }).then(({ url_map }) => {
-            this.$set(item, 'pic_url', url_map[item.file_list[0]]);
-          });
-        }
+        // if (item.file_list && item.file_list[0]) {
+        //   GetFileURLMap({ file_id_list: item.file_list }).then(({ url_map }) => {
+        //     this.$set(item, 'pic_url', url_map[item.file_list[0]]);
+        //   });
+        // }
         this.$set(item, 'show_left', true);
         this.$set(item, 'isFlipped', false);
       });

+ 17 - 9
src/views/book/courseware/preview/components/notes/NotesPreview.vue

@@ -1,7 +1,10 @@
 <!-- eslint-disable vue/no-v-html -->
 <template>
   <div class="notes-preview" :style="getAreaStyle()">
-    <SerialNumberPosition v-if="isEnable(data.property.sn_display_mode)" :property="data.property" />
+    <SerialNumberPosition
+      v-if="isEnable(data.property.hasOwnProperty('sn_display_mode') ? data.property.sn_display_mode : 'false')"
+      :property="data.property"
+    />
 
     <div class="main">
       <div class="NPC-zhedie">
@@ -39,6 +42,7 @@
                   :style="{
                     color:
                       data.unified_attrib && data.unified_attrib.topic_color ? data.unified_attrib.topic_color : '',
+                    fontSize: data.unified_attrib && data.unified_attrib.font_size ? data.unified_attrib.font_size : '',
                   }"
                   v-html="item.number"
                 ></span>
@@ -133,7 +137,11 @@
 
               <div v-if="item.note" class="NPC-notes-note" v-html="item.note"></div>
               <div v-if="item.file_list[0]" class="NPC-notes-note-img">
-                <el-image :src="item.pic_url" :preview-src-list="[item.pic_url]" fit="contain" />
+                <el-image
+                  :src="item.file_list[0].file_url"
+                  :preview-src-list="[item.file_list[0].file_url]"
+                  fit="contain"
+                />
               </div>
               <div v-if="showLang" class="NPC-notes-note">
                 {{
@@ -207,13 +215,13 @@ export default {
           this.$set(this.multilingualTextList, item.type, chunkedArr);
         });
       }
-      this.data.option.forEach((item) => {
-        if (item.file_list && item.file_list[0]) {
-          GetFileURLMap({ file_id_list: item.file_list }).then(({ url_map }) => {
-            this.$set(item, 'pic_url', url_map[item.file_list[0]]);
-          });
-        }
-      });
+      // this.data.option.forEach((item) => {
+      //   if (item.file_list && item.file_list[0]) {
+      //     GetFileURLMap({ file_id_list: item.file_list }).then(({ url_map }) => {
+      //       this.$set(item, 'pic_url', url_map[item.file_list[0]]);
+      //     });
+      //   }
+      // });
     },
   },
 };

+ 11 - 10
src/views/book/courseware/preview/components/upload_preview/UploadPreviewPreview.vue

@@ -173,16 +173,17 @@ export default {
     },
     // 预览
     viewDialog(file) {
-      this.newpath = '';
-      GetFileURLMap({ file_id_list: [file.file_id] }).then(({ url_map }) => {
-        // this.$set(
-        //   item,
-        //   'newpath',
-        //   `${this.file_preview_url}onlinePreview?url=${Base64.encode(url_map[item.file_id])}`,
-        // );
-        this.newpath = `${this.file_preview_url}onlinePreview?url=${Base64.encode(url_map[file.file_id])}`;
-        this.visible = true;
-      });
+      this.newpath = `${this.file_preview_url}onlinePreview?url=${Base64.encode(file.file_url)}`;
+      this.visible = true;
+      // GetFileURLMap({ file_id_list: [file.file_id] }).then(({ url_map }) => {
+      // this.$set(
+      //   item,
+      //   'newpath',
+      //   `${this.file_preview_url}onlinePreview?url=${Base64.encode(url_map[item.file_id])}`,
+      // );
+      // this.newpath = `${this.file_preview_url}onlinePreview?url=${Base64.encode(url_map[file.file_id])}`;
+      // this.visible = true;
+      // });
     },
   },
 };