courseView.vue 15 KB

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