Procházet zdrojové kódy

没有录音的情况下,页面上不出现评分按钮

natasha před 1 týdnem
rodič
revize
2f1824eb42

+ 2 - 0
src/views/book/courseware/preview/common/SoundRecord.vue

@@ -264,6 +264,8 @@ export default {
       } else if (this.recordList.length > 0 && this.type === 'mini') {
       } else if (this.recordList.length > 0 && this.type === 'mini') {
         this.wavblob = this.recordList[this.selectIndex].wavData;
         this.wavblob = this.recordList[this.selectIndex].wavData;
         this.changeStatus('normal');
         this.changeStatus('normal');
+      } else {
+        this.changeStatus('');
       }
       }
       this.recordFile = this.recordList.length + 1;
       this.recordFile = this.recordList.length + 1;
     },
     },

+ 204 - 36
src/views/book/courseware/preview/components/new_word/NewWordPreview.vue

@@ -43,6 +43,22 @@
           </div>
           </div>
 
 
           <div class="NPC-top-right">
           <div class="NPC-top-right">
+            <svg-icon
+              :style="{
+                color:
+                  assessmentMode && data.unified_attrib && data.unified_attrib.topic_color
+                    ? data.unified_attrib.topic_color
+                    : 'rgba(0,0,0,0.65)',
+              }"
+              :title="convertText('语音测评')"
+              @click.stop="assessmentMode = !assessmentMode"
+              v-if="
+                !(data.property.is_enable_score && data.property.is_enable_score === 'false') &&
+                !data.audio_data.file_id
+              "
+              icon-class="icon-article-practice"
+              size="24"
+            />
             <el-popover placement="right-start" width="60" trigger="click">
             <el-popover placement="right-start" width="60" trigger="click">
               <ul class="show-obj-list">
               <ul class="show-obj-list">
                 <li v-if="colHasContent[0]" @click="handleShow('pinyin')">
                 <li v-if="colHasContent[0]" @click="handleShow('pinyin')">
@@ -302,18 +318,34 @@
         <el-collapse-transition>
         <el-collapse-transition>
           <template v-if="is_list">
           <template v-if="is_list">
             <div v-if="data.new_word_list && data.new_word_list.length > 0" v-show="wordShow" class="NPC-word-list">
             <div v-if="data.new_word_list && data.new_word_list.length > 0" v-show="wordShow" class="NPC-word-list">
-              <div v-if="data.audio_data.file_id" class="aduioLine-box">
-                <AudioLine
-                  ref="audioLine"
-                  :audio-id="'newWordAudio' + indexStr"
-                  :mp3="data.audio_data.url"
-                  :get-cur-time="getCurTime"
-                  :ed="ed"
-                  type="audioLine"
-                  :attrib="data.unified_attrib"
-                  @handleListenRead="handleListenRead"
-                  :stop-audio="stopAudios"
-                />
+              <div class="aduioLine-box" v-if="data.audio_data.file_id">
+                <div class="aduioLine-content">
+                  <AudioLine
+                    ref="audioLine"
+                    :audio-id="'newWordAudio' + indexStr"
+                    :mp3="data.audio_data.url"
+                    :get-cur-time="getCurTime"
+                    :ed="ed"
+                    type="audioLine"
+                    :attrib="data.unified_attrib"
+                    @handleListenRead="handleListenRead"
+                    :stop-audio="stopAudios"
+                  />
+                </div>
+                <div
+                  class="aduioLine-right"
+                  :style="{
+                    color:
+                      assessmentMode && data.unified_attrib && data.unified_attrib.topic_color
+                        ? data.unified_attrib.topic_color
+                        : 'rgba(0,0,0,0.65)',
+                  }"
+                  :title="convertText('语音测评')"
+                  @click.stop="assessmentMode = !assessmentMode"
+                  v-if="!(data.property.is_enable_score && data.property.is_enable_score === 'false')"
+                >
+                  <svg-icon icon-class="icon-article-practice" size="24" />
+                </div>
               </div>
               </div>
               <ul
               <ul
                 v-if="isEnable(data.property.auto_wrap)"
                 v-if="isEnable(data.property.auto_wrap)"
