guanchunjie пре 3 година
родитељ
комит
c505d99a4e

+ 1 - 1
src/api/ajax.js

@@ -220,7 +220,7 @@ export function createPinyin(data) {
     SessionID = user.session_id;
   }
   return request({
-    url: `/GCLSFCServer/GCLSHMToolsServer/api/nlp/chinese/text2pinyin?UserCode=${UserCode}&UserType=${UserType}&SessionID=${SessionID}`,
+    url: `/GCLSHMToolsServer/api/nlp/chinese/text2pinyin?UserCode=${UserCode}&UserType=${UserType}&SessionID=${SessionID}`,
     method: 'post',
     data
   })

+ 2 - 2
src/components/Adult/common/NewordPhraseModule.vue

@@ -34,8 +34,8 @@
           <el-input
             style="width: 300px"
             placeholder="请输入词性"
-            v-model="curQueItem.speech"
-            @blur="onBlur(curQueItem, 'speech')"
+            v-model="curQueItem.cixing"
+            @blur="onBlur(curQueItem, 'cixing')"
           ></el-input>
         </div>
 

+ 13 - 10
src/components/Adult/inputModules/ArticleTemChs/components/ArticleChs.vue

@@ -47,19 +47,22 @@ export default {
     createPara() {
       let paraArr = this.curQue.article.split(/\n+/g);
 
-      //this.$set(this.curQue, "detail", []);
+      this.$set(this.curQue, "detail", []);
       for (let i = 0; i < paraArr.length; i++) {
         let con = paraArr[i];
         let detailItem = JSON.parse(JSON.stringify(this.detailItem));
-        if (this.curQue.detail.length == 0) {
-          detailItem.para = con;
-          detailItem.paraIndex = i;
-          this.curQue.detail.push(detailItem);
-        } else {
-          if (!(this.curQue.detail[i] && this.curQue.detail[i].para == con)) {
-            this.$set(this.curQue.detail[i], "para", con);
-          }
-        }
+        detailItem.para = con;
+        detailItem.paraIndex = i;
+        this.curQue.detail.push(detailItem);
+        // if (this.curQue.detail.length == 0) {
+        //   detailItem.para = con;
+        //   detailItem.paraIndex = i;
+        //   this.curQue.detail.push(detailItem);
+        // } else {
+        //   if (!(this.curQue.detail[i] && this.curQue.detail[i].para == con)) {
+        //     this.$set(this.curQue.detail[i], "para", con);
+        //   }
+        // }
       }
       this.changeIsPara();
       this.$message.success("生成成功");

+ 1 - 2
src/components/Adult/inputModules/ArticleTemChs/components/SegbywordChs.vue

@@ -184,7 +184,6 @@ export default {
     },
     //获取段落中句子分词结果
     getParaSegWordsResult() {
-      debugger;
       let detail = this.curQue.detail;
       for (let i = 0; i < detail.length; i++) {
         if (detail[i].paraIndex == this.paraIndex) {
@@ -299,7 +298,7 @@ export default {
     save() {
       let _this = this;
       let paraCon = JSON.parse(JSON.stringify(this.paraCon));
-      _this.$set(_this.curQue.detail, _this.paraIndex, paraCon);
+      _this.$set(_this.curQue.detail, _this.proofParaIndex, paraCon);
       _this.$message.success("保存成功");
     },
     //上一句

+ 6 - 3
src/components/Adult/inputModules/ArticleTemChs/index.vue

@@ -210,6 +210,7 @@ export default {
               },
             ],
           },
+
           {
             bg: "11990",
             ed: "16490",
@@ -3142,7 +3143,7 @@ export default {
         });
         this.loading = true;
         let data = {
-          text: textList,
+          textList: textList,
         };
         segSentences(data).then((res) => {
           this.loading = false;
@@ -3161,7 +3162,6 @@ export default {
     },
     //生成分词
     segByWord(sentences, paraIndex) {
-      debugger;
       console.log(sentences);
       this.loading = true;
       let textList = [];
@@ -3174,7 +3174,7 @@ export default {
       };
       BatchSegContent(data).then((res) => {
         this.loading = false;
-        let list = res.data.result.list;
+        let list = res.data.result;
         this.$set(this.curQue.detail[paraIndex], "segList", list);
         console.log(this.curQue);
         this.segList = list;
@@ -3223,6 +3223,9 @@ export default {
     console.log("ArticleTem");
     console.log(this.curQue);
     if (this.curQue) {
+      if (this.curQue.detail[0].para) {
+        this.isPara = true;
+      }
       if (this.curQue.detail[0].sentences.length > 0) {
         this.isClause = true;
       }

+ 1 - 1
src/components/Adult/inputModules/Neword.vue

@@ -49,7 +49,7 @@ export default {
         option: [
           {
             new_word: "",
-            speech: "", //词性
+            cixing: "", //词性
             definition_list: [""], //需要增加词性
             pinyin: "",
             img_list: [],

+ 307 - 0
src/components/Adult/preview/ArticleViewChs/Practicechs copy.vue

@@ -0,0 +1,307 @@
+<!--  -->
+<template>
+  <div class="NNPE-ArticleView" v-if="curQue">
+    <AudioLine
+      :mp3="curQue.mp3_list[0].url"
+      :getCurTime="getCurTime"
+      ref="audioLine"
+    />
+    <template v-if="resObj">
+      <div
+        class="NNPE-detail"
+        v-for="(item, index) in resObj.sentList"
+        :key="'detail' + index"
+        @click="handleChangeTime(resObj.timeList[index])"
+      >
+        <div
+          class="NNPE-words"
+          v-for="(pItem, pIndex) in item"
+          :key="'wordsList' + pIndex"
+          :class="[pItem.wordIndex == 0 ? 'textLeft' : 'textCenter']"
+        >
+          <template v-if="!pItem.width">
+            <span
+              class="NNPE-pinyin"
+              :class="[
+                pItem.padding ? 'padding' : '',
+                pItem.className ? pItem.className : '',
+              ]"
+              >{{ pItem.pinyin }}</span
+            >
+
+            <span
+              class="NNPE-chs"
+              :class="[
+                curTime >= resObj.timeList[index] &&
+                curTime <= resObj.timeList[index + 1] &&
+                curTime >= pItem.startTime
+                  ? 'active'
+                  : '',
+                pItem.padding ? 'padding' : '',
+              ]"
+              >{{ pItem.chs }}</span
+            >
+          </template>
+          <template v-else>
+            <span
+              :style="{
+                height: pItem.height + 'px',
+                width: pItem.width + 'px',
+              }"
+            ></span>
+          </template>
+        </div>
+      </div>
+    </template>
+  </div>
+</template>
+
+<script>
+import { timeStrToSen } from "@/utils/index";
+import AudioLine from "../AudioLine.vue";
+export default {
+  name: "ArticleView",
+  props: ["curQue"],
+  components: {
+    AudioLine,
+  },
+  data() {
+    return {
+      resObj: null,
+      curTime: 0, //单位s
+      chsFhList: [",", "。", "“", ":", "》", "《", "?", "!", ";"],
+      enFhList: [",", ".", ";", "?", "!", ":", ">", "<"],
+    };
+  },
+  computed: {},
+  watch: {},
+  //方法集合
+  methods: {
+    getCurTime(curTime) {
+      this.curTime = curTime;
+    },
+    handleData() {
+      let resArr = [],
+        timeArr = [];
+      let leg = this.curQue.detail.length;
+      let curQue = JSON.parse(JSON.stringify(this.curQue));
+      curQue.detail.forEach((dItem, dIndex) => {
+        let endTime = 0;
+        if (dIndex < leg - 1) {
+          endTime = curQue.detail[dIndex + 1].timeList[0];
+          dItem.timeList.push(endTime);
+          dItem.timeList = this.handleTimeList(dItem.timeList);
+        } else {
+          dItem.timeList = this.handleTimeList(dItem.timeList);
+          endTime = curQue.mp3_list[0].duration;
+          dItem.timeList.push(endTime);
+        }
+
+        dItem.wordsList.forEach((sItem, sIndex) => {
+          let sentArr = [];
+          sItem.forEach((wItem, wIndex) => {
+            let obj = {
+              paraIndex: dIndex, //段落索引
+              sentIndex: sIndex, //在段落中句子索引
+              wordIndex: wIndex, //单词的索引
+              pinyin: wItem.pinyin,
+              chs: wItem.chs,
+              padding: wItem.padding,
+              className: wItem.className,
+              startTime: startTime,
+              endTime: endTime,
+            };
+            sentArr.push(obj);
+          });
+          resArr.push(sentArr);
+        });
+
+        timeArr.push(dItem.timeList);
+      });
+      let timeList = [];
+      timeArr.forEach((item) => {
+        item.forEach((aItem) => {
+          if (timeList.indexOf(aItem) < 0) {
+            timeList.push(aItem);
+          }
+        });
+      });
+      this.resObj = { sentList: resArr, timeList: timeList };
+      console.log(this.resObj);
+    },
+    handleData2() {
+      let resArr = [],
+        timeArr = [];
+      let leg = this.curQue.detail.length;
+      let curQue = JSON.parse(JSON.stringify(this.curQue));
+      curQue.detail.forEach((dItem, dIndex) => {
+        let endTime = 0;
+        if (dIndex < leg - 1) {
+          endTime = curQue.detail[dIndex + 1].timeList[0];
+          dItem.timeList.push(endTime);
+          dItem.timeList = this.handleTimeList(dItem.timeList);
+        } else {
+          dItem.timeList = this.handleTimeList(dItem.timeList);
+          endTime = curQue.mp3_list[0].duration;
+          dItem.timeList.push(endTime);
+        }
+
+        dItem.wordsList.forEach((sItem, sIndex) => {
+          let time_diff = dItem.timeList[sIndex + 1] - dItem.timeList[sIndex];
+          let wordsLeg = dItem.sentences[sIndex].length;
+          let wordTime = time_diff / wordsLeg;
+          // console.log(time_diff, wordsLeg, wordTime);
+          let sentArr = [];
+          sItem.forEach((wItem, wIndex) => {
+            let preTotal = wIndex > 0 ? sentArr[wIndex - 1].endTime : 0;
+            let endTime =
+              wIndex > 0
+                ? wordTime * wItem.chs.length + preTotal
+                : dItem.timeList[sIndex] + wordTime * wItem.chs.length;
+            //console.log("endTime" + endTime);
+            let startTime =
+              wIndex > 0 ? sentArr[wIndex - 1].endTime : dItem.timeList[sIndex];
+            this.judgePad(sItem, wItem, wIndex);
+            let obj = {
+              paraIndex: dIndex, //段落索引
+              sentIndex: sIndex, //在段落中句子索引
+              wordIndex: wIndex, //单词的索引
+              pinyin: wItem.pinyin,
+              chs: wItem.chs,
+              padding: wItem.padding,
+              className: wItem.className,
+              startTime: startTime,
+              endTime: endTime,
+            };
+            sentArr.push(obj);
+          });
+          resArr.push(sentArr);
+        });
+
+        timeArr.push(dItem.timeList);
+      });
+      let timeList = [];
+      timeArr.forEach((item) => {
+        item.forEach((aItem) => {
+          if (timeList.indexOf(aItem) < 0) {
+            timeList.push(aItem);
+          }
+        });
+      });
+      this.resObj = { sentList: resArr, timeList: timeList };
+      console.log(this.resObj);
+    },
+    //判断是否有padding
+    judgePad(sItem, wItem, curIndex) {
+      let leg = sItem.length;
+      if (curIndex < leg - 1) {
+        let nextIndex = curIndex + 1;
+        let chs = sItem[nextIndex].chs;
+        if (
+          this.chsFhList.indexOf(chs) > -1 ||
+          this.chsFhList.indexOf(wItem.chs) > -1
+        ) {
+          wItem.padding = false;
+        } else {
+          wItem.padding = true;
+        }
+        if (this.enFhList.indexOf(wItem.pinyin) > -1) {
+          wItem.className = "textLeft";
+        }
+      }
+    },
+    //转化时间
+    handleTimeList(list) {
+      let listRes = [];
+      list.forEach((item) => {
+        let res = timeStrToSen(item);
+        listRes.push(res);
+      });
+      return listRes;
+    },
+    //计算总时间
+    countWordTime(sentArr) {
+      let total = 0;
+      sentArr.forEach((item) => {
+        total += item.endTime;
+      });
+      return total;
+    },
+    //点击播放某个句子
+    handleChangeTime(time) {
+      this.curTime = time;
+      this.$refs.audioLine.onTimeupdateTime(time);
+    },
+  },
+  //生命周期 - 创建完成(可以访问当前this实例)
+  created() {},
+  //生命周期 - 挂载完成(可以访问DOM元素)
+  mounted() {
+    console.log(this.curQue);
+    if (this.curQue) {
+      this.handleData();
+    }
+  },
+  beforeCreate() {}, //生命周期 - 创建之前
+  beforeMount() {}, //生命周期 - 挂载之前
+  beforeUpdate() {}, //生命周期 - 更新之前
+  updated() {}, //生命周期 - 更新之后
+  beforeDestroy() {}, //生命周期 - 销毁之前
+  destroyed() {}, //生命周期 - 销毁完成
+  activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
+};
+</script>
+<style lang='scss' scoped>
+//@import url(); 引入公共css类
+.NNPE-ArticleView {
+  width: 100%;
+  .NNPE-detail {
+    clear: both;
+    overflow: hidden;
+    width: 100%;
+    background: #ffffff;
+    border: 1px solid rgba(0, 0, 0, 0.1);
+    box-sizing: border-box;
+    border-radius: 8px;
+    margin-bottom: 8px;
+    box-sizing: border-box;
+    padding: 8px 16px 0px;
+    .NNPE-words {
+      float: left;
+      padding: 0 0px 8px 0px;
+      &.textLeft {
+        text-align: left;
+      }
+      &.textCenter {
+        text-align: center;
+      }
+      > span {
+        display: block;
+        &.NNPE-pinyin {
+          font-family: "GB-PINYINOK-B";
+          font-weight: normal;
+          font-size: 14px;
+          line-height: 20px;
+          color: #000000;
+          height: 20px;
+          &.textLeft {
+            text-align: left;
+          }
+        }
+        &.NNPE-chs {
+          font-family: "FZJCGFKTK";
+          font-size: 20px;
+          line-height: 150%;
+          color: #000000;
+          &.active {
+            background: rgba(60, 200, 99, 0.2);
+          }
+        }
+        &.padding {
+          padding-right: 6px;
+        }
+      }
+    }
+  }
+}
+</style>

+ 81 - 12
src/components/Adult/preview/ArticleViewChs/Practicechs.vue

@@ -29,18 +29,23 @@
               >{{ pItem.pinyin }}</span
             >
 
-            <span
-              class="NNPE-chs"
-              :class="[
-                curTime >= resObj.timeList[index] &&
-                curTime <= resObj.timeList[index + 1] &&
-                curTime >= pItem.startTime
-                  ? 'active'
-                  : '',
-                pItem.padding ? 'padding' : '',
-              ]"
-              >{{ pItem.chs }}</span
-            >
+            <span class="NNPE-chs" :class="[pItem.padding ? 'padding' : '']">
+              <template v-if="pItem.timeList && pItem.timeList.length > 0">
+                <span
+                  v-for="(wItem, wIndex) in pItem.leg"
+                  :key="'ci' + wIndex + pIndex + index"
+                  :class="[
+                    pItem.timeList[wIndex] &&
+                    curTime >= pItem.timeList[wIndex].wordBg &&
+                    curTime <= resObj.timeList[index + 1]
+                      ? 'active'
+                      : '',
+                  ]"
+                  >{{ pItem.chs[wIndex] }}</span
+                >
+              </template>
+              <!-- {{ pItem.chs }} -->
+            </span>
           </template>
           <template v-else>
             <span
@@ -81,6 +86,70 @@ export default {
       this.curTime = curTime;
     },
     handleData() {
+      debugger;
+      let resArr = [],
+        timeArr = [];
+      let curQue = JSON.parse(JSON.stringify(this.curQue));
+      let wordTimeList = curQue.wordTime;
+      curQue.detail.forEach((dItem, dIndex) => {
+        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.judgePad(sItem, wItem, wIndex);
+            let obj = {
+              paraIndex: dIndex, //段落索引
+              sentIndex: sIndex, //在段落中句子索引
+              wordIndex: wIndex, //单词的索引
+              pinyin: wItem.pinyin,
+              chs: wItem.chs,
+              padding: wItem.padding,
+              className: wItem.className,
+              startIndex: startIndex,
+              endIndex: endIndex,
+              leg: wItem.chs.length,
+              timeList: [],
+            };
+            sentArr.push(obj);
+          });
+          resArr.push(sentArr);
+        });
+
+        timeArr.push(dItem.timeList);
+      });
+      this.mergeWordTime(resArr, wordTimeList);
+      let timeList = [];
+      timeArr.forEach((item) => {
+        item.forEach((aItem) => {
+          if (timeList.indexOf(aItem) < 0) {
+            timeList.push(aItem);
+          }
+        });
+      });
+      this.resObj = { sentList: resArr, timeList: timeList };
+      console.log(this.resObj);
+    },
+    mergeWordTime(resArr, wordTimeList) {
+      resArr.forEach((item, index) => {
+        debugger;
+        let wordsResultList = wordTimeList[index].wordsResultList;
+        item.forEach((wItem) => {
+          let startIndex = wItem.startIndex;
+          let endIndex = wItem.endIndex;
+          wItem.timeList = wordsResultList.slice(startIndex, endIndex);
+        });
+      });
+    },
+    handleData2() {
       let resArr = [],
         timeArr = [];
       let leg = this.curQue.detail.length;

+ 27 - 0
src/views/adultInput.vue

@@ -615,14 +615,41 @@ export default {
     deleteCurQue(item, queIndex) {
       item.queList.splice(queIndex, 1);
     },
+    saveNewwordAndSentences() {
+      let question_list = this.question_list;
+      let sentence_list = [],
+        new_word_list = [];
+      question_list.forEach((item) => {
+        item.cur_fn_data.forEach((curItem) => {
+          curItem.table_list.forEach((tabItem) => {
+            tabItem.forEach((topicIitem) => {
+              if (topicIitem.type == "article_chs") {
+                topicIitem.data.detail.forEach((item) => {
+                  sentence_list = sentence_list.concat(item.sentences);
+                });
+              } else if (topicIitem.type == "NewWord_chs") {
+                new_word_list = topicIitem.data.option;
+              }
+            });
+          });
+        });
+      });
+      return {
+        new_word_list: new_word_list,
+        sentence_list: sentence_list,
+      };
+    },
     onSave() {
       let question_list_str = JSON.stringify(this.question_list);
       localStorage.setItem("question_list", question_list_str);
+      let result = this.saveNewwordAndSentences();
       this.$message.success("保存成功");
       const MethodName = "book-courseware_manager-SaveCoursewareContent";
       let data = {
         id: this.currentTreeID,
         content: JSON.stringify(this.question_list),
+        new_word_list: result.new_word_list,
+        sentence_list: result.sentence_list,
       };
       getContent(MethodName, data)
         .then((res) => {})