courseView.vue 10 KB

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