@@ -339,11 +371,7 @@
                     ]"
                     ]"
                     @click="changeWholeIndex(sItem.sIndex)"
                     @click="changeWholeIndex(sItem.sIndex)"
                     :style="{
                     :style="{
-                      paddingRight: !(data.property.is_enable_score && data.property.is_enable_score === 'false')
-                        ? isHasScore
-                          ? '254px'
-                          : '166px'
-                        : '',
+                      paddingRight: assessmentMode ? (isShowScoreBtn ? (isHasScore ? '254px' : '166px') : '116px') : '',
                     }"
                     }"
                   >
                   >
                     <template v-if="isMobile">
                     <template v-if="isMobile">
@@ -768,7 +796,14 @@
                           />
                           />
                         </div>
                         </div>
                         <el-button
                         <el-button
-                          v-if="!(data.property.is_enable_score && data.property.is_enable_score === 'false')"
+                          v-if="
+                            assessmentMode &&
+                            answer &&
+                            answer.answer_list &&
+                            answer.answer_list[index][sIndex] &&
+                            answer.answer_list[index][sIndex].recordList &&
+                            answer.answer_list[index][sIndex].recordList.length > 0
+                          "
                           type="text"
                           type="text"
                           :class="[
                           :class="[
                             'record-score-btn',
                             'record-score-btn',
@@ -1229,7 +1264,14 @@
                           />
                           />
                         </div>
                         </div>
                         <el-button
                         <el-button
-                          v-if="!(data.property.is_enable_score && data.property.is_enable_score === 'false')"
+                          v-if="
+                            assessmentMode &&
+                            answer &&
+                            answer.answer_list &&
+                            answer.answer_list[index][sIndex] &&
+                            answer.answer_list[index][sIndex].recordList &&
+                            answer.answer_list[index][sIndex].recordList.length > 0
+                          "
                           type="text"
                           type="text"
                           :class="[
                           :class="[
                             'record-score-btn',
                             'record-score-btn',
@@ -1836,6 +1878,8 @@ export default {
       isHasScore: false, // 是否有录音评分分数
       isHasScore: false, // 是否有录音评分分数
       isRecord: false,
       isRecord: false,
       stopAudios: false,
       stopAudios: false,
+      assessmentMode: false, // 是否开启录音评分模式
+      isShowScoreBtn: false, // 是否显示评分按钮
     };
     };
   },
   },
   computed: {
   computed: {
@@ -1901,10 +1945,6 @@ export default {
                 }
                 }
               });
               });
               this.rowWidth += 180;
               this.rowWidth += 180;
-              if (!(this.data.property.is_enable_score && this.data.property.is_enable_score === 'false')) {
-                // 有评分按钮
-                this.rowWidth += 50;
-              }
               if (this.rowWidth < this.width - 2) {
               if (this.rowWidth < this.width - 2) {
                 this.rowWidth = this.width - 2;
                 this.rowWidth = this.width - 2;
               }
               }
@@ -1957,11 +1997,119 @@ export default {
             }
             }
           });
           });
           this.rowWidth += 180;
           this.rowWidth += 180;
-          if (!(this.data.property.is_enable_score && this.data.property.is_enable_score === 'false')) {
-            // 有评分按钮
-            this.rowWidth += 50;
+
+          this.rowWidth += 138; // 加上评分分数的宽度
+          if (this.rowWidth < this.width - 2) {
+            this.rowWidth = this.width - 2;
           }
           }
