courseView.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. <template>
  2. <div class="container">
  3. <template v-if="!type">
  4. <Header />
  5. <Nav nav-value="书籍预览" />
  6. </template>
  7. <template v-else>
  8. <div class="bookname">
  9. <i
  10. style="cursor: pointer; margin-right: 5px"
  11. class="el-icon-arrow-left"
  12. @click="back"
  13. ></i>
  14. {{ name }}
  15. </div>
  16. </template>
  17. <div class="content">
  18. <div id="content-tree" class="content-tree">
  19. <TreeView
  20. ref="treeView"
  21. :book-id="bookId"
  22. :change-id="changeId"
  23. :changeTreeData="changeTreeData"
  24. :currentTreeID="chapterId"
  25. />
  26. </div>
  27. <div id="data-screen" class="inner" v-loading="loading">
  28. <!-- 显示答案按钮 -->
  29. <!-- <a v-if="chapterId" :class="['answerShow',isAnswerShow?'answerShowTrue':'']" @click="handleAnswerShow">显示答案</a> -->
  30. <!-- <a class="edit-btn" @click="handleEdit">编辑</a> -->
  31. <div v-if="chapterId" class="title-box">
  32. <img
  33. v-if="!treeFlag"
  34. src="../assets/common/icon-treelist.png"
  35. @click="treeShow"
  36. />
  37. <!-- <h2 class="title">{{ chapterName }}</h2> -->
  38. <el-switch
  39. v-if="!treeFlag"
  40. v-model="switchvalue"
  41. active-color="#FF9900"
  42. active-text
  43. inactive-text="生词模式"
  44. />
  45. </div>
  46. <template v-if="category == 'OC' || !category">
  47. <Preview
  48. v-if="chapterId && context"
  49. ref="previewAnswer"
  50. :context="context"
  51. :bookAnswerContent="bookAnswerContent"
  52. bookclientwidth="900"
  53. :TaskModel="TaskModel"
  54. @handleBookUserAnswer="handleBookUserAnswer"
  55. />
  56. </template>
  57. <template v-if="category == 'NPC'">
  58. <Booknpc
  59. v-if="chapterId && context"
  60. ref="previewAnswer"
  61. :context="context"
  62. :currentTreeID="chapterId"
  63. :FatherTreeData="FatherTreeData"
  64. :change-id="changeId"
  65. :themeColor="themeColor"
  66. :isShowTitle="true"
  67. />
  68. </template>
  69. <template v-if="category == 'NNPE'">
  70. <Booknnpe
  71. v-if="chapterId && context"
  72. ref="previewAnswer"
  73. :context="context"
  74. :currentTreeID="chapterId"
  75. :FatherTreeData="FatherTreeData"
  76. :change-id="changeId"
  77. :themeColor="themeColor"
  78. :isShowTitle="true"
  79. />
  80. </template>
  81. </div>
  82. </div>
  83. <!-- <Preview :context="context" :queIndex="queIndex" /> -->
  84. <a v-if="chapterId && treeFlag" class="screen-full" @click="fullScreen()" />
  85. </div>
  86. </template>
  87. <script>
  88. import Header from "@/components/inputModules/common/Header";
  89. import Nav from "@/components/inputModules/common/Nav";
  90. import TreeView from "@/components/inputModules/common/TreeView";
  91. import { getContent } from "@/api/ajax";
  92. import Cookies from "js-cookie";
  93. // import Preview from '@/componentsAnswer/PreviewAnswer.vue'
  94. import Preview from "@/components/Preview";
  95. export default {
  96. name: "CourseView",
  97. components: {
  98. Header,
  99. Nav,
  100. TreeView,
  101. Preview,
  102. },
  103. data() {
  104. return {
  105. bookId: "",
  106. chapterId: "",
  107. chapterName: "",
  108. fullscreen: false, // 控制全屏
  109. context: null,
  110. question: null, // 选择的模板题型
  111. queIndex: "",
  112. treeFlag: true, // tree是否显示
  113. switchvalue: true, // 生词模式
  114. isAnswerShow: false, // 是否显示答案
  115. bookAnswerContent: "[[6],[],[9]]",
  116. TaskModel: "Task",
  117. category: "",
  118. FatherTreeData: null,
  119. themeColor: "",
  120. type: "",
  121. name: "",
  122. loading: false,
  123. bookName: [
  124. {
  125. name: "新实用汉语课本1",
  126. id: "002-20211006-10-NHVOMDLDRY",
  127. },
  128. {
  129. name: "发展汉语初级综合(Ⅰ)",
  130. id: "002-20211007-06-4DGL2ZRIB5",
  131. },
  132. {
  133. name: "HSK标准教程1",
  134. id: "002-20211007-14-UNYIWU8EKW",
  135. },
  136. {
  137. name: "新实用汉语",
  138. id: "003-20210908-10-1ZWNGSASZL",
  139. },
  140. ],
  141. };
  142. },
  143. created() {
  144. const _this = this;
  145. _this.bookId = this.$route.query.bookId;
  146. _this.type = this.$route.query.type;
  147. _this.bookName.forEach((item) => {
  148. if (item.id == _this.bookId) {
  149. _this.name = item.name;
  150. }
  151. });
  152. },
  153. methods: {
  154. back() {
  155. this.$router.go(-1);
  156. },
  157. changeTreeData(val) {
  158. this.FatherTreeData = JSON.parse(JSON.stringify(val));
  159. },
  160. changeId(id, name) {
  161. const _this = this;
  162. _this.chapterId = id;
  163. _this.chapterName = name;
  164. _this.isAnswerShow = false;
  165. _this.onGetData();
  166. },
  167. // 点击全屏展示 隐藏tree
  168. fullScreen() {
  169. this.treeFlag = false;
  170. document.getElementById("content-tree").style.display = "none";
  171. },
  172. treeShow() {
  173. this.treeFlag = true;
  174. document.getElementById("content-tree").style.display = "block";
  175. },
  176. // 获取预览数据
  177. onGetData() {
  178. this.loading = true;
  179. const _this = this;
  180. const MethodName = "book-courseware_manager-GetCoursewareContent_View";
  181. const data = {
  182. id: _this.chapterId,
  183. };
  184. getContent(MethodName, data).then((res) => {
  185. this.category = res.category;
  186. this.themeColor = res.book_theme_color;
  187. if (res.content) {
  188. const _this = this;
  189. if (!this.category || this.category == "OC") {
  190. _this.context = {
  191. id: _this.chapterId,
  192. ui_type: JSON.parse(res.content).question
  193. ? JSON.parse(res.content).question.ui_type
  194. : "",
  195. sort_number: 1,
  196. content: JSON.parse(res.content),
  197. };
  198. } else if (this.category == "NPC") {
  199. _this.context = JSON.parse(res.content);
  200. } else if (this.category == "NNPE") {
  201. _this.context = JSON.parse(res.content);
  202. }
  203. } else {
  204. const _this = this;
  205. _this.context = null;
  206. }
  207. this.loading = false;
  208. });
  209. },
  210. // 跳转编辑页面
  211. handleEdit() {
  212. const index = this.$refs.treeView.handleParentIndex().split("###");
  213. if (index.length > 1) {
  214. Cookies.set("bookIndex", index[0]);
  215. Cookies.set("bookLevel", index[1]);
  216. Cookies.set("bookNodename", index[2]);
  217. }
  218. this.$router.push("/input?bookId=" + this.bookId);
  219. },
  220. // 显示或隐藏答案
  221. handleAnswerShow() {
  222. this.isAnswerShow = !this.isAnswerShow;
  223. this.$refs.previewAnswer.bookAnswerShow(this.isAnswerShow);
  224. },
  225. // 得到用户答题答案
  226. handleBookUserAnswer(data) {
  227. console.log(data);
  228. },
  229. },
  230. };
  231. </script>
  232. <style lang="scss" scoped>
  233. .container {
  234. width: 100%;
  235. height: auto;
  236. .bookname {
  237. width: 100%;
  238. height: 60px;
  239. display: flex;
  240. align-items: center;
  241. box-sizing: border-box;
  242. padding: 0 46px;
  243. background: #f3f7fa;
  244. position: relative;
  245. z-index: 999;
  246. }
  247. .content {
  248. width: 100%;
  249. display: flex;
  250. justify-content: flex-start;
  251. align-items: flex-start;
  252. &-tree {
  253. width: 340px;
  254. height: 100%;
  255. overflow: auto;
  256. padding: 20px 0px;
  257. border-right: 1px solid #d9d9d9;
  258. position: fixed;
  259. top: 0px;
  260. left: 0;
  261. padding-top: 124px;
  262. background: #fff;
  263. }
  264. .inner {
  265. // border-left: 1px solid #d9d9d9;
  266. width: 1000px;
  267. margin: 0 auto;
  268. margin-left: 340px;
  269. flex: 1;
  270. box-sizing: border-box;
  271. padding: 20px;
  272. position: relative;
  273. background: #fff;
  274. .title-box {
  275. display: flex;
  276. align-items: center;
  277. margin-bottom: 12px;
  278. padding-right: 160px;
  279. position: relative;
  280. > img {
  281. width: 40px;
  282. margin-right: 16px;
  283. cursor: pointer;
  284. }
  285. }
  286. .title {
  287. font-size: 24px;
  288. margin-bottom: 20px;
  289. line-height: 40px;
  290. margin: 0;
  291. }
  292. .has-module {
  293. display: flex;
  294. justify-content: flex-start;
  295. align-items: flex-start;
  296. &-tree {
  297. width: 340px;
  298. height: 100%;
  299. overflow: auto;
  300. padding: 20px 0px;
  301. border-right: 1px solid #d9d9d9;
  302. }
  303. .inner {
  304. // border-left: 1px solid #d9d9d9;
  305. width: 1000px;
  306. flex: 1;
  307. margin: 0 auto;
  308. box-sizing: border-box;
  309. padding: 20px;
  310. position: relative;
  311. background: #fff;
  312. .title-box {
  313. display: flex;
  314. align-items: center;
  315. margin-bottom: 12px;
  316. padding-right: 160px;
  317. position: relative;
  318. > img {
  319. width: 40px;
  320. margin-right: 16px;
  321. cursor: pointer;
  322. }
  323. }
  324. .title {
  325. font-size: 24px;
  326. margin-bottom: 20px;
  327. line-height: 40px;
  328. margin: 0;
  329. }
  330. .has-module {
  331. display: flex;
  332. justify-content: flex-start;
  333. align-items: flex-start;
  334. }
  335. .edit-btn {
  336. display: inline-block;
  337. font-size: 14px;
  338. background: #ff9900;
  339. float: right;
  340. line-height: 36px;
  341. color: #fff;
  342. width: 60px;
  343. text-align: center;
  344. border-radius: 4px;
  345. }
  346. }
  347. }
  348. }
  349. .nav-list {
  350. width: 200px;
  351. height: 40px;
  352. background: rgba(49, 212, 134, 0.2);
  353. border-radius: 240px;
  354. display: flex;
  355. justify-content: flex-start;
  356. align-items: center;
  357. padding: 0;
  358. margin: 0;
  359. margin-bottom: 10px;
  360. list-style: none;
  361. > li {
  362. height: 40px;
  363. width: 100px;
  364. text-align: center;
  365. font-style: normal;
  366. font-weight: bold;
  367. font-size: 14px;
  368. line-height: 40px;
  369. color: #19b068;
  370. cursor: pointer;
  371. &.active {
  372. background: #19b068;
  373. border-radius: 240px;
  374. color: #ffffff;
  375. }
  376. }
  377. }
  378. .screen-full {
  379. position: fixed;
  380. right: 30px;
  381. bottom: 30px;
  382. width: 48px;
  383. height: 48px;
  384. background: rgba(0, 0, 0, 0.4) url("../assets/common/icon-screenFull.png")
  385. center no-repeat;
  386. background-size: 32px;
  387. }
  388. }
  389. .answerShow {
  390. position: absolute;
  391. right: 20px;
  392. top: 20px;
  393. width: 112px;
  394. height: 40px;
  395. background: #ffffff url("../assets/common/icon-eye-close.png") 16px center
  396. no-repeat;
  397. background-size: 16px;
  398. border: 1px solid rgba(44, 44, 44, 0.15);
  399. box-sizing: border-box;
  400. border-radius: 4px;
  401. font-size: 14px;
  402. line-height: 150%;
  403. color: #000000;
  404. padding: 9px 16px 9px 36px;
  405. cursor: pointer;
  406. z-index: 2;
  407. &.answerShowTrue {
  408. background: #f5f5f5 url("../assets/common/icon-eye-open.png") 16px center
  409. no-repeat;
  410. background-size: 16px;
  411. }
  412. }
  413. }
  414. </style>
  415. <style lang="scss">
  416. .title-box {
  417. .el-switch {
  418. position: absolute;
  419. top: 0;
  420. right: 0px;
  421. border: 1px solid rgba(44, 44, 44, 0.15);
  422. border-radius: 40px;
  423. height: 40px;
  424. padding: 6px 6px 6px 16px;
  425. }
  426. .el-switch__label.is-active {
  427. color: #000000;
  428. font-size: 16px;
  429. }
  430. }
  431. </style>