courseView.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <div class="container GCLS-BOOK-Container">
  3. <template v-if="!type">
  4. <Header />
  5. <Nav nav-value="书籍预览" />
  6. </template>
  7. <template v-else>
  8. <div class="bookname">
  9. <i
  10. style="cursor: pointer; margin-right: 5px"
  11. class="el-icon-arrow-left"
  12. @click="back"
  13. ></i>
  14. {{ name }}
  15. </div>
  16. </template>
  17. <div class="content">
  18. <div id="content-tree" :class="[fullTree ? 'content-tree-full' : 'content-tree']">
  19. <TreeView
  20. ref="treeView"
  21. :book-id="bookId"
  22. :change-id="changeId"
  23. :changeTreeData="changeTreeData"
  24. :currentTreeID="chapterId"
  25. />
  26. </div>
  27. <div id="data-screen" class="inner" v-loading="loading">
  28. <!-- 显示答案按钮 -->
  29. <!-- <a v-if="chapterId" :class="['answerShow',isAnswerShow?'answerShowTrue':'']" @click="handleAnswerShow">显示答案</a> -->
  30. <!-- <a class="edit-btn" @click="handleEdit">编辑</a> -->
  31. <div v-if="chapterId" class="title-box">
  32. <img
  33. v-if="!treeFlag"
  34. src="../assets/common/icon-view-back.png"
  35. @click="treeShow"
  36. />
  37. <img
  38. v-if="!treeFlag"
  39. src="../assets/common/icon-treelist.png"
  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. </div>
  87. </div>
  88. <!-- <Preview :context="context" :queIndex="queIndex" /> -->
  89. <a v-if="chapterId && treeFlag" class="screen-full" @click="fullScreen()" />
  90. </div>
  91. </template>
  92. <script>
  93. import Header from "@/components/inputModules/common/Header";
  94. import Nav from "@/components/inputModules/common/Nav";
  95. import TreeView from "@/components/inputModules/common/TreeView";
  96. import { getContent } from "@/api/ajax";
  97. import Cookies from "js-cookie";
  98. // import Preview from '@/componentsAnswer/PreviewAnswer.vue'
  99. import Preview from "@/components/Preview";
  100. export default {
  101. name: "CourseView",
  102. components: {
  103. Header,
  104. Nav,
  105. TreeView,
  106. Preview,
  107. },
  108. data() {
  109. return {
  110. bookId: "",
  111. chapterId: "",
  112. chapterName: "",
  113. fullscreen: false, // 控制全屏
  114. fullTree: false, // 全屏模式下树是否显示
  115. context: null,
  116. question: null, // 选择的模板题型
  117. queIndex: "",
  118. treeFlag: true, // tree是否显示
  119. switchvalue: true, // 生词模式
  120. isAnswerShow: false, // 是否显示答案
  121. bookAnswerContent: "[[6],[],[9]]",
  122. TaskModel: "Task",
  123. category: "",
  124. FatherTreeData: null,
  125. themeColor: "",
  126. type: "",
  127. name: "",
  128. loading: false,
  129. bookName: [
  130. {
  131. name: "新实用汉语课本1",
  132. id: "002-20211006-10-NHVOMDLDRY",
  133. },
  134. {
  135. name: "发展汉语初级综合(Ⅰ)",
  136. id: "002-20211007-06-4DGL2ZRIB5",
  137. },
  138. {
  139. name: "HSK标准教程1",
  140. id: "002-20211007-14-UNYIWU8EKW",
  141. },
  142. {
  143. name: "新实用汉语",
  144. id: "003-20210908-10-1ZWNGSASZL",
  145. },
  146. {
  147. name: "新航标职业英语 综合英语(基础级)学生用书1(修订版)",
  148. id: "002-20211029-14-9VGMXLV2NU",
  149. },
  150. {
  151. name: "新航标职业英语",
  152. id: "002-20211011-10-GOLXUZST4G",
  153. },
  154. ],
  155. };
  156. },
  157. created() {
  158. const _this = this;
  159. _this.bookId = this.$route.query.bookId;
  160. _this.type = this.$route.query.type;
  161. _this.bookName.forEach((item) => {
  162. if (item.id == _this.bookId) {
  163. _this.name = item.name;
  164. }
  165. });
  166. },
  167. methods: {
  168. back() {
  169. this.$router.go(-1);
  170. },
  171. changeTreeData(val) {
  172. this.FatherTreeData = JSON.parse(JSON.stringify(val));
  173. },
  174. changeId(id, name) {
  175. const _this = this;
  176. _this.chapterId = id;
  177. _this.chapterName = name;
  178. _this.isAnswerShow = false;
  179. _this.onGetData();
  180. if (!_this.treeFlag) {
  181. _this.fullTree = false;
  182. document.getElementById("content-tree").style.display = "none";
  183. }
  184. },
  185. // 点击全屏展示 隐藏tree
  186. fullScreen() {
  187. this.treeFlag = false;
  188. document.getElementById("content-tree").style.display = "none";
  189. },
  190. treeShow() {
  191. this.treeFlag = true;
  192. this.fullTree = false;
  193. document.getElementById("content-tree").style.display = "block";
  194. },
  195. // 获取预览数据
  196. onGetData() {
  197. this.loading = true;
  198. const _this = this;
  199. const MethodName = "book-courseware_manager-GetCoursewareContent_View";
  200. const data = {
  201. id: _this.chapterId,
  202. };
  203. getContent(MethodName, data).then((res) => {
  204. this.category = res.category;
  205. this.themeColor = res.book_theme_color;
  206. if (res.content) {
  207. const _this = this;
  208. if (!this.category || this.category == "OC") {
  209. _this.context = {
  210. id: _this.chapterId,
  211. ui_type: JSON.parse(res.content).question
  212. ? JSON.parse(res.content).question.ui_type
  213. : "",
  214. sort_number: 1,
  215. content: JSON.parse(res.content),
  216. };
  217. } else if (this.category == "NPC") {
  218. _this.context = JSON.parse(res.content);
  219. } else if (this.category == "NNPE") {
  220. _this.context = JSON.parse(res.content);
  221. }
  222. } else {
  223. const _this = this;
  224. _this.context = null;
  225. }
  226. this.loading = false;
  227. });
  228. },
  229. // 跳转编辑页面
  230. handleEdit() {
  231. const index = this.$refs.treeView.handleParentIndex().split("###");
  232. if (index.length > 1) {
  233. Cookies.set("bookIndex", index[0]);
  234. Cookies.set("bookLevel", index[1]);
  235. Cookies.set("bookNodename", index[2]);
  236. }
  237. this.$router.push("/input?bookId=" + this.bookId);
  238. },
  239. // 显示或隐藏答案
  240. handleAnswerShow() {
  241. this.isAnswerShow = !this.isAnswerShow;
  242. this.$refs.previewAnswer.bookAnswerShow(this.isAnswerShow);
  243. },
  244. // 得到用户答题答案
  245. handleBookUserAnswer(data) {
  246. console.log(data);
  247. },
  248. // 悬浮树隐藏显示
  249. chooseCourseware() {
  250. this.fullTree = !this.fullTree;
  251. if (this.fullTree) {
  252. document.getElementById("content-tree").style.display = "block";
  253. } else {
  254. document.getElementById("content-tree").style.display = "none";
  255. }
  256. },
  257. },
  258. };
  259. </script>
  260. <style lang="scss" scoped>
  261. .container {
  262. width: 100%;
  263. height: auto;
  264. .bookname {
  265. width: 100%;
  266. height: 60px;
  267. display: flex;
  268. align-items: center;
  269. box-sizing: border-box;
  270. padding: 0 46px;
  271. background: #f3f7fa;
  272. position: relative;
  273. z-index: 999;
  274. }
  275. .content {
  276. width: 100%;
  277. display: flex;
  278. justify-content: flex-start;
  279. align-items: flex-start;
  280. &-tree {
  281. width: 340px;
  282. height: 100%;
  283. overflow: auto;
  284. padding: 20px 0px;
  285. border-right: 1px solid #d9d9d9;
  286. position: fixed;
  287. top: 0px;
  288. left: 0;
  289. padding-top: 124px;
  290. background: #fff;
  291. }
  292. .content-tree-full {
  293. position: fixed;
  294. top: 100px;
  295. left: 152px;
  296. max-height: 588px;
  297. overflow: auto;
  298. z-index: 999;
  299. background: #fff;
  300. box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.25);
  301. border-radius: 4px;
  302. }
  303. .inner {
  304. // border-left: 1px solid #d9d9d9;
  305. width: 1000px;
  306. margin: 0 auto;
  307. margin-left: 340px;
  308. flex: 1;
  309. box-sizing: border-box;
  310. padding: 20px;
  311. position: relative;
  312. background: #fff;
  313. .title-box {
  314. display: flex;
  315. align-items: center;
  316. margin-bottom: 12px;
  317. padding-right: 160px;
  318. position: relative;
  319. > img {
  320. width: 40px;
  321. margin-right: 16px;
  322. cursor: pointer;
  323. }
  324. }
  325. .title {
  326. font-size: 24px;
  327. margin-bottom: 20px;
  328. line-height: 40px;
  329. margin: 0;
  330. }
  331. .has-module {
  332. display: flex;
  333. justify-content: flex-start;
  334. align-items: flex-start;
  335. &-tree {
  336. width: 340px;
  337. height: 100%;
  338. overflow: auto;
  339. padding: 20px 0px;
  340. border-right: 1px solid #d9d9d9;
  341. }
  342. .inner {
  343. // border-left: 1px solid #d9d9d9;
  344. width: 1000px;
  345. flex: 1;
  346. margin: 0 auto;
  347. box-sizing: border-box;
  348. padding: 20px;
  349. position: relative;
  350. background: #fff;
  351. .title-box {
  352. display: flex;
  353. align-items: center;
  354. margin-bottom: 12px;
  355. padding-right: 160px;
  356. position: relative;
  357. > img {
  358. width: 40px;
  359. margin-right: 16px;
  360. cursor: pointer;
  361. }
  362. }
  363. .title {
  364. font-size: 24px;
  365. margin-bottom: 20px;
  366. line-height: 40px;
  367. margin: 0;
  368. }
  369. .has-module {
  370. display: flex;
  371. justify-content: flex-start;
  372. align-items: flex-start;
  373. }
  374. .edit-btn {
  375. display: inline-block;
  376. font-size: 14px;
  377. background: #ff9900;
  378. float: right;
  379. line-height: 36px;
  380. color: #fff;
  381. width: 60px;
  382. text-align: center;
  383. border-radius: 4px;
  384. }
  385. }
  386. }
  387. }
  388. .nav-list {
  389. width: 200px;
  390. height: 40px;
  391. background: rgba(49, 212, 134, 0.2);
  392. border-radius: 240px;
  393. display: flex;
  394. justify-content: flex-start;
  395. align-items: center;
  396. padding: 0;
  397. margin: 0;
  398. margin-bottom: 10px;
  399. list-style: none;
  400. > li {
  401. height: 40px;
  402. width: 100px;
  403. text-align: center;
  404. font-style: normal;
  405. font-weight: bold;
  406. font-size: 14px;
  407. line-height: 40px;
  408. color: #19b068;
  409. cursor: pointer;
  410. &.active {
  411. background: #19b068;
  412. border-radius: 240px;
  413. color: #ffffff;
  414. }
  415. }
  416. }
  417. }
  418. .answerShow {
  419. position: absolute;
  420. right: 20px;
  421. top: 20px;
  422. width: 112px;
  423. height: 40px;
  424. background: #ffffff url("../assets/common/icon-eye-close.png") 16px center
  425. no-repeat;
  426. background-size: 16px;
  427. border: 1px solid rgba(44, 44, 44, 0.15);
  428. box-sizing: border-box;
  429. border-radius: 4px;
  430. font-size: 14px;
  431. line-height: 150%;
  432. color: #000000;
  433. padding: 9px 16px 9px 36px;
  434. cursor: pointer;
  435. z-index: 2;
  436. &.answerShowTrue {
  437. background: #f5f5f5 url("../assets/common/icon-eye-open.png") 16px center
  438. no-repeat;
  439. background-size: 16px;
  440. }
  441. }
  442. }
  443. </style>
  444. <style lang="scss">
  445. .GCLS-BOOK-Container{
  446. .screen-full {
  447. position: fixed;
  448. right: 30px;
  449. bottom: 30px;
  450. width: 48px;
  451. height: 48px;
  452. background: rgba(0, 0, 0, 0.4) url("../assets/common/icon-screenFull.png")
  453. center no-repeat;
  454. background-size: 32px;
  455. }
  456. }
  457. .title-box {
  458. .el-switch {
  459. position: absolute;
  460. top: 0;
  461. right: 0px;
  462. border: 1px solid rgba(44, 44, 44, 0.15);
  463. border-radius: 40px;
  464. height: 40px;
  465. padding: 6px 6px 6px 16px;
  466. }
  467. .el-switch__label.is-active {
  468. color: #000000;
  469. font-size: 16px;
  470. }
  471. }
  472. </style>