-          this.rowWidth += 88; // 加上评分分数的宽度
+        }
+      },
+      deep: true,
+      immediate: true,
+    },
+    isShowScoreBtn: {
+      handler(val) {
+        if (val && this.assessmentMode) {
+          // 如果有录音评分数据
+          let totalWidth = document.querySelector('.newWord-preview').clientWidth;
+          this.width = `${totalWidth - (this.data.property.sn_display_mode === 'true' ? 15 : 0) - 1}`;
+          this.rowWidth = 0;
+          this.data.col_width.forEach((item, index) => {
+            if (
+              this.data.property.pinyin_position &&
+              (this.data.property.pinyin_position === 'top' || this.data.property.pinyin_position === 'bottom')
+            ) {
+              if (index < 2) {
+                this.rowWidth = this.rowWidth > Number(item.value) ? this.rowWidth : Number(item.value);
+              } else {
+                this.rowWidth += this.colHasContent[index] ? Number(item.value) : 0;
+              }
+            } else {
+              this.rowWidth += this.colHasContent[index] ? Number(item.value) : 0;
+            }
+          });
+          this.rowWidth += 180;
+
+          // 有评分按钮
+          this.rowWidth += 50;
+          if (this.rowWidth < this.width - 2) {
+            this.rowWidth = this.width - 2;
+          }
+        } else {
+          // 如果有录音评分数据
+          let totalWidth = document.querySelector('.newWord-preview').clientWidth;
+          this.width = `${totalWidth - (this.data.property.sn_display_mode === 'true' ? 15 : 0) - 1}`;
+          this.rowWidth = 0;
+          this.data.col_width.forEach((item, index) => {
+            if (
+              this.data.property.pinyin_position &&
+              (this.data.property.pinyin_position === 'top' || this.data.property.pinyin_position === 'bottom')
+            ) {
+              if (index < 2) {
+                this.rowWidth = this.rowWidth > Number(item.value) ? this.rowWidth : Number(item.value);
+              } else {
+                this.rowWidth += this.colHasContent[index] ? Number(item.value) : 0;
+              }
+            } else {
+              this.rowWidth += this.colHasContent[index] ? Number(item.value) : 0;
+            }
+          });
+          this.rowWidth += 180;
+          if (this.rowWidth < this.width - 2) {
+            this.rowWidth = this.width - 2;
+          }
+        }
+      },
+      deep: true,
+      immediate: true,
+    },
+    assessmentMode: {
+      handler(val) {
+        if (val && this.isShowScoreBtn) {
+          // 如果有录音评分数据
+          let totalWidth = document.querySelector('.newWord-preview').clientWidth;
+          this.width = `${totalWidth - (this.data.property.sn_display_mode === 'true' ? 15 : 0) - 1}`;
+          this.rowWidth = 0;
+          this.data.col_width.forEach((item, index) => {
+            if (
+              this.data.property.pinyin_position &&
+              (this.data.property.pinyin_position === 'top' || this.data.property.pinyin_position === 'bottom')
+            ) {
+              if (index < 2) {
+                this.rowWidth = this.rowWidth > Number(item.value) ? this.rowWidth : Number(item.value);
+              } else {
+                this.rowWidth += this.colHasContent[index] ? Number(item.value) : 0;
+              }
+            } else {
+              this.rowWidth += this.colHasContent[index] ? Number(item.value) : 0;
+            }
+          });
+          this.rowWidth += 180;
+          // 有评分按钮
+          this.rowWidth += 50;
+          if (this.rowWidth < this.width - 2) {
+            this.rowWidth = this.width - 2;
+          }
+        } else {
+          // 如果有录音评分数据
+          let totalWidth = document.querySelector('.newWord-preview').clientWidth;
+          this.width = `${totalWidth - (this.data.property.sn_display_mode === 'true' ? 15 : 0) - 1}`;
+          this.rowWidth = 0;
+          this.data.col_width.forEach((item, index) => {
+            if (
+              this.data.property.pinyin_position &&
+              (this.data.property.pinyin_position === 'top' || this.data.property.pinyin_position === 'bottom')
+            ) {
+              if (index < 2) {
+                this.rowWidth = this.rowWidth > Number(item.value) ? this.rowWidth : Number(item.value);
+              } else {
+                this.rowWidth += this.colHasContent[index] ? Number(item.value) : 0;
+              }
+            } else {
+              this.rowWidth += this.colHasContent[index] ? Number(item.value) : 0;
+            }
+          });
+          this.rowWidth += 180;
           if (this.rowWidth < this.width - 2) {
           if (this.rowWidth < this.width - 2) {
             this.rowWidth = this.width - 2;
             this.rowWidth = this.width - 2;
           }
           }
@@ -1992,10 +2140,6 @@ export default {
           }
           }
         });
         });
         this.rowWidth += 180;
         this.rowWidth += 180;
