2
0

2 Коммиты 2177190f95 ... bbcfd03d68

Автор SHA1 Сообщение Дата
  dsy bbcfd03d68 Merge branch 'master' of http://60.205.254.193:3000/GCLS/eep_page 3 недель назад
  dsy 02c027c186 1. 语音矩阵录音评分功能 2. 富文本、填空题分词加6px间距 3. 富文本、填空题中当一行居中设置并且其中有多种字体时的换行问题 4. 编辑页面组件加载时新增 loading 样式 3 недель назад

+ 1 - 1
.env

@@ -11,4 +11,4 @@ VUE_APP_BookWebSI = '/GCLSBookWebSI/ServiceInterface'
 VUE_APP_EepServer = '/EEPServer/SI'
 
 #version
-VUE_APP_VERSION = '2026.10.26'
+VUE_APP_VERSION = '2026.11.09'

+ 1 - 1
src/api/app.js

@@ -212,4 +212,4 @@ export function ToolVoiceEval(data) {
  */
 export function ToolMergeAudio(data) {
   return http.post(`${process.env.VUE_APP_EepServer}?MethodName=tool-MergeAudio`, data);
-}
+}

+ 204 - 120
src/components/PinyinText.vue

@@ -10,127 +10,131 @@
 
     <!-- 新规则:使用 richTextList -->
     <div v-if="richTextList && richTextList.length > 0" class="rich-text-container" :style="bodyStyles">
-      <template v-for="(block, index) in parsedBlocks">
-        <!-- 文字块:包含 word_list -->
-        <span
-          v-if="block.type === 'text'"
-          :key="'text-' + index"
-          class="pinyin-sentence"
-          :style="[
-            { 'align-items': pinyinPosition === 'top' ? 'flex-end' : 'flex-start' },
-            block.sentenceStyle,
-            block.parentStyle,
-          ]"
-        >
+      <div
+        v-for="(group, gIndex) in parsedGroups"
+        :key="'group-' + gIndex"
+        class="pinyin-line-group"
+        :style="group.style"
+      >
+        <template v-for="(block, index) in group.blocks">
+          <!-- 文字块:包含 word_list -->
           <span
-            v-for="(word, wIndex) in block.word_list"
-            :key="wIndex"
-            class="pinyin-text"
-            :style="[block.styleObj, getBlockSpacingStyle(block)]"
+            v-if="block.type === 'text'"
+            :key="'text-' + index"
+            class="pinyin-sentence"
+            :style="[{ 'align-items': pinyinPosition === 'top' ? 'flex-end' : 'flex-start' }, block.sentenceStyle]"
           >
             <span
-              :title="isPreview ? '' : '点击校对'"
-              :style="{
-                cursor: isPreview ? '' : 'pointer',
-              }"
-              @click="!isPreview && handleWordClick(word, block.paragraphIndex, block.oldIndex, wIndex)"
-              @mouseover="isPreview && handlePreviewHover(word, $event)"
-              @mouseleave="onLeave"
+              v-for="(word, wIndex) in block.word_list"
+              :key="wIndex"
+              class="pinyin-text"
+              :class="getPinyinWordSpacingClass(word, block.word_list[wIndex + 1])"
+              :style="[block.styleObj, getBlockSpacingStyle(block)]"
             >
               <span
-                v-if="word.pinyin_list && word.pinyin_list.length < Array.from(word.text).length"
+                :title="isPreview ? '' : '点击校对'"
                 :style="{
-                  flexDirection: pinyinPosition === 'top' ? 'column' : 'column-reverse',
-                  'align-items': getWordAlignItems(word, block),
+                  cursor: isPreview ? '' : 'pointer',
                 }"
+                @click="!isPreview && handleWordClick(word, block.paragraphIndex, block.oldIndex, wIndex)"
+                @mouseover="isPreview && handlePreviewHover(word, $event)"
+                @mouseleave="onLeave"
               >
                 <span
-                  v-if="isShowPinyin"
-                  class="pinyin"
-                  :style="[getPinyinStyle(word, block), getWholePinyinStyle(word, block)]"
+                  v-if="word.pinyin_list && word.pinyin_list.length < Array.from(word.text).length"
+                  :style="{
+                    flexDirection: pinyinPosition === 'top' ? 'column' : 'column-reverse',
+                    'align-items': getWordAlignItems(word, block),
+                  }"
                 >
-                  {{ getPinyinText(word) }}
-                </span>
-                <span class="py-char" :style="getCharStyle(word, block)">{{ convertText(word.text) }}</span>
-              </span>
-              <template v-else>
-                <span v-for="(char, cIndex) in Array.from(word.text)" :key="cIndex">
                   <span
-                    :style="{
-                      flexDirection: pinyinPosition === 'top' ? 'column' : 'column-reverse',
-                      'align-items': getWordAlignItems(word, block),
-                    }"
+                    v-if="isShowPinyin"
+                    class="pinyin"
+                    :style="[getPinyinStyle(word, block), getWholePinyinStyle(word, block)]"
                   >
-                    <span v-if="isShowPinyin" class="pinyin" :style="getPinyinStyle(word, block)">
-                      {{ getCharPinyin(word, cIndex) }}
-                    </span>
-                    <span class="py-char" :style="getCharStyle(word, block, cIndex)">{{ convertText(char) }}</span>
+                    {{ getPinyinText(word) }}
                   </span>
+                  <span class="py-char" :style="getCharStyle(word, block)">{{ convertText(word.text) }}</span>
                 </span>
-              </template>
+                <template v-else>
+                  <span v-for="(char, cIndex) in Array.from(word.text)" :key="cIndex">
+                    <span
+                      :style="{
+                        flexDirection: pinyinPosition === 'top' ? 'column' : 'column-reverse',
+                        'align-items': getWordAlignItems(word, block),
+                      }"
+                    >
+                      <span v-if="isShowPinyin" class="pinyin" :style="getPinyinStyle(word, block)">
+                        {{ getCharPinyin(word, cIndex) }}
+                      </span>
+                      <span class="py-char" :style="getCharStyle(word, block, cIndex)">{{ convertText(char) }}</span>
+                    </span>
+                  </span>
+                </template>
+              </span>
             </span>
           </span>
-        </span>
-        <!-- 图片块 -->
-        <span
-          v-else-if="block.type === 'image'"
-          :key="'image-' + index"
-          :style="block.containerStyle"
-          class="image-container"
-        >
-          <img
-            :src="block.src"
-            :alt="block.alt"
-            :width="block.width"
-            :height="block.height"
-            :style="block.imageStyle"
-            class="inline-image"
-          />
-        </span>
-
-        <!-- 视频块 -->
-        <span
-          v-else-if="block.type === 'video'"
-          :key="'video-' + index"
-          :style="block.containerStyle"
-          class="video-container"
-        >
-          <video
-            :poster="block.poster"
-            :width="block.width"
-            :height="block.height"
-            :style="block.mediaStyle"
-            controls
-            class="inline-video"
+          <!-- 图片块 -->
+          <span
+            v-else-if="block.type === 'image'"
+            :key="'image-' + index"
+            :style="block.containerStyle"
+            class="image-container"
           >
-            <source :src="block.src" :type="block.videoType" />
-            您的浏览器不支持视频播放
-          </video>
-        </span>
-
-        <!-- 音频块 -->
-        <span
-          v-else-if="block.type === 'audio'"
-          :key="'audio-' + index"
-          :style="block.containerStyle"
-          class="audio-container"
-        >
-          <audio :src="block.src" :style="block.mediaStyle" controls class="inline-audio">
-            您的浏览器不支持音频播放
-          </audio>
-        </span>
-
-        <!-- 数学公式块(保留 MathJax 原始结构) -->
-        <MathHtml
-          v-else-if="block.type === 'math'"
-          :key="'math-' + index"
-          :html="block.html"
-          :style-obj="block.containerStyle"
-          :is-display="block.isDisplay"
-        />
-        <!-- 换行符 -->
-        <br v-else-if="block.type === 'newline'" :key="'newline-' + index" />
-      </template>
+            <img
+              :src="block.src"
+              :alt="block.alt"
+              :width="block.width"
+              :height="block.height"
+              :style="block.imageStyle"
+              class="inline-image"
+            />
+          </span>
+
+          <!-- 视频块 -->
+          <span
+            v-else-if="block.type === 'video'"
+            :key="'video-' + index"
+            :style="block.containerStyle"
+            class="video-container"
+          >
+            <video
+              :poster="block.poster"
+              :width="block.width"
+              :height="block.height"
+              :style="block.mediaStyle"
+              controls
+              class="inline-video"
+            >
+              <source :src="block.src" :type="block.videoType" />
+              您的浏览器不支持视频播放
+            </video>
+          </span>
+
+          <!-- 音频块 -->
+          <span
+            v-else-if="block.type === 'audio'"
+            :key="'audio-' + index"
+            :style="block.containerStyle"
+            class="audio-container"
+          >
+            <audio :src="block.src" :style="block.mediaStyle" controls class="inline-audio">
+              您的浏览器不支持音频播放
+            </audio>
+          </span>
+
+          <!-- 数学公式块(保留 MathJax 原始结构) -->
+          <MathHtml
+            v-else-if="block.type === 'math'"
+            :key="'math-' + index"
+            :html="block.html"
+            :style-obj="block.containerStyle"
+            :is-display="block.isDisplay"
+          />
+          <!-- 换行符 -->
+          <br v-else-if="block.type === 'newline'" :key="'newline-' + index" />
+        </template>
+      </div>
     </div>
 
     <!-- 老规则:使用 paragraphList -->
@@ -142,7 +146,12 @@
           class="pinyin-sentence"
           :style="{ 'align-items': pinyinPosition === 'top' ? 'flex-end' : 'flex-start' }"
         >
-          <span v-for="(word, wIndex) in sentence" :key="wIndex" class="pinyin-text">
+          <span
+            v-for="(word, wIndex) in sentence"
+            :key="wIndex"
+            class="pinyin-text"
+            :class="getPinyinWordSpacingClass(word, sentence[wIndex + 1])"
+          >
             <span
               :title="isPreview ? '' : '点击校对'"
               :style="{
