Просмотр исходного кода

按要求去掉文章录入时自动调用分词接口

natasha 2 недель назад
Родитель
Сommit
d7fe016e20

+ 43 - 15
src/views/book/courseware/create/components/question/article/Article.vue

@@ -3,7 +3,7 @@
     <template #content>
       <!-- eslint-disable max-len -->
       <div v-loading="loading" class="article-wrapper">
-        <el-input v-model="data.content" placeholder="输入" type="textarea" @change="handleChangeContent" />
+        <el-input v-model="data.content" placeholder="输入" type="textarea" />
         <SelectUpload label="课文音频" type="audio" width="500px" @uploadSuccess="uploadAudioSuccess" />
         <div v-if="data.mp3_list.length > 0" class="upload-file">
           <div class="file-name">
@@ -304,7 +304,15 @@ export default {
     },
     // 校对文章
     checkArticle() {
-      this.showArticleFlag = true;
+      let verseList = [];
+      this.data.detail.forEach((item) => {
+        verseList = verseList.concat(item.sentences);
+      });
+      if (verseList.length > 0) {
+        this.showArticleFlag = true;
+      } else {
+        this.$message.warning('请先生成分词');
+      }
     },
     saveWord(saveArr) {
       saveArr.forEach((item, index) => {
@@ -465,17 +473,21 @@ export default {
           _this.data.detail.forEach((item) => {
             verseList = verseList.concat(item.sentences);
           });
-          _this.isWordTime = true;
-          let data = {
-            audio_file_id: _this.data.mp3_list[0].file_id,
-            text: _this.data.content,
-            text_type: 'line_text_list',
-            line_text_list: verseList,
-          };
-          getWordTimes(data).then((res) => {
-            _this.data.wordTime = res.data.result;
-            _this.isWordTime = false;
-          });
+          if (verseList.length > 0) {
+            _this.isWordTime = true;
+            let data = {
+              audio_file_id: _this.data.mp3_list[0].file_id,
+              text: _this.data.content,
+              text_type: 'line_text_list',
+              line_text_list: verseList,
+            };
+            getWordTimes(data).then((res) => {
+              _this.data.wordTime = res.data.result;
+              _this.isWordTime = false;
+            });
+          } else {
+            this.$message.warning('请先生成分词');
+          }
         }
       } else {
         _this.$message.warning('请先上传音频');
@@ -561,8 +573,12 @@ export default {
     },
     handleMultilingual() {
       this.multilingualText = '';
+      let flag = false;
       this.data.detail.forEach((item) => {
         if (item.para) {
+          if (item.sentences && item.sentences.length > 0) {
+            flag = true;
+          }
           item.sentences.forEach((items) => {
             this.multilingualText += `<p>${items}<p>`;
           });
@@ -571,11 +587,23 @@ export default {
         }
         // this.multilingualText += item.para ? '<p>' + item.para + '<p>' : '<p>&nbsp;</p>';
       });
-      this.multilingualVisible = true;
+      if (flag) {
+        this.multilingualVisible = true;
+      } else {
+        this.$message.warning('请先生成分词');
+      }
     },
     // 点击插入图片按钮
     picArticle() {
-      this.showPicArticleFlag = true;
+      let verseList = [];
+      this.data.detail.forEach((item) => {
+        verseList = verseList.concat(item.sentences);
+      });
+      if (verseList.length > 0) {
+        this.showPicArticleFlag = true;
+      } else {
+        this.$message.warning('请先生成分词');
+      }
     },
   },
 };