PurePreview.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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. ></el-input>
  18. </div>
  19. <template
  20. v-if="type == 'text_problem_chs' || type == 'newWord_preview_chs'"
  21. >
  22. <div
  23. class="Big-Book-main"
  24. v-for="(item, index) in curQue.option"
  25. :key="item + index"
  26. style="margin-bottom: 20px"
  27. >
  28. <template v-if="type == 'text_problem_chs'">
  29. <div class="adult-book-input-item">
  30. <span class="adult-book-lable">序号:</span>
  31. <el-input
  32. class="adult-book-input"
  33. type="textarea"
  34. :autosize="{ minRows: 2 }"
  35. placeholder="请输入序号"
  36. v-model="item.number"
  37. @blur="onBlur(item, 'number')"
  38. ></el-input>
  39. <img
  40. @click="deleteOptionOne(index)"
  41. class="close"
  42. src="../../../assets/adult/del-close.png"
  43. alt=""
  44. />
  45. </div>
  46. <div class="NPC-sentence-Segword">
  47. <SentenceSegwordChs :curQue="item.detail" />
  48. </div>
  49. <div class="adult-book-input-item">
  50. <span class="adult-book-lable">英文:</span>
  51. <el-input
  52. class="adult-book-input"
  53. type="textarea"
  54. :autosize="{ minRows: 2 }"
  55. placeholder="请输入英文"
  56. v-model="item.en"
  57. @blur="onBlur(item, 'en')"
  58. ></el-input>
  59. <img
  60. @click="deleteOptionOne(index)"
  61. class="close"
  62. src="../../../assets/adult/del-close.png"
  63. alt=""
  64. />
  65. </div>
  66. </template>
  67. <template v-if="type == 'newWord_preview_chs'">
  68. <div class="adult-book-input-item">
  69. <span class="adult-book-lable">拼音:</span>
  70. <el-input
  71. class="adult-book-input"
  72. type="textarea"
  73. :autosize="{ minRows: 2 }"
  74. placeholder="请输入拼音"
  75. v-model="item.pinyin"
  76. @blur="onBlur(item, 'pinyin')"
  77. ></el-input>
  78. <img
  79. @click="deleteOptionOne(index)"
  80. class="close"
  81. src="../../../assets/adult/del-close.png"
  82. alt=""
  83. />
  84. </div>
  85. <div class="adult-book-input-item">
  86. <span class="adult-book-lable">英文:</span>
  87. <el-input
  88. class="adult-book-input"
  89. type="textarea"
  90. :autosize="{ minRows: 2 }"
  91. placeholder="请输入英文"
  92. v-model="item.en"
  93. @blur="onBlur(item, 'en')"
  94. ></el-input>
  95. </div>
  96. <div class="adult-book-input-item">
  97. <span class="adult-book-lable">展示方式:</span>
  98. <el-radio-group v-model="item.imgOrText">
  99. <el-radio label="image">图片</el-radio>
  100. <el-radio label="text">文本</el-radio>
  101. </el-radio-group>
  102. </div>
  103. <template v-if="item.imgOrText == 'image'">
  104. <div class="adult-book-input-item">
  105. <span class="adult-book-lable">图片:</span>
  106. <Upload
  107. :changeFillId="changeImage"
  108. :datafileList="item.img_list"
  109. :filleNumber="mp3Number"
  110. :uploadType="'image'"
  111. :index="index"
  112. />
  113. </div>
  114. </template>
  115. <template v-if="item.imgOrText == 'text'">
  116. <div class="adult-book-input-item">
  117. <span class="adult-book-lable">生字:</span>
  118. <el-input
  119. class="adult-book-input"
  120. type="textarea"
  121. :autosize="{ minRows: 2 }"
  122. placeholder="请输入生字"
  123. v-model="item.con"
  124. @blur="onBlur(item, 'con')"
  125. ></el-input>
  126. </div>
  127. <div class="adult-book-input-item">
  128. <span class="adult-book-lable">音频:</span>
  129. <Upload
  130. :changeFillId="changeMp3"
  131. :datafileList="item.mp3_list"
  132. :filleNumber="mp3Number"
  133. :uploadType="'mp3'"
  134. :index="index"
  135. />
  136. </div>
  137. </template>
  138. </template>
  139. </div>
  140. </template>
  141. <template v-if="type == 'listen_record_single_syllable_chs'">
  142. <div
  143. class="Big-Book-main"
  144. v-for="(item, index) in curQue"
  145. :key="item + index"
  146. style="margin-bottom: 20px"
  147. >
  148. <div class="adult-book-input-item">
  149. <span class="adult-book-lable">序号:</span>
  150. <el-input
  151. class="adult-book-input"
  152. type="textarea"
  153. :autosize="{ minRows: 2 }"
  154. placeholder="请输入拼音"
  155. v-model="item.number"
  156. @blur="onBlur(item, 'number')"
  157. ></el-input>
  158. <img
  159. @click="deleteyinjie(index, itI)"
  160. class="close"
  161. src="../../../assets/adult/del-close.png"
  162. alt=""
  163. />
  164. </div>
  165. <div class="adult-book-input-item">
  166. <span class="adult-book-lable">音频:</span>
  167. <Upload
  168. :changeFillId="listenchangeMp3"
  169. :datafileList="item.mp3_list"
  170. :filleNumber="mp3Number"
  171. :uploadType="'mp3'"
  172. :index="index"
  173. />
  174. </div>
  175. <div v-for="(it, itI) in item.option" :key="'it' + itI">
  176. <div class="adult-book-input-item">
  177. <span class="adult-book-lable">拼音:</span>
  178. <el-input
  179. class="adult-book-input"
  180. type="textarea"
  181. :autosize="{ minRows: 2 }"
  182. placeholder="请输入拼音"
  183. v-model="it.pinyin"
  184. @blur="onBlur(it, 'pinyin')"
  185. ></el-input>
  186. <img
  187. @click="deleteyinjie(index, itI)"
  188. class="close"
  189. src="../../../assets/adult/del-close.png"
  190. alt=""
  191. />
  192. </div>
  193. </div>
  194. <div class="addoption" @click="addyinjie(index, itI)">
  195. 添加一个音节
  196. </div>
  197. </div>
  198. </template>
  199. <div class="Big-Book-addrole">
  200. <div class="addoption" @click="addOption">添加一个</div>
  201. </div>
  202. <template v-if="type == 'newWord_preview_chs'">
  203. <div class="Big-Book-divide">
  204. <el-divider content-position="center">功能设置</el-divider>
  205. <span style="margin: 0 10px">请选择每行数量</span>
  206. <el-select v-model="curQue.numberList.con" placeholder="请选择">
  207. <el-option
  208. v-for="(item, i) in curQue.numberList.arr"
  209. :key="i"
  210. :label="item.value"
  211. :value="item.id"
  212. >
  213. </el-option>
  214. </el-select>
  215. </div>
  216. </template>
  217. </div>
  218. </div>
  219. </template>
  220. <script>
  221. import Upload from "../common/Upload";
  222. import SentenceSegwordChs from "../common/SentenceSegwordChs/index.vue";
  223. export default {
  224. name: "PurePreview",
  225. props: ["curQue", "fn_data", "changeCurQue", "type"],
  226. components: {
  227. SentenceSegwordChs,
  228. Upload,
  229. },
  230. data() {
  231. return {
  232. checkList: [],
  233. mp3Number: 1,
  234. form: {
  235. stem: {
  236. con: "",
  237. pinyin: "",
  238. english: "",
  239. highlight: "",
  240. underline: "",
  241. img_url: [],
  242. mp3_url: [],
  243. },
  244. },
  245. data_structure: {
  246. type: "text_problem_chs",
  247. name: "课文上面的问题",
  248. title: "",
  249. option: [
  250. {
  251. mp3_list: [],
  252. number: "",
  253. detail: {
  254. en: "",
  255. pyPosition: "top", //top 拼音在上面;bottom 拼音在下面
  256. sentence: "", //句子
  257. segList: [], //分词结果
  258. seg_words: "",
  259. wordsList: [],
  260. },
  261. en: "", //英文
  262. answer: [""],
  263. judge: true,
  264. },
  265. ],
  266. },
  267. data_structure2: {
  268. type: "newWord_preview_chs",
  269. name: "生字展示",
  270. title: "",
  271. imgOrText: null,
  272. option: [
  273. {
  274. mp3_list: [],
  275. img_list: [],
  276. con: "", //生字
  277. en: "",
  278. pinyin: "", //拼音
  279. },
  280. ],
  281. numberList: {
  282. type: "number",
  283. name: "每行几个",
  284. con: "7",
  285. arr: [
  286. {
  287. id: 1,
  288. value: 1,
  289. },
  290. {
  291. id: 2,
  292. value: 2,
  293. },
  294. {
  295. id: 3,
  296. value: 3,
  297. },
  298. {
  299. id: 4,
  300. value: 4,
  301. },
  302. {
  303. id: 5,
  304. value: 5,
  305. },
  306. {
  307. id: 6,
  308. value: 6,
  309. },
  310. {
  311. id: 7,
  312. value: 7,
  313. },
  314. ],
  315. },
  316. },
  317. data_structure3: [
  318. {
  319. type: "listen_record_single_syllable_chs",
  320. name: "听录音选择音节",
  321. title: "",
  322. mp3_list: [],
  323. number: "",
  324. option: [
  325. {
  326. number: "",
  327. pinyin: "", //拼音
  328. },
  329. ],
  330. },
  331. ],
  332. };
  333. },
  334. computed: {},
  335. watch: {},
  336. //方法集合
  337. methods: {
  338. // 添加音节
  339. addyinjie(index) {
  340. let obj = JSON.parse(JSON.stringify(this.data_structure3[0].option[0]));
  341. this.curQue[index].option.push(obj);
  342. },
  343. // 删除音节
  344. deleteyinjie(index, yjIndex) {
  345. if (this.curQue[index].option.length <= 1) {
  346. this.$message.warning("至少要保留1个音节");
  347. return;
  348. }
  349. this.curQue[index].option.splice(yjIndex, 1);
  350. },
  351. onBlur(item, field) {
  352. item[field] = item[field] ? item[field].trim() : "";
  353. },
  354. // 删除其中一个选项
  355. deleteOptionOne(index) {
  356. if (this.type == "listen_record_single_syllable_chs") {
  357. if (this.curQue[index].option.length <= 1) {
  358. this.$message.warning("至少要保留1个选项");
  359. return;
  360. }
  361. }
  362. if (this.curQue.option.length <= 1) {
  363. this.$message.warning("至少要保留1个选项");
  364. return;
  365. }
  366. this.curQue.option.splice(index, 1);
  367. },
  368. // 新增选项
  369. addOption() {
  370. let obj;
  371. if (this.type == "newWord_preview_chs") {
  372. obj = JSON.parse(JSON.stringify(this.data_structure2.option[0]));
  373. this.curQue.option.push(obj);
  374. } else if (this.type == "text_problem_chs") {
  375. obj = JSON.parse(JSON.stringify(this.data_structure.option[0]));
  376. this.curQue.option.push(obj);
  377. } else if (this.type == "listen_record_single_syllable_chs") {
  378. obj = JSON.parse(JSON.stringify(this.data_structure3[0]));
  379. this.curQue.push(obj);
  380. }
  381. },
  382. initcurQue() {
  383. let data;
  384. if (this.type == "newWord_preview_chs") {
  385. data = JSON.parse(JSON.stringify(this.data_structure2));
  386. } else if (this.type == "text_problem_chs") {
  387. data = JSON.parse(JSON.stringify(this.data_structure));
  388. } else if (this.type == "listen_record_single_syllable_chs") {
  389. data = JSON.parse(JSON.stringify(this.data_structure3));
  390. }
  391. this.changeCurQue(data);
  392. },
  393. // 选项的图片
  394. changeImage(fileList, item, index) {
  395. const articleImgList = JSON.parse(JSON.stringify(fileList));
  396. const articleImgRes = [];
  397. articleImgList.forEach((item) => {
  398. if (item.response) {
  399. const obj = {
  400. name: item.name,
  401. url: item.response.file_info_list[0].file_url,
  402. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  403. media_duration: item.response.file_info_list[0].media_duration, //音频时长
  404. };
  405. articleImgRes.push(obj);
  406. }
  407. });
  408. this.curQue.option[index].mp3_list = JSON.parse(
  409. JSON.stringify(articleImgRes)
  410. );
  411. },
  412. // 选项的音频
  413. changeMp3(fileList, item, index) {
  414. const articleImgList = JSON.parse(JSON.stringify(fileList));
  415. const articleImgRes = [];
  416. articleImgList.forEach((item) => {
  417. if (item.response) {
  418. const obj = {
  419. name: item.name,
  420. url: item.response.file_info_list[0].file_url,
  421. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  422. media_duration: item.response.file_info_list[0].media_duration, //音频时长
  423. };
  424. articleImgRes.push(obj);
  425. }
  426. });
  427. this.curQue.option[index].mp3_list = JSON.parse(
  428. JSON.stringify(articleImgRes)
  429. );
  430. },
  431. // 听录音选择音调的上传音频
  432. listenchangeMp3(fileList, item, index) {
  433. const articleImgList = JSON.parse(JSON.stringify(fileList));
  434. const articleImgRes = [];
  435. articleImgList.forEach((item) => {
  436. if (item.response) {
  437. const obj = {
  438. name: item.name,
  439. url: item.response.file_info_list[0].file_url,
  440. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  441. media_duration: item.response.file_info_list[0].media_duration, //音频时长
  442. };
  443. articleImgRes.push(obj);
  444. }
  445. });
  446. this.curQue[index].mp3_list = JSON.parse(JSON.stringify(articleImgRes));
  447. },
  448. // 题目的音频
  449. timuchangeMp3(fileList) {
  450. const articleImgList = JSON.parse(JSON.stringify(fileList));
  451. const articleImgRes = [];
  452. articleImgList.forEach((item) => {
  453. if (item.response) {
  454. const obj = {
  455. name: item.name,
  456. url: item.response.file_info_list[0].file_url,
  457. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  458. media_duration: item.response.file_info_list[0].media_duration, //音频时长
  459. };
  460. articleImgRes.push(obj);
  461. }
  462. });
  463. this.curQue.mp3_list = JSON.parse(JSON.stringify(articleImgRes));
  464. },
  465. },
  466. //生命周期 - 创建完成(可以访问当前this实例)
  467. created() {
  468. if (!this.curQue) {
  469. this.initcurQue();
  470. } else {
  471. if (this.type == "newWord_preview_chs") {
  472. let obj = {
  473. type: "number",
  474. name: "每行几个",
  475. con: "7",
  476. arr: [
  477. {
  478. id: 1,
  479. value: 1,
  480. },
  481. {
  482. id: 2,
  483. value: 2,
  484. },
  485. {
  486. id: 3,
  487. value: 3,
  488. },
  489. {
  490. id: 4,
  491. value: 4,
  492. },
  493. {
  494. id: 5,
  495. value: 5,
  496. },
  497. {
  498. id: 6,
  499. value: 6,
  500. },
  501. {
  502. id: 7,
  503. value: 7,
  504. },
  505. ],
  506. };
  507. this.$set(this.curQue, "numberList", obj);
  508. }
  509. }
  510. },
  511. //生命周期 - 挂载完成(可以访问DOM元素)
  512. mounted() {},
  513. beforeCreate() {}, //生命周期 - 创建之前
  514. beforeMount() {}, //生命周期 - 挂载之前
  515. beforeUpdate() {}, //生命周期 - 更新之前
  516. updated() {}, //生命周期 - 更新之后
  517. beforeDestroy() {}, //生命周期 - 销毁之前
  518. destroyed() {}, //生命周期 - 销毁完成
  519. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  520. };
  521. </script>
  522. <style lang='scss' scope>
  523. //@import url(); 引入公共css类
  524. .Big-Book-PurePreview {
  525. &-content {
  526. &.m {
  527. display: flex;
  528. justify-content: flex-start;
  529. align-items: flex-start;
  530. }
  531. .Big-Book-title {
  532. font-size: 16px;
  533. line-height: 40px;
  534. color: #000;
  535. margin-right: 15px;
  536. }
  537. .Big-Book-main {
  538. > div {
  539. margin-bottom: 10px;
  540. &.Big-Book-pinyin {
  541. display: flex;
  542. justify-content: flex-start;
  543. align-items: center;
  544. }
  545. }
  546. }
  547. }
  548. .addoption {
  549. width: 200px;
  550. height: 40px;
  551. left: 40px;
  552. top: 304px;
  553. background: #f3f3f3;
  554. border: 1px dashed rgba(0, 0, 0, 0.15);
  555. box-sizing: border-box;
  556. border-radius: 4px;
  557. text-align: center;
  558. line-height: 40px;
  559. cursor: pointer;
  560. }
  561. .Big-Book-addrole {
  562. > div {
  563. width: 300px;
  564. height: 40px;
  565. background: #f3f3f3;
  566. border: 1px dashed rgba(0, 0, 0, 0.15);
  567. box-sizing: border-box;
  568. border-radius: 4px;
  569. text-align: center;
  570. line-height: 40px;
  571. cursor: pointer;
  572. }
  573. }
  574. .Big-Book-more {
  575. .Big-Book-more-text {
  576. position: relative;
  577. text-align: center;
  578. }
  579. .Big-Book-more-text:before,
  580. .Big-Book-more-text:after {
  581. position: absolute;
  582. background: #ccc;
  583. content: "";
  584. height: 1px;
  585. top: 50%;
  586. width: 45%;
  587. }
  588. .Big-Book-more-text:before {
  589. left: 10px;
  590. }
  591. .Big-Book-more-text:after {
  592. right: 10px;
  593. }
  594. .Big-Book-more-main {
  595. display: flex;
  596. > :not(:nth-child(1)) {
  597. margin-left: 30px;
  598. }
  599. }
  600. }
  601. .Big-Book-con {
  602. display: flex;
  603. align-items: center;
  604. }
  605. .close {
  606. width: 24px;
  607. cursor: pointer;
  608. }
  609. }
  610. </style>
  611. <style lang="scss">
  612. </style>