@@ -321,6 +330,7 @@ export default {
       word_index: 0,
       note: '',
       isAllSetting: false,
+      chsFhList: [',', '。', '”', ':', '》', '?', '!', ';', '#', '、', '’', ')', '〕', '〕〕', '〉'],
     };
   },
   computed: {
@@ -395,9 +405,33 @@ export default {
       let textBlockIndex = 0;
       let oldIndex = -1;
       let paragraphIndex = 0;
+      let groupIndex = 0;
+      let groupHasContent = false;
+      let pendingGroupBoundary = false;
       const tagStack = [];
       let mathContext = null;
 
+      // 同一段落内的块归入同一分组,段落级样式(对齐、缩进)由分组容器承载,
+      // 避免一个段落被样式标签拆成多个块后各自独占一行。
+      // 换行仍保留 <br>(填空题等把分组强制成 inline 的场景依赖它换行);
+      // 段落闭合/换行只标记边界,等下一块内容到来时再开启新分组,
+      // 这样 </p> 后的换行不会和标签边界重复计数。
+      const pushBlock = (block) => {
+        if (!block) return;
+        if (block.type !== 'newline' && pendingGroupBoundary) {
+          groupIndex += 1;
+          groupHasContent = false;
+          pendingGroupBoundary = false;
+        }
+        block.groupIndex = groupIndex;
+        blocks.push(block);
+        if (block.type === 'newline') {
+          pendingGroupBoundary = true;
+        } else {
+          groupHasContent = true;
+        }
+      };
+
       for (const item of listToParse) {
         oldIndex += 1;
 
@@ -407,7 +441,7 @@ export default {
           if (item.is_style === 'true' || item.is_style === true) {
             this.updateHtmlTagStack(mathContext.stack, item.text || '');
             if (mathContext.stack.length === 0) {
-              blocks.push(this.parseMathBlock(mathContext.html, tagStack));
+              pushBlock(this.parseMathBlock(mathContext.html, tagStack));
               mathContext = null;
             }
           }
@@ -424,35 +458,66 @@ export default {
         }
 
         if (item.text && typeof item.text === 'string' && item.text.includes('<img')) {
-          blocks.push(this.parseImageBlock(item, tagStack));
+          pushBlock(this.parseImageBlock(item, tagStack));
         } else if (item.text && typeof item.text === 'string' && item.text.includes('<video')) {
           // item.text 是完整的 video 标签串
-          blocks.push(this.parseVideoBlock(item, tagStack));
+          pushBlock(this.parseVideoBlock(item, tagStack));
         } else if (item.text && typeof item.text === 'string' && item.text.includes('<audio')) {
-          blocks.push(this.parseAudioBlock(item, tagStack));
+          pushBlock(this.parseAudioBlock(item, tagStack));
         } else if (item.is_style === 'true' || item.is_style === true) {
-          if (item.text.includes('<br')) {
-            blocks.push({ type: 'newline' });
+          const tagText = (item.text || '').trim();
+          const isBlockOpen = /^<(p|div|h[1-6]|li|blockquote)\b/i.test(tagText);
+          const isBlockClose = /^<\/(p|div|h[1-6]|li|blockquote)\s*>$/i.test(tagText);
+          if (isBlockOpen && groupHasContent && !pendingGroupBoundary) {
+            pendingGroupBoundary = true;
+          }
+          if (tagText.includes('<br')) {
+            pushBlock({ type: 'newline' });
             paragraphIndex += 1;
           } else {
             this.handleStyleTag(item, tagStack);
+            if (isBlockClose) pendingGroupBoundary = true;
           }
         } else if (item.text === '\n') {
-          blocks.push({ type: 'newline' });
+          pushBlock({ type: 'newline' });
           paragraphIndex += 1;
         } else if (item.word_list && item.word_list.length > 0) {
           const hasEmphasisDot = this.checkHasEmphasisDot(tagStack);
-          blocks.push(this.createTextBlock(item, tagStack, textBlockIndex, oldIndex, paragraphIndex, hasEmphasisDot));
+          pushBlock(this.createTextBlock(item, tagStack, textBlockIndex, oldIndex, paragraphIndex, hasEmphasisDot));
           textBlockIndex += 1;
         }
       }
 
       if (mathContext) {
-        blocks.push(this.parseMathBlock(mathContext.html, tagStack));
+        pushBlock(this.parseMathBlock(mathContext.html, tagStack));
       }
 
       return blocks;
     },
+
+    /**
+     * 按段落把块分组,段落级样式挂在分组容器上。
+     * 段落内混排不同字体/样式的 span 时,后端会返回多个 word_list 块,
+     * 若把 text-align 挂到每个块上(并 display:block),这些块会各占一行。
+     * @returns {Array} [{ groupIndex, style, blocks }]
+     */
+    parsedGroups() {
+      const groups = [];
+      this.parsedBlocks.forEach((block) => {
+        let group = groups[groups.length - 1];
+        if (!group || group.groupIndex !== block.groupIndex) {
+          group = { groupIndex: block.groupIndex, style: {}, blocks: [] };
+          groups.push(group);
+        }
+        group.blocks.push(block);
+        if (block.type === 'text' && block.groupStyle) {
+          Object.keys(block.groupStyle).forEach((prop) => {
+            if (group.style[prop] === undefined) group.style[prop] = block.groupStyle[prop];
+          });
+        }
+      });
+      return groups;
+    },
   },
   watch: {
     styleWatch: {
@@ -712,17 +777,18 @@ export default {
       const styleObj = combinedStyle ? this.parseStyleToObject(combinedStyle) : null;
 
       const sentenceStyle = {};
-      let parentStyle = {};
+      // 段落级样式:作用于整段,不能落到单个词块上
+      const groupStyle = {};
       if (styleObj) {
         // 段落间距由分组容器统一处理,不能落到每个拼音词块上
         delete styleObj.marginBottom;
         // 提取 paddingLeft 用于段落缩进,从 styleObj 中移除
         if (styleObj.paddingLeft) {
-          sentenceStyle.paddingLeft = styleObj.paddingLeft;
+          groupStyle.paddingLeft = styleObj.paddingLeft;
           delete styleObj.paddingLeft;
         }
         if (styleObj.paddingRight) {
-          sentenceStyle.paddingRight = styleObj.paddingRight;
+          groupStyle.paddingRight = styleObj.paddingRight;
           delete styleObj.paddingRight;
         }
         // 提取 lineHeight 用于行高,从 styleObj 中移除
@@ -731,8 +797,8 @@ export default {
           delete styleObj.lineHeight;
         }
         if (styleObj.textAlign) {
-          parentStyle['text-align'] = styleObj.textAlign;
-          parentStyle['display'] = 'block';
+          groupStyle.textAlign = styleObj.textAlign;
+          delete styleObj.textAlign;
         }
       }
 
@@ -744,9 +810,9 @@ export default {
         paragraphIndex,
         styleObj,
         sentenceStyle,
+        groupStyle,
         rawStyleText: combinedStyle,
         hasEmphasisDot,
-        parentStyle,
       };
     },
 
@@ -774,6 +840,16 @@ export default {
       return lineHeight > 1 ? { marginBottom: `${lineHeight - 1}em` } : {};
     },
 
+    getPinyinWordSpacingClass(word, nextWord) {
+      if (!this.isShowPinyin) return {};
+      const text = typeof word?.text === 'string' ? word.text.trim() : '';
+      const nextText = typeof nextWord?.text === 'string' ? nextWord.text.trim() : '';
+      return {
+        'pinyin-text-padding': Boolean(text) && !this.chsFhList.includes(text),
+        'pinyin-text-padding-left': Boolean(nextText) && this.chsFhList.includes(nextText),
+      };
+    },
+
     // 解析样式字符串为对象
     parseStyleToObject(styleStr) {
       const styleObj = {};
@@ -1195,6 +1271,14 @@ export default {
     text-wrap: pretty;
     hanging-punctuation: allow-end;
 
+    &-padding {
+      padding: 0 3px;
+    }
+
+    &-padding-left {
+      padding-left: 3px;
+    }
+
     > span {
       display: inline-flex;
     }

+ 7 - 8
src/utils/recordScore.js

@@ -1,17 +1,18 @@
-import { ToolVoiceEval,ToolMergeAudio } from '@/api/app';
+import { ToolVoiceEval, ToolMergeAudio } from '@/api/app';
 /**
  * 录音评分
  */
 export function recordSocreSingle(data) {
   return ToolVoiceEval({
-    audio_bytes_base64: data.audio_paramter_type === 0 ? String(data.base64).replace(/^data:audio\/[^;]+;base64,/, '') : null,
+    audio_bytes_base64:
+      data.audio_paramter_type === 0 ? String(data.base64).replace(/^data:audio\/[^;]+;base64,/, '') : null,
     audio_file_id: data.audio_paramter_type === 1 ? data.base64 : null,
     text: data.text,
     audio_paramter_type: data.audio_paramter_type,
     is_attach_audio_url_user: 'true',
-    is_attach_audio_url_standard: data.standard
+    is_attach_audio_url_standard: data.standard,
   }).then((res) => {
-    if (!res ) {
+    if (!res) {
       throw new Error((res && (res.error || res.message)) || '评分接口失败');
     }
     return res;
@@ -24,13 +25,11 @@ export function recordSocreSingle(data) {
 export function mergeAudio(list) {
   return ToolMergeAudio({
     audio_file_id_list: list,
-    audio_file_type: 'wav'
+    audio_file_type: 'wav',
   }).then((res) => {
-    if (!res ) {
+    if (!res) {
       throw new Error((res && (res.error || res.message)) || '合并音频接口失败');
     }
     return res;
   });
 }
-
-

+ 8 - 0
src/views/book/courseware/create/components/CreateCanvas.vue

@@ -68,6 +68,7 @@
                   :id="grid.id"
                   ref="component"
                   :key="`grid-${grid.id}`"
+                  v-loading="componentLoadingState[grid.id] !== false"
                   :old-id="grid?.oldId"
                   :class="['grid', grid.id]"
                   :data-id="grid.id"
@@ -78,10 +79,13 @@
                   :border-color="computedBorderColor(row.row_id)"
                   :style="computedGridStyle(grid, row.row_id)"
                   :component-move="componentMove(i, j, k)"
+                  element-loading-spinner="el-icon-loading"
+                  element-loading-background="rgba(255, 255, 255, 0.75)"
                   @deleteComponent="deleteComponentConfirm"
                   @showSetting="showSetting"
                   @copyComponent="copyComponent"
                   @changeData="changeData"
+                  @contentLoading="setComponentLoading(grid.id, $event)"
                 />
                 <span
                   :key="`right-${grid.id}`"
@@ -172,6 +176,7 @@ export default {
         // 样式调整
         unified_attrib,
       },
+      componentLoadingState: {},
       visibleBackground: false, // 背景设置弹窗
       rowCheckList: {}, // 行复选框列表
       content_group_row_list: [], // 行分组id列表
@@ -1610,6 +1615,9 @@ export default {
     findChildComponentByKey(key) {
       return (this.$refs.component || []).find((child) => child.$vnode.key === key);
     },
+    setComponentLoading(id, isLoading) {
+      this.$set(this.componentLoadingState, id, isLoading);
+    },
 
     /**
      * 初始化画布 ResizeObserver,监听画布高度变化

+ 7 - 1
src/views/book/courseware/create/components/common/ModuleMixin.js

@@ -139,7 +139,9 @@ const mixin = {
   },
   inject: ['courseware_id', 'project_id', 'getBookUnifiedAttr', 'getTemporaryCoursewareID'],
   created() {
-    if (this.type !== 'interaction') {
+    if (this.type === 'interaction') {
+      this.$emit('contentLoading', !this.property.isGetContent);
+    } else {
       this.GetCoursewareComponentContent();
     }
     // 初始化 mind_map.node_list[0].id
@@ -154,6 +156,7 @@ const mixin = {
   methods: {
     GetCoursewareComponentContent() {
       if (this.courseware_id === '' || this.id === '') return;
+      this.$emit('contentLoading', true);
       this.property.isSilentPropertyWatch = true;
       let temporaryCoursewareID = this.getTemporaryCoursewareID();
       let coursewareID = temporaryCoursewareID || this.courseware_id;
@@ -209,6 +212,7 @@ const mixin = {
           }
 
           this.property.isGetContent = true;
+          this.$emit('contentLoading', false);
 
           this.$watch(
             'data',
@@ -275,10 +279,12 @@ const mixin = {
       this.property.isSilentPropertyWatch = true;
       // 先卸载内容区,让依赖 isGetContent 渲染的编辑器(如富文本)用新内容重新初始化
       this.property.isGetContent = false;
+      this.$emit('contentLoading', true);
       this.data = data;
       this.background = background;
       this.$nextTick(() => {
         this.property.isGetContent = true;
+        this.$emit('contentLoading', false);
         this.$nextTick(() => {
           this.property.isSilentPropertyWatch = false;
         });

+ 5 - 13
src/views/book/courseware/create/components/question/fill/Fill.vue

@@ -133,7 +133,7 @@ import WordProofread from '@/views/book/courseware/create/components/common/Word
 import { buildWordProofreadData } from '@/views/book/courseware/create/components/common/wordProofread';
 
 import { getFillData, arrangeTypeList, fillTypeList, fillTextMixin } from '@/views/book/courseware/data/fill';
-import { addTone, handleToneValue, mergePunctuationToWords } from '@/views/book/courseware/data/common';
+import { convertPinyinTone, mergePunctuationToWords } from '@/views/book/courseware/data/common';
 import { getRandomNumber } from '@/utils';
 import { TextToAudioFile } from '@/api/app';
 import { sanitizeHTML } from '@/utils/common';
@@ -709,18 +709,9 @@ export default {
     },
 
     handleTone(value, item) {
-      if (!item || !/^[a-zA-Z0-9\s]+$/.test(value)) return;
-      item.value = value
-        .trim()
-        .split(/\s+/)
-        .map((valItem) => {
-          return handleToneValue(valItem);
-        })
-        .map((valItem) =>
-          valItem.map(({ number, con }) => (number && con ? addTone(Number(number), con) : number || con || '')),
-        )
-        .filter((valItem) => valItem.length > 0)
-        .join(' ');
+      if (!item) return;
+      // 答案中可能夹带汉字、标点、斜杠,交给 convertPinyinTone 逐个音节转换
+      item.value = convertPinyinTone(value ?? '').trim();
     },
     uploads(file_id) {
       this.data.audio_file_id = file_id;
@@ -926,6 +917,7 @@ export default {
 
     :deep .pinyin-area .rich-text-container,
     :deep .pinyin-area .pinyin-paragraph,
+    :deep .pinyin-area .pinyin-line-group,
     :deep .pinyin-area .pinyin-sentence {
       display: inline;
     }

+ 3 - 4
src/views/book/courseware/create/components/question/pinyin_base/PinyinBase.vue

@@ -32,10 +32,9 @@
             style="width: 200px"
           />
         </div>
-        <span
-v-if="data.property.fun_type === 'input'" class="tips"
-          >在需要加空的内容处插入 3 个或以上的下划线“_”。</span
-        >
+        <span v-if="data.property.fun_type === 'input'" class="tips">
+          在需要加空的内容处插入 3 个或以上的下划线“_”。
+        </span>
         <span v-else-if="data.property.fun_type === 'mark'" class="tips">轻声不需要标注数字0</span>
         <div v-if="data.audio_file_id">
           <SoundRecord :wav-blob.sync="data.audio_file_id" />

+ 33 - 0
src/views/book/courseware/data/common.js

@@ -253,6 +253,39 @@ export function handleToneValue(valItem) {
 }
 
 /**
+ * 可转换的拼音音节:字母(含 ü)+ 单个数字声调。
+ * 前面必须是非字母数字(行首、空格、标点、汉字等),避免 abc123 这类连续文本被拆开转换;
+ * 声调数字后面也不能紧跟数字,避免把 2023、第3课 里的数字当成声调。
+ */
+const PINYIN_SYLLABLE_REGEX = /(^|[^a-zA-Z0-9üÜ])([a-zA-ZüÜ]+)([0-5])(?![0-9])/g;
+
+/**
+ * 单个拼音音节转声调,复用通用转换方式(handleToneValue + addTone)
+ * @param {String} syllable 拼音字母
+ * @param {String} toneNumber 数字声调
+ * @returns {String} 带声调的拼音
+ */
+function convertPinyinSyllable(syllable, toneNumber) {
+  return handleToneValue(`${syllable}${toneNumber}`)
+    .map(({ number, con }) => (number && con ? addTone(Number(number), con) : number || con || ''))
+    .join('');
+}
+
+/**
+ * 拼音转换(通用):把带数字声调的拼音转换成带声调的拼音,如 ni3 hao3 -> nǐ hǎo
+ * 逐个音节转换,答案中夹带汉字、标点、斜杠(如「你好 ni3」「ni3/ni2」)也能正常转换,
+ * 不含数字声调的内容原样返回
+ * @param {String} value 输入内容
+ * @returns {String} 转换后的内容
+ */
+export function convertPinyinTone(value) {
+  return `${value ?? ''}`.replace(
+    PINYIN_SYLLABLE_REGEX,
+    (match, prefix, syllable, toneNumber) => `${prefix}${convertPinyinSyllable(syllable, toneNumber)}`,
+  );
+}
+
+/**
  * 判断序号类型
  * @param {string} str
  */

+ 85 - 0
src/views/book/courseware/preview/common/RecordProgressBar.vue

@@ -0,0 +1,85 @@
+<template>
+  <div class="record-progress-bar">
+    <div class="record-progress-content">
+      <span class="record-progress-text"
+        >正在录 第 {{ index + 1 }} / {{ total }} {{ unit }}<template v-if="label">:{{ label }}</template></span
+      >
+      <el-button round icon="el-icon-refresh-left" :disabled="busy" @click="$emit('reset')">
+        重读本{{ unit }}</el-button
+      >
+      <el-button v-if="index + 1 < total" round :disabled="busy" @click="$emit('next')">
+        下一个<i class="el-icon-right"></i>
+      </el-button>
+      <el-button v-else round :disabled="busy" @click="$emit('finish')"> 完成<i class="el-icon-check"></i></el-button>
+      <el-button round icon="el-icon-close" type="warning" :disabled="busy" @click="$emit('cancel')"> 取消</el-button>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'RecordProgressBar',
+  props: {
+    // 当前录制序号(从 0 开始)与总条数
+    index: {
+      type: Number,
+      default: 0,
+    },
+    total: {
+      type: Number,
+      default: 0,
+    },
+    // 录制单位:句 / 词
+    unit: {
+      type: String,
+      default: '词',
+    },
+    // 附加在当前条数后的说明,如语音矩阵的当前词
+    label: {
+      type: String,
+      default: '',
+    },
+    // 切换录制中时禁用操作,避免重复触发
+    busy: {
+      type: Boolean,
+      default: false,
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.record-progress-bar {
+  position: fixed;
+  bottom: 200px;
+  left: 0;
+  z-index: 1;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  width: 100%;
+}
+
+.record-progress-content {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 8px;
+  align-items: center;
+  padding: 8px 14px;
+  background: #fff;
+  border-radius: 30px;
+  box-shadow: 0 4px 18px rgba(30, 50, 80, 18%);
+
+  .el-button {
+    flex: 0 0 auto;
+  }
+
+  .el-button + .el-button {
+    margin-left: 0;
+  }
+
+  .el-button:focus {
+    outline: none;
+  }
+}
+</style>

+ 16 - 18
src/views/book/courseware/preview/common/RecordScoreSingleDetail.vue

@@ -13,16 +13,15 @@
     <div class="progress-box">
       <div class="progress-left">
         <el-progress
-          width="92"
+          :width="92"
           type="circle"
-          stroke-width="11"
+          :stroke-width="11"
           define-back-color="#e9edf2"
           stroke-linecap="butt"
           :color="customColor"
           :percentage="recordScoreDetail.score_total"
           :show-text="false"
-        >
-        </el-progress>
+        />
         <div class="progress-left-text">
           <p :style="textColor(recordScoreDetail.score_total)">
             {{ recordScoreDetail.score_total }}
@@ -34,13 +33,12 @@
         <div class="progress-right-item">
           <span>准确度</span>
           <el-progress
-            stroke-width="6"
+            :stroke-width="6"
             define-back-color="#e9edf2"
             :color="customColor"
             :percentage="recordScoreDetail.accuracy"
             :show-text="false"
-          >
-          </el-progress>
+          />
           <b :style="textColor(recordScoreDetail.accuracy)">
             {{ recordScoreDetail.accuracy }}
           </b>
@@ -48,13 +46,12 @@
         <div class="progress-right-item">
           <span>流利度</span>
           <el-progress
-            stroke-width="6"
+            :stroke-width="6"
             define-back-color="#e9edf2"
             :color="customColor"
             :percentage="recordScoreDetail.fluency"
             :show-text="false"
-          >
-          </el-progress>
+          />
           <b :style="textColor(recordScoreDetail.fluency)">
             {{ recordScoreDetail.fluency }}
           </b>
@@ -62,13 +59,12 @@
         <div class="progress-right-item">
           <span>完整度</span>
           <el-progress
-            stroke-width="6"
+            :stroke-width="6"
             define-back-color="#e9edf2"
             :color="customColor"
             :percentage="recordScoreDetail.integrity"
             :show-text="false"
-          >
-          </el-progress>
+          />
           <b :style="textColor(recordScoreDetail.integrity)">
             {{ recordScoreDetail.integrity }}
           </b>
@@ -106,15 +102,17 @@
     <h5>逐字评分</h5>
     <div class="word-score-box">
       <div
-        class="word-score-item"
         v-for="(item, index) in recordScoreDetail.detail_list"
         :key="index"
+        class="word-score-item"
         :style="wordScoreItem(item.score)"
       >
         <p :style="textColor(item.score)">{{ item.hz }}</p>
-        <i class="word-pinyin">{{ item.pinyin }}</i>
-        <b class="word-score" :style="textColor(item.score)">{{ item.score }}</b>
-        <div class="char-item" v-for="(items, indexs) in item.phoneme_list" :key="indexs">
+        <div class="char-item">
+          <span>{{ item.pinyin }}</span>
+          <b :style="textColor(item.score)">{{ item.score }}</b>
+        </div>
+        <div v-for="(items, indexs) in item.phoneme_list" :key="indexs" class="char-item">
           <span>{{ items.char }}</span>
           <b :style="textColor(items.score)">{{ items.score }}</b>
         </div>
@@ -138,8 +136,8 @@
       :get-cur-time="getCurTime"
       :ed="ed"
       type="audioLine"
-      @handleListenRead="handleListenRead"
       style="height: 0; opacity: 0"
+      @handleListenRead="handleListenRead"
     />
   </el-dialog>
 </template>

Разница между файлами не показана из-за своего большого размера
+ 24 - 18
src/views/book/courseware/preview/common/RecordScoreWholeBtn.vue


+ 58 - 33
src/views/book/courseware/preview/common/RecordScoreWholeDetail.vue

@@ -12,16 +12,15 @@
     <div class="progress-box">
       <div class="progress-left">
         <el-progress
-          width="92"
+          :width="92"
           type="circle"
-          stroke-width="11"
+          :stroke-width="11"
           define-back-color="#e9edf2"
           stroke-linecap="butt"
           :color="customColor"
           :percentage="score_total"
           :show-text="false"
-        >
-        </el-progress>
+        />
         <div class="progress-left-text">
           <p :style="textColor(score_total)">
             {{ score_total }}
@@ -33,13 +32,12 @@
         <div class="progress-right-item">
           <span>准确度</span>
           <el-progress
-            stroke-width="6"
+            :stroke-width="6"
             define-back-color="#e9edf2"
             :color="customColor"
             :percentage="accuracy"
             :show-text="false"
-          >
-          </el-progress>
+          />
           <b :style="textColor(accuracy)">
             {{ accuracy }}
           </b>
@@ -47,13 +45,12 @@
         <div class="progress-right-item">
           <span>流利度</span>
           <el-progress
-            stroke-width="6"
+            :stroke-width="6"
             define-back-color="#e9edf2"
             :color="customColor"
             :percentage="fluency"
             :show-text="false"
-          >
-          </el-progress>
+          />
           <b :style="textColor(fluency)">
             {{ fluency }}
           </b>
@@ -61,13 +58,12 @@
         <div class="progress-right-item">
           <span>完整度</span>
           <el-progress
-            stroke-width="6"
+            :stroke-width="6"
             define-back-color="#e9edf2"
             :color="customColor"
             :percentage="integrity"
             :show-text="false"
-          >
-          </el-progress>
+          />
           <b :style="textColor(integrity)">
             {{ integrity }}
           </b>
@@ -75,11 +71,13 @@
       </div>
     </div>
 
-    <h5>按句得分</h5>
-    <div class="whole-detail" v-for="(items, indexs) in recordScoreDetail" :key="indexs">
+    <h5>{{ scoreTitle }}</h5>
+    <div v-for="(items, indexs) in recordScoreDetail" :key="indexs" class="whole-detail">
       <div class="top" :style="wordScoreItem(items.score_total)">
-        <span>第{{ indexs + 1 }}句</span>
-        <p>{{ items.text }}</p>
+        <span v-if="showIndex">第{{ indexs + 1 }}{{ itemUnit }}</span>
+        <p>
+          {{ items.text }}<i v-if="items.position" class="position">{{ items.position }}</i>
+        </p>
         <template v-if="items.detail_list">
           <b :style="textColor(items.score_total)">{{ items.score_total }}</b>
           <a @click="items.isShow = !items.isShow">{{ items.isShow ? '收起' : '详情' }}</a>
@@ -124,16 +122,17 @@
         </div>
         <div class="word-score-box">
           <div
-            class="word-score-item"
             v-for="(item, index) in items.detail_list"
             :key="index"
+            class="word-score-item"
             :style="wordScoreItem(item.score)"
           >
             <p :style="textColor(item.score)">{{ item.hz }}</p>
-            <i class="word-pinyin">{{ item.pinyin }}</i>
-            <b class="word-score" :style="textColor(item.score)">{{ item.score }}</b>
-
-            <div class="char-item" v-for="(items, indexs) in item.phoneme_list" :key="indexs">
+            <div class="char-item">
+              <span>{{ item.pinyin }}</span>
+              <b :style="textColor(item.score)">{{ item.score }}</b>
+            </div>
+            <div v-for="(items, indexs) in item.phoneme_list" :key="indexs" class="char-item">
               <span>{{ items.char }}</span>
               <b :style="textColor(items.score)">{{ items.score }}</b>
             </div>
@@ -151,7 +150,7 @@
         class="color-block"
         style="background-color: #fdf1d6"
       ></span
-      >60–79<span class="color-block" style="background-color: #fbe0e0"></span> < 60
+      >60–79<span class="color-block" style="background-color: #fbe0e0"></span> &lt; 60
     </div>
     <AudioLine
       ref="audioLine"
@@ -160,8 +159,8 @@
       :get-cur-time="getCurTime"
       :ed="ed"
       type="audioLine"
-      @handleListenRead="handleListenRead"
       style="height: 0; opacity: 0"
+      @handleListenRead="handleListenRead"
     />
   </el-dialog>
 </template>
@@ -177,6 +176,21 @@ export default {
     },
   },
   props: {
+    // 得分明细的小标题,课文按句评分为「按句得分」
+    scoreTitle: {
+      type: String,
+      default: '按句得分',
+    },
+    // 明细条目的计量单位(课文为句,语音矩阵为词)
+    itemUnit: {
+      type: String,
+      default: '句',
+    },
+    // 是否显示「第 N 句/词」序号(语音矩阵按词汇得分时不显示)
+    showIndex: {
+      type: Boolean,
+      default: true,
+    },
     visible: {
       type: Boolean,
       required: true,
@@ -208,11 +222,11 @@ export default {
   computed: {},
 
   created() {
-    let n = 0,
-      score_total = 0,
-      accuracy = 0,
-      fluency = 0,
-      integrity = 0;
+    let accuracy = 0;
+    let fluency = 0;
+    let integrity = 0;
+    let n = 0;
+    let score_total = 0;
 
     this.recordScoreDetail.forEach((item) => {
       if (item.detail_list) {
@@ -223,10 +237,12 @@ export default {
         integrity += item.integrity;
       }
     });
-    this.score_total = Math.min(Math.round(score_total / n), 100);
-    this.accuracy = Math.min(Math.round(accuracy / n), 100);
-    this.fluency = Math.min(Math.round(fluency / n), 100);
-    this.integrity = Math.min(Math.round(integrity / n), 100);
+    // n 为 0(全部未读)时避免 0/0 得到 NaN,否则进度环和分数会显示异常
+    const average = (total) => (n ? Math.min(Math.round(total / n), 100) : 0);
+    this.score_total = average(score_total);
+    this.accuracy = average(accuracy);
+    this.fluency = average(fluency);
+    this.integrity = average(integrity);
   },
   methods: {
     handleClose() {
@@ -509,6 +525,15 @@ export default {
       color: #2b3544;
     }
 
+    // 词汇位置(如「第1行 第1列」),视觉上与词汇区分开
+    .position {
+      margin-left: 8px;
+      font-size: 11px;
+      font-style: normal;
+      font-weight: normal;
+      color: #8b97a8;
+    }
+
     b {
       font-size: 17px;
     }

+ 47 - 10
src/views/book/courseware/preview/components/fill/FillPreview.vue

@@ -42,6 +42,7 @@
                         },
                       ]"
                       @input="handleInput(li.input, li.mark)"
+                      @blur="handleInputBlur(li)"
                     />
                   </template>
 
@@ -143,7 +144,12 @@
       :analysis-list="data.analysis_list"
       @closeAnswerAnalysis="closeAnswerAnalysis"
     >
-      <div slot="right-answer" class="fill-wrapper" :style="{ '--fill-font-family': data.property.fill_font }">
+      <div
+        v-if="isShowJudgeCorrect"
+        slot="right-answer"
+        class="fill-wrapper"
+        :style="{ '--fill-font-family': data.property.fill_font }"
+      >
         <div class="fill-content">
           <template v-for="(group, gi) in groupedModelEssay">
             <span :key="`answer-group-${gi}`" :style="groupStyle(group)">
@@ -164,7 +170,7 @@
                     v-show="computedAnswerText(li.mark).length > 0"
                     :key="`answer-${group.indexes[i]}`"
                     class="right-answer"
-                    :style="{ marginBottom: resolveFillControlMargin(li) }"
+                    :style="{ marginBottom: resolveFillControlMargin(li, true) }"
                   >
                     {{ computedAnswerText(li.mark) }}
                   </span>
@@ -192,6 +198,7 @@ import {
   audioPositionList,
   fillTextMixin,
 } from '@/views/book/courseware/data/fill';
+import { convertPinyinTone } from '@/views/book/courseware/data/common';
 
 // 复用同一个 canvas 测量文本宽度,避免每次输入都重新创建
 let textMeasureContext = null;
@@ -202,6 +209,10 @@ function getTextMeasureContext() {
   return textMeasureContext;
 }
 
+// 填空控件 em 补偿的基准字号(px):输入框 .el-input 的 font-size 在样式中显式固定为该值,
+// 与输入框字号不同的元素(如答案解析中的答案文字)按此基准换算,才能与输入框偏移一致
+const FILL_CONTROL_EM_BASIS_PX = 14;
+
 export default {
   name: 'FillPreview',
   components: {
@@ -365,10 +376,13 @@ export default {
      * 不显示拼音时汉字按段落行高居中,只需补偿半行留白。
      * 输入框需要使用相同补偿,才能与词级文本处于同一视觉基线。
      * 预览页再按实际渲染微调:开启拼音 +6px,未开启拼音 +1px。
+     * 返回值默认用 em(随控件字号缩放);答案解析里的答案文字字号与输入框的 em 基准不同,
+     * 同一个 calc 会算出不同的 px,此时传 toPixel 按输入框基准换算成 px,保证两处横线偏移一致。
      * @param {Object} li 填空块对象
+     * @param {Boolean} [toPixel] 是否按输入框的 em 基准换算成 px
      * @returns {String} 与拼音词块行间距一致的补偿值
      */
-    resolveFillControlMargin(li) {
+    resolveFillControlMargin(li, toPixel = false) {
       let lineHeight = '';
       (li?.rich_text_list || []).forEach((item) => {
         const match = String(item?.text || '').match(/line-height\s*:\s*([^;"']+)/i);
@@ -400,6 +414,10 @@ export default {
       }
       // 预览页在原有补偿基础上追加微调量
       const totalOffset = offset + (isShowPinyin ? 6 : 1);
+      // 按输入框的 em 基准(见样式里 .el-input 的 font-size)换算成 px,
+      // 避免不同字号的元素用同一 em 算式却得到不同偏移
+      if (toPixel) return `${Number((spacing * FILL_CONTROL_EM_BASIS_PX + totalOffset).toFixed(2))}px`;
+
       const offsetExpression = totalOffset < 0 ? ` - ${Math.abs(totalOffset)}px` : ` + ${totalOffset}px`;
 
       return `calc(${spacing}em${offsetExpression})`;
@@ -596,6 +614,21 @@ export default {
 
       this.$set(this.inputWidthMap, mark, nextWidth);
     },
+    /**
+     * 输入框失焦:此时才做拼音转换(输入过程中不处理,避免边输入边改内容)
+     * @param {Object} li 填空块对象
+     */
+    handleInputBlur(li) {
+      if (!li?.mark) return;
+
+      const value = `${li.input ?? ''}`;
+      const nextValue = convertPinyinTone(value);
+      if (nextValue !== value) {
+        li.input = nextValue;
+        // 转换后文本变短,重新计算输入框宽度
+        this.handleInput(nextValue, li.mark);
+      }
+    },
   },
 };
 </script>
@@ -619,12 +652,12 @@ export default {
 
     :deep .pinyin-area .rich-text-container,
     :deep .pinyin-area .pinyin-paragraph,
+    :deep .pinyin-area .pinyin-line-group,
     :deep .pinyin-area .pinyin-sentence {
       display: inline;
     }
 
     .fill-content {
-      width: calc(100% - 82px);
       margin: 0;
 
       :deep .el-input__inner {
@@ -684,11 +717,11 @@ export default {
       width: 120px;
       margin: 0 10px;
       margin-bottom: -2px;
-      vertical-align: bottom;
 
-      &.pinyin :deep input.el-input__inner {
-        font-family: 'PINYIN-B', sans-serif;
-      }
+      // 显式固定 em 补偿的基准(element-ui 默认值):
+      // 模板传入的 marginBottom 是 em 单位,基准需与 resolveFillControlMargin 中的换算保持一致
+      font-size: 14px;
+      vertical-align: bottom;
 
       &.chinese :deep input.el-input__inner {
         font-family: 'arial', sans-serif;
@@ -727,14 +760,18 @@ export default {
     }
 
     .right-answer {
-      // 盒模型/行高与填空输入框一致:文字底部贴正文文字底部,下边框即填空横线
+      // 与上面的填空输入框(.el-input)保持同一套盒模型:1em 行盒 + 文字垂直居中,
+      // 下边框即填空横线;上下偏移由模板传入的 marginBottom 统一补偿
       // 字体与学生输入保持一致(--fill-font-family 由模板传入)
       position: relative;
       box-sizing: border-box;
-      display: inline-block;
+      display: inline-flex;
+      align-items: center;
+      justify-content: center;
       height: 1em;
       margin: 0 4px;
       font-family: var(--fill-font-family, 'arial'), sans-serif;
+      font-size: 16pt;
       line-height: 1em;
       vertical-align: bottom;
       border-bottom: 1px solid $font-color;

+ 143 - 33
src/views/book/courseware/preview/components/voice_matrix/VoiceMatrixPreview.vue

@@ -133,6 +133,7 @@
                       ? 'playing'
                       : '',
                     column?.is_only_text ? 'title' : '',
+                    recordingWord && recordingWord.row === i && recordingWord.column === j ? 'recording-current' : '',
                   ]"
                   @click="matrixCellClick(i, j)"
                 >
@@ -145,6 +146,14 @@
                   <div v-if="showLang" class="lang">
                     {{ column.multilingual.find((item) => item.type === getLang())?.translation }}
                   </div>
+                  <span
+                    v-if="cellBadge(i, j)"
+                    :class="['matrix-score', { 'is-unread': cellBadge(i, j).unread }]"
+                    @click.stop="showScoreDetail"
+                  >
+                    <i v-if="cellBadge(i, j).unread" class="matrix-score-line"></i>
+                    <template v-else>{{ cellBadge(i, j).text }}</template>
+                  </span>
                 </div>
               </div>
             </template>
@@ -180,33 +189,42 @@
       </div>
       <!-- 录音 -->
       <div v-if="isEnable(data.property.is_enable_record)" class="voice-luyin">
-        <SoundRecord
+        <MatrixRecord
           ref="luyin"
-          type="promax"
           class="luyin-box"
           :answer-record-list="data.record_list"
           :select-data="selectData"
+          :selected-words="selectedWords"
+          :all-words="matrixWords"
           :attrib="data.unified_attrib"
+          :standard-url="mp3Url"
+          :task-model="isJudgingRightWrong ? 'ANSWER' : ''"
           @getWavblob="getWavblob"
           @getSelectData="getSelectData"
-          @handleParentPlay="pauseOtherAudio"
+          @selectRecord="selectRecord"
+          @recordProgress="recordingWord = $event"
           @sentPause="sentPause"
+          @handleParentPlay="pauseOtherAudio"
           @handleWav="handleWav"
-        />
-        <AudioCompare
-          :theme-color="themeColor"
-          :wavblob="wavblob"
-          type="full"
-          :attrib="data.unified_attrib"
-          :url="mp3Url"
-          :is-record="isRecord"
-          :sent-pause="sentPause"
-          :matrix-select-lrc="matrixSelectLrc"
-          :get-cur-time="getCurTime"
-          :cur-time="curTime"
-          :handle-change-stop-audio="handleChangeStopAudio"
-          @playing="playChange"
-        />
+        >
+          <!-- 对比按钮排在评分 / 整体录音 / 已选提示之前 -->
+          <template #record-extra>
+            <AudioCompare
+              :theme-color="themeColor"
+              :wavblob="wavblob"
+              type="full"
+              :attrib="data.unified_attrib"
+              :url="mp3Url"
+              :is-record="isRecord"
+              :sent-pause="sentPause"
+              :matrix-select-lrc="matrixSelectLrc"
+              :get-cur-time="getCurTime"
+              :cur-time="curTime"
+              :handle-change-stop-audio="handleChangeStopAudio"
+              @playing="playChange"
+            />
+          </template>
+        </MatrixRecord>
       </div>
       <PreviewOperation @showAnswerAnalysis="showAnswerAnalysis" @judgeCorrect="judgeCorrect" @retry="retry" />
     </div>
@@ -232,14 +250,14 @@ import { getRandomNumber } from '@/utils/index.js';
 
 import PreviewMixin from '../common/PreviewMixin';
 import Bus from './components/Bus.js';
-import SoundRecord from '../../common/SoundRecord.vue';
+import MatrixRecord from './components/MatrixRecord.vue';
 import AudioCompare from './components/AudioCompareMatrix.vue';
 import AudioLine from './components/AudioLine.vue';
 
 export default {
   name: 'VoiceMatrixPreview',
   components: {
-    SoundRecord,
+    MatrixRecord,
     AudioCompare,
     AudioLine,
   },
@@ -273,6 +291,8 @@ export default {
       wavblob: null,
       isRecord: false,
       matrixSelectLrc: null,
+      selectedRecord: null,
+      recordingWord: null,
     };
   },
   computed: {
@@ -306,6 +326,30 @@ export default {
         column,
       };
     },
+    matrixWords() {
+      const words = [];
+      this.data.option_list.forEach((row, rowIndex) => {
+        row.forEach((cell, columnIndex) => {
+          if (!cell || cell.is_only_text || cell.type === 'connection') return;
+          const element = document.createElement('div');
+          element.innerHTML = this.sanitizeHTML(cell.content || '');
+          const text = (element.textContent || '').trim();
+          if (!text) return;
+          const lrcData = { ...cell.lrc_data };
+          if (lrcData.end_time === -1) lrcData.end_time = this.mp3Duration;
+          words.push({ row: rowIndex, column: columnIndex, text, lrc_data: lrcData });
+        });
+      });
+      return words;
+    },
+    selectedWords() {
+      const { type, index, row, column } = this.selectData;
+      return this.matrixWords.filter((word) => {
+        if (type === 'row') return word.row === index;
+        if (type === 'column') return word.column === index;
+        return word.row === row && word.column === column;
+      });
+    },
   },
   watch: {
     hasSelectedCell() {
@@ -339,11 +383,37 @@ export default {
   methods: {
     onAudioPause(id) {
       if (this.cid === id) return;
-      if (this.$refs.luyin?.microphoneStatus) this.$refs.luyin.microphone();
+      if (this.$refs.luyin) this.$refs.luyin.pausePlayback();
+      if (this.$refs.luyin?.recording) this.$refs.luyin.stopIfRecording();
       this.handleParentPlay();
     },
     handleWav(data) {
-      this.data.record_list = data;
+      this.$set(this.data, 'record_list', data);
+      this.$set(this.answer, 'record_list', data);
+    },
+    selectRecord(record) {
+      this.selectedRecord = record;
+      const selection = record && record.selectData;
+      this.selectedLine = { type: '', index: -1 };
+      this.selectCell = { row: -1, column: -1 };
+      if (selection && (selection.type === 'row' || selection.type === 'column')) {
+        this.selectedLine = { type: selection.type, index: selection.index };
+      } else if (selection && selection.type === 'cell') {
+        this.selectCell = { row: selection.row, column: selection.column };
+      }
+      this.getSelectData(selection || { type: 'all' });
+    },
+    // 单元格评分气泡:未读(评分失败)时只显示灰色气泡里的白色横线
+    cellBadge(row, column) {
+      const record = this.selectedRecord;
+      if (!record || !record.words) return null;
+      const word = record.words.find((item) => item.row === row && item.column === column);
+      if (!word || !word.score) return null;
+      if (!Number.isFinite(word.score.score_total)) return { text: '', unread: true };
+      return { text: word.score.score_total, unread: false };
+    },
+    showScoreDetail() {
+      if (this.$refs.luyin) this.$refs.luyin.showScore();
     },
     // 鼠标移入移出
     matrixCellMouseenter(i, j, type) {
@@ -363,6 +433,7 @@ export default {
 
     // 单击单元格
     matrixCellClick(row, column) {
+      if (this.$refs.luyin && this.$refs.luyin.recording) return;
       if (this.playing) this.handleParentPlay();
       if (this.unWatch) this.unWatch();
       this.lrcArray = [];
@@ -388,6 +459,7 @@ export default {
      * @param {PointerEvent} event
      */
     restoreAudioStatus(event) {
+      if (this.$refs.luyin?.recording) return;
       const whitePath = [
         'column-green',
         'column-red',
@@ -397,6 +469,7 @@ export default {
         'audio-simple-image',
         'audio-simple-repeat',
         'luyin-box',
+        'el-select-dropdown',
       ];
       const operable = event.composedPath().some((item) => {
         const className = item.className;
@@ -421,6 +494,7 @@ export default {
 
     // 选中行、列
     selectRowOrColumn(index, type) {
+      if (this.$refs.luyin && this.$refs.luyin.recording) return;
       this.handleParentPlay();
       this.lrcArray = [];
       this.selectCell = { row: -1, column: -1 };
@@ -432,11 +506,6 @@ export default {
       }
       this.selectedLine = { type, index };
       let number = index;
-      if (type === 'column') {
-        this.data.option_list[index].forEach((item, i) => {
-          if (i >= index) return;
-        });
-      }
       this.fileName = `第 ${number + 1} ${type === 'row' ? '行' : '列'}`;
     },
 
@@ -529,6 +598,10 @@ export default {
 
     getSelectData({ type, index, row, column }) {
       if (type === '') return;
+      if (type === 'all') {
+        this.matrixSelectLrc = this.fullAudioLrc;
+        return;
+      }
       const arr = [];
       if (type.length > 0 && index >= 0 && type === 'row') {
         this.data.option_list[index].forEach((item) => {
@@ -604,6 +677,7 @@ export default {
     retry() {
       this.clearSelectCell();
       this.selectedLine = { type: '', index: -1 };
+      this.selectCell = { row: -1, column: -1 };
       this.handleParentPlay();
       this.wavblob = null;
       this.matrixSelectLrc = null;
@@ -829,6 +903,11 @@ $border-color: #e6e6e6;
               background-color: rgba(24, 144, 255, 10%);
             }
 
+            &.recording-current {
+              background-color: #fdecec;
+              border-color: #e05252;
+            }
+
             &.title {
               background-color: transparent;
               border-color: transparent;
@@ -956,19 +1035,16 @@ $border-color: #e6e6e6;
 
     .voice-luyin {
       display: flex;
+      flex-wrap: wrap;
       align-items: center;
-      height: 40px;
+      min-height: 40px;
       padding: 3px 16px;
       border: 1px solid $border-color;
       border-top-width: 0;
       border-radius: 0 0 8px 8px;
 
-      :deep .record {
-        max-width: 280px;
-      }
-
       :deep .compara-content {
-        margin-left: 8px;
+        margin-left: 0;
       }
 
       :deep .compare-box,
@@ -984,6 +1060,40 @@ $border-color: #e6e6e6;
         margin-top: 2px;
       }
     }
+
+    .matrix-score {
+      position: absolute;
+      right: -9px;
+      bottom: -9px;
+      z-index: 1;
+      box-sizing: border-box;
+      width: auto !important;
+      min-width: 26px;
+      height: 26px;
+      padding: 0 6px !important;
+      font-size: 12px;
+      font-weight: bold;
+      line-height: 22px !important;
+      color: #fff;
+      text-align: center !important;
+      white-space: nowrap;
+      background-color: #43a047;
+      border: 2px solid #fff;
+      border-radius: 13px;
+
+      &.is-unread {
+        padding: 0 !important;
+        background-color: #9aa5b5;
+      }
+
+      .matrix-score-line {
+        display: block;
+        width: 20px;
+        height: 2px;
+        background-color: #fff;
+        border-radius: 1px;
+      }
+    }
   }
 }
 

+ 665 - 0
src/views/book/courseware/preview/components/voice_matrix/components/MatrixRecord.vue

@@ -0,0 +1,665 @@
+<template>
+  <div class="matrix-record" @click.stop>
+    <div class="record-controls">
+      <SvgIcon
+        :icon-class="recording ? 'luyin-ing' : 'luyin-radio-button'"
+        size="24"
+        :style="{ color: attrib && attrib.topic_color }"
+        :class="['record-action', { unavailable: answerMode }]"
+        @click="start(false)"
+      />
+      <span class="record-time">{{
+        formatTime(recording ? elapsed : (selectedRecord && selectedRecord.toltime) || 0)
+      }}</span>
+      <el-select
+        v-model="selectedIndex"
+        placeholder="无录音"
+        :disabled="recording || busy || scoring"
+        @change="changeRecord"
+      >
+        <el-option v-for="(record, index) in records" :key="record.id || index" :label="record.name" :value="index" />
+      </el-select>
+      <div
+        class="play-back icon-mask"
+        :style="{
+          backgroundColor: selectedRecord ? (attrib && attrib.topic_color) || '#000' : '#aaa',
+          maskImage: playing
+            ? `url(${require('@/assets/voice_matrix/luyin-play-stop.png')})`
+            : `url(${require('@/assets/voice_matrix/luyin-play-active.png')})`,
+        }"
+        @click="playRecording"
+      ></div>
+      <a class="record-action" :class="{ unavailable: !selectedRecord || answerMode }" @click="deleteRecording">
+        <SvgIcon icon-class="luyin-delete" size="24" />
+      </a>
+      <slot name="record-extra"></slot>
+      <div class="record-tail">
+        <el-button type="text" :disabled="!selectedRecord || busy || scoring" @click="showScore">评分</el-button>
+        <el-button class="whole-btn" size="mini" :disabled="wholeDisabled" @click="start(true)">整体录音</el-button>
+        <span class="selection-tip" :title="selectionLabel">{{ selectionLabel }}</span>
+      </div>
+    </div>
+    <div v-if="scoring" class="score-progress">
+      <i class="el-icon-loading"></i> 评测中… 已完成 {{ scoreIndex }} / {{ scoreTotal }} 词
+    </div>
+    <RecordProgressBar
+      v-if="recording"
+      :index="currentIndex"
+      :total="sessionWords.length"
+      unit="词"
+      :label="currentWordText"
+      :busy="busy"
+      @reset="next('reset')"
+      @next="next('next')"
+      @finish="next('finish')"
+      @cancel="cancel"
+    />
+    <RecordScoreWholeDetail
+      v-if="visibleScore"
+      :visible.sync="visibleScore"
+      :attrib="attrib"
+      :record-score-detail="scoreDetails"
+      :score-title="scoreTitle"
+      item-unit="词"
+      :show-index="false"
+    />
+  </div>
+</template>
+
+<script>
+import Recorder from 'js-audio-recorder';
+import { playAudioElement, releaseAudioElement, releaseRecorder } from '@/utils';
+import { blobToDataUrl, uploadRecording, trackUpload, registerRecorder } from '@/utils/recordingUpload';
+import { resolveAudioSrc } from '@/utils/audioSource';
+import { mergeAudio, recordSocreSingle } from '@/utils/recordScore';
+import RecordScoreWholeDetail from '../../../common/RecordScoreWholeDetail.vue';
+import RecordProgressBar from '../../../common/RecordProgressBar.vue';
+
+export default {
+  components: { RecordScoreWholeDetail, RecordProgressBar },
+  props: {
+    answerRecordList: { type: Array, default: () => [] },
+    selectData: { type: Object, default: () => ({}) },
+    selectedWords: { type: Array, default: () => [] },
+    allWords: { type: Array, default: () => [] },
+    attrib: { type: Object, default: () => ({}) },
+    standardUrl: { type: String, default: '' },
+    // 与课文录音组件一致:ANSWER(查看答案)模式下禁止录音与删除
+    taskModel: { type: String, default: '' },
+  },
+  data() {
+    return {
+      records: [],
+      selectedIndex: null,
+      recording: false,
+      busy: false,
+      playing: false,
+      scoring: false,
+      scoreIndex: 0,
+      scoreTotal: 0,
+      scoreGeneration: 0,
+      sessionGeneration: 0,
+      visibleScore: false,
+      elapsed: 0,
+      currentIndex: 0,
+      sessionWords: [],
+      sessionSelection: null,
+      sessionAll: false,
+      audio: new window.Audio(),
+    };
+  },
+  computed: {
+    answerMode() {
+      return this.taskModel === 'ANSWER';
+    },
+    wholeDisabled() {
+      return this.busy || this.scoring || this.answerMode;
+    },
+    selectedRecord() {
+      return this.selectedIndex === null ? null : this.records[this.selectedIndex] || null;
+    },
+    selectionLabel() {
+      if (this.recording) {
+        return this.sessionAll
+          ? '整体录音中'
+          : `已选:${this.describeSelection(this.sessionSelection, this.sessionWords)}`;
+      }
+      if (!this.selectedWords.length) return '未选择词汇';
+      return `已选:${this.describeSelection(this.selectData, this.selectedWords)}`;
+    },
+    scoreDetails() {
+      const words = this.selectedRecord && this.selectedRecord.words;
+      if (!words) return [];
+      // 兼容历史答案中缺少逐词评分的情况,避免详情弹窗读到 undefined
+      return words.map((word) => word.score || { text: word.text, isShow: false });
+    },
+    // 得分明细小标题:单个单元格为逐字得分,整行/整列为第 x 行(词1、词2)
+    scoreTitle() {
+      const record = this.selectedRecord;
+      if (!record || !record.words || !record.words.length) return '逐字得分';
+      const selection = record.selectData || {};
+      const texts = record.words.map((word) => word.text).join('、');
+      if (selection.type === 'row') return `第 ${selection.index + 1} 行(${texts})`;
+      if (selection.type === 'column') return `第 ${selection.index + 1} 列(${texts})`;
+      if (selection.type === 'all') return '整体录音(逐词连录)';
+      return '逐字得分';
+    },
+    currentWordText() {
+      const word = this.sessionWords[this.currentIndex];
+      return word ? word.text : '';
+    },
+  },
+  watch: {
+    answerRecordList(value) {
+      if (value === this.records) return;
+      if (this.recording) this.abortSession();
+      this.scoreGeneration += 1;
+      this.scoring = false;
+      this.visibleScore = false;
+      this.records = Array.isArray(value) ? value : [];
+      this.selectedIndex = this.records.length ? 0 : null;
+      this.changeRecord(this.selectedIndex);
+    },
+  },
+  mounted() {
+    this.segmentTasks = new WeakMap();
+    this.records = this.answerRecordList || [];
+    this.selectedIndex = this.records.length ? 0 : null;
+    this.changeRecord(this.selectedIndex);
+    this.audio.addEventListener('play', this.onPlay);
+    this.audio.addEventListener('pause', this.onPause);
+    this.unregisterRecorder = registerRecorder({ stopIfRecording: () => this.stopIfRecording() });
+  },
+  beforeDestroy() {
+    this.tearingDown = true;
+    this.sessionGeneration += 1;
+    this.scoreGeneration += 1;
+    if (this.unregisterRecorder) this.unregisterRecorder();
+    clearInterval(this.timer);
+    this.clearSegmentGap();
+    if (this.recorder && !this.startPromise) releaseRecorder(this.recorder);
+    if (this.recording) this.$root.isRecording = false;
+    releaseAudioElement(this.audio);
+  },
+  methods: {
+    formatTime(seconds) {
+      const time = Math.max(0, Math.floor(seconds || 0));
+      return `${String(Math.floor(time / 60)).padStart(2, '0')}:${String(time % 60).padStart(2, '0')}`;
+    },
+    // 已选对象描述:单词用引号,整行/整列带序号和词汇列表
+    describeSelection(selection, words) {
+      const texts = words.map((word) => word.text).join('、');
+      if (selection.type === 'row') return `第 ${selection.index + 1} 行(${texts})`;
+      if (selection.type === 'column') return `第 ${selection.index + 1} 列(${texts})`;
+      return `词汇「${texts}」`;
+    },
+    onPlay() {
+      this.playing = true;
+    },
+    onPause() {
+      this.playing = false;
+    },
+    emitRecords() {
+      this.$emit('handleWav', this.records);
+    },
+    changeRecord(index) {
+      this.audio.pause();
+      const record = index === null ? null : this.records[index];
+      this.$emit('getWavblob', record ? record.wavData || null : null);
+      // 与课文组件一致:切换录音后对比播放回到标准音
+      this.$emit('sentPause', false);
+      this.$emit('selectRecord', record || null);
+    },
+    async start(all) {
+      if (this.answerMode) return;
+      if (this.recording || this.busy || this.scoring) return;
+      const words = all ? this.allWords : this.selectedWords;
+      if (!words.length) {
+        this.$message.warning(all ? '没有可录音的词汇' : '请先选择:词汇卡片 / 列头 / 行首,或点「整体录音」');
+        return;
+      }
+      this.audio.pause();
+      this.$emit('handleParentPlay');
+      this.$emit('sentPause', false);
+      this.sessionWords = words.map((word) => ({ ...word, lrc_data: { ...word.lrc_data } }));
+      this.sessionSelection = all ? { type: 'all' } : { ...this.selectData };
+      this.sessionAll = all;
+      this.sessionGeneration += 1;
+      const generation = this.sessionGeneration;
+      this.currentIndex = 0;
+      this.elapsed = 0;
+      this.recording = true;
+      this.$emit('recordProgress', this.sessionWords[0]);
+      if (all) this.$emit('selectRecord', { selectData: { type: 'all' } });
+      this.busy = true;
+      try {
+        this.operation = this.startSegment();
+        await this.operation;
+      } catch (error) {
+        if (generation === this.sessionGeneration) {
+          this.abortSession();
+          if (!this.tearingDown) this.$message.warning('录音启动失败,请检查麦克风权限后重试');
+        }
+      } finally {
+        this.operation = null;
+        this.busy = false;
+      }
+    },
+    async startSegment() {
+      const generation = this.sessionGeneration;
+      const recorder = new Recorder({ sampleBits: 16, sampleRate: 16000, numChannels: 1 });
+      this.recorder = recorder;
+      this.startPromise = recorder.start();
+      try {
+        await this.startPromise;
+      } catch (error) {
+        this.startPromise = null;
+        releaseRecorder(recorder);
+        if (this.recorder === recorder) this.recorder = null;
+        throw error;
+      }
+      this.startPromise = null;
+      if (this.tearingDown || generation !== this.sessionGeneration) {
+        releaseRecorder(recorder);
+        if (this.recorder === recorder) this.recorder = null;
+        throw new Error('录音组件已销毁');
+      }
+      this.$root.isRecording = true;
+      // 与课文组件一致:时长按当前这一段计,不累计前面录过的词
+      this.elapsed = 0;
+      clearInterval(this.timer);
+      this.timer = setInterval(() => {
+        this.elapsed += 1;
+        if (this.elapsed >= 600) {
+          this.$message.warning('单次录音最多可以录音10分钟');
+          this.stopIfRecording();
+        }
+      }, 1000);
+    },
+    async stopSegment() {
+      if (this.startPromise) await this.startPromise;
+      if (!this.recorder) throw new Error('录音尚未启动');
+      const recorder = this.recorder;
+      recorder.stop();
+      const wav = recorder.getWAVBlob();
+      const duration = Math.floor(recorder.duration);
+      const fileSize = recorder.fileSize;
+      releaseRecorder(recorder);
+      this.recorder = null;
+      this.$root.isRecording = false;
+      clearInterval(this.timer);
+      return { wavData: await blobToDataUrl(wav), toltime: duration, fileSize, upload_state: 'uploading' };
+    },
+    // 与课文组件一致:停止即上传,与后续录音并行,不必等整段录完
+    uploadSegment(segment) {
+      const task = uploadRecording(segment.wavData)
+        .then((res) => {
+          this.$set(segment, 'wavData', res.file_id);
+          this.$set(segment, 'file_url', res.file_url || '');
+          this.$set(segment, 'upload_state', 'done');
+          return res;
+        })
+        .catch((error) => {
+          this.$set(segment, 'upload_state', 'failed');
+          this.$set(segment, 'upload_error', (error && error.message) || '录音上传失败');
+          throw error;
+        });
+      // 登记到提交前统一等待;拒绝由具体使用方处理,这里吞掉避免未处理异常
+      trackUpload(task);
+      task.catch(() => {});
+      return task;
+    },
+    next(action) {
+      if (!this.recording || this.busy) return;
+      this.busy = true;
+      const operation = this.advance(action);
+      this.operation = operation;
+      return operation.finally(() => {
+        if (this.operation === operation) this.operation = null;
+        this.busy = false;
+      });
+    },
+    async advance(action) {
+      const generation = this.sessionGeneration;
+      try {
+        const segment = await this.stopSegment();
+        // 会话已取消/销毁,本次录音作废,不再上传
+        if (this.tearingDown || !this.recording) return;
+        if (action !== 'reset') {
+          this.$set(this.sessionWords[this.currentIndex], 'segment', segment);
+          this.segmentTasks.set(segment, this.uploadSegment(segment));
+        }
+        if (action === 'finish') {
+          this.saveSession();
+          return;
+        }
+        if (action === 'next') this.currentIndex += 1;
+        this.$emit('recordProgress', this.sessionWords[this.currentIndex]);
+        // 与课文组件一致:停止与下一次开始之间留 800ms,等麦克风释放、上传启动
+        await this.waitSegmentGap();
+        if (this.tearingDown || !this.recording) return;
+        await this.startSegment();
+      } catch (error) {
+        if (generation === this.sessionGeneration) {
+          this.abortSession();
+          if (!this.tearingDown) this.$message.error('录音保存或启动失败,请重新录制');
+        }
+      }
+    },
+    waitSegmentGap() {
+      return new Promise((resolve) => {
+        this.segmentGapResolve = resolve;
+        this.segmentGapTimer = setTimeout(() => {
+          this.segmentGapTimer = null;
+          this.segmentGapResolve = null;
+          resolve();
+        }, 800);
+      });
+    },
+    /**
+     * 结束切词间隔。
+     * cancel/销毁时必须让等待中的 advance 立即继续,否则 next() 的 finally 不会执行,
+     * busy 会一直为 true,提交前 stopIfRecording 也会卡在这里。
+     */
+    clearSegmentGap() {
+      if (this.segmentGapTimer) clearTimeout(this.segmentGapTimer);
+      this.segmentGapTimer = null;
+      const resolve = this.segmentGapResolve;
+      this.segmentGapResolve = null;
+      if (resolve) resolve();
+    },
+    saveSession() {
+      const words = this.sessionWords.filter((word) => word.segment);
+      if (!words.length) {
+        this.abortSession();
+        return;
+      }
+      const record = {
+        id: `${Date.now()}-${Math.random().toString(36).slice(2)}`,
+        name: `${this.sessionAll ? '整体录音' : '选词录音'}${this.records.length + 1}${
+          words.length < this.sessionWords.length ? '(未完成)' : ''
+        }`,
+        selectData: this.sessionSelection,
+        words,
+        toltime: words.reduce((sum, word) => sum + word.segment.toltime, 0),
+        src: '',
+        wavData: words.length === 1 ? words[0].segment.wavData : '',
+        upload_state: 'uploading',
+      };
+      this.records.push(record);
+      this.selectedIndex = this.records.length - 1;
+      this.recording = false;
+      this.$emit('recordProgress', null);
+      this.$root.isRecording = false;
+      this.emitRecords();
+      this.changeRecord(this.selectedIndex);
+      const upload = this.finalizeRecord(record);
+      trackUpload(upload);
+      upload.catch((error) => {
+        this.$set(record, 'upload_state', 'failed');
+        this.$set(record, 'upload_error', error.message || '录音上传失败');
+        if (this.records.includes(record)) {
+          this.emitRecords();
+          this.$message.error('录音上传或合并失败,请检查网络后重新录制');
+        }
+      });
+    },
+    /**
+     * 逐词上传在停止录音时就已开始,这里等它们完成后再合并整条录音。
+     * 与课文组件一致:合并结果同时保留可播放地址(src)与 file_id。
+     */
+    async finalizeRecord(record) {
+      await Promise.all(record.words.map((word) => this.segmentTasks.get(word.segment) || Promise.resolve()));
+      if (record.words.length === 1) {
+        const segment = record.words[0].segment;
+        this.$set(record, 'wavData', segment.wavData);
+        this.$set(record, 'src', segment.file_url || '');
+      } else {
+        const merged = await mergeAudio(record.words.map((word) => word.segment.wavData));
+        if (!merged.audio_file_id) throw new Error('合并录音失败');
+        this.$set(record, 'wavData', merged.audio_file_id);
+        this.$set(record, 'src', merged.audio_file_url || '');
+        if (merged.media_duration) this.$set(record, 'toltime', merged.media_duration);
+      }
+      this.$set(record, 'upload_state', 'done');
+      if (this.records.includes(record)) {
+        this.emitRecords();
+        if (this.selectedRecord === record) this.$emit('getWavblob', record.wavData);
+      }
+    },
+    async stopIfRecording() {
+      if (!this.recording) return;
+      if (this.operation) await this.operation;
+      if (!this.recording) return;
+      if (this.currentIndex + 1 < this.sessionWords.length) this.$message.warning('录音提前结束,已保存已录制的词');
+      await this.next('finish');
+    },
+    abortSession() {
+      clearInterval(this.timer);
+      this.clearSegmentGap();
+      this.sessionGeneration += 1;
+      if (this.recorder && !this.startPromise) releaseRecorder(this.recorder);
+      this.recorder = null;
+      this.startPromise = null;
+      if (this.recording) this.$root.isRecording = false;
+      this.recording = false;
+      this.$emit('recordProgress', null);
+    },
+    pausePlayback() {
+      this.audio.pause();
+    },
+    async cancel() {
+      try {
+        await this.$confirm('取消将放弃本次录音,确定?', '提示', { type: 'warning' });
+      } catch (error) {
+        return;
+      }
+      this.abortSession();
+      this.changeRecord(this.selectedIndex);
+    },
+    async playRecording() {
+      if (!this.selectedRecord || this.recording) return;
+      if (this.playing) {
+        this.audio.pause();
+        return;
+      }
+      const record = this.selectedRecord;
+      if (!record.src && !record.wavData) {
+        this.$message.warning('录音正在合并或合并失败,请稍后重试');
+        return;
+      }
+      // 与课文组件一致:优先播放合并返回的地址,历史答案才按 file_id 解析
+      const src = record.src || (await resolveAudioSrc(record.wavData));
+      if (record !== this.selectedRecord) return;
+      if (!src) {
+        this.$message.warning('录音加载失败,请稍后重试');
+        return;
+      }
+      this.$emit('handleParentPlay');
+      this.audio.src = src;
+      playAudioElement(this.audio);
+    },
+    deleteRecording() {
+      if (this.answerMode) return;
+      if (!this.selectedRecord || this.recording || this.busy || this.scoring) return;
+      this.audio.pause();
+      this.records.splice(this.selectedIndex, 1);
+      this.selectedIndex = this.records.length ? this.records.length - 1 : null;
+      this.emitRecords();
+      this.changeRecord(this.selectedIndex);
+    },
+    async showScore() {
+      const record = this.selectedRecord;
+      if (!record || this.recording || this.busy || this.scoring) return;
+      if (!record.words || !record.words.length) {
+        this.$message.warning('历史录音缺少逐词数据,无法评分,请重新录制');
+        return;
+      }
+      if (record.hasScore) {
+        this.visibleScore = true;
+        return;
+      }
+      this.scoring = true;
+      this.scoreIndex = 0;
+      this.scoreTotal = record.words.length;
+      this.scoreGeneration += 1;
+      const generation = this.scoreGeneration;
+      const scores = [];
+      const needPosition = Boolean(record.selectData && record.selectData.type !== 'cell');
+      const withPosition = (score, word) => {
+        if (needPosition && Number.isFinite(word.row) && Number.isFinite(word.column)) {
+          this.$set(score, 'position', `第${word.row + 1}行 第${word.column + 1}列`);
+        }
+        return score;
+      };
+      try {
+        for (const word of record.words) {
+          try {
+            const value = word.segment.wavData;
+            const lrc = word.lrc_data || {};
+            const hasStandard = this.standardUrl && Number.isFinite(lrc.begin_time) && lrc.end_time > lrc.begin_time;
+            const score = await recordSocreSingle({
+              text: word.text,
+              base64: value,
+              audio_paramter_type: value.startsWith('data:audio/') ? 0 : 1,
+              standard: hasStandard ? 'false' : 'true',
+            });
+            if (generation !== this.scoreGeneration || !this.records.includes(record)) return;
+            if (![score.accuracy, score.fluency, score.integrity].every(Number.isFinite)) {
+              throw new Error('评分结果不完整');
+            }
+            score.score_total = Math.max(
+              0,
+              Math.min(100, Math.round((score.accuracy + score.fluency + score.integrity) / 3)),
+            );
+            score.text = word.text;
+            score.isShow = false;
+            if (hasStandard) {
+              score.audio_url_standard = this.standardUrl;
+              score.audio_url_standard_bg = lrc.begin_time;
+              score.audio_url_standard_ed = lrc.end_time;
+            }
+            scores.push(withPosition(score, word));
+          } catch (error) {
+            // 与课文组件一致:单个词失败留占位继续,详情里显示「未读」,单元格气泡显示未读样式
+            console.error('语音矩阵单词评分失败', error);
+            scores.push(withPosition({ text: word.text, isShow: false }, word));
+          }
+          this.scoreIndex += 1;
+        }
+        if (generation !== this.scoreGeneration || !this.records.includes(record)) return;
+        record.words.forEach((word, index) => this.$set(word, 'score', scores[index]));
+        this.$set(record, 'hasScore', true);
+        this.emitRecords();
+        this.$emit('selectRecord', record);
+        this.visibleScore = true;
+      } finally {
+        if (generation === this.scoreGeneration) this.scoring = false;
+      }
+    },
+    handleReset() {
+      this.scoreGeneration += 1;
+      this.scoring = false;
+      this.visibleScore = false;
+      this.abortSession();
+      this.audio.pause();
+      this.records = [];
+      this.selectedIndex = null;
+      this.emitRecords();
+      this.changeRecord(null);
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.matrix-record {
+  display: block;
+  flex: 1 1 auto;
+  min-width: 0;
+}
+
+.record-controls {
+  display: flex;
+  flex-wrap: nowrap;
+  gap: 8px;
+  align-items: center;
+  min-width: 0;
+  min-height: 32px;
+
+  :deep .el-select {
+    flex: 0 0 136px;
+    width: 136px;
+  }
+}
+
+.record-action,
+.play-back {
+  flex: 0 0 auto;
+  cursor: pointer;
+}
+
+.record-action.unavailable {
+  color: #b0b0b0;
+}
+
+.play-back {
+  width: 20px;
+  height: 20px;
+}
+
+.record-time {
+  flex: 0 0 auto;
+  min-width: 42px;
+  font-size: 14px;
+}
+
+.selection-tip {
+  flex: 0 1 auto;
+  min-width: 0;
+  overflow: hidden;
+  font-size: 12px;
+  color: #8b97a8;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+}
+
+// 评分、整体录音、已选提示固定为录音条最后一组
+.record-tail {
+  display: flex;
+  flex: 0 1 auto;
+  flex-wrap: nowrap;
+  gap: 8px;
+  align-items: center;
+  min-width: 0;
+}
+
+.whole-btn {
+  flex: 0 0 auto;
+  color: #e05252;
+  border-color: #e05252;
+  border-radius: 16px;
+}
+
+.score-progress {
+  position: fixed;
+  top: 50%;
+  left: 50%;
+  z-index: 1;
+  display: flex;
+  flex-wrap: wrap;
+  gap: 8px;
+  align-items: center;
+  padding: 10px 18px;
+  font-size: 14px;
+  color: #44515f;
+  background: rgba(255, 255, 255, 97%);
+  border-radius: 14px;
+  box-shadow: 0 8px 30px rgba(30, 50, 80, 25%);
+  transform: translate(-50%, -50%);
+
+  .el-icon-loading {
+    font-size: 20px;
+  }
+}
+</style>

+ 1 - 1
src/views/personal_workbench/template_list/preview/CommonPreview.vue

@@ -27,7 +27,7 @@
         <slot name="middle" :courseware="courseware_info"></slot>
 
         <div class="operator">
-          <el-checkbox v-model="hideRemarkView" v-if="isShowAudit">隐藏批注</el-checkbox>
+          <el-checkbox v-if="isShowAudit" v-model="hideRemarkView">隐藏批注</el-checkbox>
           <span v-if="type !== 'manager' && is_can_edit === 'true'" class="link" @click="editTask">开始编辑</span>
 
           <span class="link" @click="goBackTemplateList">返回模板列表</span>

Некоторые файлы не были показаны из-за большого количества измененных файлов