bookView.vue 10.0 KB

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