CommonPreview.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288
  1. <template>
  2. <div class="common-preview">
  3. <div class="common-preview__header">
  4. <div class="courseware">
  5. <span class="flow-nodename">{{ courseware_info.cur_audit_flow_node_name }}</span>
  6. <slot name="middle" :courseware="courseware_info"></slot>
  7. <div class="group">
  8. <el-checkbox v-model="isShowGroup">显示分组</el-checkbox>
  9. <el-checkbox v-model="groupShowAll">分组显示全部</el-checkbox>
  10. <el-checkbox v-model="isJudgeCorrect">判断对错</el-checkbox>
  11. <el-checkbox v-model="isShowAnswer" :disabled="!isJudgeCorrect">显示答案</el-checkbox>
  12. </div>
  13. <span class="link">
  14. <el-select v-model="lang" placeholder="请选择语言" size="mini" class="lang-select">
  15. <el-option v-for="item in langList" :key="item.type" :label="item.name" :value="item.type" />
  16. </el-select>
  17. </span>
  18. <div class="operator">
  19. <slot name="operator" :courseware="courseware_info" :project-id="projectId"></slot>
  20. </div>
  21. </div>
  22. </div>
  23. <div class="audit-content">
  24. <!-- 左侧菜单栏 -->
  25. <aside v-if="navigationShow" class="left-menu">
  26. <div class="courseware-info">
  27. <div class="cover-image">
  28. <img v-if="project.cover_image_file_url.length > 0" :src="project.cover_image_file_url" alt="cover-image" />
  29. </div>
  30. <div class="info-content">
  31. <div class="catalogue-icon" @click="toggleNavigationShow">
  32. <SvgIcon icon-class="catalogue" size="54" />
  33. </div>
  34. <div class="courseware">
  35. <div class="name nowrap-ellipsis" :title="courseware_info.book_name">
  36. {{ courseware_info.book_name }}
  37. </div>
  38. <div class="editor" :title="project.editor">
  39. {{ project.editor }}
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <!-- 教材章节树 -->
  45. <div class="courseware-tree">
  46. <div
  47. v-for="{ id: nodeId, name, deep, is_leaf_chapter } in node_list"
  48. :key="nodeId"
  49. :class="['menu-item', { active: curSelectId === nodeId }, { courseware: isTrue(is_leaf_chapter) }]"
  50. :style="computedNameStyle(deep, isTrue(is_leaf_chapter))"
  51. @click="selectChapterNode(nodeId, isTrue(is_leaf_chapter))"
  52. >
  53. <span class="name nowrap-ellipsis" :title="name">
  54. {{ name }}
  55. </span>
  56. </div>
  57. </div>
  58. </aside>
  59. <div
  60. ref="previewMain"
  61. class="main-container"
  62. :style="{ paddingLeft: navigationShow ? '15px' : '315px', paddingRight: sidebarShow ? '15px' : '315px' }"
  63. >
  64. <!-- 左侧菜单栏 - 收缩 -->
  65. <div v-if="!navigationShow" class="catalogue-bar" @click="toggleNavigationShow">
  66. <SvgIcon icon-class="catalogue" size="54" />
  67. </div>
  68. <main :class="['preview-main', { 'no-audit': !isShowAudit }]">
  69. <div class="preview-left"></div>
  70. <CoursewarePreview
  71. v-if="courseware_info.book_name"
  72. ref="courserware"
  73. :is-show-group="isShowGroup"
  74. :group-show-all="groupShowAll"
  75. :group-row-list="content_group_row_list"
  76. :data="data"
  77. :component-list="component_list"
  78. :background="background"
  79. :can-remark="isTrue(courseware_info.is_my_audit_task) && isTrue(courseware_info.is_can_add_audit_remark)"
  80. :show-remark="isShowAudit"
  81. :component-remark-obj="remark_list_obj"
  82. :project="project"
  83. @computeScroll="computeScroll"
  84. @addRemark="addRemark"
  85. />
  86. <div class="preview-right"></div>
  87. </main>
  88. <!-- 右侧菜单栏 - 收缩 -->
  89. <aside v-if="!sidebarShow" class="sidebar-bar">
  90. <aside class="toolbar">
  91. <div class="toolbar-special">
  92. <!-- <img :src="require('@/assets/icon/sidebar-fullscreen.png')" alt="全屏" />
  93. <img :src="require('@/assets/icon/sidebar-toolkit.png')" alt="工具箱" /> -->
  94. <img :src="require(`@/assets/icon/arrow-down.png`)" alt="伸缩" @click="toggleSidebarShow" />
  95. </div>
  96. </aside>
  97. </aside>
  98. </div>
  99. <div v-if="!sidebarShow" class="back-top" @click="backTop">
  100. <img :src="require(`@/assets/icon/back-top.png`)" alt="返回顶部" />
  101. </div>
  102. <!-- 右侧工具栏 -->
  103. <aside v-if="sidebarShow" ref="sidebarMenu" class="sidebar">
  104. <aside class="toolbar">
  105. <div class="toolbar-special">
  106. <!-- <img :src="require('@/assets/icon/sidebar-fullscreen.png')" alt="全屏" />
  107. <img :src="require('@/assets/icon/sidebar-toolkit.png')" alt="工具箱" /> -->
  108. </div>
  109. <div v-if="sidebarShow" class="toolbar-list">
  110. <div
  111. v-for="{ icon, title, handle, param } in sidebarIconList"
  112. :key="icon"
  113. :class="['sidebar-item', { active: curToolbarIcon === icon }]"
  114. :title="title"
  115. @click="handleSidebarClick(handle, param, icon)"
  116. >
  117. <div
  118. class="sidebar-icon icon-mask"
  119. :style="{
  120. backgroundColor: curToolbarIcon === icon ? '#fff' : '#1E2129',
  121. maskImage: `url(${require(`@/assets/icon/sidebar-${icon}.png`)})`,
  122. }"
  123. ></div>
  124. </div>
  125. </div>
  126. <div class="adjustable" @click="toggleSidebarShow">
  127. <img :src="require(`@/assets/icon/arrow-up.png`)" alt="伸缩" />
  128. </div>
  129. </aside>
  130. <div class="content">
  131. <template v-if="curToolbarIcon === 'audit'">
  132. <AuditRemark :remark-list="remark_list" :is-audit="isShowAudit" @deleteRemarks="deleteRemarks" />
  133. </template>
  134. <el-drawer
  135. custom-class="custom-drawer"
  136. :visible="drawerType.length > 0"
  137. :with-header="false"
  138. :modal="false"
  139. size="240"
  140. direction="ltr"
  141. :style="drawerStyle"
  142. >
  143. <div class="infinite-list-wrapper">
  144. <h5>{{ drawerTitle }}</h5>
  145. <ul
  146. v-infinite-scroll="loadMore"
  147. class="scroll-container"
  148. infinite-scroll-disabled="disabled"
  149. :infinite-scroll-immediate="false"
  150. >
  151. <li
  152. v-for="(item, index) in file_list"
  153. :key="index"
  154. class="list-item"
  155. @click="handleFileClick(item?.courseware_id, item?.component_id)"
  156. >
  157. <template v-if="parseInt(drawerType) === 0">
  158. <el-image :src="item.file_url" fit="contain" />
  159. <!-- <span class="text-box">{{ item.file_name.slice(0, item.file_name.lastIndexOf('.')) }}</span> -->
  160. </template>
  161. <template v-else-if="parseInt(drawerType) === 1">
  162. <AudioPlay
  163. view-size="middle"
  164. :file-id="item.file_id"
  165. :file-name="item.file_name.slice(0, item.file_name.lastIndexOf('.'))"
  166. :show-slider="true"
  167. :audio-index="index"
  168. />
  169. </template>
  170. <template v-else-if="parseInt(drawerType) === 2">
  171. <VideoPlay view-size="small" :file-id="item.file_id" :video-index="index" />
  172. <!-- <span class="text-box">{{ item.file_name.slice(0, item.file_name.lastIndexOf('.')) }}</span> -->
  173. </template>
  174. </li>
  175. </ul>
  176. <p v-if="loading">加载中...</p>
  177. <p v-if="noMore">没有更多了</p>
  178. </div>
  179. </el-drawer>
  180. </div>
  181. <div class="back-top" @click="backTop">
  182. <img :src="require(`@/assets/icon/back-top.png`)" alt="返回顶部" />
  183. </div>
  184. </aside>
  185. </div>
  186. <el-dialog
  187. title="添加课件审校批注"
  188. :visible="visible"
  189. width="680px"
  190. :close-on-click-modal="false"
  191. class="remark-dialog"
  192. @close="dialogClose('')"
  193. >
  194. <RichText
  195. v-model="remark_content"
  196. toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright"
  197. :wordlimit-num="false"
  198. :height="240"
  199. page-from="audit"
  200. />
  201. <div slot="footer">
  202. <el-button @click="dialogClose('')">取消</el-button>
  203. <el-button type="primary" :loading="submit_loading" @click="addCoursewareAuditRemark(select_node)">
  204. 确定
  205. </el-button>
  206. </div>
  207. </el-dialog>
  208. <el-dialog title="" :visible="visibleMindMap" width="1100px" class="audit-dialog" @close="dialogClose('MindMap')">
  209. <MindMap
  210. v-if="isChildDataLoad"
  211. ref="mindMapRef"
  212. :project-id="projectId"
  213. :mind-map-json-data="mindMapJsonData"
  214. @child-click="handleNodeClick"
  215. />
  216. </el-dialog>
  217. </div>
  218. </template>
  219. <script>
  220. import CoursewarePreview from '@/views/book/courseware/preview/CoursewarePreview.vue';
  221. import RichText from '@/components/RichText.vue';
  222. import { isTrue } from '@/utils/validate';
  223. import MindMap from '@/components/MindMap.vue';
  224. import VideoPlay from '@/views/book/courseware/preview/components/common/VideoPlay.vue';
  225. import AudioPlay from '@/views/book/courseware/preview/components/common/AudioPlay.vue';
  226. import AuditRemark from '@/components/AuditRemark.vue';
  227. import * as OpenCC from 'opencc-js';
  228. import {
  229. GetBookCoursewareInfo,
  230. GetProjectBaseInfo,
  231. GetCoursewareAuditRemarkList,
  232. AddCoursewareAuditRemark,
  233. DeleteCoursewareAuditRemarkList,
  234. GetProjectInfo,
  235. } from '@/api/project';
  236. import {
  237. ContentGetCoursewareContent_View,
  238. ChapterGetBookChapterStructExpandList,
  239. GetBookBaseInfo,
  240. MangerGetBookMindMap,
  241. PageQueryBookResourceList,
  242. GetLanguageTypeList,
  243. GetBookUnifiedAttrib,
  244. } from '@/api/book';
  245. export default {
  246. name: 'CommonPreview',
  247. components: {
  248. CoursewarePreview,
  249. RichText,
  250. MindMap,
  251. AudioPlay,
  252. VideoPlay,
  253. AuditRemark,
  254. },
  255. provide() {
  256. return {
  257. getLang: () => this.lang,
  258. getChinese: () => this.chinese,
  259. getLangList: () => this.langList,
  260. convertText: this.convertText,
  261. };
  262. },
  263. props: {
  264. projectId: {
  265. type: String,
  266. required: true,
  267. },
  268. id: {
  269. type: String,
  270. default: '',
  271. },
  272. // 是否是审校页面
  273. isAudit: {
  274. type: Boolean,
  275. default: false,
  276. },
  277. isShowAudit: {
  278. type: Boolean,
  279. default: true,
  280. },
  281. isBook: {
  282. type: Boolean,
  283. default: false,
  284. },
  285. },
  286. data() {
  287. const sidebarIconList = [
  288. // { icon: 'search', title: '搜索', handle: '', param: {} },
  289. { icon: 'mindmap', title: '思维导图', handle: 'openMindMap', param: {} },
  290. // { icon: 'knowledge', title: '知识图谱', handle: '', param: {} },
  291. // { icon: 'totalResources', title: '总资源', handle: '', param: {} },
  292. // { icon: 'collect', title: '收藏', handle: '', param: {} },
  293. { icon: 'audio', title: '音频', handle: 'openDrawer', param: { type: '1' } },
  294. { icon: 'image', title: '图片', handle: 'openDrawer', param: { type: '0' } },
  295. { icon: 'video', title: '视频', handle: 'openDrawer', param: { type: '2' } },
  296. // { icon: 'note', title: '笔记', handle: '', param: {} },
  297. // { icon: 'translate', title: '翻译', handle: '', param: {} },
  298. // { icon: 'setting', title: '设置', handle: '', param: {} },
  299. ];
  300. if (this.isShowAudit) {
  301. sidebarIconList.push({ icon: 'audit', title: '审校批注', handle: 'openAudit', param: {} });
  302. }
  303. return {
  304. select_node: this.id,
  305. courseware_info: {
  306. book_name: '',
  307. is_can_start_edit: 'false',
  308. is_can_submit_audit: 'false',
  309. is_can_audit_pass: 'false',
  310. is_can_audit_reject: 'false',
  311. is_can_add_audit_remark: 'false',
  312. is_can_finish_audit: 'false',
  313. is_can_request_shangjia_book: 'false',
  314. is_can_request_rollback_project: 'false',
  315. is_can_shangjia_book: 'false',
  316. is_can_rollback_project: 'false',
  317. },
  318. background: {
  319. background_image_url: '',
  320. background_position: {
  321. left: 0,
  322. top: 0,
  323. },
  324. },
  325. node_list: [],
  326. data: { row_list: [] },
  327. component_list: [],
  328. content_group_row_list: [],
  329. remark_list: [],
  330. remark_list_obj: {}, // 存放以组件为对象的数组
  331. visible: false,
  332. remark_content: '',
  333. submit_loading: false,
  334. isTrue,
  335. menuPosition: {
  336. x: -1,
  337. y: -1,
  338. componentId: 'WHOLE',
  339. },
  340. curToolbarIcon: this.isShowAudit ? 'audit' : '',
  341. sidebarIconList,
  342. visibleMindMap: false,
  343. isChildDataLoad: false,
  344. mindMapJsonData: {}, // 思维导图json数据
  345. drawerType: '', // 抽屉类型
  346. drawerStyle: {
  347. top: '0',
  348. height: '0',
  349. right: '0',
  350. },
  351. page_capacity: 10,
  352. cur_page: 1,
  353. file_list: [],
  354. total_count: 0,
  355. loading: true,
  356. lastLoadTime: 0,
  357. minLoadInterval: 3 * 1000,
  358. isShowGroup: false,
  359. groupShowAll: true,
  360. opencc: OpenCC.Converter({ from: 'cn', to: 'tw' }),
  361. langList: [],
  362. lang: 'ZH',
  363. chinese: 'zh-Hans',
  364. isJudgeCorrect: false,
  365. isShowAnswer: false,
  366. unified_attrib: {},
  367. curSelectId: this.id,
  368. navigationShow: true,
  369. sidebarShow: true,
  370. project: {
  371. editor: '', // 作者
  372. cover_image_file_id: null, // 封面图片ID
  373. cover_image_file_url: '', // 封面图片URL
  374. },
  375. };
  376. },
  377. computed: {
  378. disabled() {
  379. const result = this.loading || this.noMore;
  380. return result;
  381. },
  382. noMore() {
  383. const result = this.file_list.length >= this.total_count;
  384. return result;
  385. },
  386. drawerTitle() {
  387. const titleMap = {
  388. 0: '图片资源',
  389. 1: '音频资源',
  390. 2: '视频资源',
  391. };
  392. return titleMap[this.drawerType] || '资源列表';
  393. },
  394. },
  395. watch: {
  396. isJudgeCorrect(newVal) {
  397. if (!newVal) {
  398. this.isShowAnswer = false;
  399. }
  400. this.simulateAnswer(newVal);
  401. },
  402. isShowAnswer() {
  403. this.simulateAnswer();
  404. },
  405. },
  406. created() {
  407. if (this.id) {
  408. this.getBookCoursewareInfo(this.id);
  409. this.getCoursewareComponentContent_View(this.id);
  410. this.getCoursewareAuditRemarkList(this.id);
  411. } else {
  412. this.isBook ? this.getBookBaseInfo() : this.getProjectBaseInfo();
  413. }
  414. this.getBookChapterStructExpandList();
  415. this.getBookUnifiedAttr();
  416. if (!this.isBook) {
  417. this.getProjectInfo();
  418. }
  419. },
  420. mounted() {
  421. this.calcDrawerPosition();
  422. },
  423. methods: {
  424. getProjectBaseInfo() {
  425. GetProjectBaseInfo({ id: this.projectId }).then(({ project_info }) => {
  426. this.courseware_info = { ...project_info, book_name: project_info.name };
  427. });
  428. },
  429. getBookBaseInfo() {
  430. GetBookBaseInfo({ id: this.projectId }).then(({ book_info }) => {
  431. this.courseware_info = { ...this.courseware_info, ...book_info, book_name: book_info.name };
  432. this.project = {
  433. editor: book_info.editor,
  434. cover_image_file_id: book_info.cover_image_file_id,
  435. cover_image_file_url: book_info.cover_image_file_url,
  436. };
  437. });
  438. },
  439. getProjectInfo() {
  440. GetProjectInfo({ id: this.projectId }).then(({ project_info }) => {
  441. if (project_info.cover_image_file_url) {
  442. this.project = project_info;
  443. }
  444. });
  445. },
  446. /**
  447. * 得到教材课件信息
  448. * @param {string} id - 课件ID
  449. */
  450. getBookCoursewareInfo(id) {
  451. GetBookCoursewareInfo({ id, is_contain_producer: 'true', is_contain_auditor: 'true' }).then(
  452. ({ courseware_info }) => {
  453. this.courseware_info = { ...this.courseware_info, ...courseware_info };
  454. this.getLangList();
  455. },
  456. );
  457. },
  458. /**
  459. * 得到课件内容(展示内容)
  460. * @param {string} id - 课件ID
  461. */
  462. getCoursewareComponentContent_View(id) {
  463. ContentGetCoursewareContent_View({ id }).then(({ content, component_list, content_group_row_list }) => {
  464. if (content) {
  465. const _content = JSON.parse(content);
  466. this.data = _content;
  467. this.background = {
  468. background_image_url: _content.background_image_url,
  469. background_position: _content.background_position,
  470. };
  471. } else {
  472. this.data = { row_list: [] };
  473. }
  474. if (component_list) this.component_list = component_list;
  475. if (content_group_row_list) this.content_group_row_list = JSON.parse(content_group_row_list) || [];
  476. });
  477. },
  478. getLangList() {
  479. GetLanguageTypeList({ book_id: this.courseware_info.book_id, is_contain_zh: 'true' }).then(
  480. ({ language_type_list }) => {
  481. this.langList = language_type_list;
  482. },
  483. );
  484. },
  485. /**
  486. * 得到教材章节结构展开列表
  487. */
  488. getBookChapterStructExpandList() {
  489. ChapterGetBookChapterStructExpandList({
  490. book_id: this.projectId,
  491. node_deep_mode: 0,
  492. is_contain_producer: 'true',
  493. is_contain_auditor: 'true',
  494. }).then(({ node_list }) => {
  495. this.node_list = node_list;
  496. });
  497. },
  498. getBookUnifiedAttr() {
  499. GetBookUnifiedAttrib({ book_id: this.projectId }).then(({ content }) => {
  500. if (content) {
  501. this.unified_attrib = JSON.parse(content);
  502. }
  503. });
  504. },
  505. /**
  506. * 选择节点
  507. * @param {string} nodeId - 节点ID
  508. */
  509. selectNode(nodeId) {
  510. this.getCoursewareComponentContent_View(nodeId);
  511. this.getBookCoursewareInfo(nodeId);
  512. this.getCoursewareAuditRemarkList(nodeId);
  513. this.select_node = nodeId;
  514. },
  515. // 审校批注列表
  516. getCoursewareAuditRemarkList(id) {
  517. this.remark_list = [];
  518. GetCoursewareAuditRemarkList({
  519. courseware_id: id,
  520. }).then(({ remark_list }) => {
  521. this.remark_list = remark_list;
  522. if (!remark_list) return;
  523. this.remark_list_obj = remark_list.reduce((acc, item) => {
  524. if (!acc[item.component_id]) {
  525. acc[item.component_id] = [];
  526. }
  527. acc[item.component_id].push(item);
  528. return acc;
  529. }, {});
  530. });
  531. },
  532. addRemark(selectNode, x, y, componentId) {
  533. this.remark_content = '';
  534. this.visible = true;
  535. if (selectNode) {
  536. this.menuPosition = {
  537. x,
  538. y,
  539. componentId,
  540. };
  541. } else {
  542. this.menuPosition = {
  543. x: -1,
  544. y: -1,
  545. componentId: 'WHOLE',
  546. };
  547. }
  548. },
  549. dialogClose(type) {
  550. this[`visible${type}`] = false;
  551. },
  552. // 添加审校批注
  553. addCoursewareAuditRemark(id) {
  554. this.submit_loading = true;
  555. AddCoursewareAuditRemark({
  556. courseware_id: id || this.id,
  557. content: this.remark_content,
  558. component_id: this.menuPosition.componentId,
  559. position_x: this.menuPosition.x,
  560. position_y: this.menuPosition.y,
  561. })
  562. .then(() => {
  563. this.submit_loading = false;
  564. this.visible = false;
  565. this.getCoursewareAuditRemarkList(id || this.id);
  566. })
  567. .catch(() => {
  568. this.submit_loading = false;
  569. });
  570. },
  571. // 删除批注
  572. deleteRemarks(id) {
  573. this.$confirm('确定要删除此条批注吗?', '提示', {
  574. confirmButtonText: '确定',
  575. cancelButtonText: '取消',
  576. type: 'warning',
  577. })
  578. .then(() => {
  579. DeleteCoursewareAuditRemarkList({ id }).then(() => {
  580. this.getCoursewareAuditRemarkList(this.select_node ? this.select_node : this.id);
  581. this.$message.success('删除成功!');
  582. });
  583. })
  584. .catch(() => {});
  585. },
  586. // 计算previewMain滑动距离
  587. computeScroll() {
  588. this.$refs.courserware.handleResult(
  589. this.$refs.previewMain.scrollTop,
  590. this.$refs.previewMain.scrollLeft,
  591. this.select_node,
  592. );
  593. },
  594. /**
  595. * 处理侧边栏图标点击事件
  596. * @param {string} handle - 处理函数名
  597. * @param {any} param - 处理函数参数
  598. * @param {string} icon - 图标名称
  599. */
  600. handleSidebarClick(handle, param, icon) {
  601. if (typeof handle === 'string' && handle && typeof this[handle] === 'function') {
  602. this[handle](param);
  603. }
  604. this.curToolbarIcon = icon;
  605. },
  606. openMindMap() {
  607. MangerGetBookMindMap({ book_id: this.projectId }).then(({ content }) => {
  608. if (content) {
  609. this.mindMapJsonData = JSON.parse(content);
  610. this.isChildDataLoad = true;
  611. }
  612. });
  613. this.visibleMindMap = true;
  614. },
  615. async handleNodeClick(data) {
  616. let [nodeId, componentId] = data.split('#');
  617. if (nodeId) this.selectNode(nodeId);
  618. if (componentId) {
  619. let node = await this.$refs.courserware.findChildComponentByKey(componentId);
  620. if (node) {
  621. await this.$nextTick();
  622. this.$refs.previewMain.scrollTo({
  623. top: node.$el.offsetTop - 50,
  624. left: node.$el.offsetLeft - 50,
  625. behavior: 'smooth',
  626. });
  627. }
  628. }
  629. this.visibleMindMap = false;
  630. },
  631. // 计算抽屉滑出位置
  632. calcDrawerPosition() {
  633. const menu = this.$refs.sidebarMenu;
  634. if (menu) {
  635. const rect = menu.getBoundingClientRect();
  636. this.drawerStyle = {
  637. top: `${rect.top}px`,
  638. height: `${rect.height}px`,
  639. left: `${rect.right - 240}px`,
  640. };
  641. }
  642. },
  643. /**
  644. * 打开抽屉并初始化加载
  645. * @param {Object} param - 抽屉参数
  646. * @param {string} param.type - 抽屉类型(0: 图片, 1: 音频, 2: 视频)
  647. */
  648. openDrawer({ type }) {
  649. if (this.drawerType === type) {
  650. this.drawerType = '';
  651. return;
  652. }
  653. // 重置所有加载状态
  654. this.resetLoadState();
  655. this.drawerType = type; // 假设这是你的类型变量
  656. this.$nextTick(() => {
  657. // 确保DOM更新后触发加载
  658. this.loadMore();
  659. });
  660. },
  661. openAudit() {
  662. this.drawerType = '';
  663. },
  664. resetLoadState() {
  665. this.cur_page = 1;
  666. this.file_list = [];
  667. this.total_count = 0;
  668. this.loading = false;
  669. this.lastLoadTime = 0; // 重置时间戳,允许立即加载
  670. this.loadCount = 0;
  671. },
  672. // 加载更多数据
  673. async loadMore() {
  674. const now = Date.now();
  675. // 只有当lastLoadTime不为0(不是第一次)且时间间隔太短时才return
  676. if (this.lastLoadTime > 0 && now - this.lastLoadTime < this.minLoadInterval) {
  677. return;
  678. }
  679. if (this.disabled || this.loading) {
  680. if (this.lastLoadTime > 0) {
  681. return;
  682. }
  683. }
  684. this.loading = true;
  685. const params = {
  686. page_capacity: this.page_capacity,
  687. cur_page: this.cur_page,
  688. book_id: this.projectId,
  689. type: parseInt(this.drawerType),
  690. };
  691. await PageQueryBookResourceList(params)
  692. .then(({ total_count, resource_list }) => {
  693. this.total_count = total_count;
  694. // 记录加载前的滚动高度
  695. const scrollContainer = this.$el.querySelector('.el-drawer__body');
  696. const isAtBottom = this.isScrollAtBottom(scrollContainer);
  697. this.file_list = this.cur_page === 1 ? resource_list : [...this.file_list, ...resource_list];
  698. if (!resource_list || resource_list.length === 0) {
  699. return;
  700. }
  701. this.cur_page += 1;
  702. // 只有当前已经在底部时才微调滚动位置
  703. if (isAtBottom) {
  704. this.$nextTick(() => {
  705. // 轻微向上滚动,创造滚动空间
  706. scrollContainer.scrollTop -= 5;
  707. });
  708. }
  709. })
  710. .finally(() => {
  711. this.loading = false;
  712. this.lastLoadTime = now;
  713. });
  714. },
  715. isScrollAtBottom(container) {
  716. if (!container) return false;
  717. return container.scrollHeight - container.scrollTop <= container.clientHeight + 5;
  718. },
  719. async handleFileClick(courseware_id, component_id) {
  720. if (courseware_id) this.selectNode(courseware_id);
  721. if (component_id) {
  722. let node = await this.$refs.courserware.findChildComponentByKey(component_id);
  723. if (node) {
  724. await this.$nextTick();
  725. this.$refs.previewMain.scrollTo({
  726. top: node.offsetTop - 50,
  727. left: node.offsetLeft - 50,
  728. behavior: 'smooth',
  729. });
  730. }
  731. }
  732. },
  733. /**
  734. * 文本转换
  735. * @param {string} text - 要转换的文本
  736. * @returns {string} - 转换后的文本
  737. */
  738. convertText(text) {
  739. if (this.chinese === 'zh-Hant' && this.opencc) {
  740. return this.opencc(text);
  741. }
  742. return text;
  743. },
  744. simulateAnswer(disabled = true) {
  745. this.$refs.courserware.simulateAnswer(this.isJudgeCorrect, this.isShowAnswer, disabled);
  746. },
  747. /**
  748. * 选择节点
  749. * @param {string} nodeId - 节点ID
  750. * @param {boolean} isLeaf - 是否是叶子节点
  751. */
  752. selectChapterNode(nodeId, isLeaf) {
  753. if (!isLeaf) return;
  754. if (this.curSelectId === nodeId) return;
  755. this.curSelectId = nodeId;
  756. this.selectNode(nodeId);
  757. },
  758. /**
  759. * 计算章节名称样式
  760. * @param {number} deep - 节点深度
  761. * @param {boolean} isLeaf - 是否是叶子节点
  762. * @returns {Object} - 样式对象
  763. */
  764. computedNameStyle(deep, isLeaf) {
  765. return {
  766. 'padding-left': `${(deep - 1) * 8}px`,
  767. cursor: isLeaf ? 'pointer' : 'auto',
  768. };
  769. },
  770. /**
  771. * 切换左侧导航栏显示与隐藏
  772. */
  773. toggleNavigationShow() {
  774. this.navigationShow = !this.navigationShow;
  775. },
  776. /**
  777. * 切换右侧工具栏显示与隐藏
  778. */
  779. toggleSidebarShow() {
  780. this.sidebarShow = !this.sidebarShow;
  781. },
  782. backTop() {
  783. this.$refs.previewMain.scrollTo({
  784. top: 0,
  785. left: 0,
  786. behavior: 'smooth',
  787. });
  788. },
  789. },
  790. };
  791. </script>
  792. <style lang="scss" scoped>
  793. @use '@/styles/mixin.scss' as *;
  794. $total-width: $courseware-width + $courseware-left-margin + $courseware-right-margin;
  795. .common-preview {
  796. &__header {
  797. position: sticky;
  798. top: 56px;
  799. left: 0;
  800. z-index: 9;
  801. display: flex;
  802. align-items: center;
  803. height: 40px;
  804. padding: 6px 4px;
  805. margin-bottom: 5px;
  806. background-color: #fff;
  807. border-top: $border;
  808. border-bottom: $border;
  809. > .courseware {
  810. display: flex;
  811. flex-grow: 1;
  812. column-gap: 16px;
  813. align-items: center;
  814. justify-content: space-between;
  815. height: 40px;
  816. .lang-select {
  817. :deep .el-input {
  818. width: 100px;
  819. }
  820. :deep .el-input__inner {
  821. height: 24px;
  822. line-height: 24px;
  823. background-color: #fff;
  824. }
  825. :deep .el-input__icon {
  826. line-height: 24px;
  827. }
  828. }
  829. .flow-nodename {
  830. flex: 1;
  831. }
  832. .group {
  833. display: flex;
  834. align-items: center;
  835. }
  836. .operator {
  837. display: flex;
  838. column-gap: 8px;
  839. align-items: center;
  840. .link {
  841. + .link {
  842. margin-left: 0;
  843. &::before {
  844. margin-right: 8px;
  845. color: #999;
  846. content: '|';
  847. }
  848. }
  849. }
  850. }
  851. }
  852. }
  853. .main-container {
  854. position: relative;
  855. flex: 1;
  856. min-width: 1110px;
  857. padding: 15px 0;
  858. overflow: auto;
  859. background-color: #ececec;
  860. .catalogue-bar {
  861. position: absolute;
  862. top: 15px;
  863. left: 0;
  864. display: flex;
  865. align-items: center;
  866. justify-content: center;
  867. width: 54px;
  868. height: 54px;
  869. margin: -9px 6px 0 240px;
  870. cursor: pointer;
  871. background-color: #fff;
  872. border-radius: 2px;
  873. box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 40%);
  874. }
  875. .sidebar-bar {
  876. position: absolute;
  877. top: 0;
  878. right: 240px;
  879. display: flex;
  880. width: 60px;
  881. height: calc(100vh - 166px);
  882. .toolbar {
  883. display: flex;
  884. flex-direction: column;
  885. align-items: center;
  886. width: 60px;
  887. height: 100%;
  888. img {
  889. cursor: pointer;
  890. }
  891. &-special {
  892. display: flex;
  893. flex-direction: column;
  894. row-gap: 16px;
  895. align-items: center;
  896. width: 100%;
  897. margin-bottom: 24px;
  898. background-color: #fff;
  899. img {
  900. width: 36px;
  901. height: 36px;
  902. }
  903. }
  904. }
  905. }
  906. }
  907. .back-top {
  908. position: absolute;
  909. right: 240px;
  910. bottom: 0;
  911. display: flex;
  912. place-content: center center;
  913. align-items: center;
  914. width: 60px;
  915. height: 60px;
  916. cursor: pointer;
  917. background-color: #fff;
  918. }
  919. main.preview-main {
  920. display: flex;
  921. flex: 1;
  922. width: calc($total-width);
  923. min-width: calc($total-width);
  924. max-width: calc($total-width);
  925. min-height: 100%;
  926. margin: 0 auto;
  927. background-color: #fff;
  928. border-radius: 4px;
  929. box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 40%);
  930. .preview-left {
  931. width: $courseware-left-margin;
  932. min-width: $courseware-left-margin;
  933. max-width: $courseware-left-margin;
  934. background-color: $courseware-bgColor;
  935. }
  936. .preview-right {
  937. width: $courseware-right-margin;
  938. min-width: $courseware-right-margin;
  939. max-width: $courseware-right-margin;
  940. background-color: $courseware-bgColor;
  941. }
  942. &.no-audit {
  943. margin: 0 auto;
  944. }
  945. }
  946. .audit-content {
  947. display: flex;
  948. min-width: 1400px;
  949. height: calc(100vh - 166px);
  950. .left-menu {
  951. display: flex;
  952. flex-direction: column;
  953. width: $catalogue-width;
  954. font-family: 'Microsoft YaHei', 'Arial', sans-serif;
  955. background-color: #fff;
  956. .courseware-info {
  957. display: flex;
  958. column-gap: 18px;
  959. width: 100%;
  960. height: 186px;
  961. padding: 6px 6px 24px;
  962. border-bottom: $border;
  963. .cover-image {
  964. display: flex;
  965. align-items: center;
  966. justify-content: center;
  967. width: 111px;
  968. height: 157px;
  969. background-color: rgba(229, 229, 229, 100%);
  970. img {
  971. max-width: 111px;
  972. max-height: 157px;
  973. }
  974. }
  975. .info-content {
  976. display: flex;
  977. flex-direction: column;
  978. justify-content: space-between;
  979. .catalogue-icon {
  980. text-align: right;
  981. .svg-icon {
  982. cursor: pointer;
  983. }
  984. }
  985. .courseware {
  986. width: 159px;
  987. height: 64px;
  988. font-size: 16px;
  989. .name {
  990. font-weight: bold;
  991. }
  992. .editor {
  993. display: -webkit-box;
  994. overflow: hidden;
  995. text-overflow: ellipsis;
  996. word-break: break-word;
  997. white-space: normal;
  998. -webkit-line-clamp: 2; /* 多行省略行数,按需调整 */
  999. -webkit-box-orient: vertical;
  1000. }
  1001. }
  1002. }
  1003. }
  1004. .courseware-tree {
  1005. display: flex;
  1006. flex: 1;
  1007. flex-direction: column;
  1008. row-gap: 8px;
  1009. padding: 12px;
  1010. margin-top: 12px;
  1011. overflow: auto;
  1012. .menu-item {
  1013. display: flex;
  1014. align-items: center;
  1015. &:not(.courseware) {
  1016. font-weight: bold;
  1017. }
  1018. &.courseware {
  1019. &:hover {
  1020. .name {
  1021. background-color: #f3f3f3;
  1022. }
  1023. }
  1024. }
  1025. .svg-icon {
  1026. margin-left: 4px;
  1027. &.my-edit-task {
  1028. color: $right-color;
  1029. }
  1030. }
  1031. .name {
  1032. flex: 1;
  1033. padding: 4px 8px 4px 4px;
  1034. border-radius: 4px;
  1035. }
  1036. &.active {
  1037. .name {
  1038. font-weight: bold;
  1039. color: #4095e5;
  1040. }
  1041. }
  1042. }
  1043. }
  1044. }
  1045. .sidebar {
  1046. position: relative;
  1047. display: flex;
  1048. width: $sidebar-width;
  1049. .toolbar {
  1050. display: flex;
  1051. flex-direction: column;
  1052. align-items: center;
  1053. width: 60px;
  1054. height: 100%;
  1055. background-color: rgba(247, 248, 250, 100%);
  1056. img {
  1057. cursor: pointer;
  1058. }
  1059. &-special {
  1060. display: flex;
  1061. flex-direction: column;
  1062. row-gap: 16px;
  1063. margin-bottom: 24px;
  1064. }
  1065. &-list {
  1066. display: flex;
  1067. flex-direction: column;
  1068. row-gap: 16px;
  1069. align-items: center;
  1070. width: 100%;
  1071. .sidebar-item {
  1072. width: 100%;
  1073. text-align: center;
  1074. .sidebar-icon {
  1075. width: 36px;
  1076. height: 36px;
  1077. cursor: pointer;
  1078. }
  1079. &.active {
  1080. background-color: #4095e5;
  1081. }
  1082. }
  1083. }
  1084. }
  1085. .content {
  1086. flex: 1;
  1087. background-color: #fff;
  1088. :deep .el-drawer {
  1089. width: 240px !important;
  1090. border: 1px solid #e5e5e5;
  1091. transition: none !important;
  1092. animation: none !important;
  1093. .el-drawer__body {
  1094. height: calc(100vh - 200px);
  1095. overflow-y: auto;
  1096. h5 {
  1097. padding: 0 5px;
  1098. margin: 0;
  1099. font-size: 18px;
  1100. line-height: 40px;
  1101. background: #f2f3f5;
  1102. }
  1103. .scroll-container {
  1104. display: flex;
  1105. flex-direction: column;
  1106. row-gap: 8px;
  1107. margin: 6px;
  1108. .list-item {
  1109. display: flex;
  1110. align-items: center;
  1111. cursor: pointer;
  1112. border: 1px solid #ccc;
  1113. border-radius: 8px;
  1114. :deep .el-slider {
  1115. .el-slider__runway {
  1116. background-color: #eee;
  1117. }
  1118. }
  1119. .el-image {
  1120. display: flex;
  1121. width: 100%;
  1122. min-width: 100%;
  1123. height: 90px;
  1124. background-color: #ccc;
  1125. border-radius: 8px;
  1126. }
  1127. .video-play {
  1128. width: 100%;
  1129. min-width: 100%;
  1130. }
  1131. .text-box {
  1132. word-break: break-word;
  1133. }
  1134. }
  1135. }
  1136. }
  1137. p {
  1138. color: #999;
  1139. text-align: center;
  1140. }
  1141. }
  1142. }
  1143. .back-top {
  1144. position: absolute;
  1145. bottom: 0;
  1146. left: 0;
  1147. display: flex;
  1148. place-content: center center;
  1149. align-items: center;
  1150. width: 60px;
  1151. height: 60px;
  1152. cursor: pointer;
  1153. }
  1154. }
  1155. }
  1156. }
  1157. :deep .scroll-container .audio-wrapper .audio-middle {
  1158. width: 210px !important;
  1159. padding: 6px 8px !important;
  1160. border: none;
  1161. border-radius: 8px;
  1162. .audio-name {
  1163. text-align: left;
  1164. }
  1165. .slider-area {
  1166. column-gap: 8px !important;
  1167. }
  1168. :deep .remark-dialog {
  1169. .el-dialog__body {
  1170. padding: 5px 20px;
  1171. }
  1172. }
  1173. :deep .audit-dialog {
  1174. .el-dialog__body {
  1175. height: calc(100vh - 260px);
  1176. padding: 5px 20px;
  1177. }
  1178. .mind-map-container .mind-map {
  1179. height: calc(100vh - 310px);
  1180. }
  1181. }
  1182. }
  1183. </style>
  1184. <style lang="scss">
  1185. .tox-tinymce-aux {
  1186. z-index: 9999 !important;
  1187. }
  1188. </style>