Browse Source

对话填空添加打点

natasha 2 years ago
parent
commit
eb3301d641

+ 0 - 1
src/components/Adult/common/SegwordConfig.vue

@@ -217,7 +217,6 @@ export default {
   created() {},
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {
-    consoel.log(this.data);
     if (this.curQue) {
       if (!this.curQue.hasOwnProperty("resetFontsize")) {
         this.$set(this.curQue, "resetFontsize", "");

+ 124 - 18
src/components/Adult/inputModules/DialogueTem/index.vue

@@ -137,6 +137,12 @@
         >
           <span>已有字幕时间节点</span>
           <el-button type="text" @click="againWordTime">重新生成</el-button>
+          <el-button @click="compareTime('句子')" size="medium"
+          >校对句子字幕时间</el-button
+          >
+          <el-button @click="compareTime('文字')" size="medium"
+          >校对文字字幕时间</el-button
+          >
         </div>
         <template v-else>
           <el-button v-if="!isWordTime" size="medium" @click="createWordTime"
@@ -181,6 +187,25 @@
       </span>
     </el-dialog>
     <el-dialog
+      title="校对字幕时间"
+      :visible.sync="compareShow"
+      width="50%"
+      :before-close="handleClose"
+      top="0"
+    >
+      <CompareTime
+        :data="compareData"
+        :type="compareType"
+        :changewordsResultList="changewordsResultList"
+      />
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="handleClose">取 消</el-button>
+        <el-button :loading="compareloading" type="primary" @click="saveCompare"
+          >确 定</el-button
+        >
+      </span>
+    </el-dialog>
+    <el-dialog
       :title="roleStatus == 1 ? '添加角色' : '编辑角色'"
       :visible.sync="roleVisible"
       :close-on-click-modal="false"
@@ -213,6 +238,8 @@ import {
   BatchSegContent,
   prepareTranscribe,
   getWordTime,
+  compareSenTenceTime,
+  getContentFile,
 } from "@/api/ajax";
 const Base64 = require("js-base64").Base64;
 import Upload from "../../common/Upload.vue";
@@ -223,6 +250,7 @@ import Clauseresult from "./components/ClauseresultChs.vue";
 import Segbyword from "./components/SegbywordChs.vue";
 import Createtimelist from "./components/CreatetimelistChs.vue";
 import RoleChs from "./components/RoleChs.vue";
+import CompareTime from "../ArticleTemChs/components/CompareTime.vue";
 
 export default {
   name: "ArticleTemChs",
@@ -235,6 +263,7 @@ export default {
     Segbyword,
     Createtimelist,
     RoleChs,
+    CompareTime,
   },
   props: ["curQue", "changeCurQue", "listIndex", "segModel", "type"],
   filters: {
@@ -300,6 +329,10 @@ export default {
       loading: false,
       segList: null,
       isWordTime: false,
+      compareType: "", //校对类型
+      compareShow: false,
+      compareData: null,
+      compareloading: false,
     };
   },
   computed: {},
@@ -325,6 +358,41 @@ export default {
   },
   //方法集合
   methods: {
+    // 得到文件流
+    getfillLiu() {
+      this.loading = true;
+      let _this = this;
+      return new Promise(function (resolve, reject) {
+        if (
+          _this.curQue.mp3_list &&
+          _this.curQue.mp3_list.length > 0 &&
+          _this.curQue.mp3_list[0].id
+        ) {
+          let Mname = "file_store_manager-GetFileByteBase64Text";
+          let id = _this.curQue.mp3_list[0].id
+            .replace("[FID##", "")
+            .replace("##FID]", "");
+          let data = {
+            file_id: id,
+          };
+          getContentFile(Mname, data).then((res) => {
+            let taskIddata = {
+              fileName: _this.curQue.mp3_list[0].name,
+              speechBase64: res.base64_text,
+              language: "ch",
+            };
+            prepareTranscribe(taskIddata).then((ress) => {
+              _this.$set(_this.curQue, "taskId", ress.data.taskId);
+              _this.loading = false;
+              resolve();
+            });
+          });
+        } else {
+          _this.$message.warning("请先上传音频");
+          _this.loading = false;
+        }
+      });
+    },
     onBlur(item, field) {
       item[field] = item[field] ? item[field].trim() : "";
     },
@@ -571,26 +639,30 @@ export default {
       });
     },
     createWordTime() {
-      if (this.curQue.taskId) {
-        let verseList = [];
-        this.curQue.detail.forEach((item) => {
-          verseList = verseList.concat(item.sentences);
-        });
-        if (verseList.length > 0) {
-          this.isWordTime = true;
-          let data = {
-            taskId: this.curQue.taskId,
-            verseList: JSON.stringify(verseList),
-            language: "ch",
-          };
-          getWordTime(data).then((res) => {
-            this.curQue.wordTime = res.data.result;
-            this.isWordTime = false;
+      this.getfillLiu().then(() => {
+        if (this.curQue.taskId) {
+          let verseList = [];
+          this.curQue.detail.forEach((item) => {
+            verseList = verseList.concat(item.sentences);
           });
+          if (verseList.length > 0) {
+            this.isWordTime = true;
+            let data = {
+              taskId: this.curQue.taskId,
+              verseList: JSON.stringify(verseList),
+              matchType: "chinese",
+              language: "ch",
+            };
+            getWordTime(data).then((res) => {
+              this.curQue.wordTime = res.data.result;
+              this.isWordTime = false;
+            });
+          }
+        } else {
+          this.$message.warning("请先上传音频");
+          this.loading = false;
         }
-      } else {
-        this.$message.warning("请先上传音频");
-      }
+      });
     },
     againWordTime() {
       this.isWordTime = false;
@@ -658,6 +730,40 @@ export default {
 
       }
     },
+    // 保存校对
+    saveCompare() {
+      if (this.compareType == "文字") {
+        this.compareloading = false;
+        return;
+      }
+      this.compareloading = true;
+      compareSenTenceTime({ matchList: JSON.stringify(this.compareData) })
+        .then((res) => {
+          console.log(res);
+          this.compareloading = false;
+          this.curQue.wordTime = res.data.result;
+        })
+        .catch(() => {
+          this.compareloading = false;
+        });
+    },
+    // 校对时间
+    compareTime(type) {
+      this.compareType = type;
+      this.compareData = JSON.parse(JSON.stringify(this.curQue.wordTime));
+      this.compareShow = true;
+    },
+    handleClose() {
+      this.compareShow = false;
+      this.compareData = null;
+      this.compareType = "";
+    },
+    // 校对每个字的时间
+    changewordsResultList(index, item) {
+      this.curQue.wordTime[index].wordsResultList = JSON.parse(
+        JSON.stringify(item)
+      );
+    },
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {},

+ 130 - 39
src/components/Adult/preview/DialogueArticleViewChs/AnswerModel.vue

@@ -16,6 +16,7 @@
         :mp3="curQue.mp3_list[0].id"
         :getCurTime="getCurTime"
         ref="audioLine"
+        :width="audioWidth"
       />
     </div>
     <template v-if="resArr.length > 0">
@@ -62,6 +63,17 @@
                       : 'textCenter',
                     pItem.chs == '“' ? 'textRight' : '',
                   ]"
+                  @click="
+                    handleChangeTime(
+                      item.timeList &&
+                        item.timeList.length > 0 &&
+                        item.timeList[pItem.sentIndex].bg,
+                      item,
+                      item.timeList &&
+                        item.timeList.length > 0 &&
+                        item.timeList[pItem.sentIndex].ed
+                    )
+                  "
                 >
                   <template v-if="!pItem.width">
                     <template v-if="pItem.isShow">
@@ -86,12 +98,31 @@
                           >
                           <template v-if="!pItem.isHeng">
                             <span
+                                v-for="(wItem, wIndex) in pItem.leg"
+                                :key="'ci' + wIndex + pIndex + index"
+                                :class="[
+                                  pItem.chstimeList &&
+                                  pItem.chstimeList[wIndex] &&
+                                  curTime >= pItem.chstimeList[wIndex].wordBg &&
+                                  curTime < item.timeList[pItem.sentIndex].ed
+                                    ? 'wordActive'
+                                    : '',
+                                  'NNPE-chs',
+                                  pItem.config.underLine
+                                  ? 'NNPE-chs-underline'
+                                  : '',
+                                ]"
+                                :style="hengStyle(pItem.config)"
+                                >{{
+                                  pItem.chs[wIndex]
+                                }}</span
+                              >
+                            <!-- <span
                               class="NNPE-chs"
                               :class="[
-                                item.timeList.length > 0 &&
-                                curTime >=
-                                  item.timeList[pItem.sentIndex]
-                                    .wordsResultList[pItem.wordIndex].wordBg &&
+                                pItem.chstimeList &&
+                                  pItem.chstimeList[wIndex] &&
+                                  curTime >= pItem.chstimeList[wIndex].wordBg &&
                                 curTime <= item.timeList[pItem.sentIndex].ed
                                   ? 'wordActive'
                                   : '',
@@ -101,7 +132,7 @@
                               ]"
                               :style="hengStyle(pItem.config)"
                               >{{ pItem.chs }}</span
-                            >
+                            > -->
                           </template>
                           <template v-else>
                             <template v-if="judgeAnswer == 'standardAnswer'">
@@ -184,16 +215,16 @@
                               item.wordsList[pIndex + 1].pinyin | handlePY
                             }}</span
                           >
-
                           <span
                             class="NNPE-chs"
                             style="text-align: left"
                             :class="[
                               item.timeList.length > 0 &&
+                              pItem.chstimeList &&
+                              pItem.chstimeList[pItem.leg - 1] &&
                               curTime >=
-                                item.timeList[pItem.sentIndex].wordsResultList[
-                                  pItem.wordIndex
-                                ].wordBg &&
+                                pItem.chstimeList[pItem.leg - 1].wordBg &&
+                                curQue.wordTime &&
                               curTime <= item.timeList[pItem.sentIndex].ed
                                 ? 'wordActive'
                                 : '',
@@ -248,7 +279,6 @@
                             class="NNPE-chs"
                             style="text-align: left"
                             :class="[
-                              isPlaying &&
                               item.timeList &&
                               item.timeList[pItem.sentIndex] &&
                               curTime >= item.timeList[pItem.sentIndex].bg &&
@@ -300,15 +330,43 @@
                           >{{ pItem.pinyin | handlePY }}</span
                         >
                         <template v-if="!pItem.isHeng">
-                          <span
+                            <span
+                                v-if="pItem.chs != '#'"
+                                class="NNPE-chs"
+                                :class="[
+                                    pItem.chs != '“' && pItem.padding && item.isHasPY ? 'padding' : '',
+                                ]"
+                                >
+                            <template>
+                                <span
+                                v-for="(wItem, wIndex) in pItem.leg"
+                                :key="'ci' + wIndex + pIndex + index"
+                                :class="[
+                                    pItem.chstimeList &&
+                                    pItem.chstimeList[wIndex] &&
+                                    curTime >= pItem.chstimeList[wIndex].wordBg &&
+                                    curTime <= item.timeList[pItem.sentIndex].ed
+                                    ? 'wordActive'
+                                    : '',
+                                    'NNPE-chs',
+                                    pItem.config.underLine
+                                    ? 'NNPE-chs-underline'
+                                    : '',
+                                ]"
+                                :style="hengStyle(pItem.config)"
+                                >{{
+                                    pItem.chs[wIndex]
+                                }}</span
+                                >
+                            </template>
+                            </span>
+                          <!-- <span
                             v-if="pItem.chs != '#'"
                             class="NNPE-chs"
                             :class="[