-        if (!(this.data.property.is_enable_score && this.data.property.is_enable_score === 'false')) {
-          // 有评分按钮
-          this.rowWidth += 50;
-        }
         if (this.rowWidth < this.width - 2) {
         if (this.rowWidth < this.width - 2) {
           this.rowWidth = this.width - 2;
           this.rowWidth = this.width - 2;
         }
         }
@@ -2023,10 +2167,6 @@ export default {
         }
         }
       });
       });
       this.rowWidth += 180;
       this.rowWidth += 180;
-      if (!(this.data.property.is_enable_score && this.data.property.is_enable_score === 'false')) {
-        // 有评分按钮
-        this.rowWidth += 50;
-      }
       // 如果有宽度为0且有内容的列,则行宽最小为撑满
       // 如果有宽度为0且有内容的列,则行宽最小为撑满
       if (this.rowWidth < this.width - 2) {
       if (this.rowWidth < this.width - 2) {
         this.rowWidth = this.width - 2;
         this.rowWidth = this.width - 2;
@@ -2097,6 +2237,8 @@ export default {
       this.sentList = [];
       this.sentList = [];
       this.showRecordScoreList = [];
       this.showRecordScoreList = [];
       this.isHasScore = false;
       this.isHasScore = false;
+      this.isShowScoreBtn = false;
+      this.assessmentMode = false;
       this.showObj = {
       this.showObj = {
         pinyin: true,
         pinyin: true,
         newWord: true,
         newWord: true,
@@ -2260,6 +2402,7 @@ export default {
     },
     },
     handleWav(list, tmIndex, tmsIndex) {
     handleWav(list, tmIndex, tmsIndex) {
       this.$set(this.answer.answer_list[tmIndex || 0][tmsIndex || 0], 'recordList', list);
       this.$set(this.answer.answer_list[tmIndex || 0][tmsIndex || 0], 'recordList', list);
+      this.isShowScoreBtn = true;
     },
     },
     // 翻面
     // 翻面
     changeShowLeft(item) {
     changeShowLeft(item) {
@@ -2415,6 +2558,7 @@ export default {
       this.$set(scoreObj, 'singleText', singleText);
       this.$set(scoreObj, 'singleText', singleText);
       this.showRecordScoreList[index] = scoreObj;
       this.showRecordScoreList[index] = scoreObj;
       this.isHasScore = true;
       this.isHasScore = true;
+      this.isShowScoreBtn = true;
     },
     },
     recordScoreStyle(score) {
     recordScoreStyle(score) {
       let style = {
       let style = {
@@ -2509,6 +2653,7 @@ export default {
       });
       });
       this.showRecordScoreList = score;
       this.showRecordScoreList = score;
       this.isHasScore = true;
       this.isHasScore = true;
+      this.isShowScoreBtn = true;
       this.whileRecordScoreList[this.wholeRecordIndex] = list;
       this.whileRecordScoreList[this.wholeRecordIndex] = list;
     },
     },
     getCurTimes(curTime) {
     getCurTimes(curTime) {
@@ -2552,7 +2697,30 @@ export default {
     // margin-bottom: 24px;
     // margin-bottom: 24px;
 
 
     .aduioLine-box {
     .aduioLine-box {
+      display: flex;
+      align-items: center;
       margin-bottom: 8px;
       margin-bottom: 8px;
+      border-bottom: 1px solid rgba(0, 0, 0, 10%);
+
+      .aduioLine-content {
+        flex: 1;
+      }
+
+      .aduioLine-right {
+        box-sizing: border-box;
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+        height: 40px;
+        padding: 0 12px;
+        border-left: 1px solid rgba(0, 0, 0, 10%);
+
+        .svg-icon {
+          width: 16px;
+          height: 16px;
+          cursor: pointer;
+        }
+      }
     }
     }
 
 
     .practiceBox {
     .practiceBox {
@@ -2637,7 +2805,7 @@ export default {
   }
   }
 
 
   .NPC-word-list {
   .NPC-word-list {
-    padding: 10px 0 0;
+    // padding: 10px 0 0;
     border: 1px solid rgba(0, 0, 0, 10%);
     border: 1px solid rgba(0, 0, 0, 10%);
     border-radius: 4px;
     border-radius: 4px;
   }
   }