courseView.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <template>
  2. <div class="container GCLS-BOOK-Container" v-if="showContent">
  3. <div v-if="!type" class="header-box">
  4. <Header />
  5. <Nav nav-value="书籍预览" />
  6. </div>
  7. <div v-else class="header-box">
  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. </div>
  17. <div
  18. class="content"
  19. id="content-scroll"
  20. :class="[type ? 'content-top' : '']"
  21. >
  22. <div
  23. id="content-tree"
  24. :class="[fullTree ? 'content-tree-full' : 'content-tree']"
  25. >
  26. <TreeView
  27. ref="treeView"
  28. :book-id="bookId"
  29. :change-id="changeId"
  30. :changeTreeData="changeTreeData"
  31. :currentTreeID="chapterId"
  32. />
  33. <div class="moveBtn-nnpe" v-move></div>
  34. </div>
  35. <div
  36. id="data-screen"
  37. :class="['inner', fullscreen ? 'inner-full' : '']"
  38. v-loading="loading"
  39. >
  40. <el-image
  41. :src="pictureUrl"
  42. fit="scale-down"
  43. class="img_url"
  44. v-if="!chapterId && pictureUrl"
  45. >
  46. <div slot="placeholder" class="image-slot">
  47. <img src="../assets/common/icon-imgloading.png" />
  48. </div>
  49. </el-image>
  50. <!-- 显示答案按钮 -->
  51. <!-- <a v-if="chapterId" :class="['answerShow',isAnswerShow?'answerShowTrue':'']" @click="handleAnswerShow">显示答案</a> -->
  52. <!-- <a class="edit-btn" @click="handleEdit">编辑</a> -->
  53. <div v-if="chapterId" class="title-box">
  54. <img
  55. v-if="!treeFlag"
  56. src="../assets/common/icon-view-back.png"
  57. @click="treeShow"
  58. />
  59. <img
  60. v-if="!treeFlag"
  61. src="../assets/common/icon-treelist.png"
  62. @click="chooseCourseware"
  63. />
  64. <!-- <h2 class="title">{{ chapterName }}</h2> -->
  65. <!-- <el-switch
  66. v-if="!treeFlag"
  67. v-model="switchvalue"
  68. active-color="#FF9900"
  69. active-text
  70. inactive-text="生词模式"
  71. /> -->
  72. </div>
  73. <template v-if="category == 'OC' || !category">
  74. <Preview
  75. v-if="chapterId && context"
  76. ref="previewAnswer"
  77. :context="context"
  78. :bookAnswerContent="bookAnswerContent"
  79. bookclientwidth="900"
  80. :TaskModel="TaskModel"
  81. @handleBookUserAnswer="handleBookUserAnswer"
  82. />
  83. </template>
  84. <template v-if="category == 'NPC'">
  85. <Booknpc
  86. v-if="chapterId && context"
  87. ref="previewAnswerNPC"
  88. :context="context"
  89. :currentTreeID="chapterId"
  90. :FatherTreeData="FatherTreeData"
  91. :change-id="changeId"
  92. :themeColor="themeColor"
  93. :isShowTitle="true"
  94. :TaskModel="TaskModel"
  95. :isShowSave="false"
  96. @finishTaskMaterial="finishTaskMaterial"
  97. :bookAnswerContent="bookAnswerContent"
  98. :isAnswerItemShow="isAnswerItemShow"
  99. />
  100. </template>
  101. <template v-if="category == 'NNPE'">
  102. <Booknnpe
  103. v-if="chapterId && context"
  104. ref="previewAnswerNNPE"
  105. :context="context"
  106. :currentTreeID="chapterId"
  107. :FatherTreeData="FatherTreeData"
  108. :change-id="changeId"
  109. :themeColor="themeColor"
  110. :isShowTitle="true"
  111. :isAnswerItemShow="true"
  112. :TaskModel="TaskModel"
  113. :isShowSave="true"
  114. @finishTaskMaterial="finishTaskMaterial"
  115. :bookAnswerContent="bookAnswerContent"
  116. />
  117. </template>
  118. <template v-if="category == 'RLC'">
  119. <Bookrlc
  120. v-if="chapterId && context"
  121. ref="previewAnswerRLC"
  122. :context="context"
  123. :currentTreeID="chapterId"
  124. :FatherTreeData="FatherTreeData"
  125. :change-id="changeId"
  126. :themeColor="themeColor"
  127. :isShowTitle="true"
  128. :bookFontSize="bookFontSize"
  129. :isAnswerItemShow="isAnswerItemShow"
  130. :TaskModel="TaskModel"
  131. :isShowSave="false"
  132. @finishTaskMaterial="finishTaskMaterial"
  133. :bookAnswerContent="bookAnswerContent"
  134. />
  135. </template>
  136. </div>
  137. </div>
  138. <!-- <Preview :context="context" :queIndex="queIndex" /> -->
  139. <a v-if="chapterId && treeFlag" class="screen-full" @click="fullScreen()" />
  140. </div>
  141. </template>
  142. <script>
  143. import Header from "@/components/inputModules/common/Header";
  144. import Nav from "@/components/inputModules/common/Nav";
  145. import TreeView from "@/components/inputModules/common/TreeView";
  146. import { getContent, getLogin } from "@/api/ajax";
  147. import Cookies from "js-cookie";
  148. // import Preview from '@/componentsAnswer/PreviewAnswer.vue'
  149. import Preview from "@/components/Preview";
  150. import { getToken } from "../utils/auth";
  151. export default {
  152. name: "CourseView",
  153. directives: {
  154. move(el, bindings) {
  155. el.onmousedown = function (e) {
  156. var init = e.clientX;
  157. var parent = document.getElementById("content-tree");
  158. var initWidth = parent.offsetWidth;
  159. document.onmousemove = function (e) {
  160. var end = e.clientX;
  161. var newWidth = end - init + initWidth;
  162. if (newWidth >= 340 && newWidth <= 680)
  163. parent.style.width = newWidth + "px";
  164. };
  165. document.onmouseup = function () {
  166. document.onmousemove = document.onmouseup = null;
  167. };
  168. };
  169. },
  170. },
  171. components: {
  172. Header,
  173. Nav,
  174. TreeView,
  175. Preview,
  176. },
  177. data() {
  178. return {
  179. bookId: "",
  180. chapterId: "",
  181. chapterName: "",
  182. fullscreen: false, // 控制全屏
  183. fullTree: false, // 全屏模式下树是否显示
  184. context: null,
  185. question: null, // 选择的模板题型
  186. queIndex: "",
  187. treeFlag: true, // tree是否显示
  188. switchvalue: true, // 生词模式
  189. isAnswerShow: false, // 是否显示答案
  190. bookAnswerContent: "",
  191. TaskModel: "",
  192. category: "",
  193. FatherTreeData: null,
  194. themeColor: "",
  195. type: "",
  196. name: "",
  197. loading: false,
  198. bookFontSize: "",
  199. showContent: false,
  200. bookName: [
  201. {
  202. name: "新实用汉语课本1",
  203. id: "002-20211006-10-NHVOMDLDRY",
  204. },
  205. {
  206. name: "发展汉语初级综合(Ⅰ)",
  207. id: "002-20211007-06-4DGL2ZRIB5",
  208. },
  209. {
  210. name: "HSK标准教程1",
  211. id: "002-20211007-14-UNYIWU8EKW",
  212. },
  213. {
  214. name: "新实用汉语",
  215. id: "003-20210908-10-1ZWNGSASZL",
  216. },
  217. {
  218. name: "新航标职业英语 综合英语(基础级)学生用书1(修订版)",
  219. id: "002-20211029-14-9VGMXLV2NU",
  220. },
  221. {
  222. name: "新航标职业英语 综合英语(提高级)学生用书1 (第3版)",
  223. id: "002-20211011-10-GOLXUZST4G",
  224. },
  225. {
  226. name: "新航标英语 汽车英语",
  227. id: "002-20211222-15-O7WVMR4XHK",
  228. },
  229. {
  230. name: "新航标职业英语 英语视听说教程(入门级)1",
  231. id: "001-20211222-15-LXK64LQZST",
  232. },
  233. {
  234. name: "新航标职业英语 综合英语(提高级)学生用书2(第3版)",
  235. id: "001-20220118-14-EZVO52PYXF",
  236. },
  237. {
  238. name: "新航标职业英语 综合英语(基础级)学生用书2(修订版)",
  239. id: "002-20220208-09-FDKUJJSLI8",
  240. },
  241. {
  242. name: "轻松学中文. 课本 .第1册",
  243. id: "002-20220312-11-HK93JKDAGR",
  244. },
  245. {
  246. name: "轻松学中文. 课本. 第2册",
  247. id: "001-20220312-11-WU8XCRQMDB",
  248. },
  249. {
  250. name: "轻松学中文 . 练习册 . 第1册",
  251. id: "001-20220429-18-ZDIKBFQ9DP",
  252. },
  253. {
  254. name: "轻松学中文 . 练习册 . 第 2 册",
  255. id: "002-20220429-18-KIOM0VEXLY",
  256. },
  257. ],
  258. isAnswerItemShow: false,
  259. pictureUrl: "",
  260. };
  261. },
  262. created() {
  263. const _this = this;
  264. if (
  265. _this.$route.query.encryption &&
  266. _this.$route.query.encryption != "undefined" &&
  267. _this.$route.query.type
  268. ) {
  269. getLogin("login_control-CheckValidDateEncryptionString", {
  270. encryption_string: _this.$route.query.encryption,
  271. })
  272. .then((res) => {
  273. if (res.is_check_pass == "true") {
  274. _this.bookId = this.$route.query.bookId;
  275. _this.type = this.$route.query.type;
  276. const MethodName = "book-book_manager-GetBook";
  277. const data = {
  278. id: _this.bookId,
  279. };
  280. getContent(MethodName, data).then((res) => {
  281. this.showContent = true;
  282. _this.name = res.name;
  283. });
  284. } else {
  285. _this.$message({
  286. message: "链接已失效",
  287. type: "warning",
  288. });
  289. }
  290. })
  291. .catch(() => {
  292. _this.$message({
  293. message: "链接已失效",
  294. type: "warning",
  295. });
  296. });
  297. } else if (_this.$route.query.showCourse) {
  298. _this.bookId = this.$route.query.bookId;
  299. _this.type = this.$route.query.type;
  300. const MethodName = "book-book_manager-GetBook";
  301. const data = {
  302. id: _this.bookId,
  303. };
  304. getContent(MethodName, data).then((res) => {
  305. this.showContent = true;
  306. _this.name = res.name;
  307. _this.pictureUrl = res.picture_url;
  308. });
  309. } else {
  310. _this.$message({
  311. message: "链接已失效",
  312. type: "warning",
  313. });
  314. }
  315. let userInfor = JSON.parse(getToken());
  316. if (
  317. userInfor &&
  318. (userInfor.user_type == "TEACHER" || userInfor.user_type == "INNER")
  319. ) {
  320. _this.isAnswerItemShow = true;
  321. } else {
  322. _this.isAnswerItemShow = false;
  323. }
  324. },
  325. mounted() {},
  326. methods: {
  327. back() {
  328. this.$router.go(-1);
  329. },
  330. changeTreeData(val) {
  331. this.FatherTreeData = JSON.parse(JSON.stringify(val));
  332. },
  333. changeId(id, name) {
  334. const _this = this;
  335. _this.chapterId = id;
  336. _this.chapterName = name;
  337. _this.isAnswerShow = false;
  338. _this.onGetData();
  339. if (!_this.treeFlag) {
  340. _this.fullTree = false;
  341. document.getElementById("content-tree").style.display = "none";
  342. }
  343. document.getElementById("content-scroll").scrollTop = 0;
  344. },
  345. // 点击全屏展示 隐藏tree
  346. fullScreen() {
  347. this.treeFlag = false;
  348. this.fullscreen = true;
  349. document.getElementById("content-tree").style.display = "none";
  350. },
  351. treeShow() {
  352. this.treeFlag = true;
  353. this.fullTree = false;
  354. this.fullscreen = false;
  355. document.getElementById("content-tree").style.display = "block";
  356. },
  357. // 获取预览数据
  358. onGetData() {
  359. this.loading = true;
  360. const _this = this;
  361. const MethodName = "book-courseware_manager-GetCoursewareContent_View";
  362. const data = {
  363. id: _this.chapterId,
  364. };
  365. getContent(MethodName, data).then((res) => {
  366. this.category = res.category;
  367. this.themeColor = res.book_theme_color;
  368. this.bookFontSize = res.book_font_size;
  369. if (res.content) {
  370. const _this = this;
  371. if (!this.category || this.category == "OC") {
  372. _this.context = {
  373. id: _this.chapterId,
  374. ui_type: JSON.parse(res.content).question
  375. ? JSON.parse(res.content).question.ui_type
  376. : "",
  377. sort_number: 1,
  378. content: JSON.parse(res.content),
  379. };
  380. } else {
  381. _this.context = JSON.parse(res.content);
  382. }
  383. } else {
  384. const _this = this;
  385. _this.context = null;
  386. }
  387. this.loading = false;
  388. });
  389. },
  390. // 跳转编辑页面
  391. handleEdit() {
  392. const index = this.$refs.treeView.handleParentIndex().split("###");
  393. if (index.length > 1) {
  394. Cookies.set("bookIndex", index[0]);
  395. Cookies.set("bookLevel", index[1]);
  396. Cookies.set("bookNodename", index[2]);
  397. }
  398. this.$router.push("/input?bookId=" + this.bookId);
  399. },
  400. // 显示或隐藏答案
  401. handleAnswerShow() {
  402. this.isAnswerShow = !this.isAnswerShow;
  403. this.$refs.previewAnswer.bookAnswerShow(this.isAnswerShow);
  404. },
  405. // 得到用户答题答案
  406. handleBookUserAnswer(data) {
  407. console.log(data);
  408. },
  409. // 悬浮树隐藏显示
  410. chooseCourseware() {
  411. this.fullTree = !this.fullTree;
  412. if (this.fullTree) {
  413. document.getElementById("content-tree").style.display = "block";
  414. } else {
  415. document.getElementById("content-tree").style.display = "none";
  416. }
  417. },
  418. finishTaskMaterial(data, duration) {
  419. console.log("保存答案:");
  420. console.log(data);
  421. console.log(duration);
  422. },
  423. },
  424. };
  425. </script>
  426. <style lang="scss" scoped>
  427. .header-box {
  428. position: fixed;
  429. width: 100%;
  430. top: 0;
  431. left: 0;
  432. z-index: 999;
  433. }
  434. .container {
  435. width: 100%;
  436. height: auto;
  437. .bookname {
  438. width: 100%;
  439. height: 60px;
  440. display: flex;
  441. align-items: center;
  442. box-sizing: border-box;
  443. padding: 0 46px;
  444. background: #f3f7fa;
  445. position: relative;
  446. z-index: 999;
  447. }
  448. .content {
  449. width: 100%;
  450. display: flex;
  451. justify-content: flex-start;
  452. align-items: flex-start;
  453. height: 100vh;
  454. overflow: auto;
  455. padding-top: 124px;
  456. &-top {
  457. padding-top: 60px;
  458. .title-box {
  459. top: 66px !important;
  460. }
  461. .content-tree-full {
  462. top: 100px !important;
  463. }
  464. }
  465. &-tree {
  466. width: 340px;
  467. height: 85vh;
  468. overflow: auto;
  469. padding: 20px 0px;
  470. border-right: 1px solid #d9d9d9;
  471. background: #fff;
  472. position: fixed;
  473. left: 0;
  474. z-index: 2;
  475. }
  476. .content-tree-full {
  477. position: fixed !important;
  478. top: 170px;
  479. left: 152px;
  480. max-height: 588px;
  481. overflow: auto;
  482. z-index: 1000;
  483. background: #fff;
  484. box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.25);
  485. border-radius: 4px;
  486. }
  487. #content-tree {
  488. // position: relative;
  489. }
  490. .moveBtn-nnpe {
  491. position: absolute;
  492. height: 100%;
  493. width: 10px;
  494. right: 0;
  495. top: 0;
  496. cursor: col-resize;
  497. }
  498. .inner {
  499. // border-left: 1px solid #d9d9d9;
  500. width: 1000px;
  501. margin: 0 auto;
  502. flex: 1;
  503. margin-left: 340px;
  504. box-sizing: border-box;
  505. padding: 20px;
  506. position: relative;
  507. background: #fff;
  508. &.inner-full {
  509. margin-left: 0;
  510. }
  511. .title-box {
  512. display: flex;
  513. align-items: center;
  514. margin-bottom: 12px;
  515. padding-right: 160px;
  516. position: fixed;
  517. top: 130px;
  518. left: 64px;
  519. z-index: 1;
  520. > img {
  521. width: 40px;
  522. margin-right: 16px;
  523. cursor: pointer;
  524. }
  525. }
  526. .title {
  527. font-size: 24px;
  528. margin-bottom: 20px;
  529. line-height: 40px;
  530. margin: 0;
  531. }
  532. .has-module {
  533. display: flex;
  534. justify-content: flex-start;
  535. align-items: flex-start;
  536. &-tree {
  537. width: 340px;
  538. height: 100%;
  539. overflow: auto;
  540. padding: 20px 0px;
  541. border-right: 1px solid #d9d9d9;
  542. }
  543. .inner {
  544. // border-left: 1px solid #d9d9d9;
  545. width: 1000px;
  546. flex: 1;
  547. margin: 0 auto;
  548. box-sizing: border-box;
  549. padding: 20px;
  550. position: relative;
  551. background: #fff;
  552. .title-box {
  553. display: flex;
  554. align-items: center;
  555. margin-bottom: 12px;
  556. padding-right: 160px;
  557. position: relative;
  558. > img {
  559. width: 40px;
  560. margin-right: 16px;
  561. cursor: pointer;
  562. }
  563. }
  564. .title {
  565. font-size: 24px;
  566. margin-bottom: 20px;
  567. line-height: 40px;
  568. margin: 0;
  569. }
  570. .has-module {
  571. display: flex;
  572. justify-content: flex-start;
  573. align-items: flex-start;
  574. }
  575. .edit-btn {
  576. display: inline-block;
  577. font-size: 14px;
  578. background: #ff9900;
  579. float: right;
  580. line-height: 36px;
  581. color: #fff;
  582. width: 60px;
  583. text-align: center;
  584. border-radius: 4px;
  585. }
  586. }
  587. }
  588. }
  589. .nav-list {
  590. width: 200px;
  591. height: 40px;
  592. background: rgba(49, 212, 134, 0.2);
  593. border-radius: 240px;
  594. display: flex;
  595. justify-content: flex-start;
  596. align-items: center;
  597. padding: 0;
  598. margin: 0;
  599. margin-bottom: 10px;
  600. list-style: none;
  601. > li {
  602. height: 40px;
  603. width: 100px;
  604. text-align: center;
  605. font-style: normal;
  606. font-weight: bold;
  607. font-size: 14px;
  608. line-height: 40px;
  609. color: #19b068;
  610. cursor: pointer;
  611. &.active {
  612. background: #19b068;
  613. border-radius: 240px;
  614. color: #ffffff;
  615. }
  616. }
  617. }
  618. }
  619. .answerShow {
  620. position: absolute;
  621. right: 20px;
  622. top: 20px;
  623. width: 112px;
  624. height: 40px;
  625. background: #ffffff url("../assets/common/icon-eye-close.png") 16px center
  626. no-repeat;
  627. background-size: 16px;
  628. border: 1px solid rgba(44, 44, 44, 0.15);
  629. box-sizing: border-box;
  630. border-radius: 4px;
  631. font-size: 14px;
  632. line-height: 150%;
  633. color: #000000;
  634. padding: 9px 16px 9px 36px;
  635. cursor: pointer;
  636. z-index: 2;
  637. &.answerShowTrue {
  638. background: #f5f5f5 url("../assets/common/icon-eye-open.png") 16px center
  639. no-repeat;
  640. background-size: 16px;
  641. }
  642. }
  643. }
  644. .img_url {
  645. width: 1000px;
  646. height: 700px;
  647. }
  648. </style>
  649. <style lang="scss">
  650. .GCLS-BOOK-Container {
  651. .screen-full {
  652. position: fixed;
  653. right: 30px;
  654. bottom: 30px;
  655. width: 48px;
  656. height: 48px;
  657. background: rgba(0, 0, 0, 0.4) url("../assets/common/icon-screenFull.png")
  658. center no-repeat;
  659. background-size: 32px;
  660. }
  661. }
  662. .title-box {
  663. .el-switch {
  664. position: absolute;
  665. top: 0;
  666. right: 0px;
  667. border: 1px solid rgba(44, 44, 44, 0.15);
  668. border-radius: 40px;
  669. height: 40px;
  670. padding: 6px 6px 6px 16px;
  671. }
  672. .el-switch__label.is-active {
  673. color: #000000;
  674. font-size: 16px;
  675. }
  676. }
  677. </style>