Preview.vue 9.7 KB

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