-                              item.timeList.length > 0 &&
-                              curTime >=
-                                item.timeList[pItem.sentIndex].wordsResultList[
-                                  pItem.wordIndex
-                                ].wordBg &&
+                              pItem.chstimeList &&
+                                pItem.chstimeList[wIndex] &&
+                                curTime >= pItem.chstimeList[wIndex].wordBg &&
                               curTime <= item.timeList[pItem.sentIndex].ed
                                 ? 'wordActive'
                                 : '',
@@ -321,7 +379,7 @@
                             ]"
                             :style="hengStyle(pItem.config)"
                             >{{ pItem.chs }}</span
-                          >
+                          > -->
                         </template>
                         <template v-else>
                           <template v-if="judgeAnswer == 'standardAnswer'">
@@ -631,6 +689,7 @@ export default {
     "Bookanswer",
     "TaskModel",
     "judgeAnswer",
+    "audioWidth"
   ],
   components: {
     AudioLine,
@@ -731,7 +790,7 @@ export default {
           minHeight: Number(sizeVal) + 9 + "px",
           lineHeight: Number(sizeVal) + 8 + "px",
           fontSize: config ? config.fontSize : '20px',
-          fontFamily: config ? config.fontFamily : 'FZJCGFKTK'
+          fontFamily: config ? config.fontFamily : 'FZJCGFKTK',
         };
       };
     },
