Browse Source

表格拼音效果加刷新按钮 上传组件只保留上传按钮

natasha 2 days ago
parent
commit
7c399d1188

+ 10 - 2
src/views/book/courseware/create/components/common/SelectUpload.vue

@@ -3,6 +3,7 @@
     <div class="select-upload" :style="{ width: width }">
       <span v-if="label" class="label-text">{{ label }}</span>
       <el-upload
+        v-show="false"
         ref="upload"
         class="file-uploader"
         action="no"
@@ -15,7 +16,7 @@
       >
         <el-button>{{ showText }}</el-button>
       </el-upload>
-      <el-button size="small" class="upload-button" type="primary" @click="uploadFiles">本地上传</el-button>
+      <el-button size="small" class="upload-button" type="primary" @click="selectAndUpload">本地上传</el-button>
       <el-button v-if="isShowResource" size="small" type="primary" @click="useResource">使用资源</el-button>
     </div>
     <SelectResource
@@ -100,6 +101,13 @@ export default {
     },
   },
   methods: {
+    selectAndUpload() {
+      const uploadInput = this.$refs.upload.$el.querySelector('input[type="file"]');
+      if (uploadInput) {
+        uploadInput.value = '';
+        uploadInput.click();
+      }
+    },
     onFileChange(file, fileList) {
       this.fileList = fileList;
       fileList.forEach((file) => {
@@ -174,7 +182,7 @@ export default {
   }
 
   .upload-button {
-    border-radius: 0 2px 2px 0;
+    // border-radius: 0 2px 2px 0;
   }
 }
 </style>

+ 17 - 3
src/views/book/courseware/create/components/question/table/Table.vue

@@ -118,12 +118,22 @@
         :translations="data.multilingual"
         @SubmitTranslation="handleMultilingualTranslation"
       />
-      <el-divider v-if="isEnable(data.property.view_pinyin)" content-position="left">拼音效果</el-divider>
+      <el-divider v-if="isEnable(data.property.view_pinyin)" content-position="left"
+        >拼音效果<el-button
+          v-show="isEnable(data.property.view_pinyin)"
+          type="text"
+          icon="el-icon-refresh"
+          title="刷新"
+          class="refresh-pinyin-btn"
+          @click.native="identifyText"
+      /></el-divider>
+
       <PinyinText
         v-if="isEnable(data.property.view_pinyin)"
         :id="'table_pinyin_text'"
         ref="PinyinText"
         :paragraph-list="data.paragraph_list"
+        :rich-text-list="data.rich_text_list"
         :pinyin-position="data.property.pinyin_position"
         :pinyin-size="data?.unified_attrib?.pinyin_size"
         :font-size="data?.unified_attrib?.font_size"
@@ -309,7 +319,8 @@ export default {
                 // .replace(/<span class="rich-fill".*?>(.*?)<\/span>|([_]{3,})/gi, '###$1$2###');
               });
           }
-          text += `${items.content.replace(/<[^>]+>/g, '')}\n`;
+          // text += `${items.content.replace(/<[^>]+>/g, '')}\n`;
+          text += `${items.content}\n`;
         });
       });
       if (isEnable(this.data.property.view_pinyin)) {
@@ -322,9 +333,11 @@ export default {
         this.data.paragraph_list_parameter.pinyin_proofread_word_list = [];
         return;
       }
-      this.data.paragraph_list_parameter.text = text.replace(/<[^>]+>/g, '');
+      // .replace(/<[^>]+>/g, '')
+      this.data.paragraph_list_parameter.text = text;
       this.data.paragraph_list_parameter.is_first_sentence_first_hz_pinyin_first_char_upper_case =
         this.data.property.is_first_sentence_first_hz_pinyin_first_char_upper_case;
+      this.data.paragraph_list_parameter.is_rich_text = 'true';
       PinyinBuild_OldFormat(this.data.paragraph_list_parameter).then((res) => {
         if (res.parsed_text) {
           const mergedData = res.parsed_text.paragraph_list.map((outerArr, i) =>
@@ -346,6 +359,7 @@ export default {
             ),
           );
           this.data.paragraph_list = mergedData;
+          this.$set(this.data, 'rich_text_list', res.rich_text.text_list);
           let pinyin_index = 0;
           this.data.option_list.forEach((item, index) => {
             item.forEach((items, indexs) => {

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

@@ -211,21 +211,23 @@ export default {
       this.wordShow = !this.wordShow;
     },
     handleData() {
-      this.data.multilingual.forEach((item) => {
-        let trans_arr = item.translation.split('\n');
-        this.$set(this.titleTrans, item.type, trans_arr[0] ? trans_arr[0] : '');
-        let chunkSize = 2;
-        let chunkedArr = trans_arr.splice(1).reduce((acc, curr, index) => {
-          // 当索引是chunkSize的倍数时,开始一个新的子数组
-          if (index % chunkSize === 0) {
-            acc.push([curr]); // 开始新的子数组并添加当前元素
-          } else {
-            acc[acc.length - 1].push(curr); // 将当前元素添加到最后一个子数组中
-          }
-          return acc;
-        }, []);
-        this.$set(this.multilingualTextList, item.type, chunkedArr);
-      });
+      if (this.data.multilingual) {
+        this.data.multilingual.forEach((item) => {
+          let trans_arr = item.translation.split('\n');
+          this.$set(this.titleTrans, item.type, trans_arr[0] ? trans_arr[0] : '');
+          let chunkSize = 2;
+          let chunkedArr = trans_arr.splice(1).reduce((acc, curr, index) => {
+            // 当索引是chunkSize的倍数时,开始一个新的子数组
+            if (index % chunkSize === 0) {
+              acc.push([curr]); // 开始新的子数组并添加当前元素
+            } else {
+              acc[acc.length - 1].push(curr); // 将当前元素添加到最后一个子数组中
+            }
+            return acc;
+          }, []);
+          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 }) => {

+ 2 - 2
src/views/book/courseware/preview/components/pinyin_base/PinyinBasePreview.vue

@@ -296,8 +296,8 @@ export default {
   created() {
     // console.log(this.data);
     if (
-      data.property.fun_type !== 'show' ||
-      (data.property.fun_type === 'show' && this.data.answer_list && this.data.answer_list.length > 0) ||
+      this.data.property.fun_type !== 'show' ||
+      (this.data.property.fun_type === 'show' && this.data.answer_list && this.data.answer_list.length > 0) ||
       (this.data.analysis_list && this.data.analysis_list.length > 0)
     ) {
       this.isShowAnswers = true;