| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835 |
- <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" :isNormal="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 class="table-rich-toolbar" v-if="articleAttrib">
- <el-select
- v-model="articleAttrib.font"
- placeholder="请选择"
- style="width: 130px"
- @change="handleChangeStyles"
- >
- <el-option v-for="{ value, label } in fontFamilyList" :key="value" :label="label" :value="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
- class="pinyin"
- :style="{
- fontSize: articleAttrib.pinyin_size,
- }"
- v-if="isEnable(data.property.view_pinyin)"
- @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"
- />
- <!-- 关联注释 -->
- <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"></el-input>
- <div class="matchNotes-color">
- <span>气泡颜色<el-color-picker v-model="matchNotesObj.notesColor"></el-color-picker></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 ResourcesOperate from '../../common/ResourcesOperate.vue';
- import { getArticleData } from '@/views/book/courseware/data/article';
- import { fontFamilyList } from '@/views/book/courseware/data/table';
- 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,
- },
- mixins: [ModuleMixin],
- data() {
- return {
- fontFamilyList,
- 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,
- 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,
- };
- // 分段
- 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);
- contentStr += item.trim() + '\n';
- }
- });
- 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: 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);
- });
- } 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: text,
- is_rich_text: 'false',
- is_first_sentence_first_hz_pinyin_first_char_upper_case: flag ? 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>
|