courseView.vue 8.8 KB

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