courseView.vue 10.0 KB

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