natasha пре 1 месец
родитељ
комит
8615e81c9a

+ 91 - 77
src/views/book/courseware/create/components/question/article/Article.vue

@@ -198,9 +198,7 @@
               }}</span>
             </el-option>
           </el-select>
-          <p class="tips">
-            一到四声分别用数字1-4表示。拼音间用空格隔开,儿化音用_代替空格,如“骨朵儿”输入“gu1 duo3_er”。
-          </p>
+          <p class="tips">一到四声分别用数字1-4表示。拼音间用空格隔开,儿化音输入r,如“活儿”输入“huor2”。</p>
           <div class="btn-box">
             <el-button type="info" size="small" @click="cancleDialog">取消</el-button>
             <el-button type="primary" size="small" @click="surePinyin">保存</el-button>
@@ -491,82 +489,20 @@ export default {
     },
     // 解析输入内容
     handleChangeContent() {
-      this.loading = true;
-      this.data.detail = [];
       if (this.data.content.trim()) {
-        let contentArr = this.data.content.split('\n');
-        let textList = [];
-        let detailItem = {
-          paraIndex: 0,
-          para: '',
-          sentences: [],
-          segList: [],
-          seg_words: [],
-          wordsList: [],
-          timeList: [],
-          isTitle: false,
-          sentencesEn: [],
-          paraAlign: this.articleAttrib
-            ? this.articleAttrib.align === 'RIGHT'
-              ? 'right'
-              : this.articleAttrib.align === 'MIDDLE'
-                ? 'center'
-                : 'left'
-            : 'left',
-          remark: {
-            chs: '',
-            en: '',
-            heightNumber: null,
-            img_list: [],
-            widthNumber: null,
-            chsBg: '#988ed6',
-            enBg: '#fff',
-          },
-          sourceList: [],
-          sourcePosition: 'after',
-          heightNumber: null,
-          widthNumber: null,
-        };
-        // 分段
-        contentArr.forEach((item, index) => {
-          if (item.trim()) {
-            detailItem.para = item;
-            detailItem.paraIndex = index;
-            this.data.detail.push(JSON.parse(JSON.stringify(detailItem)));
-
-            let str = Base64.encode(item);
-            textList.push(str);
-          }
-        });
-        BatchSegContent({
-          text: this.data.content,
-          is_build_pinyin: 'true',
-          is_custom_fc: 'false',
-          is_vocabulary_pinyin_lt: 'true',
-          is_fill_punctuation_mark: 'true',
-        })
-          .then((res) => {
-            this.loading = false;
-            if (res.status === 1) {
-              res.paragraph_list.forEach((item, index) => {
-                let sentenceList = []; // 句子按段数组
-                let segList = []; // 句子分词结果
-                item.forEach((items) => {
-                  let sentence = items.reduce((acc, itemss) => `${acc + itemss.text}`, '');
-                  let seg = items.map((itemss) => itemss.text);
-                  sentenceList.push(sentence);
-                  segList.push(seg);
-                });
-                this.data.detail[index].sentences = sentenceList;
-                this.data.detail[index].segList = segList;
-                this.setWordsList(item, index);
-              });
-              this.handleSenWord();
-            }
+        if (this.data.detail.length === 0) {
+          this.handleResetSet();
+        } else {
+          this.$confirm('重新生成分词会重置课文内拼音、气泡、字幕和图片视频附件,确定执行此操作吗?', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning',
           })
-          .catch(() => {
-            this.loading = false;
-          });
+            .then(() => {
+              this.handleResetSet();
+            })
+            .catch(() => {});
+        }
 
         // 分句
         // let sentenceList = []; // 句子按段数组
@@ -604,6 +540,84 @@ export default {
         //   });
       }
     },
+    // 重置分词结构
+    handleResetSet() {
+      this.loading = true;
+      this.data.detail = [];
+      let contentArr = this.data.content.split('\n');
+      let textList = [];
+      let detailItem = {
+        paraIndex: 0,
+        para: '',
+        sentences: [],
+        segList: [],
+        seg_words: [],
+        wordsList: [],
+        timeList: [],
+        isTitle: false,
+        sentencesEn: [],
+        paraAlign: this.articleAttrib
+          ? this.articleAttrib.align === 'RIGHT'
+            ? 'right'
+            : this.articleAttrib.align === 'MIDDLE'
+              ? 'center'
+              : 'left'
+          : 'left',
+        remark: {
+          chs: '',
+          en: '',
+          heightNumber: null,
+          img_list: [],
+          widthNumber: null,
+          chsBg: '#988ed6',
+          enBg: '#fff',
+        },
+        sourceList: [],
+        sourcePosition: 'after',
+        heightNumber: null,
+        widthNumber: null,
+      };
+      // 分段
+      contentArr.forEach((item, index) => {
+        if (item.trim()) {
+          detailItem.para = item;
+          detailItem.paraIndex = index;
+          this.data.detail.push(JSON.parse(JSON.stringify(detailItem)));
+
+          let str = Base64.encode(item);
+          textList.push(str);
+        }
+      });
+      BatchSegContent({
+        text: this.data.content,
+        is_build_pinyin: 'true',
+        is_custom_fc: 'false',
+        is_vocabulary_pinyin_lt: 'true',
+        is_fill_punctuation_mark: 'true',
+      })
+        .then((res) => {
+          this.loading = false;
+          if (res.status === 1) {
+            res.paragraph_list.forEach((item, index) => {
+              let sentenceList = []; // 句子按段数组
+              let segList = []; // 句子分词结果
+              item.forEach((items) => {
+                let sentence = items.reduce((acc, itemss) => `${acc + itemss.text}`, '');
+                let seg = items.map((itemss) => itemss.text);
+                sentenceList.push(sentence);
+                segList.push(seg);
+              });
+              this.data.detail[index].sentences = sentenceList;
+              this.data.detail[index].segList = segList;
+              this.setWordsList(item, index);
+            });
+            this.handleSenWord();
+          }
+        })
+        .catch(() => {
+          this.loading = false;
+        });
+    },
     // 处理句子和词的关系
     handleSenWord() {
       this.data.sentence_list_mp = [];

+ 1 - 3
src/views/book/courseware/create/components/question/article/CheckPinyin.vue

@@ -77,9 +77,7 @@
             }}</span>
           </el-option>
         </el-select>
-        <p class="tips">
-          一到四声分别用数字1-4表示。拼音间用空格隔开,儿化音用_代替空格,如“骨朵儿”输入“gu1 duo3_er”。
-        </p>
+        <p class="tips">一到四声分别用数字1-4表示。拼音间用空格隔开,儿化音输入r,如“活儿”输入“huor2”。</p>
         <div class="btn-box">
           <el-button type="info" size="small" @click="cancleDialog">取消</el-button>
           <el-button type="primary" size="small" @click="surePinyin">保存</el-button>

+ 41 - 30
src/views/book/courseware/create/components/question/article/CheckWord.vue

@@ -5,7 +5,10 @@
         <div style="display: flex; align-items: end">
           <b>校对分词</b>
           <p class="tips">
-            分词:在需要分开的内容中间插入两个空格;分句:将句子另起一行;分段:两段中间加入空行。校对分词后请校对拼音。
+            分词:在需要分开的内容中间插入两个空格;分句:将句子另起一行;分段:两段中间加入空行。<span
+              style="color: #e82d2d"
+              >校对分词后请校对拼音。</span
+            >
           </p>
         </div>
         <div class="btn-box">
@@ -15,11 +18,12 @@
                 active-text="显示词性"
                 inactive-text="">
             </el-switch> -->
-          <el-button type="primary" @click="saveWord">保存分词</el-button>
         </div>
       </div>
       <el-input v-model="noPosContent" class="no-pos-content" type="textarea" :autosize="{ minRows: 15 }" />
 
+      <el-button type="primary" @click="saveWord" style="margin-top: 10px">保存分词</el-button>
+
       <div class="main-top" style="margin-top: 48px">
         <div style="display: flex">
           <b>校对拼音</b>
@@ -96,9 +100,7 @@
             }}</span>
           </el-option>
         </el-select>
