PurePreview.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-PurePreview" v-if="curQue">
  4. <div
  5. class="Big-Book-Single-content"
  6. style="margin-left: 20px; margin-top: 20px"
  7. >
  8. <div class="adult-book-input-item">
  9. <span class="adult-book-lable">标题:</span>
  10. <el-input
  11. class="adult-book-input"
  12. type="textarea"
  13. :autosize="{ minRows: 2 }"
  14. placeholder="请输入标题"
  15. v-model="curQue.title"
  16. @blur="onBlur(curQue, 'title')"
  17. maxlength="500"
  18. show-word-limit
  19. ></el-input>
  20. </div>
  21. <template v-if="type == 'listen_record_single_syllable_chs'">
  22. <div class="adult-book-input-item">
  23. <span class="adult-book-lable">题目音频:</span>
  24. <Upload
  25. :changeFillId="timuchangeMp3"
  26. :datafileList="curQue.mp3_list"
  27. :filleNumber="mp3Number"
  28. :uploadType="'mp3'"
  29. />
  30. </div>
  31. <div class="adult-book-input-item">
  32. <span class="adult-book-lable">题目lrc:</span>
  33. <Upload
  34. :changeFillId="changeLrc"
  35. :datafileList="curQue.lrc_list"
  36. :filleNumber="mp3Number"
  37. :uploadType="'lrc'"
  38. />
  39. </div>
  40. <div class="adult-book-input-item">
  41. <span class="adult-book-lable"></span>
  42. <el-button
  43. type="primary"
  44. size="small"
  45. class="distribution"
  46. @click="parseLrcFile"
  47. >
  48. 分配lrc
  49. </el-button>
  50. </div>
  51. </template>
  52. <template
  53. v-if="type == 'text_problem_chs' || type == 'newWord_preview_chs'"
  54. >
  55. <div
  56. class="Big-Book-main"
  57. v-for="(item, index) in curQue.option"
  58. :key="item + index"
  59. style="margin-bottom: 20px"
  60. >
  61. <template v-if="type == 'text_problem_chs'">
  62. <div class="adult-book-input-item">
  63. <span class="adult-book-lable">序号:</span>
  64. <el-input
  65. class="adult-book-input"
  66. type="textarea"
  67. :autosize="{ minRows: 2 }"
  68. placeholder="请输入序号"
  69. v-model="item.number"
  70. @blur="onBlur(item, 'number')"
  71. maxlength="200"
  72. show-word-limit
  73. ></el-input>
  74. <img
  75. @click="deleteOptionOne(index)"
  76. class="close"
  77. src="../../../assets/adult/del-close.png"
  78. alt=""
  79. />
  80. </div>
  81. <div class="NPC-sentence-Segword">
  82. <SentenceSegwordChs :curQue="item.detail" />
  83. </div>
  84. <div class="adult-book-input-item">
  85. <span class="adult-book-lable">英文:</span>
  86. <el-input
  87. class="adult-book-input"
  88. type="textarea"
  89. :autosize="{ minRows: 2 }"
  90. placeholder="请输入英文"
  91. v-model="item.en"
  92. @blur="onBlur(item, 'en')"
  93. maxlength="200"
  94. show-word-limit
  95. ></el-input>
  96. <img
  97. @click="deleteOptionOne(index)"
  98. class="close"
  99. src="../../../assets/adult/del-close.png"
  100. alt=""
  101. />
  102. </div>
  103. </template>
  104. <template v-if="type == 'newWord_preview_chs'">
  105. <div class="adult-book-input-item">
  106. <span class="adult-book-lable">拼音:</span>
  107. <el-input
  108. class="adult-book-input"
  109. type="textarea"
  110. :autosize="{ minRows: 2 }"
  111. placeholder="请输入拼音"
  112. v-model="item.pinyin"
  113. @blur="onBlur(item, 'pinyin')"
  114. maxlength="200"
  115. show-word-limit
  116. ></el-input>
  117. <img
  118. @click="deleteOptionOne(index)"
  119. class="close"
  120. src="../../../assets/adult/del-close.png"
  121. alt=""
  122. />
  123. </div>
  124. <div class="adult-book-input-item">
  125. <span class="adult-book-lable">英文:</span>
  126. <el-input
  127. class="adult-book-input"
  128. type="textarea"
  129. :autosize="{ minRows: 2 }"
  130. placeholder="请输入英文"
  131. v-model="item.en"
  132. @blur="onBlur(item, 'en')"
  133. maxlength="200"
  134. show-word-limit
  135. ></el-input>
  136. </div>
  137. <div class="adult-book-input-item">
  138. <span class="adult-book-lable">展示方式:</span>
  139. <el-radio-group v-model="item.imgOrText">
  140. <el-radio label="image">图片</el-radio>
  141. <el-radio label="text">文本</el-radio>
  142. </el-radio-group>
  143. </div>
  144. <template v-if="item.imgOrText == 'image'">
  145. <div class="adult-book-input-item">
  146. <span class="adult-book-lable">图片:</span>
  147. <Upload
  148. :changeFillId="changeImage"
  149. :datafileList="item.img_list"
  150. :filleNumber="mp3Number"
  151. :uploadType="'image'"
  152. :index="index"
  153. />
  154. </div>
  155. </template>
  156. <template v-if="item.imgOrText == 'text'">
  157. <div class="adult-book-input-item">
  158. <span class="adult-book-lable">生字:</span>
  159. <el-input
  160. class="adult-book-input"
  161. type="textarea"
  162. :autosize="{ minRows: 2 }"
  163. placeholder="请输入生字"
  164. v-model="item.con"
  165. @blur="onBlur(item, 'con')"
  166. maxlength="200"
  167. show-word-limit
  168. ></el-input>
  169. </div>
  170. <!-- <div class="adult-book-input-item">
  171. <span class="adult-book-lable">音频:</span>
  172. <Upload
  173. :changeFillId="changeMp3"
  174. :datafileList="item.mp3_list"
  175. :filleNumber="mp3Number"
  176. :uploadType="'mp3'"
  177. :index="index"
  178. />
  179. </div> -->
  180. </template>
  181. <!-- <div class="adult-book-input-item">
  182. <span class="adult-book-lable">配置:</span>
  183. <el-checkbox-group v-model="item.type" @change="forupdata">
  184. <el-checkbox label="mh">描红</el-checkbox>
  185. <el-checkbox label="lm">临摹</el-checkbox>
  186. </el-checkbox-group>
  187. </div> -->
  188. </template>
  189. </div>
  190. </template>
  191. <template v-if="type == 'listen_record_single_syllable_chs'">
  192. <div
  193. class="Big-Book-main"
  194. v-for="(item, index) in curQue.option"
  195. :key="item + index"
  196. style="margin-bottom: 20px"
  197. >
  198. <div class="adult-book-input-item">
  199. <span class="adult-book-lable">序号:</span>
  200. <el-input
  201. class="adult-book-input"
  202. type="textarea"
  203. :autosize="{ minRows: 2 }"
  204. placeholder="请输入序号"
  205. v-model="item.number"
  206. @blur="onBlur(item, 'number')"
  207. maxlength="200"
  208. show-word-limit
  209. ></el-input>
  210. <img
  211. @click="deleteOptionOne(index)"
  212. class="close"
  213. src="../../../assets/adult/del-close.png"
  214. alt=""
  215. />
  216. </div>
  217. <!-- <div class="adult-book-input-item">
  218. <span class="adult-book-lable">音频:</span>
  219. <Upload
  220. :changeFillId="listenchangeMp3"
  221. :datafileList="item.mp3_list"
  222. :filleNumber="mp3Number"
  223. :uploadType="'mp3'"
  224. :index="index"
  225. />
  226. </div> -->
  227. <div class="adult-book-input-item" v-if="curQue.wordTime.length > 0">
  228. <span class="adult-book-lable">字幕时间:</span>
  229. <div style="display: flex; align-items: center">
  230. <el-input
  231. class="adult-book-input"
  232. type="textarea"
  233. style="width: 200px"
  234. v-model="curQue.wordTime[index].bg"
  235. @blur="onBlur(curQue.wordTime[index], 'bg')"
  236. maxlength="200"
  237. show-word-limit
  238. ></el-input>
  239. ~
  240. <el-input
  241. class="adult-book-input"
  242. style="width: 200px"
  243. type="textarea"
  244. v-model="curQue.wordTime[index].ed"
  245. @blur="onBlur(curQue.wordTime[index], 'ed')"
  246. maxlength="200"
  247. show-word-limit
  248. ></el-input>
  249. </div>
  250. </div>
  251. <div v-for="(it, itI) in item.option" :key="'it' + itI">
  252. <div class="adult-book-input-item">
  253. <span class="adult-book-lable">拼音:</span>
  254. <el-input
  255. class="adult-book-input"
  256. type="textarea"
  257. :autosize="{ minRows: 2 }"
  258. placeholder="请输入拼音"
  259. v-model="it.pinyin"
  260. @blur="onBlur(it, 'pinyin')"
  261. maxlength="200"
  262. show-word-limit
  263. ></el-input>
  264. <img
  265. @click="deleteyinjie(index, itI)"
  266. class="close"
  267. src="../../../assets/adult/del-close.png"
  268. alt=""
  269. />
  270. </div>
  271. <div class="adult-book-input-item">
  272. <span class="adult-book-lable">正确答案:</span>
  273. <el-radio-group
  274. v-model="it.isAnswer"
  275. @change="changeIsAnswer(index, itI)"
  276. >
  277. <el-radio :label="true">是</el-radio>
  278. <el-radio :label="false">否</el-radio>
  279. </el-radio-group>
  280. </div>
  281. </div>
  282. <div class="addoption" @click="addyinjie(index)">添加一个音节</div>
  283. </div>
  284. </template>
  285. <div class="Big-Book-addrole">
  286. <div class="addoption" @click="addOption">添加一个</div>
  287. </div>
  288. <template v-if="type == 'newWord_preview_chs'">
  289. <div class="Big-Book-divide">
  290. <el-divider content-position="center">功能设置</el-divider>
  291. <span style="margin: 0 10px">请选择每行数量</span>
  292. <el-select v-model="curQue.numberList.con" placeholder="请选择">
  293. <el-option
  294. v-for="(item, i) in curQue.numberList.arr"
  295. :key="i"
  296. :label="item.value"
  297. :value="item.id"
  298. >
  299. </el-option>
  300. </el-select>
  301. </div>
  302. </template>
  303. <template v-if="type == 'listen_record_single_syllable_chs'">
  304. <!-- <div class="lrc-box">
  305. <div
  306. v-if="this.curQue.wordTime && this.curQue.wordTime.length > 0"
  307. class="lrc-box"
  308. >
  309. <span>已有字幕时间节点</span>
  310. <el-button type="text" @click="againWordTime">重新生成</el-button>
  311. <el-button @click="compareTime('句子')" size="medium"
  312. >校对句子字幕时间</el-button
  313. >
  314. <el-button @click="compareTime('文字')" size="medium"
  315. >校对文字字幕时间</el-button
  316. >
  317. </div>
  318. <template v-else>
  319. <el-button v-if="!isWordTime" size="medium" @click="createWordTime"
  320. >自动生成字幕节点</el-button
  321. >
  322. <p v-else>字幕节点生成中...请等待</p>
  323. </template>
  324. </div> -->
  325. </template>
  326. </div>
  327. <!-- <el-dialog
  328. title="校对字幕时间"
  329. :visible.sync="compareShow"
  330. width="50%"
  331. :before-close="handleClose"
  332. top="0"
  333. >
  334. <CompareTime
  335. :data="compareData"
  336. :type="compareType"
  337. :changewordsResultList="changewordsResultList"
  338. />
  339. <span slot="footer" class="dialog-footer">
  340. <el-button @click="handleClose">取 消</el-button>
  341. <el-button :loading="compareloading" type="primary" @click="saveCompare"
  342. >确 定</el-button
  343. >
  344. </span>
  345. </el-dialog> -->
  346. </div>
  347. </template>
  348. <script>
  349. import Upload from "../common/Upload";
  350. import SentenceSegwordChs from "../common/SentenceSegwordChs/index.vue";
  351. import { getWordTime, getContentFile, prepareTranscribe, compareSenTenceTime } from "@/api/ajax";
  352. import CompareTime from "./ArticleTemChs/components/CompareTime.vue";
  353. export default {
  354. name: "PurePreview",
  355. props: ["curQue", "fn_data", "changeCurQue", "type"],
  356. components: {
  357. SentenceSegwordChs,
  358. Upload,
  359. CompareTime,
  360. },
  361. data() {
  362. return {
  363. checkList: [],
  364. mp3Number: 1,
  365. list: [
  366. {
  367. con: "临摹",
  368. },
  369. {
  370. con: "描红",
  371. },
  372. ],
  373. form: {
  374. stem: {
  375. con: "",
  376. pinyin: "",
  377. english: "",
  378. highlight: "",
  379. underline: "",
  380. img_url: [],
  381. mp3_url: [],
  382. },
  383. },
  384. data_structure: {
  385. type: "text_problem_chs",
  386. name: "课文上面的问题",
  387. title: "",
  388. option: [
  389. {
  390. mp3_list: [],
  391. number: "",
  392. detail: {
  393. en: "",
  394. pyPosition: "top", //top 拼音在上面;bottom 拼音在下面
  395. sentence: "", //句子
  396. segList: [], //分词结果
  397. seg_words: "",
  398. wordsList: [],
  399. },
  400. en: "", //英文
  401. answer: [""],
  402. judge: true,
  403. },
  404. ],
  405. },
  406. data_structure2: {
  407. type: "newWord_preview_chs",
  408. name: "生字展示",
  409. title: "",
  410. imgOrText: null,
  411. option: [
  412. {
  413. mp3_list: [],
  414. img_list: [],
  415. con: "", //生字
  416. en: "",
  417. pinyin: "", //拼音
  418. type: ["lm"],
  419. },
  420. ],
  421. numberList: {
  422. type: "number",
  423. name: "每行几个",
  424. con: "7",
  425. arr: [
  426. {
  427. id: 1,
  428. value: 1,
  429. },
  430. {
  431. id: 2,
  432. value: 2,
  433. },
  434. {
  435. id: 3,
  436. value: 3,
  437. },
  438. {
  439. id: 4,
  440. value: 4,
  441. },
  442. {
  443. id: 5,
  444. value: 5,
  445. },
  446. {
  447. id: 6,
  448. value: 6,
  449. },
  450. {
  451. id: 7,
  452. value: 7,
  453. },
  454. ],
  455. },
  456. },
  457. data_structure3: {
  458. type: "listen_record_single_syllable_chs",
  459. name: "听录音选择音节",
  460. title: "",
  461. mp3_list: [],
  462. number: "",
  463. wordTime: [],
  464. option: [
  465. {
  466. number: "",
  467. mp3_list: [],
  468. option: [
  469. {
  470. number: "",
  471. pinyin: "", //拼音
  472. isAnswer: false,
  473. },
  474. ],
  475. },
  476. ],
  477. },
  478. isWordTime: false,
  479. compareType: "", //校对类型
  480. compareShow: false,
  481. compareData: null,
  482. compareloading: false,
  483. CreadMp3loading: false,
  484. loading: false,
  485. };
  486. },
  487. computed: {},
  488. watch: {},
  489. //方法集合
  490. methods: {
  491. changeIsAnswer(index, itIndex) {
  492. console.log(this.curQue.option[index].option[itIndex].isAnswer);
  493. let value = this.curQue.option[index].option[itIndex].isAnswer;
  494. if (value) {
  495. this.curQue.option[index].option.forEach((item) => {
  496. item.isAnswer = false;
  497. });
  498. this.curQue.option[index].option[itIndex].isAnswer = true;
  499. }
  500. this.$forceUpdate();
  501. },
  502. // 校对每个字的时间
  503. changewordsResultList(index, item) {
  504. this.curQue.wordTime[index].wordsResultList = JSON.parse(
  505. JSON.stringify(item)
  506. );
  507. },
  508. // 保存校对
  509. saveCompare() {
  510. if (this.compareType == "文字") {
  511. this.compareloading = false;
  512. return;
  513. }
  514. this.compareloading = true;
  515. compareSenTenceTime({ matchList: JSON.stringify(this.compareData) })
  516. .then((res) => {
  517. console.log(res);
  518. this.compareloading = false;
  519. this.curQue.wordTime = res.data.result;
  520. })
  521. .catch(() => {
  522. this.compareloading = false;
  523. });
  524. },
  525. // 校对时间
  526. compareTime(type) {
  527. this.compareType = type;
  528. this.compareData = JSON.parse(JSON.stringify(this.curQue.wordTime));
  529. this.compareShow = true;
  530. },
  531. handleClose() {
  532. this.compareShow = false;
  533. this.compareData = null;
  534. this.compareType = "";
  535. },
  536. forupdata() {
  537. this.$forceUpdate();
  538. },
  539. // 添加音节
  540. addyinjie(index) {
  541. let obj = JSON.parse(
  542. JSON.stringify(this.data_structure3.option[0].option[0])
  543. );
  544. this.curQue.option[index].option.push(obj);
  545. },
  546. // 删除音节
  547. deleteyinjie(index, yjIndex) {
  548. if (this.curQue.option[index].option.length <= 1) {
  549. this.$message.warning("至少要保留1个音节");
  550. return;
  551. }
  552. this.curQue.option[index].option.splice(yjIndex, 1);
  553. },
  554. onBlur(item, field) {
  555. item[field] = item[field] ? item[field].trim() : "";
  556. },
  557. // 删除其中一个选项
  558. deleteOptionOne(index) {
  559. if (this.type == "listen_record_single_syllable_chs") {
  560. if (this.curQue.option.length <= 1) {
  561. this.$message.warning("至少要保留1个选项");
  562. return;
  563. }
  564. this.curQue.option.splice(index, 1);
  565. return;
  566. }
  567. if (this.curQue.option.length <= 1) {
  568. this.$message.warning("至少要保留1个选项");
  569. return;
  570. }
  571. this.curQue.option.splice(index, 1);
  572. },
  573. // 新增选项
  574. addOption() {
  575. let obj;
  576. if (this.type == "newWord_preview_chs") {
  577. obj = JSON.parse(JSON.stringify(this.data_structure2.option[0]));
  578. this.curQue.option.push(obj);
  579. } else if (this.type == "text_problem_chs") {
  580. obj = JSON.parse(JSON.stringify(this.data_structure.option[0]));
  581. this.curQue.option.push(obj);
  582. } else if (this.type == "listen_record_single_syllable_chs") {
  583. obj = JSON.parse(JSON.stringify(this.data_structure3.option[0]));
  584. this.curQue.option.push(obj);
  585. }
  586. },
  587. initcurQue() {
  588. let data;
  589. if (this.type == "newWord_preview_chs") {
  590. data = JSON.parse(JSON.stringify(this.data_structure2));
  591. } else if (this.type == "text_problem_chs") {
  592. data = JSON.parse(JSON.stringify(this.data_structure));
  593. } else if (this.type == "listen_record_single_syllable_chs") {
  594. data = JSON.parse(JSON.stringify(this.data_structure3));
  595. }
  596. this.changeCurQue(data);
  597. },
  598. // 选项的图片
  599. changeImage(fileList, duration, index) {
  600. const articleImgList = JSON.parse(JSON.stringify(fileList));
  601. const articleImgRes = [];
  602. articleImgList.forEach((item) => {
  603. if (item.response) {
  604. const obj = {
  605. name: item.name,
  606. url: item.response.file_info_list[0].file_url,
  607. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  608. media_duration: item.response.file_info_list[0].media_duration, //音频时长
  609. };
  610. articleImgRes.push(obj);
  611. }
  612. });
  613. this.curQue.option[index].img_list = JSON.parse(
  614. JSON.stringify(articleImgRes)
  615. );
  616. },
  617. // 选项的音频
  618. changeMp3(fileList, items, index) {
  619. const articleImgList = JSON.parse(JSON.stringify(fileList));
  620. const articleImgRes = [];
  621. articleImgList.forEach((item) => {
  622. if (item.response) {
  623. const obj = {
  624. name: item.name,
  625. url: item.response.file_info_list[0].file_url,
  626. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  627. media_duration: item.response.file_info_list[0].media_duration, //音频时长
  628. };
  629. articleImgRes.push(obj);
  630. }
  631. });
  632. this.curQue.option[index].mp3_list = JSON.parse(
  633. JSON.stringify(articleImgRes)
  634. );
  635. },
  636. // 听录音选择音调的上传音频
  637. listenchangeMp3(fileList, items, index) {
  638. const articleImgList = JSON.parse(JSON.stringify(fileList));
  639. const articleImgRes = [];
  640. articleImgList.forEach((item) => {
  641. if (item.response) {
  642. const obj = {
  643. name: item.name,
  644. url: item.response.file_info_list[0].file_url,
  645. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  646. media_duration: item.response.file_info_list[0].media_duration, //音频时长
  647. };
  648. articleImgRes.push(obj);
  649. }
  650. });
  651. this.curQue[index].mp3_list = JSON.parse(JSON.stringify(articleImgRes));
  652. },
  653. // 题目的音频
  654. timuchangeMp3(fileList) {
  655. const articleImgList = JSON.parse(JSON.stringify(fileList));
  656. const articleImgRes = [];
  657. articleImgList.forEach((item) => {
  658. if (item.response) {
  659. const obj = {
  660. name: item.name,
  661. url: item.response.file_info_list[0].file_url,
  662. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  663. media_duration: item.response.file_info_list[0].media_duration, //音频时长
  664. };
  665. articleImgRes.push(obj);
  666. }
  667. });
  668. this.curQue.mp3_list = JSON.parse(JSON.stringify(articleImgRes));
  669. },
  670. // 上传音频文件
  671. handleChange(file, fileList) {
  672. let _this = this;
  673. _this.getBase64(file.raw).then((res) => {
  674. let base_res = res.split("base64,");
  675. let data = {
  676. fileName: file.raw.name,
  677. speechBase64: base_res[1],
  678. language: "ch",
  679. };
  680. prepareTranscribe(data).then((reses) => {
  681. _this.$set(_this.curQue, "taskId", reses.data.taskId);
  682. });
  683. });
  684. },
  685. getBase64(file) {
  686. return new Promise(function (resolve, reject) {
  687. let reader = new FileReader();
  688. let imgResult = "";
  689. reader.readAsDataURL(file);
  690. reader.onload = function () {
  691. imgResult = reader.result;
  692. };
  693. reader.onerror = function (error) {
  694. reject(error);
  695. };
  696. reader.onloadend = function () {
  697. resolve(imgResult);
  698. };
  699. });
  700. },
  701. createWordTime() {
  702. if (this.curQue.taskId) {
  703. let verseList = [];
  704. this.curQue.option.forEach((item, index) => {
  705. item.forEach((sItem, sIndex) => {
  706. verseList.push(sItem.new_word);
  707. });
  708. });
  709. if (verseList.length > 0) {
  710. this.isWordTime = true;
  711. let data = {
  712. taskId: this.curQue.taskId,
  713. verseList: JSON.stringify(verseList),
  714. matchType: "chinese",
  715. language: "ch",
  716. };
  717. getWordTime(data).then((res) => {
  718. this.curQue.wordTime = res.data.result;
  719. this.isWordTime = false;
  720. });
  721. }
  722. } else {
  723. this.$message.warning("请先上传音频");
  724. }
  725. },
  726. parseLrcFile() {
  727. let lrcList = this.curQue.lrc_list;
  728. if (lrcList.length === 0) {
  729. return this.$message.warning("请先上传lrc文件");
  730. }
  731. this.loading = this.$loading({
  732. lock: true,
  733. text: "Loading",
  734. spinner: "el-icon-loading",
  735. background: "rgba(0, 0, 0, 0.7)",
  736. });
  737. getContentFile("tool-ParseLRCFile", {
  738. content_type: "FILE",
  739. file_id: this.curQue.lrc_list[0].file_id,
  740. }).then(({ lrc_list }) => {
  741. let lrc_list_res = [];
  742. lrc_list.forEach((item) => {
  743. let obj = {
  744. bg: item.begin_time,
  745. ed: item.end_time,
  746. };
  747. lrc_list_res.push(obj);
  748. });
  749. this.curQue.wordTime = lrc_list_res;
  750. this.$forceUpdate();
  751. this.loading.close();
  752. });
  753. },
  754. againWordTime() {
  755. this.isWordTime = false;
  756. this.$set(this.curQue, "wordTime", []);
  757. },
  758. changeLrc(fileLists) {
  759. let lrc_list = [];
  760. fileLists.forEach(({ response, name }) => {
  761. if (response) {
  762. let fileList = response.file_info_list[0];
  763. lrc_list.push({
  764. name,
  765. duration: fileList.media_duration,
  766. url: fileList.file_url,
  767. id: "[FID##" + fileList.file_id + "##FID]",
  768. file_id: fileList.file_id,
  769. });
  770. }
  771. });
  772. this.curQue.lrc_list = lrc_list;
  773. },
  774. },
  775. //生命周期 - 创建完成(可以访问当前this实例)
  776. created() {
  777. if (!this.curQue) {
  778. this.initcurQue();
  779. } else {
  780. if (this.type == "newWord_preview_chs") {
  781. let obj = {
  782. type: "number",
  783. name: "每行几个",
  784. con: "7",
  785. arr: [
  786. {
  787. id: 1,
  788. value: 1,
  789. },
  790. {
  791. id: 2,
  792. value: 2,
  793. },
  794. {
  795. id: 3,
  796. value: 3,
  797. },
  798. {
  799. id: 4,
  800. value: 4,
  801. },
  802. {
  803. id: 5,
  804. value: 5,
  805. },
  806. {
  807. id: 6,
  808. value: 6,
  809. },
  810. {
  811. id: 7,
  812. value: 7,
  813. },
  814. ],
  815. };
  816. this.$set(this.curQue, "numberList", obj);
  817. this.curQue.option.forEach((item) => {
  818. if (!item.type) {
  819. item.type = ["lm"];
  820. }
  821. });
  822. }
  823. if (this.type == "listen_record_single_syllable_chs") {
  824. if (!this.curQue.wordTime) {
  825. this.curQue.wordTime = [];
  826. }
  827. this.curQue.option.forEach((item) => {
  828. item.option.forEach((it) => {
  829. if (!it.isAnswer) {
  830. it.isAnswer = false;
  831. }
  832. });
  833. });
  834. }
  835. }
  836. },
  837. //生命周期 - 挂载完成(可以访问DOM元素)
  838. mounted() {},
  839. beforeCreate() {}, //生命周期 - 创建之前
  840. beforeMount() {}, //生命周期 - 挂载之前
  841. beforeUpdate() {}, //生命周期 - 更新之前
  842. updated() {}, //生命周期 - 更新之后
  843. beforeDestroy() {}, //生命周期 - 销毁之前
  844. destroyed() {}, //生命周期 - 销毁完成
  845. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  846. };
  847. </script>
  848. <style lang='scss' scope>
  849. //@import url(); 引入公共css类
  850. .Big-Book-PurePreview {
  851. &-content {
  852. &.m {
  853. display: flex;
  854. justify-content: flex-start;
  855. align-items: flex-start;
  856. }
  857. .Big-Book-title {
  858. font-size: 16px;
  859. line-height: 40px;
  860. color: #000;
  861. margin-right: 15px;
  862. }
  863. .Big-Book-main {
  864. > div {
  865. margin-bottom: 10px;
  866. &.Big-Book-pinyin {
  867. display: flex;
  868. justify-content: flex-start;
  869. align-items: center;
  870. }
  871. }
  872. }
  873. }
  874. .addoption {
  875. width: 200px;
  876. height: 40px;
  877. left: 40px;
  878. top: 304px;
  879. background: #f3f3f3;
  880. border: 1px dashed rgba(0, 0, 0, 0.15);
  881. box-sizing: border-box;
  882. border-radius: 4px;
  883. text-align: center;
  884. line-height: 40px;
  885. cursor: pointer;
  886. }
  887. .Big-Book-addrole {
  888. > div {
  889. width: 300px;
  890. height: 40px;
  891. background: #f3f3f3;
  892. border: 1px dashed rgba(0, 0, 0, 0.15);
  893. box-sizing: border-box;
  894. border-radius: 4px;
  895. text-align: center;
  896. line-height: 40px;
  897. cursor: pointer;
  898. }
  899. }
  900. .Big-Book-more {
  901. .Big-Book-more-text {
  902. position: relative;
  903. text-align: center;
  904. }
  905. .Big-Book-more-text:before,
  906. .Big-Book-more-text:after {
  907. position: absolute;
  908. background: #ccc;
  909. content: "";
  910. height: 1px;
  911. top: 50%;
  912. width: 45%;
  913. }
  914. .Big-Book-more-text:before {
  915. left: 10px;
  916. }
  917. .Big-Book-more-text:after {
  918. right: 10px;
  919. }
  920. .Big-Book-more-main {
  921. display: flex;
  922. > :not(:nth-child(1)) {
  923. margin-left: 30px;
  924. }
  925. }
  926. }
  927. .Big-Book-con {
  928. display: flex;
  929. align-items: center;
  930. }
  931. .close {
  932. width: 24px;
  933. cursor: pointer;
  934. }
  935. }
  936. </style>
  937. <style lang="scss">
  938. </style>