bookView.vue 11 KB

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