-        <p class="tips">
-          一到四声分别用数字1-4表示。拼音间用空格隔开,儿化音用_代替空格,如“骨朵儿”输入“gu1 duo3_er”。
-        </p>
+        <p class="tips">一到四声分别用数字1-4表示。拼音间用空格隔开,儿化音输入r,如“活儿”输入“huor2”。</p>
         <div class="btn-box">
           <el-button type="info" size="small" @click="cancleDialog">取消</el-button>
           <el-button type="primary" size="small" @click="surePinyin">保存</el-button>
@@ -228,32 +230,41 @@ export default {
       this.loading = false;
     },
     saveWord() {
-      let saveArr = [];
-      let arr = this.noPosContent.split('\n');
-      let indexP = 0; // 段落索引
-      let indexS = 0; // 句子索引
-      let flag = true;
-      arr.forEach((item) => {
-        if (item === '') {
-          saveArr.push([]);
-        }
-      });
-      arr.forEach((item, index) => {
-        if (item === '') {
-          indexP++;
-          indexS = 0;
-        } else {
-          let arrs = item.trim().split('  ');
-          let saveItem = [];
-          arrs.forEach((items, indexs) => {
-            saveItem.push(items);
+      this.$confirm('<p style="color:#e82d2d">请先校对分词再校对拼音</p>', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+        dangerouslyUseHTMLString: true,
+      })
+        .then(() => {
+          let saveArr = [];
+          let arr = this.noPosContent.split('\n');
+          let indexP = 0; // 段落索引
+          let indexS = 0; // 句子索引
+          let flag = true;
+          arr.forEach((item) => {
+            if (item === '') {
+              saveArr.push([]);
+            }
           });
-          saveArr[indexP].push(saveItem);
-          indexS++;
-        }
-      });
-      this.$emit('saveWord', saveArr);
-      this.loading = true;
+          arr.forEach((item, index) => {
+            if (item === '') {
+              indexP++;
+              indexS = 0;
+            } else {
+              let arrs = item.trim().split('  ');
+              let saveItem = [];
+              arrs.forEach((items, indexs) => {
+                saveItem.push(items);
+              });
+              saveArr[indexP].push(saveItem);
+              indexS++;
+            }
+          });
+          this.$emit('saveWord', saveArr);
+          this.loading = true;
+        })
+        .catch(() => {});
     },
     refreshData() {
       this.getArticleData();

+ 29 - 3
src/views/book/courseware/create/components/question/dialogue_article/Article.vue

@@ -311,9 +311,7 @@
               }}</span>
             </el-option>
           </el-select>
