Article.vue 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835
  1. <template>
  2. <ModuleBase ref="base" :type="data.type">
  3. <template #content>
  4. <!-- eslint-disable max-len -->
  5. <div v-loading="loading" class="article-wrapper">
  6. <el-input v-model="data.content" placeholder="输入" type="textarea" />
  7. <span class="tips">输入课文文本后,请先点击生成分词</span>
  8. <el-button type="primary" @click="handleChangeContent">生成分词</el-button>
  9. <template v-if="data.detail.length > 0">
  10. <div class="new-btn-box">
  11. <p>文本内容</p>
  12. <div>
  13. <a @click="checkArticle">分词和拼音</a>
  14. <a @click="editWordsFlag = !editWordsFlag">生词和气泡</a>
  15. <a @click="handleMultilingual">多语种翻译</a>
  16. <MultilingualFill
  17. :visible.sync="multilingualVisible"
  18. :text="multilingualText"
  19. :translations="data.multilingual"
  20. @SubmitTranslation="handleMultilingualTranslation"
  21. />
  22. </div>
  23. </div>
  24. <div class="new-btn-box">
  25. <p>音频内容</p>
  26. <div>
  27. <SelectUpload label="" type="audio" :isNormal="true" @uploadSuccess="uploadAudioSuccess" />
  28. <el-button :loading="autoLoading" @click="handleAutoAudio">生成音频</el-button>
  29. <template v-if="data.mp3_list.length === 0">
  30. <el-tooltip class="item" effect="dark" content="请先设置音频" placement="top">
  31. <el-button disabled style="margin-left: 0">校对字幕</el-button>
  32. </el-tooltip>
  33. </template>
  34. <template v-else>
  35. <template v-if="data.wordTime && data.wordTime.length > 0">
  36. <a type="text" @click="againWordTime">重新生成字幕</a>
  37. <a size="medium" @click="openCheckSubtitles('句子')">句子字幕</a>
  38. <a size="medium" @click="compareTime('文字')">文字字幕</a>
  39. </template>
  40. <template v-else>
  41. <a v-if="!isWordTime" size="medium" @click="createWordTimes">自动生成字幕节点</a>
  42. <p v-else>字幕节点生成中...请等待</p>
  43. </template>
  44. </template>
  45. </div>
  46. </div>
  47. <div v-if="data.mp3_list.length > 0" class="upload-file">
  48. <div class="file-name">
  49. <span>
  50. <SvgIcon icon-class="note" size="12" />
  51. <span>{{ data.mp3_list[0].name }}</span>
  52. </span>
  53. </div>
  54. <SvgIcon icon-class="delete-black" size="12" @click="removeFile" />
  55. <ResourcesOperate :data="data.mp3_list[0]" />
  56. </div>
  57. <div class="new-btn-box">
  58. <p>多媒体内容</p>
  59. <div>
  60. <a @click="picArticle">上传图片</a>
  61. <a @click="picArticle">上传视频</a>
  62. </div>
  63. </div>
  64. <div class="table-rich-toolbar" v-if="articleAttrib">
  65. <el-select
  66. v-model="articleAttrib.font"
  67. placeholder="请选择"
  68. style="width: 130px"
  69. @change="handleChangeStyles"
  70. >
  71. <el-option v-for="{ value, label } in fontFamilyList" :key="value" :label="label" :value="value" />
  72. </el-select>
  73. <el-select
  74. v-model="articleAttrib.font_size"
  75. placeholder="请选择"
  76. style="width: 130px"
  77. @change="data.unified_attrib.font_size = articleAttrib.font_size"
  78. >
  79. <el-option
  80. v-for="(value, index) in 16"
  81. :key="index"
  82. :label="6 + value * 2 + 'pt'"
  83. :value="6 + value * 2 + 'pt'"
  84. />
  85. </el-select>
  86. <el-form :model="articleAttrib" inline>
  87. <el-form-item label="文字颜色">
  88. <el-color-picker v-model="articleAttrib.text_color" @change="handleChangeStyles" />
  89. </el-form-item>
  90. </el-form>
  91. <span :class="[data.other_attrib.isUnderline ? 'active' : '']" @click="setActiveTextStyle('underline')">
  92. <SvgIcon icon-class="underline" size="20" />
  93. </span>
  94. <span :class="[data.other_attrib.isBold ? 'active' : '']" @click="setActiveTextStyle('bold')">
  95. <SvgIcon icon-class="font-bold" size="20" />
  96. </span>
  97. <!-- <span
  98. :class="[data.other_attrib.isItalic ? 'active' : '']"
  99. @click="data.other_attrib.isItalic = !data.other_attrib.isItalic"
  100. >
  101. <SvgIcon icon-class="font-italic" size="20" />
  102. </span> -->
  103. <span
  104. :class="[data.other_attrib.isStrikethrough ? 'active' : '']"
  105. @click="setActiveTextStyle('line-through')"
  106. >
  107. <SvgIcon icon-class="strikethrough" size="20" />
  108. </span>
  109. <span :class="[data.other_attrib.border === 'dotted' ? 'active' : '']">
  110. <SvgIcon icon-class="borderDotted" title="下划虚线" size="16" @click="setActiveTextStyle('border')" />
  111. </span>
  112. <span
  113. :class="[articleAttrib.align === 'LEFT' ? 'active' : '']"
  114. @click="setActiveTextStyle('align', 'LEFT')"
  115. >
  116. <SvgIcon icon-class="align-left" size="20" />
  117. </span>
  118. <span
  119. :class="[articleAttrib.align === 'MIDDLE' ? 'active' : '']"
  120. @click="setActiveTextStyle('align', 'MIDDLE')"
  121. >
  122. <SvgIcon icon-class="align-center" size="20" />
  123. </span>
  124. <span
  125. :class="[articleAttrib.align === 'RIGHT' ? 'active' : '']"
  126. @click="setActiveTextStyle('align', 'RIGHT')"
  127. >
  128. <SvgIcon icon-class="align-right" size="20" />
  129. </span>
  130. </div>
  131. </template>
  132. <!-- <div v-if="data.content" class="btn-box">
  133. <a @click="handleChangeContent">生成分词</a>
  134. <a @click="checkArticle">文章校对</a>
  135. <a @click="picArticle">添加图片</a>
  136. <a @click="editWordsFlag = !editWordsFlag">编辑生词短语气泡</a>
  137. <template v-if="data.wordTime && data.wordTime.length > 0">
  138. <a type="text" @click="againWordTime">重新生成字幕时间</a>
  139. <a size="medium" @click="openCheckSubtitles('句子')">校对句子字幕时间</a>
  140. <a size="medium" @click="compareTime('文字')">校对文字字幕时间</a>
  141. </template>
  142. <template v-else>
  143. <a v-if="!isWordTime" size="medium" @click="createWordTimes">自动生成字幕节点</a>
  144. <p v-else>字幕节点生成中...请等待</p>
  145. </template>
  146. <el-button @click="handleMultilingual">课文多语言</el-button>
  147. <MultilingualFill
  148. :visible.sync="multilingualVisible"
  149. :text="multilingualText"
  150. :translations="data.multilingual"
  151. @SubmitTranslation="handleMultilingualTranslation"
  152. />
  153. </div> -->
  154. </div>
  155. <template v-if="data.detail.length > 0">
  156. <el-divider content-position="left"
  157. >预览效果<el-button
  158. v-show="data.detail.length > 0"
  159. type="text"
  160. icon="el-icon-refresh"
  161. title="刷新"
  162. class="refresh-pinyin-btn"
  163. @click.native="handleChangeContent"
  164. /></el-divider>
  165. <div v-for="(item, index) in data.detail" :key="index" class="text">
  166. <div class="text-item">
  167. <span
  168. class="word"
  169. :style="{
  170. fontSize: articleAttrib.font_size,
  171. }"
  172. >
  173. &nbsp;&nbsp;&nbsp;&nbsp;
  174. </span>
  175. </div>
  176. <div class="text-item">
  177. <span
  178. class="word"
  179. :style="{
  180. fontSize: articleAttrib.font_size,
  181. }"
  182. >
  183. &nbsp;&nbsp;&nbsp;&nbsp;
  184. </span>
  185. </div>
  186. <template v-for="(witem, windex) in item.wordsList">
  187. <div
  188. v-for="(wItem, wIndex) in witem"
  189. :key="windex + '-' + wIndex"
  190. class="text-item"
  191. :style="{
  192. textAlign: wIndex === 0 ? 'left' : '',
  193. }"
  194. >
  195. <span
  196. class="pinyin"
  197. :style="{
  198. fontSize: articleAttrib.pinyin_size,
  199. }"
  200. v-if="isEnable(data.property.view_pinyin)"
  201. @click="selectItem(wItem, wIndex)"
  202. >{{
  203. wIndex === 0 && data.property.is_first_sentence_first_hz_pinyin_first_char_upper_case === 'true'
  204. ? wItem.pinyin_up
  205. : wItem.pinyin
  206. }}</span
  207. >
  208. <span
  209. class="word"
  210. :style="{
  211. fontFamily: wItem.fontFamily,
  212. textDecoration: wItem.textDecoration,
  213. borderBottom: wItem.border === 'dotted' ? '1px dotted' : '',
  214. fontWeight: wItem.fontWeight,
  215. color:
  216. wItem.matchNotesObj.con && wItem.matchNotesObj.notesColor
  217. ? wItem.matchNotesObj.notesColor
  218. : wItem.color,
  219. fontSize: articleAttrib.font_size,
  220. }"
  221. @click="matchItemNotes(wItem)"
  222. >{{ wItem.chs }}</span
  223. >
  224. </div>
  225. </template>
  226. </div>
  227. </template>
  228. <el-dialog
  229. v-if="dialogFlag"
  230. :visible.sync="dialogFlag"
  231. :show-close="false"
  232. :close-on-click-modal="false"
  233. :modal-append-to-body="false"
  234. :modal="false"
  235. width="250px"
  236. class="article-checkpinyin-dialog"
  237. >
  238. <div class="check-box">
  239. <div class="content">
  240. <div class="words-box">
  241. <span class="pinyin">
  242. {{ itemActiveIndex === 0 ? itemActive.pinyin_up : itemActive.pinyin }}
  243. </span>
  244. <span class="words">
  245. {{ itemActive.chs }}
  246. </span>
  247. </div>
  248. </div>
  249. <!-- <el-input v-model="checkPinyinInput" type="text" class="checkPinyinInput" /> -->
  250. <el-select
  251. v-model="checkPinyinInput"
  252. placeholder="请输入"
  253. filterable
  254. allow-create
  255. default-first-option
  256. class="checkPinyinInput"
  257. >
  258. <el-option v-for="item in pinyinList" :key="item.pinyin" :value="item.pinyin.replace(/,/g, '')">
  259. <span style="float: left">{{ item.pinyin.replace(/,/g, '') }}</span>
  260. <span style="float: right; font-size: 13px; color: #8492a6">{{
  261. item.storage_type === 1 ? '机构库' : item.storage_type === 2 ? '全域库' : '个人库'
  262. }}</span>
  263. </el-option>
  264. </el-select>
  265. <p class="tips">一到四声分别用数字1-4表示。拼音间用空格隔开,儿化音输入r,如“活儿”输入“huor2”。</p>
  266. <div class="btn-box">
  267. <el-button type="info" size="small" @click="cancleDialog">取消</el-button>
  268. <el-button type="primary" size="small" @click="surePinyin">保存</el-button>
  269. </div>
  270. </div>
  271. </el-dialog>
  272. <el-dialog
  273. v-if="showArticleFlag"
  274. :visible.sync="showArticleFlag"
  275. :show-close="true"
  276. :close-on-click-modal="true"
  277. :modal-append-to-body="true"
  278. :append-to-body="true"
  279. :lock-scroll="true"
  280. width="80%"
  281. class="practiceBox"
  282. >
  283. <CheckArticle
  284. ref="CheckArticle"
  285. :data="data"
  286. @saveWord="saveWord"
  287. @savePinyin="savePinyin"
  288. @saveStyle="saveStyle"
  289. />
  290. </el-dialog>
  291. <el-dialog title="校对字幕时间" :visible.sync="compareShow" width="50%" :before-close="handleClose" top="0">
  292. <CompareTime
  293. :data="compareData"
  294. :type="compareType"
  295. :changewords-result-list="changewordsResultList"
  296. :open-check-subtitles="openCheckSubtitles"
  297. />
  298. <span slot="footer" class="dialog-footer">
  299. <el-button @click="handleClose">取 消</el-button>
  300. <el-button :loading="compareloading" type="primary" @click="saveCompare">确 定</el-button>
  301. </span>
  302. </el-dialog>
  303. <!-- <el-dialog title="" :visible.sync="editWordsFlag" width="80%" :close-on-click-modal="true" top="0"> -->
  304. <template v-if="editWordsFlag">
  305. <div class="tabs-box">
  306. <a :class="[editWordIndex === 0 ? 'active' : '']" @click="editWordIndex = 0">生词</a>
  307. <a :class="[editWordIndex === 2 ? 'active' : '']" @click="editWordIndex = 2">其他词汇</a>
  308. <a :class="[editWordIndex === 1 ? 'active' : '']" @click="editWordIndex = 1">气泡</a>
  309. </div>
  310. <NewWord
  311. v-if="editWordIndex === 0"
  312. key="new_word"
  313. :data-new-word="data.new_word_list"
  314. :unified-attrib="data.unified_attrib ? data.unified_attrib : null"
  315. @sureNewWords="sureNewWords"
  316. />
  317. <Notes
  318. v-if="editWordIndex === 1"
  319. key="notes"
  320. :data-notes="data.notes_list"
  321. :unified-attrib="data.unified_attrib ? data.unified_attrib : null"
  322. @sureNotes="sureNotes"
  323. @handleSyncCon="handleSyncCon"
  324. />
  325. <NewWord
  326. v-if="editWordIndex === 2"
  327. :data-new-word="data.other_word_list"
  328. :unified-attrib="data.unified_attrib ? data.unified_attrib : null"
  329. @sureNewWords="sureOtherNewWords"
  330. />
  331. </template>
  332. <!-- </el-dialog> -->
  333. <!-- 添加图片 -->
  334. <el-dialog
  335. v-if="showPicArticleFlag"
  336. :visible.sync="showPicArticleFlag"
  337. :show-close="true"
  338. :close-on-click-modal="true"
  339. :modal-append-to-body="true"
  340. :append-to-body="true"
  341. :lock-scroll="true"
  342. width="80%"
  343. class="practiceBox"
  344. >
  345. <CheckPic :data="data" />
  346. </el-dialog>
  347. <CheckSubtitles
  348. v-if="visible"
  349. :visible.sync="visible"
  350. :audio-id="data.mp3_list[0] && data.mp3_list[0].file_id ? data.mp3_list[0].file_id : ''"
  351. :option-list="subtitleList"
  352. @saveSubtitles="saveSubtitles"
  353. />
  354. <!-- 关联注释 -->
  355. <el-dialog
  356. v-if="matchNoteFlag"
  357. :visible.sync="matchNoteFlag"
  358. :show-close="true"
  359. :close-on-click-modal="false"
  360. :modal-append-to-body="false"
  361. :modal="false"
  362. width="600px"
  363. class="article-matchNotes-dialog"
  364. :title="matchNotesObj.id ? '编辑气泡' : '添加气泡'"
  365. >
  366. <div class="matchNotes-box">
  367. <RichText
  368. v-if="matchNotesObj.isRich"
  369. ref="richText"
  370. v-model="matchNotesObj.con"
  371. :font-size="'14pt'"
  372. :font-family="data.unified_attrib?.font"
  373. :font-color="data.unified_attrib?.text_color"
  374. toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright image media link"
  375. />
  376. <el-input v-else v-model="matchNotesObj.con" type="textarea" rows="5"></el-input>
  377. <div class="matchNotes-color">
  378. <span>气泡颜色<el-color-picker v-model="matchNotesObj.notesColor"></el-color-picker></span>
  379. <span @click="matchNotesObj.isRich = !matchNotesObj.isRich"
  380. ><SvgIcon icon-class="change" size="16" />切换文本模式</span
  381. >
  382. </div>
  383. <div class="btn-box">
  384. <el-button type="info" size="small" @click="cancleMatchNotesDialog">删除</el-button>
  385. <el-button type="primary" size="small" @click="sureMatchNotes">保存</el-button>
  386. </div>
  387. </div>
  388. </el-dialog>
  389. </template>
  390. </ModuleBase>
  391. </template>
  392. <script>
  393. import ModuleMixin from '../../common/ModuleMixin';
  394. import SelectUpload from '@/views/book/courseware/create/components/common/SelectUpload.vue';
  395. import CheckArticle from './CheckArticle.vue';
  396. import CompareTime from './CompareTime.vue';
  397. import NewWord from './NewWord.vue';
  398. import Notes from './Notes.vue';
  399. import CheckPic from './CheckPic.vue';
  400. import CheckSubtitles from '@/views/book/courseware/create/components/question/voice_matrix/CheckSubtitles.vue';
  401. import ResourcesOperate from '../../common/ResourcesOperate.vue';
  402. import { getArticleData } from '@/views/book/courseware/data/article';
  403. import { fontFamilyList } from '@/views/book/courseware/data/table';
  404. import { TextToAudioFile } from '@/api/app';
  405. import { isEnable } from '@/views/book/courseware/data/common';
  406. import {
  407. segSentences,
  408. BatchSegContent,
  409. getWordTime,
  410. prepareTranscribe,
  411. fileToBase64Text,
  412. getWordTimes,
  413. } from '@/api/article';
  414. const Base64 = require('js-base64').Base64;
  415. import cnchar from 'cnchar';
  416. import { toolGetWordPinyinCorrectionList } from '@/api/pinyinCorrection';
  417. import { PinyinBuild_OldFormat } from '@/api/book';
  418. import { getRandomNumber } from '@/utils';
  419. export default {
  420. name: 'ArticlePage',
  421. components: {
  422. SelectUpload,
  423. CheckArticle,
  424. CompareTime,
  425. NewWord,
  426. Notes,
  427. CheckPic,
  428. CheckSubtitles,
  429. ResourcesOperate,
  430. },
  431. mixins: [ModuleMixin],
  432. data() {
  433. return {
  434. fontFamilyList,
  435. isEnable,
  436. data: getArticleData(),
  437. showArticleFlag: false, // 校对文章
  438. showPicArticleFlag: false, // 添加图片
  439. toneList: [' ', 'ˉ', 'ˊ', 'ˇ', 'ˋ'],
  440. loading: false,
  441. isWordTime: false,
  442. compareType: '', // 校对类型
  443. compareIndex: null, // 校对句子索引
  444. compareShow: false,
  445. compareData: null,
  446. compareloading: false,
  447. editWordsFlag: false,
  448. editWordIndex: 0,
  449. multilingualText: '',
  450. autoLoading: false,
  451. visible: false,
  452. subtitleList: [],
  453. itemActive: null,
  454. itemActiveIndex: null,
  455. dialogFlag: false,
  456. checkPinyinInput: '',
  457. oldInput: '',
  458. tableData: [
  459. ['ā', 'á', 'ǎ', 'à', 'a'],
  460. ['ō', 'ó', 'ǒ', 'ò', 'o'],
  461. ['ē', 'é', 'ě', 'è', 'e'],
  462. ['ī', 'í', 'ǐ', 'ì', 'i'],
  463. ['ū', 'ú', 'ǔ', 'ù', 'u'],
  464. ['ǖ', 'ǘ', 'ǚ', 'ǜ', 'ü'],
  465. ['Ā', 'Á', 'Â', 'À', 'A'],
  466. ['Ō', 'Ó', 'Ô', 'Ò', 'O'],
  467. ['Ē', 'É', 'Ê', 'È', 'E'],
  468. ['Ī', 'Í', 'Î', 'Ì', 'I'],
  469. ['Ū', 'Ú', 'Û', 'Ù', 'U'],
  470. ['n', 'ń', 'ň', 'ǹ', 'n'],
  471. ['m̄', 'ḿ', 'm', 'm̀', 'm'],
  472. ],
  473. pinyinList: [], // 拼音校正列表
  474. articleAttrib: null,
  475. matchNoteItem: null, // 选中关联注释的词
  476. matchNoteFlag: false,
  477. };
  478. },
  479. watch: {
  480. 'data.content': 'handleMindMap',
  481. 'data.unified_attrib': {
  482. handler(val) {
  483. if (val) {
  484. let oldAttrib = this.data.other_attrib;
  485. this.articleAttrib = JSON.parse(JSON.stringify(val));
  486. if (oldAttrib.oldFont && oldAttrib.oldFont !== val.font) {
  487. this.$set(this.articleAttrib, 'font', oldAttrib.oldFont);
  488. }
  489. if (oldAttrib.oldColor && oldAttrib.oldColor !== val.text_color) {
  490. this.$set(this.articleAttrib, 'text_color', oldAttrib.oldColor);
  491. }
  492. if (oldAttrib.align && oldAttrib.align !== val.align) {
  493. this.$set(this.articleAttrib, 'align', oldAttrib.align);
  494. }
  495. // this.handleChangeStyles();
  496. }
  497. },
  498. deep: true,
  499. immediate: true,
  500. },
  501. // 'data.unified_attrib.font': {
  502. // handler(val) {
  503. // if (val) {
  504. // this.handleChangeStyles();
  505. // }
  506. // },
  507. // deep: true,
  508. // immediate: true,
  509. // },
  510. // 'data.unified_attrib.text_color': {
  511. // handler(val) {
  512. // if (val) {
  513. // this.handleChangeStyles();
  514. // }
  515. // },
  516. // deep: true,
  517. // immediate: true,
  518. // },
  519. // 'data.unified_attrib.align': {
  520. // handler(val) {
  521. // if (val) {
  522. // this.handleChangeStyles();
  523. // }
  524. // },
  525. // deep: true,
  526. // immediate: true,
  527. // },
  528. },
  529. created() {},
  530. methods: {
  531. // 全局样式变化
  532. handleChangeStyles() {
  533. if (this.articleAttrib.font !== this.data.other_attrib.oldFont) {
  534. this.data.other_attrib.oldFont = this.articleAttrib.font;
  535. this.data.detail.forEach((item) => {
  536. item.wordsList.forEach((items) => {
  537. items.forEach((itemss) => {
  538. itemss.fontFamily = this.articleAttrib.font;
  539. });
  540. });
  541. });
  542. }
  543. if (this.articleAttrib.text_color !== this.data.other_attrib.oldColor) {
  544. this.data.other_attrib.oldColor = this.articleAttrib.text_color;
  545. this.data.detail.forEach((item) => {
  546. item.wordsList.forEach((items) => {
  547. items.forEach((itemss) => {
  548. itemss.color = this.articleAttrib.text_color;
  549. });
  550. });
  551. });
  552. }
  553. if (this.articleAttrib.align !== this.data.other_attrib.oldAlign) {
  554. this.data.other_attrib.oldAlign = this.articleAttrib.align;
  555. this.data.detail.forEach((item) => {
  556. item.paraAlign =
  557. this.articleAttrib.align === 'RIGHT' ? 'right' : this.articleAttrib.align === 'MIDDLE' ? 'center' : 'left';
  558. });
  559. }
  560. },
  561. // 解析输入内容
  562. handleChangeContent() {
  563. if (this.data.content.trim()) {
  564. if (this.data.detail.length === 0) {
  565. this.handleResetSet();
  566. } else {
  567. this.$confirm('重新生成分词会重置课文内拼音、气泡、字幕和图片视频附件,确定执行此操作吗?', '提示', {
  568. confirmButtonText: '确定',
  569. cancelButtonText: '取消',
  570. type: 'warning',
  571. })
  572. .then(() => {
  573. this.handleResetSet();
  574. this.data.notes_list.option = [];
  575. this.isWordTime = false;
  576. this.data.wordTime = [];
  577. })
  578. .catch(() => {});
  579. }
  580. // 分句
  581. // let sentenceList = []; // 句子按段数组
  582. // let data = {
  583. // textList,
  584. // };
  585. // segSentences(data)
  586. // .then((res) => {
  587. // let result = res.data.result;
  588. // sentenceList = JSON.parse(JSON.stringify(res.data.result));
  589. // result.forEach((item, index) => {
  590. // let sentenceListBase64 = [];
  591. // this.data.detail[index].sentences = item;
  592. // item.forEach((items) => {
  593. // sentenceListBase64.push(Base64.encode(items));
  594. // });
  595. // // 分词
  596. // BatchSegContent({ textList: sentenceListBase64 })
  597. // .then((res) => {
  598. // let list = res.data.result.list;
  599. // this.data.detail[index].segList = list;
  600. // this.setWordsList(list, index);
  601. // if (index === result.length - 1) {
  602. // this.handleSenWord();
  603. // this.loading = false;
  604. // }
  605. // })
  606. // .catch(() => {
  607. // this.loading = false;
  608. // });
  609. // });
  610. // })
  611. // .catch(() => {
  612. // this.loading = false;
  613. // });
  614. }
  615. },
  616. // 重置分词结构
  617. handleResetSet() {
  618. this.loading = true;
  619. this.data.detail = [];
  620. let contentArr = this.data.content.split('\n');
  621. let textList = [];
  622. let contentStr = '';
  623. let detailItem = {
  624. paraIndex: 0,
  625. para: '',
  626. sentences: [],
  627. segList: [],
  628. seg_words: [],
  629. wordsList: [],
  630. timeList: [],
  631. isTitle: false,
  632. sentencesEn: [],
  633. paraAlign: this.articleAttrib
  634. ? this.articleAttrib.align === 'RIGHT'
  635. ? 'right'
  636. : this.articleAttrib.align === 'MIDDLE'
  637. ? 'center'
  638. : 'left'
  639. : 'left',
  640. remark: {
  641. chs: '',
  642. en: '',
  643. heightNumber: null,
  644. img_list: [],
  645. widthNumber: null,
  646. chsBg: '#988ed6',
  647. enBg: '#fff',
  648. },
  649. sourceList: [],
  650. sourcePosition: 'after',
  651. heightNumber: null,
  652. widthNumber: null,
  653. };
  654. // 分段
  655. contentArr.forEach((item, index) => {
  656. if (item.trim()) {
  657. detailItem.para = item;
  658. detailItem.paraIndex = index;
  659. this.data.detail.push(JSON.parse(JSON.stringify(detailItem)));
  660. let str = Base64.encode(item);
  661. textList.push(str);
  662. contentStr += item.trim() + '\n';
  663. }
  664. });
  665. BatchSegContent({
  666. text: contentStr,
  667. is_build_pinyin: 'true',
  668. is_custom_fc: 'false',
  669. is_vocabulary_pinyin_lt: 'true',
  670. is_fill_punctuation_mark: 'true',
  671. is_fill_space: 'true',
  672. })
  673. .then((res) => {
  674. this.loading = false;
  675. if (res.status === 1) {
  676. res.paragraph_list.forEach((item, index) => {
  677. let sentenceList = []; // 句子按段数组
  678. let segList = []; // 句子分词结果
  679. item.forEach((items) => {
  680. let sentence = items.reduce((acc, itemss) => `${acc + itemss.text}`, '');
  681. let seg = items.map((itemss) => itemss.text);
  682. sentenceList.push(sentence);
  683. segList.push(seg);
  684. });
  685. this.data.detail[index].sentences = sentenceList;
  686. this.data.detail[index].segList = segList;
  687. this.setWordsList(item, index);
  688. });
  689. this.handleSenWord();
  690. }
  691. })
  692. .catch(() => {
  693. this.loading = false;
  694. });
  695. },
  696. // 处理句子和词的关系
  697. handleSenWord() {
  698. this.data.sentence_list_mp = [];
  699. this.data.detail.forEach((item) => {
  700. item.sentences.forEach((items, indexs) => {
  701. let word_list = [];
  702. item.segList[indexs].forEach((itemw) => {
  703. word_list.push({
  704. word: itemw,
  705. });
  706. });
  707. let obj = {
  708. sentence: items,
  709. word_list,
  710. };
  711. this.data.sentence_list_mp.push(obj);
  712. });
  713. });
  714. },
  715. setWordsList(list, paraIndex) {
  716. let wordsList = [];
  717. list.forEach((item, index) => {
  718. let sentArr = [];
  719. item.map((sItem) => {
  720. // let toneStr = [];
  721. // for (let i = 0; i < sItem.length; i++) {
  722. // const pattern = /[\u4e00-\u9fa5]/;
  723. // if (cnchar.isCnChar(sItem[i]) && !pattern.test(cnchar.spell(sItem[i], 'low', 'tone'))) {
  724. // toneStr.push(this.toneList[cnchar.spellInfo(cnchar.spell(sItem[i], 'low', 'tone')).tone]);
  725. // } else {
  726. // toneStr.push(' ');
  727. // }
  728. // }
  729. let obj = {
  730. chs: sItem.text,
  731. pinyin: sItem.pinyin,
  732. pinyin_up: sItem.pinyin_up,
  733. pinyin_tone: sItem.pinyin_tone,
  734. fontFamily: this.articleAttrib ? this.articleAttrib.font : '楷体',
  735. textDecoration: this.data.other_attrib
  736. ? this.data.other_attrib.isUnderline
  737. ? this.data.other_attrib.isUnderline
  738. : this.data.other_attrib.isStrikethrough
  739. ? this.data.other_attrib.isStrikethrough
  740. : ''
  741. : '',
  742. fontWeight: this.data.other_attrib ? this.data.other_attrib.isBold : '',
  743. border: this.data.other_attrib ? this.data.other_attrib.border : '',
  744. color: this.articleAttrib ? this.articleAttrib.text_color : '',
  745. matchWords: '',
  746. matchNotes: '',
  747. notesColor: '',
  748. img: [],
  749. imgPosition: 'after',
  750. matchNotesObj: {
  751. number: '',
  752. con: '',
  753. pinyin: '',
  754. interpret: '',
  755. note: '',
  756. notesColor: '#8206BF',
  757. id: '',
  758. isRich: true,
  759. matchNotes: sItem.text,
  760. },
  761. };
  762. sentArr.push(obj);
  763. });
  764. wordsList.push(sentArr);
  765. });
  766. this.data.detail[paraIndex].wordsList = wordsList;
  767. },
  768. uploadAudioSuccess(fileList) {
  769. if (fileList.length > 0) {
  770. const { file_name: name, file_url: temporary_url, file_id, media_duration } = fileList[0];
  771. this.data.mp3_list = [
  772. {
  773. name,
  774. media_duration,
  775. temporary_url,
  776. url: file_id,
  777. file_id,
  778. },
  779. ];
  780. this.data.file_id_list = [file_id];
  781. }
  782. },
  783. removeFile() {
  784. this.$confirm('是否删除当前文件?', '提示', {
  785. confirmButtonText: '确定',
  786. cancelButtonText: '取消',
  787. type: 'warning',
  788. })
  789. .then(() => {
  790. this.data.mp3_list = [];
  791. this.data.file_id_list = [];
  792. this.isWordTime = false;
  793. this.data.wordTime = [];
  794. })
  795. .catch(() => {});
  796. },
  797. // 校对文章
  798. checkArticle() {
  799. let verseList = [];
  800. this.data.detail.forEach((item) => {
  801. verseList = verseList.concat(item.sentences);
  802. });
  803. if (verseList.length > 0) {
  804. this.showArticleFlag = true;
  805. } else {
  806. this.$message.warning('请先生成分词');
  807. }
  808. },
  809. saveWord(saveArr) {
  810. BatchSegContent({
  811. text: this.data.content,
  812. is_build_pinyin: 'true',
  813. is_custom_fc: 'true',
  814. is_vocabulary_pinyin_lt: 'true',
  815. is_fill_punctuation_mark: 'true',
  816. is_fill_space: 'true',
  817. fc_paragraph_list: saveArr,
  818. }).then((res) => {
  819. if (res.status === 1) {
  820. res.paragraph_list.forEach((item, index) => {
  821. let sentenceList = []; // 句子按段数组
  822. let segList = []; // 句子分词结果
  823. let sentenceStr = [];
  824. let para = '';
  825. let wordsList = [];
  826. item.forEach((items) => {
  827. let sentence = items.reduce((acc, itemss) => `${acc + itemss.text}`, '');
  828. let sentenceS = items.reduce((acc, itemss) => `${acc + itemss.text}&nbsp;&nbsp;`, '');
  829. let seg = items.map((itemss) => itemss.text);
  830. para += items.map((itemss) => itemss.text);
  831. sentenceList.push(sentence);
  832. sentenceStr.push(sentenceS);
  833. segList.push(seg);
  834. let sentArr = [];
  835. items.forEach((sItem) => {
  836. let obj = {
  837. chs: sItem.text,
  838. pinyin: sItem.pinyin,
  839. pinyin_up: sItem.pinyin_up,
  840. pinyin_tone: sItem.pinyin_tone,
  841. fontFamily: this.articleAttrib ? this.articleAttrib.font : '楷体',
  842. textDecoration: this.data.other_attrib
  843. ? this.data.other_attrib.isUnderline
  844. ? this.data.other_attrib.isUnderline
  845. : this.data.other_attrib.isStrikethrough
  846. ? this.data.other_attrib.isStrikethrough
  847. : ''
  848. : '',
  849. fontWeight: this.data.other_attrib ? this.data.other_attrib.isBold : '',
  850. border: this.data.other_attrib ? this.data.other_attrib.border : '',
  851. color: this.articleAttrib ? this.articleAttrib.text_color : '',
  852. matchWords: '',
  853. matchNotes: '',
  854. notesColor: '',
  855. img: [],
  856. imgPosition: 'after',
  857. matchNotesObj: {
  858. number: '',
  859. con: '',
  860. pinyin: '',
  861. interpret: '',
  862. note: '',
  863. notesColor: '#8206BF',
  864. id: '',
  865. isRich: true,
  866. matchNotes: sItem.text,
  867. },
  868. };
  869. sentArr.push(obj);
  870. });
  871. wordsList.push(sentArr);
  872. });
  873. if (this.data.detail[index]) {
  874. this.data.detail[index].segList = segList;
  875. this.data.detail[index].para = para;
  876. this.data.detail[index].sentenceStr = sentenceStr;
  877. this.data.detail[index].sentences = sentenceList;
  878. this.data.detail[index].wordsList = wordsList;
  879. } else {
  880. let obj = {
  881. paraIndex: index,
  882. para,
  883. sentences: sentenceList,
  884. segList: segList,
  885. seg_words: [],
  886. wordsList,
  887. timeList: [],
  888. isTitle: false,
  889. sentencesEn: [],
  890. sentenceStr,
  891. paraAlign: this.articleAttrib
  892. ? this.articleAttrib.align === 'RIGHT'
  893. ? 'right'
  894. : this.articleAttrib.align === 'MIDDLE'
  895. ? 'center'
  896. : 'left'
  897. : 'left',
  898. remark: {
  899. chs: '',
  900. en: '',
  901. heightNumber: null,
  902. img_list: [],
  903. widthNumber: null,
  904. chsBg: '#988ed6',
  905. enBg: '#fff',
  906. },
  907. sourceList: [],
  908. sourcePosition: 'after',
  909. heightNumber: null,
  910. widthNumber: null,
  911. };
  912. this.data.detail.push(obj);
  913. }
  914. });
  915. this.$refs.CheckArticle.refreshData();
  916. }
  917. });
  918. this.$message.success('保存成功,请校对拼音');
  919. this.handleSenWord();
  920. },
  921. // 保存拼音
  922. savePinyin(paraIndex, sentenceIndex, wordIndex, pinyin) {
  923. if (this.data.pinyin_type === 'tone') {
  924. this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].pinyin_tone = pinyin;
  925. } else if (wordIndex === 0) {
  926. this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].pinyin_up = pinyin;
  927. } else {
  928. this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].pinyin = pinyin;
  929. }
  930. },
  931. saveStyle(
  932. paraIndex,
  933. sentenceIndex,
  934. wordIndex,
  935. fontFamily,
  936. textDecoration,
  937. fontWeight,
  938. border,
  939. color,
  940. matchWords,
  941. matchNotes,
  942. notesColor,
  943. img,
  944. imgPosition,
  945. ) {
  946. this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].fontFamily = fontFamily;
  947. this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].textDecoration = textDecoration;
  948. this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].fontWeight = fontWeight;
  949. this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].border = border;
  950. this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].color = color;
  951. this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].matchWords = matchWords;
  952. this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].matchNotes = matchNotes;
  953. this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].notesColor = notesColor;
  954. this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].img = img;
  955. this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].imgPosition = imgPosition;
  956. },
  957. // 保存校对
  958. saveCompare() {
  959. this.compareloading = false;
  960. // this.data.wordTime = this.compareData;
  961. this.handleClose();
  962. // this.compareloading = true;
  963. // compareSenTenceTime({ matchList: JSON.stringify(this.compareData) })
  964. // .then((res) => {
  965. // this.compareloading = false;
  966. // this.data.wordTime = res.data.result;
  967. // })
  968. // .catch(() => {
  969. // this.compareloading = false;
  970. // });
  971. },
  972. // 校对时间
  973. compareTime(type) {
  974. this.compareType = type;
  975. this.compareData = JSON.parse(JSON.stringify(this.data.wordTime));
  976. this.compareShow = true;
  977. },
  978. handleClose() {
  979. this.compareShow = false;
  980. this.compareData = null;
  981. this.compareType = '';
  982. },
  983. // 校对每个字的时间
  984. changewordsResultList(index, item) {
  985. this.data.wordTime[index].wordsResultList = JSON.parse(JSON.stringify(item));
  986. },
  987. againWordTime() {
  988. this.isWordTime = false;
  989. this.data.wordTime = [];
  990. },
  991. createWordTimes() {
  992. let _this = this;
  993. let verseList = [];
  994. if (_this.data.mp3_list && _this.data.mp3_list.length > 0 && _this.data.mp3_list[0].file_id) {
  995. if (_this.data.content) {
  996. _this.data.detail.forEach((item) => {
  997. verseList = verseList.concat(item.sentences);
  998. });
  999. if (verseList.length > 0) {
  1000. _this.isWordTime = true;
  1001. let data = {
  1002. audio_file_id: _this.data.mp3_list[0].file_id,
  1003. text: _this.data.content,
  1004. text_type: 'line_text_list',
  1005. line_text_list: verseList,
  1006. };
  1007. getWordTimes(data).then((res) => {
  1008. _this.data.wordTime = res.data.result;
  1009. _this.isWordTime = false;
  1010. });
  1011. } else {
  1012. this.$message.warning('请先生成分词');
  1013. }
  1014. }
  1015. } else {
  1016. _this.$message.warning('请先上传音频');
  1017. _this.loading = false;
  1018. }
  1019. },
  1020. createWordTime() {
  1021. let _this = this;
  1022. this.getfillLiu().then(() => {
  1023. if (_this.data.taskId) {
  1024. let verseList = [];
  1025. _this.data.detail.forEach((item) => {
  1026. verseList = verseList.concat(item.sentences);
  1027. });
  1028. if (verseList.length > 0) {
  1029. _this.isWordTime = true;
  1030. let data = {
  1031. taskId: _this.data.taskId,
  1032. verseList: JSON.stringify(verseList),
  1033. matchType: 'chinese',
  1034. language: 'ch',
  1035. };
  1036. getWordTime(data).then((res) => {
  1037. _this.data.wordTime = res.data.result;
  1038. _this.isWordTime = false;
  1039. });
  1040. }
  1041. } else {
  1042. _this.$message.warning('请先上传音频');
  1043. _this.loading = false;
  1044. }
  1045. });
  1046. },
  1047. // 得到文件流
  1048. getfillLiu() {
  1049. this.loading = true;
  1050. let _this = this;
  1051. return new Promise(function (resolve, reject) {
  1052. if (_this.data.mp3_list && _this.data.mp3_list.length > 0 && _this.data.mp3_list[0].file_id) {
  1053. let id = _this.data.mp3_list[0].file_id;
  1054. let data = {
  1055. file_id: id,
  1056. };
  1057. fileToBase64Text(data).then((res) => {
  1058. let taskIddata = {
  1059. fileName: _this.data.mp3_list[0].name,
  1060. speechBase64: res.base64_text,
  1061. language: 'ch',
  1062. };
  1063. prepareTranscribe(taskIddata)
  1064. .then((ress) => {
  1065. _this.$set(_this.data, 'taskId', ress.data.taskId);
  1066. _this.loading = false;
  1067. resolve();
  1068. })
  1069. .catch(() => {
  1070. _this.loading = false;
  1071. });
  1072. });
  1073. } else {
  1074. _this.$message.warning('请先上传音频');
  1075. _this.loading = false;
  1076. }
  1077. });
  1078. },
  1079. sureNewWords(data) {
  1080. this.data.new_word_list = data;
  1081. },
  1082. sureOtherNewWords(data) {
  1083. this.data.other_word_list = data;
  1084. },
  1085. sureNotes(data) {
  1086. this.data.notes_list = data;
  1087. },
  1088. handleMindMap() {
  1089. // 思维导图数据
  1090. let node_list = [];
  1091. node_list.push({
  1092. name: this.data.content,
  1093. id: Math.random().toString(36).substring(2, 12),
  1094. });
  1095. this.data.mind_map.node_list = node_list;
  1096. },
  1097. handleMultilingual() {
  1098. this.multilingualText = '';
  1099. let flag = false;
  1100. this.data.detail.forEach((item) => {
  1101. if (item.para) {
  1102. if (item.sentences && item.sentences.length > 0) {
  1103. flag = true;
  1104. }
  1105. item.sentences.forEach((items) => {
  1106. this.multilingualText += `<p>${items}<p>`;
  1107. });
  1108. } else {
  1109. this.multilingualText += '<p>&nbsp;</p>';
  1110. }
  1111. // this.multilingualText += item.para ? '<p>' + item.para + '<p>' : '<p>&nbsp;</p>';
  1112. });
  1113. if (flag) {
  1114. this.multilingualVisible = true;
  1115. } else {
  1116. this.$message.warning('请先生成分词');
  1117. }
  1118. },
  1119. // 点击插入图片按钮
  1120. picArticle() {
  1121. let verseList = [];
  1122. this.data.detail.forEach((item) => {
  1123. verseList = verseList.concat(item.sentences);
  1124. });
  1125. if (verseList.length > 0) {
  1126. this.showPicArticleFlag = true;
  1127. } else {
  1128. this.$message.warning('请先生成分词');
  1129. }
  1130. },
  1131. // 自动生成音频
  1132. handleAutoAudio() {
  1133. this.autoLoading = true;
  1134. TextToAudioFile({
  1135. text: this.data.content,
  1136. voice_type: this.data.property.voice_type,
  1137. emotion: this.data.property.emotion,
  1138. speed_ratio: this.data.property.speed_ratio,
  1139. sentence_interval: 1000,
  1140. })
  1141. .then(({ status, file_id, file_url }) => {
  1142. this.autoLoading = false;
  1143. if (status === 1) {
  1144. this.data.mp3_list = [
  1145. {
  1146. name: '自动生成课文音频.mp3',
  1147. media_duration: 0,
  1148. temporary_url: file_url,
  1149. url: file_id,
  1150. file_id,
  1151. },
  1152. ];
  1153. this.data.file_id_list = [file_id];
  1154. }
  1155. })
  1156. .catch(() => {
  1157. this.autoLoading = false;
  1158. });
  1159. },
  1160. /**
  1161. * 打开校对字幕
  1162. */
  1163. openCheckSubtitles(type, index) {
  1164. this.compareType = type;
  1165. // this.compareData = JSON.parse(JSON.stringify(this.data.wordTime));
  1166. // this.compareShow = true;
  1167. if (this.data.mp3_list.length === 0) {
  1168. return this.$message.warning('请先上传音频文件');
  1169. }
  1170. this.subtitleList = [];
  1171. if (this.compareType === '句子') {
  1172. this.data.wordTime.forEach((item, index) => {
  1173. let obj = {
  1174. content: item.onebest,
  1175. lrc_data: {
  1176. begin_time: item.bg,
  1177. end_time: item.ed,
  1178. },
  1179. };
  1180. this.subtitleList.push(obj);
  1181. });
  1182. } else {
  1183. this.compareIndex = index;
  1184. this.data.wordTime[index].wordsResultList.forEach((item, index) => {
  1185. let obj = {
  1186. content: item.wordsName,
  1187. lrc_data: {
  1188. begin_time: item.wordBg,
  1189. end_time: item.wordEd,
  1190. },
  1191. };
  1192. this.subtitleList.push(obj);
  1193. });
  1194. }
  1195. this.visible = true;
  1196. },
  1197. /**
  1198. * 保存字幕
  1199. * @param {Array} dataList
  1200. */
  1201. saveSubtitles(dataList) {
  1202. if (this.compareType === '句子') {
  1203. this.data.wordTime.forEach((item, index) => {
  1204. item.bg = dataList[index] ? dataList[index].lrc_data.begin_time : 0;
  1205. item.ed = dataList[index] ? dataList[index].lrc_data.end_time : 0;
  1206. });
  1207. } else {
  1208. this.data.wordTime[this.compareIndex].wordsResultList.forEach((item, index) => {
  1209. item.wordBg = dataList[index] ? dataList[index].lrc_data.begin_time : 0;
  1210. item.wordEd = dataList[index] ? dataList[index].lrc_data.end_time : 0;
  1211. });
  1212. }
  1213. },
  1214. selectItem(item, index) {
  1215. this.itemActive = item;
  1216. this.itemActiveIndex = index;
  1217. this.pinyinList = [];
  1218. toolGetWordPinyinCorrectionList({
  1219. word: item.chs,
  1220. })
  1221. .then((res) => {
  1222. if (res.status === 1) {
  1223. this.pinyinList = res.pinyin_correction_list;
  1224. }
  1225. this.dialogFlag = true;
  1226. })
  1227. .catch(() => {
  1228. this.dialogFlag = true;
  1229. });
  1230. this.checkPinyinInput = '';
  1231. },
  1232. cancleDialog() {
  1233. this.itemActive = null;
  1234. this.checkPinyinInput = '';
  1235. this.oldInput = '';
  1236. this.dialogFlag = false;
  1237. },
  1238. surePinyin() {
  1239. this.oldInput = JSON.parse(JSON.stringify(this.checkPinyinInput.trim()));
  1240. if (this.oldInput) {
  1241. this.handleReplaceTone(this.checkPinyinInput.trim());
  1242. } else {
  1243. this.itemActive.pinyin = ' ';
  1244. this.itemActive.pinyin_up = ' ';
  1245. this.$message.success('保存成功');
  1246. // this.itemActive = null;
  1247. this.dialogFlag = false;
  1248. }
  1249. },
  1250. handleReplaceTone(e) {
  1251. let _this = this;
  1252. _this.$nextTick(() => {
  1253. let value = e;
  1254. _this.resArr = [];
  1255. if (value) {
  1256. let valueArr = [];
  1257. value.replace(/\s+/g, ' ');
  1258. valueArr = value.split(' ');
  1259. // let reg = /\s+/g;
  1260. // valueArr = value.split(reg);
  1261. valueArr.forEach((item, index) => {
  1262. if (this.data.pinyin_type === 'tone') {
  1263. this.resArr.push([
  1264. {
  1265. con: this.toneList[Number(item)],
  1266. },
  1267. ]);
  1268. } else {
  1269. this.handleValue(item);
  1270. }
  1271. });
  1272. let str = '';
  1273. setTimeout(() => {
  1274. _this.resArr.forEach((item) => {
  1275. str += ' ';
  1276. item.forEach((sItem) => {
  1277. if (sItem.number && sItem.con) {
  1278. let number = Number(sItem.number);
  1279. let con = sItem.con;
  1280. let word = _this.addTone(number, con);
  1281. str += word;
  1282. } else if (sItem.number) {
  1283. str += sItem.number;
  1284. } else if (sItem.con) {
  1285. str += ` ${sItem.con} `;
  1286. }
  1287. });
  1288. });
  1289. this.checkPinyinInput = str.trim();
  1290. this.itemActive.pinyin = this.checkPinyinInput.replace(/\s+/g, '');
  1291. this.itemActive.pinyin_up = this.checkPinyinInput.replace(/\s+/g, '');
  1292. this.$message.success('保存成功');
  1293. // this.itemActive = null;
  1294. this.checkPinyinInput = '';
  1295. this.oldInput = '';
  1296. this.dialogFlag = false;
  1297. }, 10);
  1298. }
  1299. });
  1300. },
  1301. handleValue(valItem) {
  1302. let reg = /\d/;
  1303. let reg2 = /[A-Za-z]+\d/g;
  1304. let numList = [];
  1305. let valArr = valItem.split('');
  1306. if (reg2.test(valItem)) {
  1307. for (let i = 0; i < valArr.length; i++) {
  1308. let item = valItem[i];
  1309. if (reg.test(item)) {
  1310. let numIndex = numList.length === 0 ? 0 : numList[numList.length - 1].index;
  1311. let con = valItem.substring(numIndex, i);
  1312. con = con.replace(/\d/g, '');
  1313. let obj = {
  1314. index: i,
  1315. number: item,
  1316. con,
  1317. isTran: true,
  1318. };
  1319. numList.push(obj);
  1320. }
  1321. }
  1322. } else {
  1323. numList = [];
  1324. }
  1325. if (numList.length === 0) {
  1326. this.resArr.push([{ con: valItem }]);
  1327. } else {
  1328. this.resArr.push(numList);
  1329. }
  1330. },
  1331. addTone(number, con) {
  1332. let _this = this;
  1333. let zmList = ['a', 'o', 'e', 'i', 'u', 'v', 'A', 'O', 'E', 'I', 'U', 'n', 'm'];
  1334. if (number) {
  1335. for (let i = 0; i < zmList.length; i++) {
  1336. let zm = zmList[i];
  1337. if (con.indexOf(zm) > -1) {
  1338. let zm2 = _this.tableData[i][number - 1];
  1339. if (con.indexOf('iu') > -1) {
  1340. zm2 = _this.tableData[4][number - 1];
  1341. con = con.replace('u', zm2);
  1342. } else if (con.indexOf('ui') > -1) {
  1343. zm2 = _this.tableData[3][number - 1];
  1344. con = con.replace('i', zm2);
  1345. } else if (
  1346. con.indexOf('yv') > -1 ||
  1347. con.indexOf('jv') > -1 ||
  1348. con.indexOf('qv') > -1 ||
  1349. con.indexOf('xv') > -1
  1350. ) {
  1351. zm2 = _this.tableData[4][number - 1];
  1352. con = con.replace('v', zm2);
  1353. } else {
  1354. con = con.replace(zm, zm2);
  1355. }
  1356. break;
  1357. }
  1358. }
  1359. }
  1360. return con;
  1361. },
  1362. // 设置样式
  1363. setActiveTextStyle(type, val) {
  1364. let style = this.data.other_attrib;
  1365. if (type === 'underline') {
  1366. style.isUnderline = style.isUnderline === 'underline' ? '' : 'underline';
  1367. if (style.isUnderline === 'underline') {
  1368. style.isStrikethrough = '';
  1369. }
  1370. this.data.detail.forEach((item) => {
  1371. item.wordsList.forEach((items) => {
  1372. items.forEach((itemss) => {
  1373. itemss.textDecoration = style.isUnderline;
  1374. });
  1375. });
  1376. });
  1377. } else if (type === 'bold') {
  1378. style.isBold = style.isBold === 'bold' ? '' : 'bold';
  1379. this.data.detail.forEach((item) => {
  1380. item.wordsList.forEach((items) => {
  1381. items.forEach((itemss) => {
  1382. itemss.fontWeight = style.isBold;
  1383. });
  1384. });
  1385. });
  1386. } else if (type === 'line-through') {
  1387. style.isStrikethrough = style.isStrikethrough === 'line-through' ? '' : 'line-through';
  1388. if (style.isStrikethrough === 'line-through') {
  1389. style.isUnderline = '';
  1390. }
  1391. this.data.detail.forEach((item) => {
  1392. item.wordsList.forEach((items) => {
  1393. items.forEach((itemss) => {
  1394. itemss.textDecoration = style.isStrikethrough;
  1395. });
  1396. });
  1397. });
  1398. } else if (type === 'border') {
  1399. style.border = style.border === 'dotted' ? '' : 'dotted';
  1400. this.data.detail.forEach((item) => {
  1401. item.wordsList.forEach((items) => {
  1402. items.forEach((itemss) => {
  1403. itemss.border = style.border;
  1404. });
  1405. });
  1406. });
  1407. } else if (type === 'align') {
  1408. style.align = val;
  1409. this.articleAttrib.align = val;
  1410. this.data.detail.forEach((item) => {
  1411. item.paraAlign =
  1412. this.articleAttrib.align === 'RIGHT' ? 'right' : this.articleAttrib.align === 'MIDDLE' ? 'center' : 'left';
  1413. });
  1414. }
  1415. },
  1416. // 点击汉字打开关联注释弹窗
  1417. matchItemNotes(item) {
  1418. if (!item.matchNotesObj.id) {
  1419. item.matchNotesObj.id = getRandomNumber();
  1420. }
  1421. this.matchNotesObj = item.matchNotesObj;
  1422. this.matchNoteFlag = true;
  1423. },
  1424. cancleMatchNotesDialog() {
  1425. this.$confirm('确定要删除此条气泡吗?', '提示', {
  1426. confirmButtonText: '确定',
  1427. cancelButtonText: '取消',
  1428. type: 'warning',
  1429. })
  1430. .then(() => {
  1431. this.handleSyncCon(this.matchNotesObj, 'delete');
  1432. let index = this.data.notes_list.option.findIndex((items) => items.id === this.matchNotesObj.id);
  1433. this.data.notes_list.option.splice(index, 1);
  1434. this.matchNoteFlag = false;
  1435. })
  1436. .catch(() => {});
  1437. },
  1438. // 确定关联注释
  1439. sureMatchNotes() {
  1440. let index = this.data.notes_list.option.findIndex((items) => items.id === this.matchNotesObj.id);
  1441. if (index > -1) {
  1442. this.data.notes_list.option[index] = this.matchNotesObj;
  1443. } else {
  1444. this.data.notes_list.option.push(this.matchNotesObj);
  1445. }
  1446. this.matchNoteFlag = false;
  1447. this.editWordsFlag = true;
  1448. this.editWordIndex = 1;
  1449. },
  1450. async handleBlurCon() {
  1451. let text = this.matchNotesObj.con.replace(/<[^>]+>/g, '');
  1452. if (text) {
  1453. this.matchNotesObj.pinyin = await this.handlePinyins(
  1454. text,
  1455. this.data.notes_list.property.is_first_sentence_first_hz_pinyin_first_char_upper_case,
  1456. );
  1457. }
  1458. },
  1459. // 自动生成拼音
  1460. handlePinyins(text, flag) {
  1461. let data = {
  1462. text: text,
  1463. is_rich_text: 'false',
  1464. is_first_sentence_first_hz_pinyin_first_char_upper_case: flag ? flag : 'false',
  1465. is_fill_space: 'false',
  1466. is_custom_fc: 'false',
  1467. };
  1468. return new Promise((resolve, reject) => {
  1469. PinyinBuild_OldFormat(data).then((res) => {
  1470. if (res.parsed_text) {
  1471. let mergedData = '';
  1472. res.parsed_text.paragraph_list.map((outerArr, i) =>
  1473. outerArr.map((innerArr, j) =>
  1474. innerArr.map((newItem, k) => {
  1475. mergedData += newItem.pinyin + ' ';
  1476. }),
  1477. ),
  1478. );
  1479. resolve(mergedData);
  1480. }
  1481. });
  1482. });
  1483. },
  1484. // 在气泡列表里修改了内容,同步detail的内容
  1485. handleSyncCon(obj, type) {
  1486. this.data.detail.forEach((item) => {
  1487. item.wordsList.forEach((items) => {
  1488. items.forEach((itemss) => {
  1489. if (itemss.matchNotesObj.id === obj.id) {
  1490. if (type === 'delete') {
  1491. itemss.matchNotesObj = {
  1492. number: '',
  1493. con: '',
  1494. pinyin: '',
  1495. interpret: '',
  1496. note: '',
  1497. notesColor: '#8206BF',
  1498. id: '',
  1499. isRich: true,
  1500. matchNotes: itemss.chs,
  1501. };
  1502. } else {
  1503. itemss.matchNotesObj = obj;
  1504. }
  1505. }
  1506. });
  1507. });
  1508. });
  1509. },
  1510. },
  1511. };
  1512. </script>
  1513. <style lang="scss" scoped>
  1514. .article-wrapper {
  1515. display: flex;
  1516. flex-direction: column;
  1517. row-gap: 16px;
  1518. align-items: flex-start;
  1519. }
  1520. .upload-file {
  1521. display: flex;
  1522. column-gap: 12px;
  1523. align-items: center;
  1524. .file-name {
  1525. display: flex;
  1526. column-gap: 14px;
  1527. align-items: center;
  1528. justify-content: space-between;
  1529. max-width: 360px;
  1530. padding: 8px 12px;
  1531. font-size: 14px;
  1532. color: #1d2129;
  1533. background-color: #f7f8fa;
  1534. span {
  1535. display: flex;
  1536. column-gap: 14px;
  1537. align-items: center;
  1538. }
  1539. }
  1540. .svg-icon {
  1541. cursor: pointer;
  1542. }
  1543. }
  1544. .btn-box {
  1545. display: flex;
  1546. flex-flow: wrap;
  1547. gap: 10px;
  1548. a {
  1549. padding: 5px 16px;
  1550. font-size: 14px;
  1551. line-height: 22px;
  1552. color: #4e5969;
  1553. cursor: pointer;
  1554. background: #f2f3f5;
  1555. border-radius: 2px;
  1556. }
  1557. p {
  1558. margin: 0;
  1559. }
  1560. }
  1561. .new-btn-box {
  1562. p {
  1563. margin: 0 0 10px;
  1564. font-size: 14px;
  1565. font-weight: bold;
  1566. color: #333;
  1567. }
  1568. > div {
  1569. display: flex;
  1570. flex-wrap: wrap;
  1571. gap: 8px;
  1572. }
  1573. a {
  1574. display: block;
  1575. padding: 6px 14px;
  1576. font-size: 13px;
  1577. color: #000;
  1578. cursor: pointer;
  1579. background: #fff;
  1580. border: 1px solid #d9d9d9;
  1581. border-radius: 4px;
  1582. &:hover {
  1583. color: #1890ff;
  1584. border-color: #1890ff;
  1585. }
  1586. }
  1587. :deep .el-button {
  1588. padding: 6px 14px;
  1589. font-size: 13px;
  1590. line-height: 1.5;
  1591. color: #000;
  1592. cursor: pointer;
  1593. background: #fff;
  1594. border: 1px solid #d9d9d9;
  1595. border-radius: 4px;
  1596. &:hover {
  1597. color: #1890ff;
  1598. border-color: #1890ff;
  1599. }
  1600. &.is-disabled {
  1601. color: #ccc;
  1602. border-color: #e8e8e8;
  1603. }
  1604. }
  1605. }
  1606. .tips {
  1607. margin: 0;
  1608. font-size: 12px;
  1609. color: #e82d2d;
  1610. }
  1611. .tabs-box {
  1612. display: flex;
  1613. column-gap: 12px;
  1614. margin: 12px 0;
  1615. a {
  1616. padding: 5px 16px;
  1617. font-size: 14px;
  1618. font-weight: 400;
  1619. line-height: 22px; /* 157.143% */
  1620. color: #4e5969;
  1621. cursor: pointer;
  1622. border-radius: 100px;
  1623. &.active {
  1624. color: #165dff;
  1625. background: #f2f3f5;
  1626. }
  1627. }
  1628. }
  1629. .text {
  1630. display: flex;
  1631. flex-flow: wrap;
  1632. .text-item {
  1633. padding: 0 1px;
  1634. text-align: center;
  1635. cursor: pointer;
  1636. }
  1637. .pinyin {
  1638. display: block;
  1639. font-family: 'PINYIN-B';
  1640. white-space: pre;
  1641. }
  1642. .word {
  1643. display: block;
  1644. }
  1645. }
  1646. .table-rich-toolbar {
  1647. display: flex;
  1648. gap: 5px;
  1649. /* align-items: center; */
  1650. :deep .el-form-item--small.el-form-item {
  1651. margin: 0 5px 0 0;
  1652. }
  1653. :deep .el-form-item__label {
  1654. padding-right: 3px;
  1655. }
  1656. > span {
  1657. height: 30px;
  1658. padding: 5px 6px;
  1659. color: #222f3e;
  1660. cursor: pointer;
  1661. border-radius: 5px;
  1662. &:hover {
  1663. background: #cce2fa;
  1664. }
  1665. &.active {
  1666. background: #a6ccf7;
  1667. }
  1668. }
  1669. }
  1670. </style>
  1671. <style lang="scss">
  1672. .article-matchNotes-dialog {
  1673. .el-dialog__header,
  1674. .el-dialog__body {
  1675. padding: 5px 10px;
  1676. }
  1677. .btn-box {
  1678. display: block;
  1679. padding: 5px 0;
  1680. text-align: right;
  1681. .el-button {
  1682. padding: 2px 12px;
  1683. font-size: 12px;
  1684. line-height: 20px;
  1685. }
  1686. }
  1687. .matchNotes-color {
  1688. display: flex;
  1689. align-items: center;
  1690. justify-content: space-between;
  1691. margin-top: 5px;
  1692. span {
  1693. display: flex;
  1694. gap: 3px;
  1695. align-items: center;
  1696. cursor: pointer;
  1697. }
  1698. .el-color-picker--small {
  1699. height: 16px;
  1700. }
  1701. .el-color-picker__trigger {
  1702. width: 16px;
  1703. height: 16px;
  1704. padding: 0;
  1705. border: none;
  1706. }
  1707. }
  1708. }
  1709. .article-checkpinyin-dialog {
  1710. .el-dialog__header {
  1711. padding: 0;
  1712. }
  1713. .el-dialog__body {
  1714. padding: 0;
  1715. }
  1716. .el-input__inner {
  1717. text-align: center;
  1718. background: #f3f3f3;
  1719. }
  1720. .check-box {
  1721. padding: 24px;
  1722. background: #fff;
  1723. border-radius: 4px;
  1724. box-shadow: 0 4px 4px 0 rgba(0, 0, 0, 25%);
  1725. .content {
  1726. display: flex;
  1727. align-items: center;
  1728. justify-content: center;
  1729. .words-box {
  1730. color: #000;
  1731. text-align: center;
  1732. .words {
  1733. display: block;
  1734. font-size: 28px;
  1735. font-weight: 400;
  1736. line-height: 40px;
  1737. }
  1738. .pinyin {
  1739. display: block;
  1740. height: 20px;
  1741. font-family: 'League';
  1742. font-size: 20px;
  1743. font-weight: 400;
  1744. line-height: 1;
  1745. }
  1746. }
  1747. }
  1748. .checkPinyinInput {
  1749. margin: 16px 0 8px;
  1750. }
  1751. .tips {
  1752. margin: 0 0 24px;
  1753. font-size: 12px;
  1754. font-weight: 400;
  1755. line-height: 18px;
  1756. color: #a0a0a0;
  1757. }
  1758. .btn-box {
  1759. display: block;
  1760. text-align: right;
  1761. .el-button {
  1762. padding: 2px 12px;
  1763. font-size: 12px;
  1764. line-height: 20px;
  1765. }
  1766. }
  1767. }
  1768. }
  1769. </style>