| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848 |
- <template>
- <ModuleBase ref="base" :type="data.type">
- <template #content>
- <!-- eslint-disable max-len -->
- <div v-loading="loading" class="article-wrapper">
- <el-input v-model="data.content" placeholder="输入" type="textarea" />
- <span class="tips">输入课文文本后,请先点击生成分词</span>
- <el-button type="primary" @click="handleChangeContent">生成分词</el-button>
- <template v-if="data.detail.length > 0">
- <div class="new-btn-box">
- <p>文本内容</p>
- <div>
- <a @click="checkArticle">分词和拼音</a>
- <a @click="editWordsFlag = !editWordsFlag">生词和气泡</a>
- <a @click="handleMultilingual">多语种翻译</a>
- <MultilingualFill
- :visible.sync="multilingualVisible"
- :text="multilingualText"
- :translations="data.multilingual"
- @SubmitTranslation="handleMultilingualTranslation"
- />
- </div>
- </div>
- <div class="new-btn-box">
- <p>音频内容</p>
- <div>
- <SelectUpload label="" type="audio" :is-normal="true" @uploadSuccess="uploadAudioSuccess" />
- <el-button :loading="autoLoading" @click="handleAutoAudio">生成音频</el-button>
- <template v-if="data.mp3_list.length === 0">
- <el-tooltip class="item" effect="dark" content="请先设置音频" placement="top">
- <el-button disabled style="margin-left: 0">校对字幕</el-button>
- </el-tooltip>
- </template>
- <template v-else>
- <template v-if="data.wordTime && data.wordTime.length > 0">
- <a type="text" @click="againWordTime">重新生成字幕</a>
- <a size="medium" @click="openCheckSubtitles('句子')">句子字幕</a>
- <a size="medium" @click="compareTime('文字')">文字字幕</a>
- </template>
- <template v-else>
- <a v-if="!isWordTime" size="medium" @click="createWordTimes">自动生成字幕节点</a>
- <p v-else>字幕节点生成中...请等待</p>
- </template>
- </template>
- </div>
- </div>
- <div v-if="data.mp3_list.length > 0" class="upload-file">
- <div class="file-name">
- <span>
- <SvgIcon icon-class="note" size="12" />
- <span>{{ data.mp3_list[0].name }}</span>
- </span>
- </div>
- <SvgIcon icon-class="delete-black" size="12" @click="removeFile" />
- <ResourcesOperate :data="data.mp3_list[0]" />
- </div>
- <div class="new-btn-box">
- <p>多媒体内容</p>
- <div>
- <a @click="picArticle">上传图片</a>
- <a @click="picArticle">上传视频</a>
- </div>
- </div>
- <div v-if="articleAttrib" class="table-rich-toolbar">
- <el-select
- v-model="articleAttrib.font"
- placeholder="请选择"
- style="width: 130px"
- @change="handleChangeStyles"
- >
- <el-option v-for="font in fontList" :key="font.value" :label="font.label" :value="font.value" />
- </el-select>
- <el-select
- v-model="articleAttrib.font_size"
- placeholder="请选择"
- style="width: 130px"
- @change="data.unified_attrib.font_size = articleAttrib.font_size"
- >
- <el-option
- v-for="(value, index) in 16"
- :key="index"
- :label="6 + value * 2 + 'pt'"
- :value="6 + value * 2 + 'pt'"
- />
- </el-select>
- <el-form :model="articleAttrib" inline>
- <el-form-item label="文字颜色">
- <el-color-picker v-model="articleAttrib.text_color" @change="handleChangeStyles" />
- </el-form-item>
- </el-form>
- <span :class="[data.other_attrib.isUnderline ? 'active' : '']" @click="setActiveTextStyle('underline')">
- <SvgIcon icon-class="underline" size="20" />
- </span>
- <span :class="[data.other_attrib.isBold ? 'active' : '']" @click="setActiveTextStyle('bold')">
- <SvgIcon icon-class="font-bold" size="20" />
- </span>
- <!-- <span
- :class="[data.other_attrib.isItalic ? 'active' : '']"
- @click="data.other_attrib.isItalic = !data.other_attrib.isItalic"
- >
- <SvgIcon icon-class="font-italic" size="20" />
- </span> -->
- <span
- :class="[data.other_attrib.isStrikethrough ? 'active' : '']"
- @click="setActiveTextStyle('line-through')"
- >
- <SvgIcon icon-class="strikethrough" size="20" />
- </span>
- <span :class="[data.other_attrib.border === 'dotted' ? 'active' : '']">
- <SvgIcon icon-class="borderDotted" title="下划虚线" size="16" @click="setActiveTextStyle('border')" />
- </span>
- <span
- :class="[articleAttrib.align === 'LEFT' ? 'active' : '']"
- @click="setActiveTextStyle('align', 'LEFT')"
- >
- <SvgIcon icon-class="align-left" size="20" />
- </span>
- <span
- :class="[articleAttrib.align === 'MIDDLE' ? 'active' : '']"
- @click="setActiveTextStyle('align', 'MIDDLE')"
- >
- <SvgIcon icon-class="align-center" size="20" />
- </span>
- <span
- :class="[articleAttrib.align === 'RIGHT' ? 'active' : '']"
- @click="setActiveTextStyle('align', 'RIGHT')"
- >
- <SvgIcon icon-class="align-right" size="20" />
- </span>
- </div>
- </template>
- <!-- <div v-if="data.content" class="btn-box">
- <a @click="handleChangeContent">生成分词</a>
- <a @click="checkArticle">文章校对</a>
- <a @click="picArticle">添加图片</a>
- <a @click="editWordsFlag = !editWordsFlag">编辑生词短语气泡</a>
- <template v-if="data.wordTime && data.wordTime.length > 0">
- <a type="text" @click="againWordTime">重新生成字幕时间</a>
- <a size="medium" @click="openCheckSubtitles('句子')">校对句子字幕时间</a>
- <a size="medium" @click="compareTime('文字')">校对文字字幕时间</a>
- </template>
- <template v-else>
- <a v-if="!isWordTime" size="medium" @click="createWordTimes">自动生成字幕节点</a>
- <p v-else>字幕节点生成中...请等待</p>
- </template>
- <el-button @click="handleMultilingual">课文多语言</el-button>
- <MultilingualFill
- :visible.sync="multilingualVisible"
- :text="multilingualText"
- :translations="data.multilingual"
- @SubmitTranslation="handleMultilingualTranslation"
- />
- </div> -->
- </div>
- <template v-if="data.detail.length > 0">
- <el-divider content-position="left"
- >预览效果<el-button
- v-show="data.detail.length > 0"
- type="text"
- icon="el-icon-refresh"
- title="刷新"
- class="refresh-pinyin-btn"
- @click.native="handleChangeContent"
- /></el-divider>
- <div v-for="(item, index) in data.detail" :key="index" class="text">
- <div class="text-item">
- <span
- class="word"
- :style="{
- fontSize: articleAttrib.font_size,
- }"
- >
-
- </span>
- </div>
- <div class="text-item">
- <span
- class="word"
- :style="{
- fontSize: articleAttrib.font_size,
- }"
- >
-
- </span>
- </div>
- <template v-for="(witem, windex) in item.wordsList">
- <div
- v-for="(wItem, wIndex) in witem"
- :key="windex + '-' + wIndex"
- class="text-item"
- :style="{
- textAlign: wIndex === 0 ? 'left' : '',
- }"
- >
- <span
- v-if="isEnable(data.property.view_pinyin)"
- class="pinyin"
- :style="{
- fontSize: articleAttrib.pinyin_size,
- }"
- @click="selectItem(wItem, wIndex)"
- >{{
- (wIndex === 0 && data.property.is_first_sentence_first_hz_pinyin_first_char_upper_case === 'true'
- ? wItem.pinyin_up
- : wItem.pinyin) || ' '
- }}</span
- >
- <span
- class="word"
- :style="{
- fontFamily: wItem.fontFamily,
- textDecoration: wItem.textDecoration,
- borderBottom: wItem.border === 'dotted' ? '1px dotted' : '',
- fontWeight: wItem.fontWeight,
- color:
- wItem.matchNotesObj.con && wItem.matchNotesObj.notesColor
- ? wItem.matchNotesObj.notesColor
- : wItem.color,
- fontSize: articleAttrib.font_size,
- }"
- @click="matchItemNotes(wItem)"
- >{{ wItem.chs }}</span
- >
- </div>
- </template>
- </div>
- </template>
- <el-dialog
- v-if="dialogFlag"
- :visible.sync="dialogFlag"
- :show-close="false"
- :close-on-click-modal="false"
- :modal-append-to-body="false"
- :modal="false"
- width="250px"
- class="article-checkpinyin-dialog"
- >
- <div class="check-box">
- <div class="content">
- <div class="words-box">
- <span class="pinyin">
- {{ itemActiveIndex === 0 ? itemActive.pinyin_up : itemActive.pinyin }}
- </span>
- <span class="words">
- {{ itemActive.chs }}
- </span>
- </div>
- </div>
- <!-- <el-input v-model="checkPinyinInput" type="text" class="checkPinyinInput" /> -->
- <el-select
- v-model="checkPinyinInput"
- placeholder="请输入"
- filterable
- allow-create
- default-first-option
- class="checkPinyinInput"
- >
- <el-option v-for="item in pinyinList" :key="item.pinyin" :value="item.pinyin.replace(/,/g, '')">
- <span style="float: left">{{ item.pinyin.replace(/,/g, '') }}</span>
- <span style="float: right; font-size: 13px; color: #8492a6">{{
- item.storage_type === 1 ? '机构库' : item.storage_type === 2 ? '全域库' : '个人库'
- }}</span>
- </el-option>
- </el-select>
- <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>
- </div>
- </div>
- </el-dialog>
- <el-dialog
- v-if="showArticleFlag"
- :visible.sync="showArticleFlag"
- :show-close="true"
- :close-on-click-modal="true"
- :modal-append-to-body="true"
- :append-to-body="true"
- :lock-scroll="true"
- width="80%"
- class="practiceBox"
- >
- <CheckArticle
- ref="CheckArticle"
- :data="data"
- @saveWord="saveWord"
- @savePinyin="savePinyin"
- @saveStyle="saveStyle"
- />
- </el-dialog>
- <el-dialog title="校对字幕时间" :visible.sync="compareShow" width="50%" :before-close="handleClose" top="0">
- <CompareTime
- :data="compareData"
- :type="compareType"
- :changewords-result-list="changewordsResultList"
- :open-check-subtitles="openCheckSubtitles"
- />
- <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="" :visible.sync="editWordsFlag" width="80%" :close-on-click-modal="true" top="0"> -->
- <template v-if="editWordsFlag">
- <div class="tabs-box">
- <a :class="[editWordIndex === 0 ? 'active' : '']" @click="editWordIndex = 0">生词</a>
- <a :class="[editWordIndex === 2 ? 'active' : '']" @click="editWordIndex = 2">其他词汇</a>
- <a :class="[editWordIndex === 1 ? 'active' : '']" @click="editWordIndex = 1">气泡</a>
- </div>
- <NewWord
- v-if="editWordIndex === 0"
- key="new_word"
- :data-new-word="data.new_word_list"
- :unified-attrib="data.unified_attrib ? data.unified_attrib : null"
- @sureNewWords="sureNewWords"
- />
- <Notes
- v-if="editWordIndex === 1"
- key="notes"
- :data-notes="data.notes_list"
- :unified-attrib="data.unified_attrib ? data.unified_attrib : null"
- @sureNotes="sureNotes"
- @handleSyncCon="handleSyncCon"
- />
- <NewWord
- v-if="editWordIndex === 2"
- :data-new-word="data.other_word_list"
- :unified-attrib="data.unified_attrib ? data.unified_attrib : null"
- @sureNewWords="sureOtherNewWords"
- />
- </template>
- <!-- </el-dialog> -->
- <!-- 添加图片 -->
- <el-dialog
- v-if="showPicArticleFlag"
- :visible.sync="showPicArticleFlag"
- :show-close="true"
- :close-on-click-modal="true"
- :modal-append-to-body="true"
- :append-to-body="true"
- :lock-scroll="true"
- width="80%"
- class="practiceBox"
- >
- <CheckPic :data="data" />
- </el-dialog>
- <CheckSubtitles
- v-if="visible"
- :visible.sync="visible"
- :audio-id="data.mp3_list[0] && data.mp3_list[0].file_id ? data.mp3_list[0].file_id : ''"
- :option-list="subtitleList"
- @saveSubtitles="saveSubtitles"
- />
- <CheckSubtitlesSentence
- v-if="visibleSentce"
- :visible.sync="visibleSentce"
- :audio-id="data.mp3_list[0] && data.mp3_list[0].file_id ? data.mp3_list[0].file_id : ''"
- :option-list="subtitleList"
- @saveSubtitles="saveSubtitles"
- />
- <!-- 关联注释 -->
- <el-dialog
- v-if="matchNoteFlag"
- :visible.sync="matchNoteFlag"
- :show-close="true"
- :close-on-click-modal="false"
- :modal-append-to-body="false"
- :modal="false"
- width="600px"
- class="article-matchNotes-dialog"
- :title="matchNotesObj.id ? '编辑气泡' : '添加气泡'"
- >
- <div class="matchNotes-box">
- <RichText
- v-if="matchNotesObj.isRich"
- ref="richText"
- v-model="matchNotesObj.con"
- :font-size="'14pt'"
- :font-family="data.unified_attrib?.font"
- :font-color="data.unified_attrib?.text_color"
- toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright image media link"
- />
- <el-input v-else v-model="matchNotesObj.con" type="textarea" rows="5" />
- <div class="matchNotes-color">
- <span>气泡颜色<el-color-picker v-model="matchNotesObj.notesColor" /></span>
- <span @click="matchNotesObj.isRich = !matchNotesObj.isRich"
- ><SvgIcon icon-class="change" size="16" />切换文本模式</span
- >
- </div>
- <div class="btn-box">
- <el-button type="info" size="small" @click="cancleMatchNotesDialog">删除</el-button>
- <el-button type="primary" size="small" @click="sureMatchNotes">保存</el-button>
- </div>
- </div>
- </el-dialog>
- </template>
- </ModuleBase>
- </template>
- <script>
- import ModuleMixin from '../../common/ModuleMixin';
- import SelectUpload from '@/views/book/courseware/create/components/common/SelectUpload.vue';
- import CheckArticle from './CheckArticle.vue';
- import CompareTime from './CompareTime.vue';
- import NewWord from './NewWord.vue';
- import Notes from './Notes.vue';
- import CheckPic from './CheckPic.vue';
- import CheckSubtitles from '@/views/book/courseware/create/components/question/voice_matrix/CheckSubtitles.vue';
- import CheckSubtitlesSentence from './CheckSubtitlesSentence.vue';
- import ResourcesOperate from '../../common/ResourcesOperate.vue';
- import { getArticleData } from '@/views/book/courseware/data/article';
- import { fontList } from '@/common/data';
- import { TextToAudioFile } from '@/api/app';
- import { isEnable } from '@/views/book/courseware/data/common';
- import {
- segSentences,
- BatchSegContent,
- getWordTime,
- prepareTranscribe,
- fileToBase64Text,
- getWordTimes,
- } from '@/api/article';
- const Base64 = require('js-base64').Base64;
- import cnchar from 'cnchar';
- import { toolGetWordPinyinCorrectionList } from '@/api/pinyinCorrection';
- import { PinyinBuild_OldFormat } from '@/api/book';
- import { getRandomNumber } from '@/utils';
- export default {
- name: 'ArticlePage',
- components: {
- SelectUpload,
- CheckArticle,
- CompareTime,
- NewWord,
- Notes,
- CheckPic,
- CheckSubtitles,
- ResourcesOperate,
- CheckSubtitlesSentence,
- },
- mixins: [ModuleMixin],
- data() {
- return {
- fontList,
- isEnable,
- data: getArticleData(),
- showArticleFlag: false, // 校对文章
- showPicArticleFlag: false, // 添加图片
- toneList: [' ', 'ˉ', 'ˊ', 'ˇ', 'ˋ'],
- loading: false,
- isWordTime: false,
- compareType: '', // 校对类型
- compareIndex: null, // 校对句子索引
- compareShow: false,
- compareData: null,
- compareloading: false,
- editWordsFlag: false,
- editWordIndex: 0,
- multilingualText: '',
- autoLoading: false,
- visible: false,
- visibleSentce: false,
- subtitleList: [],
- itemActive: null,
- itemActiveIndex: null,
- dialogFlag: false,
- checkPinyinInput: '',
- oldInput: '',
- tableData: [
- ['ā', 'á', 'ǎ', 'à', 'a'],
- ['ō', 'ó', 'ǒ', 'ò', 'o'],
- ['ē', 'é', 'ě', 'è', 'e'],
- ['ī', 'í', 'ǐ', 'ì', 'i'],
- ['ū', 'ú', 'ǔ', 'ù', 'u'],
- ['ǖ', 'ǘ', 'ǚ', 'ǜ', 'ü'],
- ['Ā', 'Á', 'Â', 'À', 'A'],
- ['Ō', 'Ó', 'Ô', 'Ò', 'O'],
- ['Ē', 'É', 'Ê', 'È', 'E'],
- ['Ī', 'Í', 'Î', 'Ì', 'I'],
- ['Ū', 'Ú', 'Û', 'Ù', 'U'],
- ['n', 'ń', 'ň', 'ǹ', 'n'],
- ['m̄', 'ḿ', 'm', 'm̀', 'm'],
- ],
- pinyinList: [], // 拼音校正列表
- articleAttrib: null,
- matchNoteItem: null, // 选中关联注释的词
- matchNoteFlag: false,
- };
- },
- watch: {
- 'data.content': 'handleMindMap',
- 'data.unified_attrib': {
- handler(val) {
- if (val) {
- let oldAttrib = this.data.other_attrib;
- this.articleAttrib = JSON.parse(JSON.stringify(val));
- if (oldAttrib.oldFont && oldAttrib.oldFont !== val.font) {
- this.$set(this.articleAttrib, 'font', oldAttrib.oldFont);
- }
- if (oldAttrib.oldColor && oldAttrib.oldColor !== val.text_color) {
- this.$set(this.articleAttrib, 'text_color', oldAttrib.oldColor);
- }
- if (oldAttrib.align && oldAttrib.align !== val.align) {
- this.$set(this.articleAttrib, 'align', oldAttrib.align);
- }
- // this.handleChangeStyles();
- }
- },
- deep: true,
- immediate: true,
- },
- // 'data.unified_attrib.font': {
- // handler(val) {
- // if (val) {
- // this.handleChangeStyles();
- // }
- // },
- // deep: true,
- // immediate: true,
- // },
- // 'data.unified_attrib.text_color': {
- // handler(val) {
- // if (val) {
- // this.handleChangeStyles();
- // }
- // },
- // deep: true,
- // immediate: true,
- // },
- // 'data.unified_attrib.align': {
- // handler(val) {
- // if (val) {
- // this.handleChangeStyles();
- // }
- // },
- // deep: true,
- // immediate: true,
- // },
- },
- created() {},
- methods: {
- // 全局样式变化
- handleChangeStyles() {
- if (this.articleAttrib.font !== this.data.other_attrib.oldFont) {
- this.data.other_attrib.oldFont = this.articleAttrib.font;
- this.data.detail.forEach((item) => {
- item.wordsList.forEach((items) => {
- items.forEach((itemss) => {
- itemss.fontFamily = this.articleAttrib.font;
- });
- });
- });
- }
- if (this.articleAttrib.text_color !== this.data.other_attrib.oldColor) {
- this.data.other_attrib.oldColor = this.articleAttrib.text_color;
- this.data.detail.forEach((item) => {
- item.wordsList.forEach((items) => {
- items.forEach((itemss) => {
- itemss.color = this.articleAttrib.text_color;
- });
- });
- });
- }
- if (this.articleAttrib.align !== this.data.other_attrib.oldAlign) {
- this.data.other_attrib.oldAlign = this.articleAttrib.align;
- this.data.detail.forEach((item) => {
- item.paraAlign =
- this.articleAttrib.align === 'RIGHT' ? 'right' : this.articleAttrib.align === 'MIDDLE' ? 'center' : 'left';
- });
- }
- },
- // 解析输入内容
- handleChangeContent() {
- if (this.data.content.trim()) {
- if (this.data.detail.length === 0) {
- this.handleResetSet();
- } else {
- this.$confirm('重新生成分词会重置课文内拼音、气泡、字幕和图片视频附件,确定执行此操作吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- })
- .then(() => {
- this.handleResetSet();
- this.data.notes_list.option = [];
- this.isWordTime = false;
- this.data.wordTime = [];
- })
- .catch(() => {});
- }
- // 分句
- // let sentenceList = []; // 句子按段数组
- // let data = {
- // textList,
- // };
- // segSentences(data)
- // .then((res) => {
- // let result = res.data.result;
- // sentenceList = JSON.parse(JSON.stringify(res.data.result));
- // result.forEach((item, index) => {
- // let sentenceListBase64 = [];
- // this.data.detail[index].sentences = item;
- // item.forEach((items) => {
- // sentenceListBase64.push(Base64.encode(items));
- // });
- // // 分词
- // BatchSegContent({ textList: sentenceListBase64 })
- // .then((res) => {
- // let list = res.data.result.list;
- // this.data.detail[index].segList = list;
- // this.setWordsList(list, index);
- // if (index === result.length - 1) {
- // this.handleSenWord();
- // this.loading = false;
- // }
- // })
- // .catch(() => {
- // this.loading = false;
- // });
- // });
- // })
- // .catch(() => {
- // this.loading = false;
- // });
- }
- },
- // 重置分词结构
- handleResetSet() {
- this.loading = true;
- this.data.detail = [];
- let contentArr = this.data.content.split('\n');
- let textList = [];
- let contentStr = '';
- 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,
- };
- // 分段
- let paraindex = 0;
- contentArr.forEach((item, index) => {
- if (item.trim()) {
- detailItem.para = item;
- detailItem.paraIndex = paraindex;
- this.data.detail.push(JSON.parse(JSON.stringify(detailItem)));
- let str = Base64.encode(item);
- textList.push(str);
- contentStr += `${item.trim()}\n`;
- paraindex++;
- }
- });
- BatchSegContent({
- text: contentStr,
- is_build_pinyin: 'true',
- is_custom_fc: 'false',
- is_vocabulary_pinyin_lt: 'true',
- is_fill_punctuation_mark: 'true',
- is_fill_space: '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 = [];
- this.data.detail.forEach((item) => {
- item.sentences.forEach((items, indexs) => {
- let word_list = [];
- item.segList[indexs].forEach((itemw) => {
- word_list.push({
- word: itemw,
- });
- });
- let obj = {
- sentence: items,
- word_list,
- };
- this.data.sentence_list_mp.push(obj);
- });
- });
- },
- setWordsList(list, paraIndex) {
- let wordsList = [];
- list.forEach((item, index) => {
- let sentArr = [];
- item.map((sItem) => {
- // let toneStr = [];
- // for (let i = 0; i < sItem.length; i++) {
- // const pattern = /[\u4e00-\u9fa5]/;
- // if (cnchar.isCnChar(sItem[i]) && !pattern.test(cnchar.spell(sItem[i], 'low', 'tone'))) {
- // toneStr.push(this.toneList[cnchar.spellInfo(cnchar.spell(sItem[i], 'low', 'tone')).tone]);
- // } else {
- // toneStr.push(' ');
- // }
- // }
- let obj = {
- chs: sItem.text,
- pinyin: sItem.pinyin,
- pinyin_up: sItem.pinyin_up,
- pinyin_tone: sItem.pinyin_tone,
- fontFamily: this.articleAttrib ? this.articleAttrib.font : '楷体',
- textDecoration: this.data.other_attrib
- ? this.data.other_attrib.isUnderline
- ? this.data.other_attrib.isUnderline
- : this.data.other_attrib.isStrikethrough
- ? this.data.other_attrib.isStrikethrough
- : ''
- : '',
- fontWeight: this.data.other_attrib ? this.data.other_attrib.isBold : '',
- border: this.data.other_attrib ? this.data.other_attrib.border : '',
- color: this.articleAttrib ? this.articleAttrib.text_color : '',
- matchWords: '',
- matchNotes: '',
- notesColor: '',
- img: [],
- imgPosition: 'after',
- matchNotesObj: {
- number: '',
- con: '',
- pinyin: '',
- interpret: '',
- note: '',
- notesColor: '#8206BF',
- id: '',
- isRich: true,
- matchNotes: sItem.text,
- },
- };
- sentArr.push(obj);
- });
- wordsList.push(sentArr);
- });
- this.data.detail[paraIndex].wordsList = wordsList;
- },
- uploadAudioSuccess(fileList) {
- if (fileList.length > 0) {
- const { file_name: name, file_url: temporary_url, file_id, media_duration } = fileList[0];
- this.data.mp3_list = [
- {
- name,
- media_duration,
- temporary_url,
- url: file_id,
- file_id,
- },
- ];
- this.data.file_id_list = [file_id];
- }
- },
- removeFile() {
- this.$confirm('是否删除当前文件?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- })
- .then(() => {
- this.data.mp3_list = [];
- this.data.file_id_list = [];
- this.isWordTime = false;
- this.data.wordTime = [];
- })
- .catch(() => {});
- },
- // 校对文章
- checkArticle() {
- 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) {
- BatchSegContent({
- text: this.data.content,
- is_build_pinyin: 'true',
- is_custom_fc: 'true',
- is_vocabulary_pinyin_lt: 'true',
- is_fill_punctuation_mark: 'true',
- is_fill_space: 'true',
- fc_paragraph_list: saveArr,
- }).then((res) => {
- if (res.status === 1) {
- res.paragraph_list.forEach((item, index) => {
- let sentenceList = []; // 句子按段数组
- let segList = []; // 句子分词结果
- let sentenceStr = [];
- let para = '';
- let wordsList = [];
- item.forEach((items) => {
- let sentence = items.reduce((acc, itemss) => `${acc + itemss.text}`, '');
- let sentenceS = items.reduce((acc, itemss) => `${acc + itemss.text} `, '');
- let seg = items.map((itemss) => itemss.text);
- para += items.map((itemss) => itemss.text);
- sentenceList.push(sentence);
- sentenceStr.push(sentenceS);
- segList.push(seg);
- let sentArr = [];
- items.forEach((sItem) => {
- let obj = {
- chs: sItem.text,
- pinyin: sItem.pinyin,
- pinyin_up: sItem.pinyin_up,
- pinyin_tone: sItem.pinyin_tone,
- fontFamily: this.articleAttrib ? this.articleAttrib.font : '楷体',
- textDecoration: this.data.other_attrib
- ? this.data.other_attrib.isUnderline
- ? this.data.other_attrib.isUnderline
- : this.data.other_attrib.isStrikethrough
- ? this.data.other_attrib.isStrikethrough
- : ''
- : '',
- fontWeight: this.data.other_attrib ? this.data.other_attrib.isBold : '',
- border: this.data.other_attrib ? this.data.other_attrib.border : '',
- color: this.articleAttrib ? this.articleAttrib.text_color : '',
- matchWords: '',
- matchNotes: '',
- notesColor: '',
- img: [],
- imgPosition: 'after',
- matchNotesObj: {
- number: '',
- con: '',
- pinyin: '',
- interpret: '',
- note: '',
- notesColor: '#8206BF',
- id: '',
- isRich: true,
- matchNotes: sItem.text,
- },
- };
- sentArr.push(obj);
- });
- wordsList.push(sentArr);
- });
- if (this.data.detail[index]) {
- this.data.detail[index].segList = segList;
- this.data.detail[index].para = para;
- this.data.detail[index].sentenceStr = sentenceStr;
- this.data.detail[index].sentences = sentenceList;
- this.data.detail[index].wordsList = wordsList;
- } else {
- let obj = {
- paraIndex: index,
- para,
- sentences: sentenceList,
- segList,
- seg_words: [],
- wordsList,
- timeList: [],
- isTitle: false,
- sentencesEn: [],
- sentenceStr,
- 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,
- };
- this.data.detail.push(obj);
- }
- });
- this.$refs.CheckArticle.refreshData();
- }
- });
- this.$message.success('保存成功,请校对拼音');
- this.handleSenWord();
- },
- // 保存拼音
- savePinyin(paraIndex, sentenceIndex, wordIndex, pinyin) {
- if (this.data.pinyin_type === 'tone') {
- this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].pinyin_tone = pinyin;
- } else if (wordIndex === 0) {
- this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].pinyin_up = pinyin;
- } else {
- this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].pinyin = pinyin;
- }
- },
- saveStyle(
- paraIndex,
- sentenceIndex,
- wordIndex,
- fontFamily,
- textDecoration,
- fontWeight,
- border,
- color,
- matchWords,
- matchNotes,
- notesColor,
- img,
- imgPosition,
- ) {
- this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].fontFamily = fontFamily;
- this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].textDecoration = textDecoration;
- this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].fontWeight = fontWeight;
- this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].border = border;
- this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].color = color;
- this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].matchWords = matchWords;
- this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].matchNotes = matchNotes;
- this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].notesColor = notesColor;
- this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].img = img;
- this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].imgPosition = imgPosition;
- },
- // 保存校对
- saveCompare() {
- this.compareloading = false;
- // this.data.wordTime = this.compareData;
- this.handleClose();
- // this.compareloading = true;
- // compareSenTenceTime({ matchList: JSON.stringify(this.compareData) })
- // .then((res) => {
- // this.compareloading = false;
- // this.data.wordTime = res.data.result;
- // })
- // .catch(() => {
- // this.compareloading = false;
- // });
- },
- // 校对时间
- compareTime(type) {
- this.compareType = type;
- this.compareData = JSON.parse(JSON.stringify(this.data.wordTime));
- this.compareShow = true;
- },
- handleClose() {
- this.compareShow = false;
- this.compareData = null;
- this.compareType = '';
- },
- // 校对每个字的时间
- changewordsResultList(index, item) {
- this.data.wordTime[index].wordsResultList = JSON.parse(JSON.stringify(item));
- },
- againWordTime() {
- this.isWordTime = false;
- this.data.wordTime = [];
- },
- createWordTimes() {
- let _this = this;
- let verseList = [];
- if (_this.data.mp3_list && _this.data.mp3_list.length > 0 && _this.data.mp3_list[0].file_id) {
- if (_this.data.content) {
- _this.data.detail.forEach((item) => {
- verseList = verseList.concat(item.sentences);
- });
- 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('请先上传音频');
- _this.loading = false;
- }
- },
- createWordTime() {
- let _this = this;
- this.getfillLiu().then(() => {
- if (_this.data.taskId) {
- let verseList = [];
- _this.data.detail.forEach((item) => {
- verseList = verseList.concat(item.sentences);
- });
- if (verseList.length > 0) {
- _this.isWordTime = true;
- let data = {
- taskId: _this.data.taskId,
- verseList: JSON.stringify(verseList),
- matchType: 'chinese',
- language: 'ch',
- };
- getWordTime(data).then((res) => {
- _this.data.wordTime = res.data.result;
- _this.isWordTime = false;
- });
- }
- } else {
- _this.$message.warning('请先上传音频');
- _this.loading = false;
- }
- });
- },
- // 得到文件流
- getfillLiu() {
- this.loading = true;
- let _this = this;
- return new Promise(function (resolve, reject) {
- if (_this.data.mp3_list && _this.data.mp3_list.length > 0 && _this.data.mp3_list[0].file_id) {
- let id = _this.data.mp3_list[0].file_id;
- let data = {
- file_id: id,
- };
- fileToBase64Text(data).then((res) => {
- let taskIddata = {
- fileName: _this.data.mp3_list[0].name,
- speechBase64: res.base64_text,
- language: 'ch',
- };
- prepareTranscribe(taskIddata)
- .then((ress) => {
- _this.$set(_this.data, 'taskId', ress.data.taskId);
- _this.loading = false;
- resolve();
- })
- .catch(() => {
- _this.loading = false;
- });
- });
- } else {
- _this.$message.warning('请先上传音频');
- _this.loading = false;
- }
- });
- },
- sureNewWords(data) {
- this.data.new_word_list = data;
- },
- sureOtherNewWords(data) {
- this.data.other_word_list = data;
- },
- sureNotes(data) {
- this.data.notes_list = data;
- },
- handleMindMap() {
- // 思维导图数据
- let node_list = [];
- node_list.push({
- name: this.data.content,
- id: Math.random().toString(36).substring(2, 12),
- });
- this.data.mind_map.node_list = node_list;
- },
- 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>`;
- });
- } else {
- this.multilingualText += '<p> </p>';
- }
- // this.multilingualText += item.para ? '<p>' + item.para + '<p>' : '<p> </p>';
- });
- if (flag) {
- this.multilingualVisible = true;
- } else {
- this.$message.warning('请先生成分词');
- }
- },
- // 点击插入图片按钮
- picArticle() {
- let verseList = [];
- this.data.detail.forEach((item) => {
- verseList = verseList.concat(item.sentences);
- });
- if (verseList.length > 0) {
- this.showPicArticleFlag = true;
- } else {
- this.$message.warning('请先生成分词');
- }
- },
- // 自动生成音频
- handleAutoAudio() {
- this.autoLoading = true;
- TextToAudioFile({
- text: this.data.content,
- voice_type: this.data.property.voice_type,
- emotion: this.data.property.emotion,
- speed_ratio: this.data.property.speed_ratio,
- sentence_interval: 1000,
- })
- .then(({ status, file_id, file_url }) => {
- this.autoLoading = false;
- if (status === 1) {
- this.data.mp3_list = [
- {
- name: '自动生成课文音频.mp3',
- media_duration: 0,
- temporary_url: file_url,
- url: file_id,
- file_id,
- },
- ];
- this.data.file_id_list = [file_id];
- }
- })
- .catch(() => {
- this.autoLoading = false;
- });
- },
- /**
- * 打开校对字幕
- */
- openCheckSubtitles(type, index) {
- this.compareType = type;
- // this.compareData = JSON.parse(JSON.stringify(this.data.wordTime));
- // this.compareShow = true;
- if (this.data.mp3_list.length === 0) {
- return this.$message.warning('请先上传音频文件');
- }
- this.subtitleList = [];
- if (this.compareType === '句子') {
- this.data.wordTime.forEach((item, index) => {
- let obj = {
- content: item.onebest,
- lrc_data: {
- begin_time: item.bg,
- end_time: item.ed,
- },
- };
- this.subtitleList.push(obj);
- });
- this.visibleSentce = true;
- } else {
- this.compareIndex = index;
- this.data.wordTime[index].wordsResultList.forEach((item, index) => {
- let obj = {
- content: item.wordsName,
- lrc_data: {
- begin_time: item.wordBg,
- end_time: item.wordEd,
- },
- };
- this.subtitleList.push(obj);
- });
- this.visible = true;
- }
- },
- /**
- * 保存字幕
- * @param {Array} dataList
- */
- saveSubtitles(dataList) {
- if (this.compareType === '句子') {
- this.data.wordTime.forEach((item, index) => {
- item.bg = dataList[index] ? dataList[index].lrc_data.begin_time : 0;
- item.ed = dataList[index] ? dataList[index].lrc_data.end_time : 0;
- });
- } else {
- this.data.wordTime[this.compareIndex].wordsResultList.forEach((item, index) => {
- item.wordBg = dataList[index] ? dataList[index].lrc_data.begin_time : 0;
- item.wordEd = dataList[index] ? dataList[index].lrc_data.end_time : 0;
- });
- }
- },
- selectItem(item, index) {
- this.itemActive = item;
- this.itemActiveIndex = index;
- this.pinyinList = [];
- toolGetWordPinyinCorrectionList({
- word: item.chs,
- })
- .then((res) => {
- if (res.status === 1) {
- this.pinyinList = res.pinyin_correction_list;
- }
- this.dialogFlag = true;
- })
- .catch(() => {
- this.dialogFlag = true;
- });
- this.checkPinyinInput = '';
- },
- cancleDialog() {
- this.itemActive = null;
- this.checkPinyinInput = '';
- this.oldInput = '';
- this.dialogFlag = false;
- },
- surePinyin() {
- this.oldInput = JSON.parse(JSON.stringify(this.checkPinyinInput.trim()));
- if (this.oldInput) {
- this.handleReplaceTone(this.checkPinyinInput.trim());
- } else {
- this.itemActive.pinyin = ' ';
- this.itemActive.pinyin_up = ' ';
- this.$message.success('保存成功');
- // this.itemActive = null;
- this.dialogFlag = false;
- }
- },
- handleReplaceTone(e) {
- let _this = this;
- _this.$nextTick(() => {
- let value = e;
- _this.resArr = [];
- if (value) {
- let valueArr = [];
- value.replace(/\s+/g, ' ');
- valueArr = value.split(' ');
- // let reg = /\s+/g;
- // valueArr = value.split(reg);
- valueArr.forEach((item, index) => {
- if (this.data.pinyin_type === 'tone') {
- this.resArr.push([
- {
- con: this.toneList[Number(item)],
- },
- ]);
- } else {
- this.handleValue(item);
- }
- });
- let str = '';
- setTimeout(() => {
- _this.resArr.forEach((item) => {
- str += ' ';
- item.forEach((sItem) => {
- if (sItem.number && sItem.con) {
- let number = Number(sItem.number);
- let con = sItem.con;
- let word = _this.addTone(number, con);
- str += word;
- } else if (sItem.number) {
- str += sItem.number;
- } else if (sItem.con) {
- str += ` ${sItem.con} `;
- }
- });
- });
- this.checkPinyinInput = str.trim();
- this.itemActive.pinyin = this.checkPinyinInput.replace(/\s+/g, '');
- this.itemActive.pinyin_up = this.checkPinyinInput.replace(/\s+/g, '');
- this.$message.success('保存成功');
- // this.itemActive = null;
- this.checkPinyinInput = '';
- this.oldInput = '';
- this.dialogFlag = false;
- }, 10);
- }
- });
- },
- handleValue(valItem) {
- let reg = /\d/;
- let reg2 = /[A-Za-z]+\d/g;
- let numList = [];
- let valArr = valItem.split('');
- if (reg2.test(valItem)) {
- for (let i = 0; i < valArr.length; i++) {
- let item = valItem[i];
- if (reg.test(item)) {
- let numIndex = numList.length === 0 ? 0 : numList[numList.length - 1].index;
- let con = valItem.substring(numIndex, i);
- con = con.replace(/\d/g, '');
- let obj = {
- index: i,
- number: item,
- con,
- isTran: true,
- };
- numList.push(obj);
- }
- }
- } else {
- numList = [];
- }
- if (numList.length === 0) {
- this.resArr.push([{ con: valItem }]);
- } else {
- this.resArr.push(numList);
- }
- },
- addTone(number, con) {
- let _this = this;
- let zmList = ['a', 'o', 'e', 'i', 'u', 'v', 'A', 'O', 'E', 'I', 'U', 'n', 'm'];
- if (number) {
- for (let i = 0; i < zmList.length; i++) {
- let zm = zmList[i];
- if (con.indexOf(zm) > -1) {
- let zm2 = _this.tableData[i][number - 1];
- if (con.indexOf('iu') > -1) {
- zm2 = _this.tableData[4][number - 1];
- con = con.replace('u', zm2);
- } else if (con.indexOf('ui') > -1) {
- zm2 = _this.tableData[3][number - 1];
- con = con.replace('i', zm2);
- } else if (
- con.indexOf('yv') > -1 ||
- con.indexOf('jv') > -1 ||
- con.indexOf('qv') > -1 ||
- con.indexOf('xv') > -1
- ) {
- zm2 = _this.tableData[4][number - 1];
- con = con.replace('v', zm2);
- } else {
- con = con.replace(zm, zm2);
- }
- break;
- }
- }
- }
- return con;
- },
- // 设置样式
- setActiveTextStyle(type, val) {
- let style = this.data.other_attrib;
- if (type === 'underline') {
- style.isUnderline = style.isUnderline === 'underline' ? '' : 'underline';
- if (style.isUnderline === 'underline') {
- style.isStrikethrough = '';
- }
- this.data.detail.forEach((item) => {
- item.wordsList.forEach((items) => {
- items.forEach((itemss) => {
- itemss.textDecoration = style.isUnderline;
- });
- });
- });
- } else if (type === 'bold') {
- style.isBold = style.isBold === 'bold' ? '' : 'bold';
- this.data.detail.forEach((item) => {
- item.wordsList.forEach((items) => {
- items.forEach((itemss) => {
- itemss.fontWeight = style.isBold;
- });
- });
- });
- } else if (type === 'line-through') {
- style.isStrikethrough = style.isStrikethrough === 'line-through' ? '' : 'line-through';
- if (style.isStrikethrough === 'line-through') {
- style.isUnderline = '';
- }
- this.data.detail.forEach((item) => {
- item.wordsList.forEach((items) => {
- items.forEach((itemss) => {
- itemss.textDecoration = style.isStrikethrough;
- });
- });
- });
- } else if (type === 'border') {
- style.border = style.border === 'dotted' ? '' : 'dotted';
- this.data.detail.forEach((item) => {
- item.wordsList.forEach((items) => {
- items.forEach((itemss) => {
- itemss.border = style.border;
- });
- });
- });
- } else if (type === 'align') {
- style.align = val;
- this.articleAttrib.align = val;
- this.data.detail.forEach((item) => {
- item.paraAlign =
- this.articleAttrib.align === 'RIGHT' ? 'right' : this.articleAttrib.align === 'MIDDLE' ? 'center' : 'left';
- });
- }
- },
- // 点击汉字打开关联注释弹窗
- matchItemNotes(item) {
- if (!item.matchNotesObj.id) {
- item.matchNotesObj.id = getRandomNumber();
- }
- this.matchNotesObj = item.matchNotesObj;
- this.matchNoteFlag = true;
- },
- cancleMatchNotesDialog() {
- this.$confirm('确定要删除此条气泡吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- })
- .then(() => {
- this.handleSyncCon(this.matchNotesObj, 'delete');
- let index = this.data.notes_list.option.findIndex((items) => items.id === this.matchNotesObj.id);
- this.data.notes_list.option.splice(index, 1);
- this.matchNoteFlag = false;
- })
- .catch(() => {});
- },
- // 确定关联注释
- sureMatchNotes() {
- let index = this.data.notes_list.option.findIndex((items) => items.id === this.matchNotesObj.id);
- if (index > -1) {
- this.data.notes_list.option[index] = this.matchNotesObj;
- } else {
- this.data.notes_list.option.push(this.matchNotesObj);
- }
- this.matchNoteFlag = false;
- this.editWordsFlag = true;
- this.editWordIndex = 1;
- },
- async handleBlurCon() {
- let text = this.matchNotesObj.con.replace(/<[^>]+>/g, '');
- if (text) {
- this.matchNotesObj.pinyin = await this.handlePinyins(
- text,
- this.data.notes_list.property.is_first_sentence_first_hz_pinyin_first_char_upper_case,
- );
- }
- },
- // 自动生成拼音
- handlePinyins(text, flag) {
- let data = {
- text,
- is_rich_text: 'false',
- is_first_sentence_first_hz_pinyin_first_char_upper_case: flag || 'false',
- is_fill_space: 'false',
- is_custom_fc: 'false',
- };
- return new Promise((resolve, reject) => {
- PinyinBuild_OldFormat(data).then((res) => {
- if (res.parsed_text) {
- let mergedData = '';
- res.parsed_text.paragraph_list.map((outerArr, i) =>
- outerArr.map((innerArr, j) =>
- innerArr.map((newItem, k) => {
- mergedData += `${newItem.pinyin} `;
- }),
- ),
- );
- resolve(mergedData);
- }
- });
- });
- },
- // 在气泡列表里修改了内容,同步detail的内容
- handleSyncCon(obj, type) {
- this.data.detail.forEach((item) => {
- item.wordsList.forEach((items) => {
- items.forEach((itemss) => {
- if (itemss.matchNotesObj.id === obj.id) {
- if (type === 'delete') {
- itemss.matchNotesObj = {
- number: '',
- con: '',
- pinyin: '',
- interpret: '',
- note: '',
- notesColor: '#8206BF',
- id: '',
- isRich: true,
- matchNotes: itemss.chs,
- };
- } else {
- itemss.matchNotesObj = obj;
- }
- }
- });
- });
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .article-wrapper {
- display: flex;
- flex-direction: column;
- row-gap: 16px;
- align-items: flex-start;
- }
- .upload-file {
- display: flex;
- column-gap: 12px;
- align-items: center;
- .file-name {
- display: flex;
- column-gap: 14px;
- align-items: center;
- justify-content: space-between;
- max-width: 360px;
- padding: 8px 12px;
- font-size: 14px;
- color: #1d2129;
- background-color: #f7f8fa;
- span {
- display: flex;
- column-gap: 14px;
- align-items: center;
- }
- }
- .svg-icon {
- cursor: pointer;
- }
- }
- .btn-box {
- display: flex;
- flex-flow: wrap;
- gap: 10px;
- a {
- padding: 5px 16px;
- font-size: 14px;
- line-height: 22px;
- color: #4e5969;
- cursor: pointer;
- background: #f2f3f5;
- border-radius: 2px;
- }
- p {
- margin: 0;
- }
- }
- .new-btn-box {
- p {
- margin: 0 0 10px;
- font-size: 14px;
- font-weight: bold;
- color: #333;
- }
- > div {
- display: flex;
- flex-wrap: wrap;
- gap: 8px;
- }
- a {
- display: block;
- padding: 6px 14px;
- font-size: 13px;
- color: #000;
- cursor: pointer;
- background: #fff;
- border: 1px solid #d9d9d9;
- border-radius: 4px;
- &:hover {
- color: #1890ff;
- border-color: #1890ff;
- }
- }
- :deep .el-button {
- padding: 6px 14px;
- font-size: 13px;
- line-height: 1.5;
- color: #000;
- cursor: pointer;
- background: #fff;
- border: 1px solid #d9d9d9;
- border-radius: 4px;
- &:hover {
- color: #1890ff;
- border-color: #1890ff;
- }
- &.is-disabled {
- color: #ccc;
- border-color: #e8e8e8;
- }
- }
- }
- .tips {
- margin: 0;
- font-size: 12px;
- color: #e82d2d;
- }
- .tabs-box {
- display: flex;
- column-gap: 12px;
- margin: 12px 0;
- a {
- padding: 5px 16px;
- font-size: 14px;
- font-weight: 400;
- line-height: 22px; /* 157.143% */
- color: #4e5969;
- cursor: pointer;
- border-radius: 100px;
- &.active {
- color: #165dff;
- background: #f2f3f5;
- }
- }
- }
- .text {
- display: flex;
- flex-flow: wrap;
- .text-item {
- padding: 0 1px;
- text-align: center;
- cursor: pointer;
- }
- .pinyin {
- display: block;
- font-family: 'PINYIN-B';
- white-space: pre;
- }
- .word {
- display: block;
- }
- }
- .table-rich-toolbar {
- display: flex;
- gap: 5px;
- /* align-items: center; */
- :deep .el-form-item--small.el-form-item {
- margin: 0 5px 0 0;
- }
- :deep .el-form-item__label {
- padding-right: 3px;
- }
- > span {
- height: 30px;
- padding: 5px 6px;
- color: #222f3e;
- cursor: pointer;
- border-radius: 5px;
- &:hover {
- background: #cce2fa;
- }
- &.active {
- background: #a6ccf7;
- }
- }
- }
- </style>
- <style lang="scss">
- .article-matchNotes-dialog {
- .el-dialog__header,
- .el-dialog__body {
- padding: 5px 10px;
- }
- .btn-box {
- display: block;
- padding: 5px 0;
- text-align: right;
- .el-button {
- padding: 2px 12px;
- font-size: 12px;
- line-height: 20px;
- }
- }
- .matchNotes-color {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-top: 5px;
- span {
- display: flex;
- gap: 3px;
- align-items: center;
- cursor: pointer;
- }
- .el-color-picker--small {
- height: 16px;
- }
- .el-color-picker__trigger {
- width: 16px;
- height: 16px;
- padding: 0;
- border: none;
- }
- }
- }
- .article-checkpinyin-dialog {
- .el-dialog__header {
- padding: 0;
- }
- .el-dialog__body {
- padding: 0;
- }
- .el-input__inner {
- text-align: center;
- background: #f3f3f3;
- }
- .check-box {
- padding: 24px;
- background: #fff;
- border-radius: 4px;
- box-shadow: 0 4px 4px 0 rgba(0, 0, 0, 25%);
- .content {
- display: flex;
- align-items: center;
- justify-content: center;
- .words-box {
- color: #000;
- text-align: center;
- .words {
- display: block;
- font-size: 28px;
- font-weight: 400;
- line-height: 40px;
- }
- .pinyin {
- display: block;
- height: 20px;
- font-family: 'League';
- font-size: 20px;
- font-weight: 400;
- line-height: 1;
- }
- }
- }
- .checkPinyinInput {
- margin: 16px 0 8px;
- }
- .tips {
- margin: 0 0 24px;
- font-size: 12px;
- font-weight: 400;
- line-height: 18px;
- color: #a0a0a0;
- }
- .btn-box {
- display: block;
- text-align: right;
- .el-button {
- padding: 2px 12px;
- font-size: 12px;
- line-height: 20px;
- }
- }
- }
- }
- </style>
|