-          <p class="tips">
-            一到四声分别用数字1-4表示。拼音间用空格隔开,儿化音用_代替空格,如“骨朵儿”输入“gu1 duo3_er”。
-          </p>
+          <p class="tips">一到四声分别用数字1-4表示。拼音间用空格隔开,儿化音输入r,如“活儿”输入“huor2”。</p>
           <div class="btn-box">
             <el-button type="info" size="small" @click="cancleDialog">取消</el-button>
             <el-button type="primary" size="small" @click="surePinyin">保存</el-button>
@@ -919,6 +917,34 @@ export default {
     },
     // 解析输入内容
     handleChangeContent() {
+      let flag = false;
+      this.data.detail.forEach((item, index) => {
+        if (item.type === 'text') {
+          if (item.wordsList.length !== 0) {
+            flag = true;
+          }
+        } else if (item.type === 'notice') {
+          if (item.noticeSegList.length !== 0) {
+            flag = true;
+          }
+        }
+      });
+      if (!flag) {
+        this.handleResetSet();
+      } else {
+        this.$confirm('重新生成分词会重置课文内拼音、气泡、字幕,确定执行此操作吗?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning',
+        })
+          .then(() => {
+            this.handleResetSet();
+          })
+          .catch(() => {});
+      }
+    },
+    // 重置分词结构
+    handleResetSet() {
       this.loading = true;
       let textList = '';
       this.data.detail.forEach((item, index) => {

+ 1 - 3
src/views/book/courseware/create/components/question/image_text/CheckPinyin.vue

@@ -69,9 +69,7 @@
             }}</span>
           </el-option>
         </el-select>
-        <p class="tips">
-          一到四声分别用数字1-4表示。拼音间用空格隔开,儿化音用_代替空格,如“骨朵儿”输入“gu1 duo3_er”。
-        </p>
+        <p class="tips">一到四声分别用数字1-4表示。拼音间用空格隔开,儿化音输入r,如“活儿”输入“huor2”。</p>
         <div class="btn-box">
           <el-button type="info" size="small" @click="cancleDialog">取消</el-button>
           <el-button type="primary" size="small" @click="surePinyin">保存</el-button>

+ 1 - 3
src/views/book/courseware/create/components/question/image_text/CheckWord.vue

@@ -86,9 +86,7 @@
             }}</span>
           </el-option>
         </el-select>
-        <p class="tips">
-          一到四声分别用数字1-4表示。拼音间用空格隔开,儿化音用_代替空格,如“骨朵儿”输入“gu1 duo3_er”。
-        </p>
+        <p class="tips">一到四声分别用数字1-4表示。拼音间用空格隔开,儿化音输入r,如“活儿”输入“huor2”。</p>
         <div class="btn-box">
           <el-button type="info" size="small" @click="cancleDialog">取消</el-button>
           <el-button type="primary" size="small" @click="surePinyin">保存</el-button>