bookView.vue 12 KB

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