bookView.vue 11 KB

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