courseView.vue 10 KB

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