Preview.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <!-- -->
  2. <template>
  3. <div class="NNPE-Big-Book-preview NPC-Book-Sty">
  4. <div class="NNPE-title">
  5. <h1>{{ fatherName }}</h1>
  6. <div class="NNPE-operate">
  7. <a class="btn-prev" @click="handleNNPEprev"></a>
  8. <a class="btn-next" @click="handleNNPEnext"></a>
  9. </div>
  10. </div>
  11. <div class="NNPE-Book-content-inner" v-if="cur">
  12. <div v-for="(item, index) in cur.cur_fn_data" :key="index">
  13. <h2 v-if="item.title_z">{{ item.title_z }}</h2>
  14. <h3 v-if="item.title_f">{{ item.title_f }}</h3>
  15. <div
  16. :class="['NNPE-tableList', item.Isbg ? 'NNPE-tableList-hasBg' : '']"
  17. >
  18. <div
  19. class="NNPE-tableList-tr"
  20. v-for="(items, indexs) in item.table_list"
  21. :key="indexs"
  22. >
  23. <div
  24. :class="[
  25. 'NNPE-tableList-item',
  26. items.length == 1 ? 'NNPE-tableList-item-noMargin' : '',
  27. ]"
  28. v-for="(itemss, indexss) in items"
  29. :key="indexss"
  30. >
  31. <template v-if="itemss.data">
  32. <template v-if="itemss.data.type == 'ligature'">
  33. <Ligature :curQue="itemss.que" />
  34. </template>
  35. <template v-if="itemss.data.type == 'image_chs'">
  36. <Picture :curQue="itemss.data" />
  37. </template>
  38. <template v-if="itemss.data.type == 'record_chs'">
  39. <Record :curQue="itemss.data" />
  40. </template>
  41. <template v-if="itemss.data.type == 'phrase_chs'">
  42. <WordPhrase :curQue="itemss.data" />
  43. </template>
  44. <template v-if="itemss.data.type == 'NewWord_chs'">
  45. <WordPhrase :curQue="itemss.data" />
  46. </template>
  47. <template v-if="itemss.data.type == 'annotation_chs'">
  48. <WordPhrase :curQue="itemss.data" />
  49. </template>
  50. <template v-if="itemss.data.type == 'notes_chs'">
  51. <Notes :curQue="itemss.data" />
  52. </template>
  53. <template v-if="itemss.data.type == 'article_chs'">
  54. <ArticleTemChs
  55. :curQue="itemss.data"
  56. :NNPENewWordList="NNPENewWordList"
  57. :NNPENewPhraseList="NNPENewPhraseList"
  58. :NNPEAnnotationList="NNPEAnnotationList"
  59. />
  60. </template>
  61. <template v-if="itemss.data.type == 'dialogue_article_chs'">
  62. <DialogueArticleViewChs
  63. :curQue="itemss.data"
  64. :NNPENewWordList="NNPENewWordList"
  65. :NNPENewPhraseList="NNPENewPhraseList"
  66. :NNPEAnnotationList="NNPEAnnotationList"
  67. />
  68. </template>
  69. <template v-if="itemss.data.type == 'sentence_segword_chs'">
  70. <SentenceSegWordViewChs :curQue="itemss.data" />
  71. </template>
  72. <template v-if="itemss.data.type == 'input_record_chs'">
  73. <InputHasRecord :curQue="itemss.data" />
  74. </template>
  75. <template v-if="itemss.data.type == 'recordHZ_inputPY_chs'">
  76. <TextInputRecord :curQue="itemss.data" />
  77. </template>
  78. <template v-if="itemss.data.type == 'inputItem_chs'">
  79. <SentenceInput :curQue="itemss.data" />
  80. </template>
  81. <template v-if="itemss.data.type == 'NumberCombination_chs'">
  82. <NumberSelectHasRecord :curQue="itemss.data" />
  83. </template>
  84. </template>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. </template>
  92. <script>
  93. import Picture from "./preview/Picture.vue"; // 图片模板
  94. import Record from "./preview/Record.vue"; // 音频播放
  95. import Soundrecord from "./preview/Soundrecord.vue"; // 录音模板
  96. import ArticleTemChs from "./preview/ArticleViewChs/index.vue"; // 文章模板
  97. import DialogueArticleViewChs from "./preview/DialogueArticleViewChs/index.vue"; // 文章模板
  98. import SentenceSegWordViewChs from "./preview/SentenceSegWordViewChs.vue"; //句子分词
  99. import WordPhrase from "./preview/WordPhrase.vue"; // 生词 短语
  100. import Notes from "./preview/Notes.vue"; // 注释
  101. import Ligature from "./preview/Ligature.vue";
  102. import InputHasRecord from "./preview/InputHasRecord.vue"; // 输入加录音
  103. import TextInputRecord from "./preview/TextInputRecord.vue"; // 文本+输入+录音
  104. import SentenceInput from "./preview/SentenceInput.vue"; // 输入选项
  105. import NumberSelectHasRecord from "./preview/NumberSelectHasRecord.vue"; // 数字组合
  106. export default {
  107. name: "preview",
  108. components: {
  109. Picture,
  110. Record,
  111. Soundrecord,
  112. ArticleTemChs,
  113. DialogueArticleViewChs,
  114. SentenceSegWordViewChs,
  115. WordPhrase,
  116. Notes,
  117. Ligature,
  118. InputHasRecord,
  119. TextInputRecord,
  120. SentenceInput,
  121. NumberSelectHasRecord,
  122. },
  123. props: ["context", "fatherName"],
  124. data() {
  125. return {
  126. contextData: null,
  127. queIndex: -1, // 题目的索引
  128. cur: null, // 当前的题目
  129. watchIndex: -1, // 监听的值
  130. queList: [],
  131. queTotal: 0, // 题目总数
  132. NNPENewWordList: [], // 存放文章的生词
  133. NNPENewPhraseList: [], // 存放文章的短语
  134. NNPEAnnotationList: [], // 存放文章注释
  135. height: "", //总体的高度
  136. };
  137. },
  138. computed: {},
  139. watch: {
  140. context: {
  141. handler: function (val, oldVal) {
  142. const _this = this;
  143. if (val) {
  144. _this.initContextData();
  145. }
  146. },
  147. // 深度观察监听
  148. deep: true,
  149. },
  150. },
  151. //方法集合
  152. methods: {
  153. initContextData() {
  154. const _this = this;
  155. _this.contextData = JSON.parse(JSON.stringify(_this.context));
  156. _this.queIndex = 0;
  157. _this.NNPENewWordList = [];
  158. _this.NNPENewPhraseList = [];
  159. _this.watchIndex = _this.queIndex + new Date().getTime();
  160. if (_this.contextData) {
  161. const list = _this.contextData;
  162. if (list && list.length > 0) {
  163. _this.queList = list;
  164. _this.cur = list[_this.queIndex];
  165. _this.queTotal = list.length;
  166. _this.cur.cur_fn_data.forEach((item) => {
  167. item.table_list.forEach((items) => {
  168. items.forEach((itemss) => {
  169. if (itemss.data && itemss.data.type == "NewWord_chs") {
  170. _this.NNPENewWordList = _this.NNPENewWordList.concat(
  171. itemss.data.option
  172. );
  173. } else if (itemss.data && itemss.data.type == "notes_chs") {
  174. _this.NNPEAnnotationList = _this.NNPEAnnotationList.concat(
  175. itemss.data.option
  176. );
  177. }
  178. });
  179. });
  180. });
  181. }
  182. }
  183. },
  184. // 上一页
  185. handleNNPEprev() {
  186. const _this = this;
  187. if (_this.queIndex == 0) {
  188. // this.$message({
  189. // message: "已经是第一题",
  190. // type: "success",
  191. // });
  192. } else {
  193. _this.queIndex = _this.queIndex - 1;
  194. _this.watchIndex = _this.queIndex + new Date().getTime();
  195. _this.cur = _this.queList[_this.queIndex];
  196. }
  197. },
  198. // 下一页
  199. handleNNPEnext() {
  200. const _this = this;
  201. if (_this.queIndex == _this.queTotal - 1) {
  202. // this.$message({
  203. // message: "已经是最后一题",
  204. // type: "success",
  205. // });
  206. } else {
  207. _this.queIndex = _this.queIndex + 1;
  208. _this.watchIndex = _this.queIndex + new Date().getTime();
  209. _this.cur = _this.queList[_this.queIndex];
  210. }
  211. },
  212. },
  213. //生命周期 - 创建完成(可以访问当前this实例)
  214. created() {},
  215. //生命周期 - 挂载完成(可以访问DOM元素)
  216. mounted() {
  217. const _this = this;
  218. if (_this.context) {
  219. _this.initContextData();
  220. }
  221. },
  222. beforeCreate() {}, //生命周期 - 创建之前
  223. beforeMount() {}, //生命周期 - 挂载之前
  224. beforeUpdate() {}, //生命周期 - 更新之前
  225. updated() {}, //生命周期 - 更新之后
  226. beforeDestroy() {}, //生命周期 - 销毁之前
  227. destroyed() {}, //生命周期 - 销毁完成
  228. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  229. };
  230. </script>
  231. <style lang='scss' scoped>
  232. //@import url(); 引入公共css类
  233. .NNPE-Big-Book-preview {
  234. width: 860px;
  235. margin: 0 auto;
  236. position: relative;
  237. .NNPE-title {
  238. background: #4f92f6;
  239. padding: 20px 24px;
  240. position: relative;
  241. h1 {
  242. color: #ffffff;
  243. font-weight: bold;
  244. font-size: 16px;
  245. line-height: 150%;
  246. margin: 0;
  247. }
  248. .NNPE-operate {
  249. position: absolute;
  250. top: 10px;
  251. right: 20px;
  252. a {
  253. background: #66a3ff url("../../assets/newImage/common/btn-pre.png")
  254. center no-repeat;
  255. border-radius: 4px;
  256. width: 44px;
  257. height: 44px;
  258. display: inline-block;
  259. margin: 0 4px;
  260. &.btn-next {
  261. background: #66a3ff url("../../assets/newImage/common/btn-next.png")
  262. center no-repeat;
  263. }
  264. &:hover {
  265. background-color: #3f75c4;
  266. }
  267. }
  268. }
  269. }
  270. .NNPE-Book-content-inner {
  271. padding: 0 40px;
  272. > div {
  273. padding-top: 24px;
  274. > h2 {
  275. color: #000000;
  276. font-size: 16px;
  277. line-height: 150%;
  278. font-weight: bold;
  279. margin: 0;
  280. }
  281. > h3 {
  282. color: #000000;
  283. font-size: 16px;
  284. line-height: 150%;
  285. font-weight: normal;
  286. margin: 8px 0 16px 0;
  287. }
  288. }
  289. .NNPE-tableList {
  290. background: #fff;
  291. border-radius: 8px;
  292. padding: 0;
  293. &.NNPE-tableList-hasBg {
  294. background: #f3f3f3;
  295. padding: 12px 8px;
  296. }
  297. .NNPE-tableList-tr {
  298. display: flex;
  299. justify-content: space-between;
  300. // flex-flow: wrap;
  301. .NNPE-tableList-item {
  302. width: 100%;
  303. margin: 12px 16px;
  304. // padding: 16px;
  305. // background: #FFFFFF;
  306. // border-radius: 4px;
  307. display: flex;
  308. flex-flow: wrap;
  309. justify-content: center;
  310. &.NNPE-tableList-item-noMargin {
  311. margin: 0;
  312. }
  313. }
  314. }
  315. }
  316. }
  317. }
  318. </style>