@@ -791,9 +850,11 @@ export default {
     },
     handleData() {
       let resArr = [];
+      let curQue = JSON.parse(JSON.stringify(this.curQue));
+      let wordTimeList = curQue.wordTime;
       let reg = /_{2,}/g;
       let leg = this.curQue.detail.length;
-      let curQue = JSON.parse(JSON.stringify(this.curQue));
+      let asIndex = 0;
       this.curQue.answerArr = this.curQue.answer
         ? this.curQue.answer.split("\n")
         : [];
@@ -809,7 +870,17 @@ export default {
         let paraArr = [];
         if (dItem.wordsList && dItem.wordsList.length > 0) {
           dItem.wordsList.forEach((sItem, sIndex) => {
+            let sentArr = [];
             sItem.forEach((wItem, wIndex) => {
+              let startIndex =
+              wIndex == 0
+                ? 0
+                : sentArr[wIndex - 1].startIndex +
+                  sentArr[wIndex - 1].chs.length;
+              let endIndex =
+              wIndex == 0
+                ? wItem.chs.length
+                : sentArr[wIndex - 1].endIndex + wItem.chs.length;
               this.mergeWordSymbol(wItem);
               if (wItem.pinyin) {
                 isHasPY++;
@@ -832,14 +903,28 @@ export default {
                   underLine: wItem.underLine,
                   wordPadding: wItem.wordPadding,
                 },
+                leg: wItem.chs.length,
+                chstimeList: [],
+                startIndex: startIndex,
+                endIndex: endIndex,
               };
+              if (wordTimeList && wordTimeList.length > 0) {
+                obj.chstimeList = wordTimeList[asIndex].wordsResultList.slice(
+                    startIndex,
+                    endIndex
+                );
+                }
               if (obj.isHeng) {
                 isRecord = isRecord + 1;
                 hengIndex = hengIndex + 1;
                 obj.hengIndex = hengIndex;
                 obj.answer = "";
               }
+              sentArr.push(obj);
               paraArr.push(obj);
+              if (wIndex == sItem.length - 1) {
+                asIndex++;
+              }
             });
           });
           let curSentencesLeg = dItem.sentences.length;
@@ -871,6 +956,7 @@ export default {
         }
       });
       this.resArr = resArr;
+      console.log(resArr)
       // 循环文章图片
       if (curQue.img_list) {
         curQue.img_list.forEach((item) => {
@@ -953,9 +1039,12 @@ export default {
       return listRes;
     },
     //点击播放某个句子
-    handleChangeTime(time) {
-      this.curTime = time;
-      this.$refs.audioLine.onTimeupdateTime(time / 1000);
+    handleChangeTime(time, item, ed) {
+    if (item.timeList && item.timeList.length > 0) {
+        this.curTime = time;
+        this.$refs.audioLine.onTimeupdateTime(time / 1000, true);
+      }
+      this.ed = ed;
     },
     //处理数组
     handlePara(para) {
@@ -1079,7 +1168,7 @@ export default {
       &-box {
         float: left;
         > span {
-          display: block;
+        //   display: block;
           &.NNPE-pinyin {
             font-family: "GB-PINYINOK-B";
             font-weight: normal;
@@ -1093,6 +1182,9 @@ export default {
             &.textLeft {
               text-align: left;
             }
+            &.wordActive {
+              color: #de4444;
+            }
           }
           &.NNPE-chs {
             font-family: "FZJCGFKTK";
@@ -1108,6 +1200,12 @@ export default {
             &.NNPE-chs-underline {
               text-decoration: underline;
             }
+            .NNPE-chs-underline {
+              text-decoration: underline;
+            }
+            .wordActive {
+              color: #de4444;
+            }
           }
           &.padding {
             padding: 0 3px;
@@ -1138,6 +1236,9 @@ export default {
           &.textLeft {
             text-align: left;
           }
+          &.wordActive {
+            color: #de4444;
+          }
         }
         &.NNPE-chs {
           font-family: "FZJCGFKTK";
@@ -1153,27 +1254,17 @@ export default {
           &.NNPE-chs-underline {
             text-decoration: underline;
           }
+          .NNPE-chs-underline {
+              text-decoration: underline;
+          }
+          .wordActive {
+            color: #de4444;
+          }
         }
         &.padding {
           padding: 0 3px;
         }
       }
-      .answer-input {
-        min-height: 28px;
-        box-sizing: border-box;
-        border: 0;
-        border-bottom: 1px #000 solid;
-        background: 0 0;
-        min-width: 100px;
-        outline: 0;
-        text-align: left;
-        font-family: "FZJCGFKTK";
-        font-size: 20px;
-        padding: 0 10px;
-        box-sizing: border-box;
-        color: #000000;
-        line-height: 26px;
-      }
     }
     .enwords {
       font-family: "robot";

+ 4 - 1
src/components/Adult/preview/DialogueArticleViewChs/DialogueAnswerViewChs.vue

@@ -60,6 +60,7 @@
                 :TaskModel="TaskModel"
                 :listIndex="index"
                 :judgeAnswer="judgeAnswer"
+                :audioWidth="item.number?592:620"
               />
             </div>
             <template
@@ -106,6 +107,7 @@
                 :listIndex="index"
                 :TaskModel="TaskModel"
                 :judgeAnswer="judgeAnswer"
+                :audioWidth="item.number?592:620"
               />
             </div>
             <template
@@ -366,7 +368,8 @@ export default {
       line-height: 150%;
       color: #ffffff;
       font-family: "robot";
-      margin-top: 8px;
+      margin-top: 4px;
+      flex-shrink: 0;
     }
   }
   .dialogue-answer-model {