Preview.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <!-- -->
  2. <template>
  3. <div class="NNPE-Big-Book-preview adult-book-preview-sty preview-red">
  4. <div class="NNPE-title">
  5. <h1>{{ fatherName }}</h1>
  6. <div class="NNPE-operate">
  7. <a class="btn-prev" @click="handleNNPEprev" />
  8. <a class="btn-next" @click="handleNNPEnext" />
  9. </div>
  10. </div>
  11. <div v-if="cur" class="NNPE-Book-content-inner">
  12. <div v-for="(item, index) in cur.cur_fn_data" :key="index">
  13. <h2 v-if="item.z_title">{{ item.z_title }}</h2>
  14. <h3 v-if="item.f_title">{{ item.f_title }}</h3>
  15. <div
  16. :class="['NNPE-tableList', item.is_bg ? 'NNPE-tableList-hasBg' : '']"
  17. >
  18. <div
  19. v-for="(items, indexs) in item.table_list"
  20. :key="indexs"
  21. class="NNPE-tableList-tr"
  22. >
  23. <div
  24. v-for="(itemss, indexss) in items"
  25. :key="indexss"
  26. :class="[
  27. 'NNPE-tableList-item',
  28. items.length == 1
  29. ? 'NNPE-tableList-item-noMargin'
  30. : 'NNPE-tableList-item' + items.length,
  31. ]"
  32. >
  33. <template v-if="itemss.data">
  34. <template v-if="itemss.type == 'ligature_chs'">
  35. <Ligature :cur-que="itemss.data" />
  36. </template>
  37. <template v-if="itemss.data.type == 'image'">
  38. <Picture :cur-que="itemss.data" :child-type="itemss.type" />
  39. </template>
  40. <template v-if="itemss.type == 'record_chs'">
  41. <Record :cur-que="itemss.data" />
  42. </template>
  43. <template v-if="itemss.type == 'phrase_chs'">
  44. <WordPhrase :cur-que="itemss.data" />
  45. </template>
  46. <template v-if="itemss.type == 'NewWord_chs'">
  47. <WordPhrase :cur-que="itemss.data" />
  48. </template>
  49. <template v-if="itemss.type == 'annotation_chs'">
  50. <WordPhrase :cur-que="itemss.data" />
  51. </template>
  52. <template v-if="itemss.type == 'notes_chs'">
  53. <Notes :cur-que="itemss.data" />
  54. </template>
  55. <template v-if="itemss.type == 'article_chs'">
  56. <ArticleTemChs
  57. :cur-que="itemss.data"
  58. :n-n-p-e-new-word-list="NNPENewWordList"
  59. :n-n-p-e-new-phrase-list="NNPENewPhraseList"
  60. :n-n-p-e-annotation-list="NNPEAnnotationList"
  61. />
  62. </template>
  63. <template v-if="itemss.type == 'sentence_segword_chs'">
  64. <SentenceSegWordViewChs :cur-que="itemss.data" />
  65. </template>
  66. <template v-if="itemss.type == 'dialogue_article_chs'">
  67. <DialogueArticleViewChs
  68. :cur-que="itemss.data"
  69. :n-n-p-e-new-word-list="NNPENewWordList"
  70. :n-n-p-e-new-phrase-list="NNPENewPhraseList"
  71. :n-n-p-e-annotation-list="NNPEAnnotationList"
  72. :colorBox="colorBox"
  73. />
  74. </template>
  75. <template v-if="itemss.type == 'input_record_chs'">
  76. <InputHasRecord :cur-que="itemss.data" />
  77. </template>
  78. <template v-if="itemss.type == 'recordHZ_inputPY_chs'">
  79. <TextInputRecord :cur-que="itemss.data" />
  80. </template>
  81. <template
  82. v-if="
  83. itemss.type == 'inputItem_chs' ||
  84. itemss.type == 'sentence_input_chs' ||
  85. itemss.type == 'sentence_judge_chs' ||
  86. itemss.type == 'sentence_record_chs' ||
  87. itemss.type == 'sentence_input_record_chs'
  88. "
  89. >
  90. <SentenceInput :cur-que="itemss.data" />
  91. </template>
  92. <template v-if="itemss.type == 'NumberCombination_chs'">
  93. <NumberSelectHasRecord :cur-que="itemss.data" />
  94. </template>
  95. <template v-if="itemss.type === 'voice_matrix'">
  96. <voice-matrix :cur-que="itemss.data" />
  97. </template>
  98. <template v-if="itemss.type == 'toneSelect_chs'">
  99. <SelectTone :cur-que="itemss.data" />
  100. </template>
  101. <template v-if="itemss.type == 'sudoku_chs'">
  102. <Soduko :cur-que="itemss.data" />
  103. </template>
  104. <template v-if="itemss.type == 'single_chs'">
  105. <Single :cur-que="itemss.data" />
  106. </template>
  107. <template v-if="itemss.type == 'text_problem_chs'">
  108. <TextProblem :cur-que="itemss.data" />
  109. </template>
  110. <template v-if="itemss.type == 'newWord_preview_chs'">
  111. <NewWordShow :cur-que="itemss.data" />
  112. </template>
  113. <template
  114. v-if="itemss.type == 'listen_record_single_syllable_chs'"
  115. >
  116. <SelectYinjie :cur-que="itemss.data" />
  117. </template>
  118. <template v-if="itemss.type == 'sentence_listen_read_chs'">
  119. <SentenceListenRead :cur-que="itemss.data" />
  120. </template>
  121. <template v-if="itemss.type == 'sort_chs'">
  122. <SentenceSort :cur-que="itemss.data" />
  123. </template>
  124. <template v-if="itemss.type == 'checkbox_self_assessment_chs'">
  125. <Checkbox :cur-que="itemss.data" />
  126. </template>
  127. <template
  128. v-if="
  129. itemss.type == 'record_control_mini' ||
  130. itemss.type == 'record_control_normal' ||
  131. itemss.type == 'record_control_pro' ||
  132. itemss.type == 'record_control_promax'
  133. "
  134. >
  135. <RecordModule :cur-que="itemss.data" />
  136. </template>
  137. <template
  138. v-if="
  139. itemss.type == 'upload_control_chs' ||
  140. itemss.type == 'upload_control_preview_chs'
  141. "
  142. >
  143. <UploadControlView
  144. :cur-que="itemss.data"
  145. :type="itemss.type"
  146. />
  147. </template>
  148. </template>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. </template>
  156. <script>
  157. import Picture from "./preview/Picture.vue"; // 图片模板
  158. import Record from "./preview/Record.vue"; // 音频播放
  159. import Soundrecord from "./preview/Soundrecord.vue"; // 录音模板
  160. import ArticleTemChs from "./preview/ArticleViewChs/index.vue"; // 文章模板
  161. import DialogueArticleViewChs from "./preview/DialogueArticleViewChs/index.vue"; // 文章模板
  162. import SentenceSegWordViewChs from "./preview/SentenceSegWordViewChs.vue"; // 句子分词
  163. import WordPhrase from "./preview/WordPhrase.vue"; // 生词短语
  164. import Notes from "./preview/Notes.vue"; // 注释
  165. import Ligature from "./preview/Ligature.vue";
  166. import InputHasRecord from "./preview/InputHasRecord.vue"; // 输入加录音
  167. import TextInputRecord from "./preview/TextInputRecord.vue"; // 文本+输入+录音
  168. import SentenceInput from "./preview/SentenceInput.vue"; // 输入选项
  169. import NumberSelectHasRecord from "./preview/NumberSelectHasRecord.vue"; // 数字组合
  170. import SelectTone from "./preview/SelectTone.vue"; // 选择声调
  171. import Soduko from "./preview/Soduko.vue"; // 数独
  172. import Single from "./preview/Single.vue"; // 单选
  173. import TextProblem from "./preview/TextProblem.vue"; // 课文上方的问题
  174. import NewWordShow from "./preview/NewWordShow.vue"; // 生字展示
  175. import SelectYinjie from "./preview/SelectYinjie.vue"; // 选择音节
  176. import SentenceListenRead from "./preview/SentenceListenRead.vue"; // 听并朗读
  177. import SentenceSort from "./preview/SentenceSort.vue"; // 句子拖拽排序
  178. import Checkbox from "./preview/CheckBoxModule.vue"; // 问卷调查-多选题
  179. import VoiceMatrix from "./preview/VoiceMatrix.vue"; // 语音矩阵
  180. import RecordModule from "./preview/RecordModule.vue"; // 录音组件
  181. import UploadControlView from "./preview/UploadControlView.vue";//预览控件
  182. export default {
  183. name: "Preview",
  184. components: {
  185. Picture,
  186. Record,
  187. Soundrecord,
  188. ArticleTemChs,
  189. DialogueArticleViewChs,
  190. SentenceSegWordViewChs,
  191. WordPhrase,
  192. Notes,
  193. Ligature,
  194. InputHasRecord,
  195. TextInputRecord,
  196. SentenceInput,
  197. NumberSelectHasRecord,
  198. SelectTone,
  199. Soduko,
  200. Single,
  201. TextProblem,
  202. NewWordShow,
  203. SelectYinjie,
  204. SentenceListenRead,
  205. SentenceSort,
  206. Checkbox,
  207. VoiceMatrix,
  208. RecordModule,
  209. UploadControlView,
  210. },
  211. props: [
  212. "context",
  213. "fatherName",
  214. "currentTreeID",
  215. "FatherTreeData",
  216. "changeId",
  217. ],
  218. data() {
  219. return {
  220. contextData: null,
  221. queIndex: -1, // 题目的索引
  222. cur: null, // 当前的题目
  223. watchIndex: -1, // 监听的值
  224. queList: [],
  225. queTotal: 0, // 题目总数
  226. NNPENewWordList: [], // 存放文章的生词
  227. NNPENewPhraseList: [], // 存放文章的短语
  228. NNPEAnnotationList: [], // 存放文章注释
  229. height: "", // 总体的高度
  230. colorBox: [
  231. {
  232. touxiang: "#72B51D",
  233. bg: "#E9F0DF",
  234. },
  235. {
  236. touxiang: "#DE4444",
  237. bg: "rgba(222, 68, 68, 0.1)",
  238. },
  239. {
  240. touxiang: "#A7A7A7",
  241. bg: "#ffffff",
  242. },
  243. {
  244. touxiang: "#4D91F6",
  245. bg: "#F1F7FF",
  246. },
  247. {
  248. touxiang: "#FF8A00",
  249. bg: "rgba(255, 138, 0, 0.1)",
  250. },
  251. ],
  252. };
  253. },
  254. computed: {},
  255. watch: {
  256. context: {
  257. handler(val, oldVal) {
  258. const _this = this;
  259. if (val) {
  260. _this.initContextData();
  261. }
  262. },
  263. // 深度观察监听
  264. deep: true,
  265. },
  266. },
  267. // 生命周期 - 创建完成(可以访问当前this实例)
  268. created() {},
  269. // 生命周期 - 挂载完成(可以访问DOM元素)
  270. mounted() {
  271. const _this = this;
  272. if (_this.context) {
  273. _this.initContextData();
  274. }
  275. },
  276. beforeCreate() {}, // 生命周期 - 创建之前
  277. beforeMount() {}, // 生命周期 - 挂载之前
  278. beforeUpdate() {}, // 生命周期 - 更新之前
  279. updated() {}, // 生命周期 - 更新之后
  280. beforeDestroy() {}, // 生命周期 - 销毁之前
  281. destroyed() {}, // 生命周期 - 销毁完成
  282. activated() {},
  283. // 方法集合
  284. methods: {
  285. initContextData() {
  286. const _this = this;
  287. _this.contextData = JSON.parse(JSON.stringify(_this.context));
  288. _this.queIndex = 0;
  289. _this.NNPENewWordList = [];
  290. _this.NNPENewPhraseList = [];
  291. _this.watchIndex = _this.queIndex + new Date().getTime();
  292. if (_this.contextData) {
  293. // const list = _this.contextData;
  294. // if (list && list.length > 0) {
  295. // _this.queList = list;
  296. // _this.cur = list[_this.queIndex];
  297. _this.queTotal = 1;
  298. // _this.cur.cur_fn_data.forEach((item) => {
  299. // item.table_list.forEach((items) => {
  300. // items.forEach((itemss) => {
  301. // if (itemss.data && itemss.data.type == "NewWord_chs") {
  302. // _this.NNPENewWordList = _this.NNPENewWordList.concat(
  303. // itemss.data.option
  304. // );
  305. // } else if (itemss.data && itemss.data.type == "notes_chs") {
  306. // _this.NNPEAnnotationList = _this.NNPEAnnotationList.concat(
  307. // itemss.data.option
  308. // );
  309. // }
  310. // });
  311. // });
  312. // });
  313. // }
  314. _this.cur = _this.contextData;
  315. _this.cur.cur_fn_data.forEach((item) => {
  316. item.table_list.forEach((items) => {
  317. items.forEach((itemss) => {
  318. if (itemss.data && itemss.data.type == "NewWord_chs") {
  319. _this.NNPENewWordList = _this.NNPENewWordList.concat(
  320. itemss.data.option
  321. );
  322. } else if (itemss.data && itemss.data.type == "notes_chs") {
  323. _this.NNPEAnnotationList = _this.NNPEAnnotationList.concat(
  324. itemss.data.option
  325. );
  326. }
  327. });
  328. });
  329. });
  330. }
  331. },
  332. // 上一页
  333. handleNNPEprev() {
  334. const _this = this;
  335. if (_this.queIndex == 0) {
  336. let data = {};
  337. let flg = false;
  338. let xiangdeng = false;
  339. _this.FatherTreeData.forEach((item, itemIndex) => {
  340. if (item.children) {
  341. item.children.forEach((it, childrenIndex) => {
  342. if (it.id == _this.currentTreeID) {
  343. if (itemIndex == 0 && childrenIndex == 0) {
  344. this.$message({
  345. message: "已经是最后一题",
  346. type: "success",
  347. });
  348. flg = true;
  349. } else if (childrenIndex == 0) {
  350. // 当前子节点的第一个
  351. if (_this.FatherTreeData[itemIndex - 1].children) {
  352. data.fatherName =
  353. _this.FatherTreeData[
  354. itemIndex - 1
  355. ].children[0].fatherName;
  356. data.id =
  357. _this.FatherTreeData[itemIndex - 1].children[0].id;
  358. data.name =
  359. _this.FatherTreeData[itemIndex - 1].children[0].name;
  360. } else {
  361. data.fatherName =
  362. _this.FatherTreeData[itemIndex - 1].fatherName;
  363. data.id = _this.FatherTreeData[itemIndex - 1].id;
  364. data.name = _this.FatherTreeData[itemIndex - 1].name;
  365. }
  366. } else {
  367. data.fatherName = item.children[childrenIndex - 1].fatherName;
  368. data.id = item.children[childrenIndex - 1].id;
  369. data.name = item.children[childrenIndex - 1].name;
  370. }
  371. xiangdeng = true;
  372. }
  373. });
  374. } else {
  375. if (!xiangdeng) {
  376. if (item.id == _this.currentTreeID) {
  377. if (itemIndex == 0) {
  378. this.$message({
  379. message: "已经是第一题",
  380. type: "success",
  381. });
  382. flg = true;
  383. } else {
  384. if (_this.FatherTreeData[itemIndex - 1].children) {
  385. data.fatherName =
  386. _this.FatherTreeData[itemIndex - 1].children[
  387. _this.FatherTreeData[itemIndex - 1].children.length - 1
  388. ].fatherName;
  389. data.id =
  390. _this.FatherTreeData[itemIndex - 1].children[
  391. _this.FatherTreeData[itemIndex - 1].children.length - 1
  392. ].id;
  393. data.name =
  394. _this.FatherTreeData[itemIndex - 1].children[
  395. _this.FatherTreeData[itemIndex - 1].children.length - 1
  396. ].name;
  397. } else {
  398. data.fatherName =
  399. _this.FatherTreeData[itemIndex - 1].fatherName;
  400. data.id = _this.FatherTreeData[itemIndex - 1].id;
  401. data.name = _this.FatherTreeData[itemIndex - 1].name;
  402. }
  403. }
  404. }
  405. }
  406. }
  407. });
  408. if (flg) {
  409. return;
  410. }
  411. _this.queIndex = 0;
  412. _this.changeId(data.id, data.name, data.fatherName, "Preview");
  413. } else {
  414. _this.queIndex -= 1;
  415. _this.watchIndex = _this.queIndex + new Date().getTime();
  416. _this.cur = _this.queList[_this.queIndex];
  417. }
  418. },
  419. // 下一页
  420. handleNNPEnext() {
  421. const _this = this;
  422. if (_this.queIndex == _this.queTotal - 1) {
  423. let data = {};
  424. let flg = false;
  425. let xiangdeng = false;
  426. _this.FatherTreeData.forEach((item, itemIndex) => {
  427. if (item.children) {
  428. item.children.forEach((it, childrenIndex) => {
  429. if (it.id == _this.currentTreeID) {
  430. if (
  431. itemIndex == _this.FatherTreeData.length - 1 &&
  432. childrenIndex == item.children.length - 1
  433. ) {
  434. this.$message({
  435. message: "已经是最后一题",
  436. type: "success",
  437. });
  438. flg = true;
  439. } else if (childrenIndex == item.children.length - 1) {
  440. // 当前子节点的最后一个
  441. if (_this.FatherTreeData[itemIndex + 1].children) {
  442. data.fatherName =
  443. _this.FatherTreeData[
  444. itemIndex + 1
  445. ].children[0].fatherName;
  446. data.id =
  447. _this.FatherTreeData[itemIndex + 1].children[0].id;
  448. data.name =
  449. _this.FatherTreeData[itemIndex + 1].children[0].name;
  450. } else {
  451. data.fatherName =
  452. _this.FatherTreeData[itemIndex + 1].fatherName;
  453. data.id = _this.FatherTreeData[itemIndex + 1].id;
  454. data.name = _this.FatherTreeData[itemIndex + 1].name;
  455. }
  456. } else {
  457. data.fatherName = item.children[childrenIndex + 1].fatherName;
  458. data.id = item.children[childrenIndex + 1].id;
  459. data.name = item.children[childrenIndex + 1].name;
  460. }
  461. xiangdeng = true;
  462. }
  463. });
  464. } else {
  465. if (!xiangdeng) {
  466. if (item.id == _this.currentTreeID) {
  467. if (itemIndex == _this.FatherTreeData.length - 1) {
  468. this.$message({
  469. message: "已经是最后一题",
  470. type: "success",
  471. });
  472. flg = true;
  473. } else {
  474. if (_this.FatherTreeData[itemIndex + 1].children) {
  475. data.fatherName =
  476. _this.FatherTreeData[
  477. itemIndex + 1
  478. ].children[0].fatherName;
  479. data.name =
  480. _this.FatherTreeData[itemIndex + 1].children[0].name;
  481. data.id =
  482. _this.FatherTreeData[itemIndex + 1].children[0].id;
  483. } else {
  484. data.fatherName =
  485. _this.FatherTreeData[itemIndex + 1].fatherName;
  486. data.id = _this.FatherTreeData[itemIndex + 1].id;
  487. data.name = _this.FatherTreeData[itemIndex + 1].name;
  488. }
  489. }
  490. }
  491. }
  492. }
  493. });
  494. if (flg) {
  495. return;
  496. }
  497. _this.changeId(data.id, data.name, data.fatherName, "Preview");
  498. xiangdeng = false;
  499. } else {
  500. _this.queIndex += 1;
  501. _this.watchIndex = _this.queIndex + new Date().getTime();
  502. _this.cur = _this.queList[_this.queIndex];
  503. }
  504. },
  505. }, // 如果页面有keep-alive缓存功能,这个函数会触发
  506. };
  507. </script>
  508. <style lang='scss' scoped>
  509. //@import url(); 引入公共css类
  510. .NNPE-Big-Book-preview {
  511. width: 860px;
  512. margin: 0 auto;
  513. position: relative;
  514. .NNPE-title {
  515. background: #4f92f6;
  516. padding: 20px 24px;
  517. position: relative;
  518. h1 {
  519. color: #ffffff;
  520. font-weight: bold;
  521. font-size: 16px;
  522. line-height: 150%;
  523. margin: 0;
  524. }
  525. .NNPE-operate {
  526. position: absolute;
  527. top: 10px;
  528. right: 20px;
  529. a {
  530. background: #66a3ff url("../../assets/newImage/common/btn-pre.png")
  531. center no-repeat;
  532. border-radius: 4px;
  533. width: 44px;
  534. height: 44px;
  535. display: inline-block;
  536. margin: 0 4px;
  537. &.btn-next {
  538. background: #66a3ff url("../../assets/newImage/common/btn-next.png")
  539. center no-repeat;
  540. }
  541. &:hover {
  542. background-color: #3f75c4;
  543. }
  544. }
  545. }
  546. }
  547. .NNPE-Book-content-inner {
  548. padding: 0 40px;
  549. > div {
  550. padding-top: 24px;
  551. > h2 {
  552. color: #000000;
  553. font-size: 16px;
  554. line-height: 150%;
  555. font-weight: bold;
  556. margin: 0;
  557. }
  558. > h3 {
  559. color: #000000;
  560. font-size: 16px;
  561. line-height: 150%;
  562. font-weight: normal;
  563. margin: 8px 0 16px 0;
  564. }
  565. }
  566. .NNPE-tableList {
  567. background: #fff;
  568. border-radius: 8px;
  569. // padding: 12px 8px;
  570. &.NNPE-tableList-hasBg {
  571. background: #f7f7f7;
  572. border: 1px solid rgba(0, 0, 0, 0.1);
  573. box-sizing: border-box;
  574. border-radius: 8px;
  575. }
  576. .NNPE-tableList-tr {
  577. display: flex;
  578. justify-content: space-between;
  579. // flex-flow: wrap;
  580. .NNPE-tableList-item {
  581. width: 100%;
  582. // margin: 12px 16px;
  583. // padding: 16px;
  584. // background: #FFFFFF;
  585. // border-radius: 4px;
  586. display: flex;
  587. flex-flow: wrap;
  588. justify-content: center;
  589. &.NNPE-tableList-item-noMargin {
  590. margin: 0;
  591. }
  592. &.NNPE-tableList-item2 {
  593. width: 378px;
  594. }
  595. &.NNPE-tableList-item3 {
  596. width: 244px;
  597. }
  598. }
  599. }
  600. }
  601. }
  602. }
  603. </style>