BookEep.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <template>
  2. <div class="common-preview">
  3. <div class="audit-content">
  4. <div ref="previewMain" class="main-container" :style="{ paddingLeft: '0', paddingRight: '0' }">
  5. <main :class="['preview-main', 'no-audit']" :style="computedCommonPreviewStyle">
  6. <div class="preview-left" :style="{ backgroundColor: background.background?.is_global ? '' : '#fff' }"></div>
  7. <CoursewarePreview
  8. ref="courseware"
  9. :is-show-group="false"
  10. :group-show-all="true"
  11. :group-row-list="groupRowList"
  12. :data="data"
  13. :courseware-id="curSelectId"
  14. :component-list="cList"
  15. :background="background"
  16. :can-remark="false"
  17. :show-remark="false"
  18. :component-remark-obj="{}"
  19. :project="project"
  20. />
  21. <div class="preview-right" :style="{ backgroundColor: background.background?.is_global ? '' : '#fff' }"></div>
  22. </main>
  23. </div>
  24. <div v-if="!sidebarShow" class="back-top" @click="backTop">
  25. <img :src="require(`@/assets/icon/back-top.png`)" alt="返回顶部" />
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import CoursewarePreview from '@/views/book/courseware/preview/CoursewarePreview.vue';
  32. import { isTrue } from '@/utils/validate';
  33. import { buildCoursewareStyle } from '@/views/book/courseware/preview/common/utils/coursewareStyle';
  34. export default {
  35. name: 'BookEep',
  36. components: {
  37. CoursewarePreview,
  38. },
  39. provide() {
  40. return {
  41. getLang: () => this.lang,
  42. getChinese: () => this.chinese,
  43. getShowPinYin: () => this.showPinYin,
  44. getLangList: () => this.langList,
  45. convertText: this.convertText,
  46. getTitleList: () => this.title_list,
  47. getPermissionControl: () => this.permissionControl,
  48. };
  49. },
  50. props: {
  51. id: {
  52. type: String,
  53. default: '',
  54. },
  55. // 组件内容
  56. content: {
  57. type: String,
  58. default: '',
  59. },
  60. // 内容分组行列表
  61. contentGroupRowList: {
  62. type: String,
  63. default: '',
  64. },
  65. // 组件列表
  66. componentList: {
  67. type: Array,
  68. default: () => [],
  69. },
  70. // 教材背景
  71. bookBackground: {
  72. type: String,
  73. default: '',
  74. },
  75. },
  76. data() {
  77. const processHtmlString = this.processHtmlString;
  78. const cList = this.componentList || [];
  79. cList.forEach((x) => {
  80. if (x.component_type === 'audio') {
  81. let _c = JSON.parse(x.content);
  82. let p = _c.property || {};
  83. if (!p.file_name_display_mode) p.file_name_display_mode = 'true';
  84. if (p.view_method === 'independent' && !p.style_mode) {
  85. p.style_mode = 'middle';
  86. }
  87. if (!p.style_mode) p.style_mode = 'big';
  88. if (p.view_method === 'icon') {
  89. p.file_name_display_mode = 'false';
  90. p.view_method = 'independent';
  91. p.style_mode = 'small';
  92. }
  93. x.content = JSON.stringify(_c);
  94. } else if (x.component_type === 'richtext') {
  95. if (!processHtmlString) return;
  96. let _c = JSON.parse(x.content);
  97. let p = _c.property || {};
  98. let lev = Number(p.title_style_level);
  99. if (p.is_title !== 'true' || lev < 1 || !_c.content) return;
  100. let style = this.title_list.find((y) => y.level === lev) || {};
  101. if (style && style.style) {
  102. style = JSON.parse(style.style);
  103. let c_text = _c.content;
  104. const parser = new DOMParser();
  105. const doc = parser.parseFromString(c_text, 'text/html');
  106. const body = doc.body;
  107. const pElements = body.querySelectorAll('p');
  108. processHtmlString(pElements, style);
  109. _c.content = body.innerHTML;
  110. x.content = JSON.stringify(_c);
  111. }
  112. }
  113. });
  114. return {
  115. background: this.bookBackground.length > 0 ? JSON.parse(this.bookBackground) : {},
  116. groupRowList: this.contentGroupRowList.length > 0 ? JSON.parse(this.contentGroupRowList) : [],
  117. data: this.content.length > 0 ? JSON.parse(this.content) : { row_list: [] },
  118. cList,
  119. curSelectId: this.id,
  120. isTrue,
  121. sidebarShow: true,
  122. project: {
  123. editor: '', // 作者
  124. cover_image_file_id: null, // 封面图片ID
  125. cover_image_file_url: '', // 封面图片URL
  126. },
  127. title_list: [],
  128. node_list: [],
  129. permissionControl: {
  130. can_answer: true, // 可作答
  131. can_judge_correct: false, // 可判断对错(客观题)
  132. can_show_answer: false, // 可查看答案
  133. can_correct: false, // 可批改
  134. can_check_correct: false, // 可查看批改
  135. },
  136. popoverShow: false,
  137. is_can_edit: 'false', // 是否可以编辑
  138. };
  139. },
  140. computed: {
  141. computedCommonPreviewStyle() {
  142. return buildCoursewareStyle(this.background, 'commonPreview');
  143. },
  144. },
  145. methods: {
  146. backTop() {
  147. this.$refs.previewMain.scrollTo({
  148. top: 0,
  149. left: 0,
  150. behavior: 'smooth',
  151. });
  152. },
  153. convertText(text) {
  154. return text;
  155. },
  156. processHtmlString(pElements, styleConfig, isClear = false) {
  157. const _pElements = pElements || [];
  158. _pElements.forEach((pElement) => {
  159. if (pElement.innerHTML !== '<br data-mce-bogus="1">') {
  160. pElement.innerHTML = pElement.innerText;
  161. }
  162. if (isClear) {
  163. pElement.removeAttribute('style');
  164. pElement.removeAttribute('data-mce-style');
  165. } else {
  166. const style = pElement.style;
  167. if (styleConfig.font) style.fontFamily = styleConfig.font;
  168. if (styleConfig.font_size) style.fontSize = styleConfig.font_size;
  169. if (styleConfig.text_color) style.color = styleConfig.text_color;
  170. style.fontWeight = styleConfig.bold === 'true' ? 'bold' : 'normal';
  171. style.fontStyle = styleConfig.italic === 'true' ? 'italic' : 'normal';
  172. if (styleConfig.indent || styleConfig.indent === 0) style.marginLeft = `${styleConfig.indent}px`;
  173. }
  174. });
  175. },
  176. },
  177. };
  178. </script>
  179. <style lang="scss" scoped>
  180. @use '@/styles/mixin.scss' as *;
  181. $total-width: $courseware-width + $courseware-left-margin + $courseware-right-margin;
  182. .common-preview {
  183. .main-container {
  184. position: relative;
  185. flex: 1;
  186. min-width: 1110px;
  187. padding: 15px 0;
  188. overflow: auto;
  189. background-color: #ececec;
  190. .catalogue-bar {
  191. position: absolute;
  192. top: 15px;
  193. left: 0;
  194. display: flex;
  195. align-items: center;
  196. justify-content: center;
  197. width: 54px;
  198. height: 54px;
  199. margin: -9px 6px 0 240px;
  200. cursor: pointer;
  201. background-color: #fff;
  202. border-radius: 2px;
  203. box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 40%);
  204. }
  205. .sidebar-bar {
  206. position: absolute;
  207. top: 0;
  208. right: 240px;
  209. display: flex;
  210. width: 60px;
  211. height: calc(100vh - 166px);
  212. .toolbar {
  213. display: flex;
  214. flex-direction: column;
  215. align-items: center;
  216. width: 60px;
  217. height: 100%;
  218. img {
  219. cursor: pointer;
  220. }
  221. &-special {
  222. display: flex;
  223. flex-direction: column;
  224. row-gap: 16px;
  225. align-items: center;
  226. width: 100%;
  227. margin-bottom: 24px;
  228. background-color: #fff;
  229. img {
  230. width: 36px;
  231. height: 36px;
  232. }
  233. }
  234. }
  235. }
  236. }
  237. .back-top {
  238. position: absolute;
  239. right: 240px;
  240. bottom: 0;
  241. display: flex;
  242. place-content: center center;
  243. align-items: center;
  244. width: 60px;
  245. height: 60px;
  246. cursor: pointer;
  247. background-color: #fff;
  248. }
  249. main.preview-main {
  250. display: flex;
  251. flex: 1;
  252. width: calc($total-width);
  253. min-width: calc($total-width);
  254. max-width: calc($total-width);
  255. min-height: 100%;
  256. margin: 0 auto;
  257. background-color: #fff;
  258. border-radius: 4px;
  259. box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 40%);
  260. .preview-left {
  261. width: $courseware-left-margin;
  262. min-width: $courseware-left-margin;
  263. max-width: $courseware-left-margin;
  264. background-color: $courseware-bgColor;
  265. }
  266. .preview-right {
  267. width: $courseware-right-margin;
  268. min-width: $courseware-right-margin;
  269. max-width: $courseware-right-margin;
  270. background-color: $courseware-bgColor;
  271. }
  272. &.no-audit {
  273. margin: 0 auto;
  274. }
  275. }
  276. .audit-content {
  277. display: flex;
  278. min-width: 1810px;
  279. height: calc(100vh - 166px);
  280. &_org {
  281. height: calc(100vh - 126px);
  282. }
  283. .left-menu {
  284. display: flex;
  285. flex-direction: column;
  286. width: $catalogue-width;
  287. font-family: 'Microsoft YaHei', 'Arial', sans-serif;
  288. background-color: #fff;
  289. .courseware-info {
  290. display: flex;
  291. column-gap: 18px;
  292. width: 100%;
  293. height: 186px;
  294. padding: 6px 6px 24px;
  295. border-bottom: $border;
  296. .cover-image {
  297. display: flex;
  298. align-items: center;
  299. justify-content: center;
  300. width: 111px;
  301. height: 157px;
  302. background-color: rgba(229, 229, 229, 100%);
  303. img {
  304. max-width: 111px;
  305. max-height: 157px;
  306. }
  307. }
  308. .info-content {
  309. display: flex;
  310. flex-direction: column;
  311. justify-content: space-between;
  312. .catalogue-icon {
  313. text-align: right;
  314. .svg-icon {
  315. cursor: pointer;
  316. }
  317. }
  318. .courseware {
  319. width: 159px;
  320. height: 64px;
  321. font-size: 16px;
  322. .name {
  323. font-weight: bold;
  324. }
  325. .editor {
  326. display: -webkit-box;
  327. overflow: hidden;
  328. text-overflow: ellipsis;
  329. word-break: break-word;
  330. white-space: normal;
  331. -webkit-line-clamp: 2; /* 多行省略行数,按需调整 */
  332. -webkit-box-orient: vertical;
  333. }
  334. }
  335. }
  336. }
  337. }
  338. .sidebar {
  339. position: relative;
  340. display: flex;
  341. width: $sidebar-width;
  342. .toolbar {
  343. display: flex;
  344. flex-direction: column;
  345. align-items: center;
  346. width: 60px;
  347. height: 100%;
  348. background-color: rgba(247, 248, 250, 100%);
  349. img {
  350. cursor: pointer;
  351. }
  352. &-special {
  353. display: flex;
  354. flex-direction: column;
  355. row-gap: 16px;
  356. margin-bottom: 24px;
  357. }
  358. &-list {
  359. display: flex;
  360. flex-direction: column;
  361. row-gap: 16px;
  362. align-items: center;
  363. width: 100%;
  364. .sidebar-item {
  365. width: 100%;
  366. text-align: center;
  367. .sidebar-icon {
  368. width: 36px;
  369. height: 36px;
  370. cursor: pointer;
  371. }
  372. &.active {
  373. background-color: #4095e5;
  374. }
  375. }
  376. }
  377. }
  378. .content {
  379. flex: 1;
  380. background-color: #fff;
  381. .resource_box {
  382. height: 100%;
  383. overflow-y: auto;
  384. border: 1px solid #e5e5e5;
  385. h5 {
  386. position: fixed;
  387. z-index: 999;
  388. width: 240px;
  389. padding: 0 5px;
  390. margin: 0;
  391. font-size: 18px;
  392. line-height: 40px;
  393. background: #f2f3f5;
  394. }
  395. .scroll-container {
  396. display: flex;
  397. flex-direction: column;
  398. row-gap: 8px;
  399. margin: 6px;
  400. .list-item {
  401. display: flex;
  402. align-items: center;
  403. cursor: pointer;
  404. border: 1px solid #ccc;
  405. border-radius: 8px;
  406. :deep .el-slider {
  407. .el-slider__runway {
  408. background-color: #eee;
  409. }
  410. }
  411. .el-image {
  412. display: flex;
  413. width: 100%;
  414. min-width: 100%;
  415. height: 90px;
  416. background-color: #ccc;
  417. border-radius: 8px;
  418. }
  419. .video-play {
  420. width: 100%;
  421. min-width: 100%;
  422. }
  423. .text-box {
  424. word-break: break-word;
  425. }
  426. }
  427. }
  428. p {
  429. color: #999;
  430. text-align: center;
  431. }
  432. .card-box li {
  433. padding: 10px;
  434. border-bottom: 1px solid #ccc;
  435. .el-icon-notebook-2 {
  436. display: block;
  437. margin-bottom: 4px;
  438. font-size: 12px;
  439. color: grey;
  440. }
  441. }
  442. }
  443. }
  444. .back-top {
  445. position: absolute;
  446. bottom: 0;
  447. left: 0;
  448. display: flex;
  449. place-content: center center;
  450. align-items: center;
  451. width: 60px;
  452. height: 60px;
  453. cursor: pointer;
  454. }
  455. }
  456. }
  457. }
  458. :deep .scroll-container .audio-wrapper {
  459. width: 100% !important;
  460. .audio-middle {
  461. width: 100% !important;
  462. padding: 6px 8px !important;
  463. border: none;
  464. border-radius: 8px;
  465. .audio-name {
  466. text-align: left;
  467. }
  468. .slider-area {
  469. column-gap: 8px !important;
  470. }
  471. :deep .remark-dialog {
  472. .el-dialog__body {
  473. padding: 5px 20px;
  474. }
  475. }
  476. :deep .audit-dialog {
  477. .el-dialog__body {
  478. height: calc(100vh - 260px);
  479. padding: 5px 20px;
  480. }
  481. .mind-map-container .mind-map {
  482. height: calc(100vh - 310px);
  483. }
  484. }
  485. }
  486. }
  487. .mt10 {
  488. margin: 10px 0 0 !important;
  489. background-color: #eee;
  490. }
  491. .courseware-tree {
  492. display: flex;
  493. flex: 1;
  494. flex-direction: column;
  495. row-gap: 8px;
  496. max-height: calc(100vh - 200px);
  497. overflow: auto;
  498. .menu-item {
  499. display: flex;
  500. align-items: center;
  501. &:not(.courseware) {
  502. font-weight: bold;
  503. }
  504. &.courseware {
  505. &:hover {
  506. .name {
  507. background-color: #f3f3f3;
  508. }
  509. }
  510. }
  511. .svg-icon {
  512. margin-left: 4px;
  513. &.my-edit-task {
  514. color: $right-color;
  515. }
  516. }
  517. .name {
  518. flex: 1;
  519. padding: 4px 8px 4px 4px;
  520. border-radius: 4px;
  521. }
  522. &.active {
  523. .name {
  524. font-weight: bold;
  525. color: #4095e5;
  526. }
  527. }
  528. }
  529. }
  530. </style>
  531. <style lang="scss">
  532. .tox-tinymce-aux {
  533. z-index: 9999 !important;
  534. }
  535. </style>