index.vue 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924
  1. <template>
  2. <div class="common-preview">
  3. <div class="common-preview__header">
  4. <div class="menu-container">
  5. {{ courseware_info.book_name }}
  6. </div>
  7. <div class="courseware">
  8. <span class="name-path">{{ courseware_info.name_path }}</span>
  9. <span class="flow-nodename">{{ courseware_info.cur_audit_flow_node_name }}</span>
  10. <slot name="middle" :courseware="courseware_info"></slot>
  11. <div class="group">
  12. <el-checkbox v-model="isShowGroup">显示分组</el-checkbox>
  13. <el-checkbox v-model="groupShowAll">分组显示全部</el-checkbox>
  14. <el-checkbox v-model="isJudgeCorrect">判断对错</el-checkbox>
  15. </div>
  16. <span class="link">
  17. <el-select v-model="lang" placeholder="请选择语言" size="mini" class="lang-select">
  18. <el-option v-for="item in langList" :key="item.type" :label="item.name" :value="item.type" />
  19. </el-select>
  20. </span>
  21. <span class="link">
  22. <el-checkbox v-model="chinese" true-label="zh-Hant" false-label="zh-Hans">繁体</el-checkbox>
  23. </span>
  24. <span class="link">
  25. <el-checkbox v-model="showPinYin" true-label="true" false-label="false">拼音</el-checkbox>
  26. </span>
  27. <div class="operator">
  28. <slot name="operator" :courseware="courseware_info"></slot>
  29. </div>
  30. </div>
  31. </div>
  32. <div class="audit-content">
  33. <!-- 左侧菜单栏 -->
  34. <aside v-if="navigationShow" class="left-menu">
  35. <div class="courseware-info">
  36. <div class="cover-image">
  37. <img v-if="project.cover_image_file_url.length > 0" :src="project.cover_image_file_url" alt="cover-image" />
  38. </div>
  39. <div class="info-content">
  40. <div class="catalogue-icon" @click="toggleNavigationShow">
  41. <SvgIcon icon-class="catalogue" size="54" />
  42. </div>
  43. <div class="courseware">
  44. <div class="name nowrap-ellipsis" :title="courseware_info.book_name">
  45. {{ courseware_info.book_name }}
  46. </div>
  47. <div class="editor" :title="project.editor">
  48. {{ project.editor }}
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. <!-- 教材章节树 -->
  54. <div class="courseware-tree">
  55. <div
  56. v-for="{ id: nodeId, name, deep, is_leaf_chapter } in node_list"
  57. :key="nodeId"
  58. :class="['menu-item', { active: curSelectId === nodeId }, { courseware: isTrue(is_leaf_chapter) }]"
  59. :style="computedNameStyle(deep, isTrue(is_leaf_chapter))"
  60. @click="selectChapterNode(nodeId, isTrue(is_leaf_chapter))"
  61. >
  62. <span class="name nowrap-ellipsis" :title="name">
  63. {{ name }}
  64. </span>
  65. </div>
  66. </div>
  67. </aside>
  68. <div
  69. ref="previewMain"
  70. class="main-container"
  71. :style="{ paddingLeft: navigationShow ? '15px' : '315px', paddingRight: sidebarShow ? '15px' : '315px' }"
  72. >
  73. <!-- 左侧菜单栏 - 收缩 -->
  74. <div v-if="!navigationShow && !isFullScreen" class="catalogue-bar" @click="toggleNavigationShow">
  75. <SvgIcon icon-class="catalogue" size="54" />
  76. </div>
  77. <main :class="['preview-main']">
  78. <div class="preview-left"></div>
  79. <CoursewarePreview
  80. v-if="courseware_info.book_name"
  81. ref="courserware"
  82. :is-show-group="isShowGroup"
  83. :group-show-all="groupShowAll"
  84. :group-row-list="content_group_row_list"
  85. :data="data"
  86. :courseware-id="curSelectId"
  87. :component-list="component_list"
  88. :background="background"
  89. :can-remark="isTrue(courseware_info.is_my_audit_task) && isTrue(courseware_info.is_can_add_audit_remark)"
  90. :show-remark="false"
  91. :project="project"
  92. :component-remark-obj="remark_list_obj"
  93. @computeScroll="computeScroll"
  94. @editNote="handEditNote"
  95. @saveCollect="saveCollect"
  96. />
  97. <div class="preview-right"></div>
  98. </main>
  99. <!-- 右侧菜单栏 - 收缩 -->
  100. <aside v-if="!sidebarShow && !isFullScreen" class="sidebar-bar">
  101. <aside class="toolbar">
  102. <div class="toolbar-special">
  103. <img :src="require('@/assets/icon/sidebar-fullscreen.png')" alt="全屏" @click="fullScreen" />
  104. <img :src="require('@/assets/icon/sidebar-toolkit.png')" alt="工具箱" />
  105. <img :src="require(`@/assets/icon/arrow-down.png`)" alt="伸缩" @click="toggleSidebarShow" />
  106. </div>
  107. </aside>
  108. </aside>
  109. </div>
  110. <div v-if="!sidebarShow" class="back-top" @click="backTop">
  111. <img :src="require(`@/assets/icon/back-top.png`)" alt="返回顶部" />
  112. </div>
  113. <!-- 右侧工具栏 -->
  114. <aside v-if="sidebarShow" ref="sidebarMenu" class="sidebar">
  115. <aside class="toolbar">
  116. <div class="toolbar-special">
  117. <img :src="require('@/assets/icon/sidebar-fullscreen.png')" alt="全屏" @click="fullScreen" />
  118. <img :src="require('@/assets/icon/sidebar-toolkit.png')" alt="工具箱" />
  119. </div>
  120. <div v-if="sidebarShow" class="toolbar-list">
  121. <div
  122. v-for="{ icon, title, handle, param, children } in sidebarIconList"
  123. :key="icon"
  124. :class="['sidebar-item', { active: curToolbarIcon === icon }]"
  125. :title="title"
  126. @click="handleSidebarClick(handle, param, icon, children)"
  127. >
  128. <div
  129. class="sidebar-icon icon-mask"
  130. :style="{
  131. backgroundColor: curToolbarIcon === icon ? '#fff' : '#1E2129',
  132. maskImage: `url(${require(`@/assets/icon/sidebar-${icon}.svg`)})`,
  133. }"
  134. ></div>
  135. </div>
  136. </div>
  137. <div class="adjustable" @click="toggleSidebarShow">
  138. <img :src="require(`@/assets/icon/arrow-up.png`)" alt="伸缩" />
  139. </div>
  140. </aside>
  141. <div class="content">
  142. <div v-if="curToolbarIcon === 'search'" class="resource_box">
  143. <h5>{{ drawerTitle }}</h5>
  144. <div style="height: 40px"></div>
  145. <el-row :gutter="10" style="margin: 5px">
  146. <el-col :span="16">
  147. <el-input v-model="searchContent" placeholder="请输入文本内容" clearable />
  148. </el-col>
  149. <el-col :span="4">
  150. <el-button type="primary" @click="querySearchList"> 查询 </el-button>
  151. </el-col>
  152. </el-row>
  153. <div>
  154. <el-table :data="searchList" :show-header="false">
  155. <!-- <el-table-column prop="courseware_name" label="课件" />
  156. <el-table-column prop="component_type" label="组件" /> -->
  157. <el-table-column>
  158. <template #default="{ row }">
  159. {{ row.courseware_name + ' / ' + row.component_type_name }}
  160. </template>
  161. </el-table-column>
  162. <el-table-column label="" width="50">
  163. <template #default="{ row }">
  164. <el-link type="primary" @click="handleLocation(row, 0)">定位</el-link>
  165. </template>
  166. </el-table-column>
  167. </el-table>
  168. </div>
  169. </div>
  170. <!-- <div v-if="curToolbarIcon === 'totalResources'" class="resource_box"></div> -->
  171. <div v-if="['image', 'audio', 'video', 'text'].includes(twoCurToolbarIcon)" class="resource_box">
  172. <div class="source-toolbar-list">
  173. <div
  174. v-for="{ icon, title, handle, param } in twoSidebarList"
  175. :key="icon"
  176. :class="['sidebar-item', { active: twoCurToolbarIcon === icon }]"
  177. :title="title"
  178. @click="handleSidebarClick(handle, param, icon, '', 2)"
  179. >
  180. <div
  181. class="sidebar-icon icon-mask"
  182. :style="{
  183. backgroundColor: twoCurToolbarIcon === icon ? '#fff' : '#1E2129',
  184. maskImage: `url(${require(`@/assets/icon/sidebar-${icon}.svg`)})`,
  185. }"
  186. ></div>
  187. </div>
  188. </div>
  189. <div style="height: 40px"></div>
  190. <el-collapse v-model="activeBookChapterId" accordion @change="multimediaHandleChange">
  191. <el-collapse-item
  192. v-for="chapter in bookChapterList"
  193. :key="chapter.id"
  194. :name="chapter.id"
  195. :title="chapter.name"
  196. >
  197. <!-- 加载状态 -->
  198. <div v-if="multimediaLoadingStates" class="loading-text">加载中...</div>
  199. <!-- 加载完成显示数据 -->
  200. <div v-else-if="chapter.data">
  201. <ul
  202. :class="parseInt(drawerType) == 5 ? 'scroll-container file-list' : 'scroll-container'"
  203. infinite-scroll-disabled="disabled"
  204. :infinite-scroll-immediate="false"
  205. >
  206. <li v-for="(item, index) in chapter.data" :key="`${chapter.id}-${index}`" class="list-item">
  207. <template v-if="parseInt(drawerType) === 0">
  208. <el-image v-if="shouldMediaShowItem(chapter, item)" :src="item.file_url" fit="contain" />
  209. </template>
  210. <template v-else-if="parseInt(drawerType) === 1">
  211. <AudioPlay
  212. v-if="shouldMediaShowItem(chapter, item)"
  213. view-size="middle"
  214. :file-id="item.file_id"
  215. :file-name="item.file_name.slice(0, item.file_name.lastIndexOf('.'))"
  216. :show-slider="true"
  217. :audio-index="index"
  218. />
  219. </template>
  220. <template v-else-if="parseInt(drawerType) === 2">
  221. <VideoPlay
  222. v-if="shouldMediaShowItem(chapter, item)"
  223. view-size="small"
  224. :file-id="item.file_id"
  225. :video-index="index"
  226. />
  227. </template>
  228. <template v-else-if="parseInt(drawerType) === 3"> </template>
  229. <template v-else-if="parseInt(drawerType) === 4"> </template>
  230. <template v-else-if="parseInt(drawerType) === 5">
  231. <div class="file-name">
  232. <el-link>
  233. <span @click="openFile(item)">
  234. <SvgIcon icon-class="file" size="24" />
  235. <p>
  236. <span>{{ item.file_name }}</span>
  237. </p>
  238. </span>
  239. </el-link>
  240. </div>
  241. </template>
  242. <!-- 资源底部的操作 -->
  243. <div class="file-handle-info">
  244. <span v-if="![1, 5].includes(parseInt(drawerType))" class="word">{{ item.file_name }}</span>
  245. <div class="mark">
  246. <span></span>
  247. <el-link type="primary" class="el-icon-place linkLocation" @click="handleLocation(item, 0)" />
  248. </div>
  249. </div>
  250. </li>
  251. </ul>
  252. </div>
  253. <!-- 加载失败或未加载 -->
  254. <div v-else class="error-text">没有资源</div>
  255. </el-collapse-item>
  256. </el-collapse>
  257. </div>
  258. <div v-if="curToolbarIcon === 'collect'" class="resource_box">
  259. <h5>{{ drawerTitle }}</h5>
  260. <div style="height: 40px"></div>
  261. <ul v-if="allCottectList.length > 0" class="card-box">
  262. <li v-for="item in allCottectList" :key="item.id">
  263. <span class="el-icon-notebook-2"> 原文</span>
  264. <span>{{ item.text }}</span>
  265. <div>
  266. <el-button type="text" class="el-icon-delete" @click="handDelCollect(item.id)"> 删除</el-button>
  267. <el-divider direction="vertical" />
  268. <el-button type="text" class="el-icon-place" @click="handleLocation(item, 12)"> 定位</el-button>
  269. </div>
  270. </li>
  271. </ul>
  272. </div>
  273. <div v-if="curToolbarIcon === 'note'" class="resource_box">
  274. <h5>{{ drawerTitle }}</h5>
  275. <div style="height: 40px"></div>
  276. <ul v-if="allNoteList.length > 0" class="card-box">
  277. <li v-for="item in allNoteList" :key="item.id">
  278. <span class="el-icon-notebook-2"> 原文</span>
  279. <span>{{ item.text }}</span>
  280. <el-divider class="mt10" />
  281. <span v-html="item.note"></span>
  282. <div>
  283. <el-button type="text" class="el-icon-edit" @click="handEditNote(item)"> 编辑</el-button>
  284. <el-divider direction="vertical" />
  285. <el-button type="text" class="el-icon-delete" @click="handDelNote(item.id)"> 删除</el-button>
  286. <el-divider direction="vertical" />
  287. <el-button type="text" class="el-icon-place" @click="handleLocation(item, 1)"> 定位</el-button>
  288. </div>
  289. </li>
  290. </ul>
  291. </div>
  292. <template v-if="curToolbarIcon === 'audit'">
  293. <AuditRemark :remark-list="remark_list" :is-audit="isShowAudit" @deleteRemarks="deleteRemarks" />
  294. </template>
  295. </div>
  296. <div class="back-top" @click="backTop">
  297. <img :src="require(`@/assets/icon/back-top.png`)" alt="返回顶部" />
  298. </div>
  299. </aside>
  300. </div>
  301. <el-dialog title="" :visible="visibleMindMap" width="1100px" class="audit-dialog" @close="dialogClose('MindMap')">
  302. <MindMap
  303. v-if="isChildDataLoad"
  304. ref="mindMapRef"
  305. :project-id="projectId"
  306. :mind-map-json-data="mindMapJsonData"
  307. @child-click="handleNodeClick"
  308. />
  309. </el-dialog>
  310. <el-dialog
  311. title=""
  312. :visible="visibleVisNetwork"
  313. width="1100px"
  314. class="audit-dialog"
  315. :close-on-click-modal="false"
  316. @close="dialogClose('VisNetwork')"
  317. >
  318. <VisNetwork ref="visNetworkRef" :book-id="projectId" @child-click="handleNodeClick" />
  319. </el-dialog>
  320. <ExplanatoryNoteDialog
  321. ref="explanatoryNote"
  322. :open.sync="editDialogOpen"
  323. :init-data="oldRichData"
  324. title-text="笔记"
  325. @confirm="saveNote"
  326. @cancel="delNote"
  327. />
  328. </div>
  329. </template>
  330. <script>
  331. import CoursewarePreview from '@/views/book/courseware/preview/CoursewarePreview.vue';
  332. import { isTrue } from '@/utils/validate';
  333. import MindMap from '@/components/MindMap.vue';
  334. import VideoPlay from '@/views/book/courseware/preview/components/common/VideoPlay.vue';
  335. import AudioPlay from '@/views/book/courseware/preview/components/common/AudioPlay.vue';
  336. import ExplanatoryNoteDialog from '@/components/ExplanatoryNoteDialog.vue';
  337. import VisNetwork from '@/components/VisNetwork.vue';
  338. import * as OpenCC from 'opencc-js';
  339. import { GetBookCoursewareInfo, GetCoursewareAuditRemarkList, GetProjectInfo } from '@/api/project';
  340. import {
  341. ContentGetCoursewareContent_View,
  342. ChapterGetBookChapterStructExpandList,
  343. GetBookBaseInfo,
  344. MangerGetBookMindMap,
  345. GetBookChapterStructExpandList,
  346. PageQueryBookResourceList,
  347. GetLanguageTypeList,
  348. GetBookUnifiedAttrib,
  349. GetMyNoteList,
  350. DeleteMyNote,
  351. AddMyNote,
  352. UpdateMyNote,
  353. AddMyCollect,
  354. GetMyCollectList,
  355. DeleteMyCollect,
  356. SearchBookContentText,
  357. } from '@/api/book';
  358. import { getLocalStore } from '@/utils/auth';
  359. import { toggleFullScreen } from '@/utils/common';
  360. export default {
  361. name: 'CommonPreview',
  362. components: {
  363. CoursewarePreview,
  364. MindMap,
  365. VideoPlay,
  366. AudioPlay,
  367. ExplanatoryNoteDialog,
  368. VisNetwork,
  369. },
  370. provide() {
  371. return {
  372. getLang: () => this.lang,
  373. getChinese: () => this.chinese,
  374. getShowPinYin: () => this.showPinYin,
  375. getLangList: () => this.langList,
  376. convertText: this.convertText,
  377. getProjectId: () => this.projectId,
  378. getSelectId: () => this.select_node,
  379. getTitleList: () => this.title_list,
  380. getPermissionControl: () => this.permissionControl,
  381. };
  382. },
  383. data() {
  384. const sidebarIconList = [
  385. { icon: 'search', title: '搜索', handle: 'getSearch', param: { type: '13' } },
  386. { icon: 'mindmap', title: '思维导图', handle: 'openMindMap', param: {} },
  387. { icon: 'knowledge', title: '知识图谱', handle: 'openVisNetwork', param: {} },
  388. {
  389. icon: 'totalResources',
  390. title: '总资源',
  391. handle: '',
  392. param: {},
  393. children: [
  394. { icon: 'audio', title: '音频', handle: 'openDrawer', param: { type: '1' } },
  395. { icon: 'image', title: '图片', handle: 'openDrawer', param: { type: '0' } },
  396. { icon: 'video', title: '视频', handle: 'openDrawer', param: { type: '2' } },
  397. { icon: 'text', title: '文本', handle: 'openDrawer', param: { type: '5' } },
  398. ],
  399. },
  400. { icon: 'collect', title: '收藏', handle: 'getCollect', param: { type: '11' } },
  401. { icon: 'note', title: '笔记', handle: 'getNote', param: { type: '12' } },
  402. { icon: 'translate', title: '翻译', handle: '', param: {} },
  403. { icon: 'setting', title: '设置', handle: '', param: {} },
  404. ];
  405. const book_id = getLocalStore('book_id') || '';
  406. return {
  407. projectId: book_id,
  408. select_node: this.id,
  409. courseware_info: {
  410. book_name: '',
  411. is_can_start_edit: 'false',
  412. is_can_submit_audit: 'false',
  413. is_can_audit_pass: 'false',
  414. is_can_audit_reject: 'false',
  415. is_can_add_audit_remark: 'false',
  416. is_can_finish_audit: 'false',
  417. is_can_request_shangjia_book: 'false',
  418. is_can_request_rollback_project: 'false',
  419. is_can_shangjia_book: 'false',
  420. is_can_rollback_project: 'false',
  421. },
  422. background: {
  423. background_image_url: '',
  424. background_position: {
  425. left: 0,
  426. top: 0,
  427. },
  428. },
  429. node_list: [],
  430. data: { row_list: [] },
  431. component_list: [],
  432. content_group_row_list: [],
  433. remark_list: [],
  434. remark_list_obj: {}, // 存放以组件为对象的数组
  435. searchList: [],
  436. searchContent: '',
  437. visible: false,
  438. remark_content: '',
  439. submit_loading: false,
  440. isTrue,
  441. menuPosition: {
  442. x: -1,
  443. y: -1,
  444. componentId: 'WHOLE',
  445. },
  446. curToolbarIcon: this.isShowAudit ? 'audit' : '',
  447. sidebarIconList,
  448. twoSidebarList: [],
  449. twoCurToolbarIcon: '',
  450. visibleMindMap: false,
  451. visibleVisNetwork: false,
  452. isChildDataLoad: false,
  453. mindMapJsonData: {}, // 思维导图json数据
  454. drawerType: '', // 抽屉类型
  455. drawerStyle: {
  456. top: '0',
  457. height: '0',
  458. right: '0',
  459. },
  460. page_capacity: 10,
  461. cur_page: 1,
  462. file_list: [],
  463. total_count: 0,
  464. loading: false,
  465. lastLoadTime: 0,
  466. minLoadInterval: 3 * 1000,
  467. isShowGroup: false,
  468. groupShowAll: true,
  469. opencc: OpenCC.Converter({ from: 'cn', to: 'tw' }),
  470. langList: [],
  471. lang: 'ZH',
  472. chinese: 'zh-Hans',
  473. showPinYin: 'false',
  474. isJudgeCorrect: false,
  475. unified_attrib: {},
  476. curSelectId: this.id,
  477. navigationShow: true,
  478. sidebarShow: true,
  479. project: {
  480. editor: '', // 作者
  481. cover_image_file_id: null, // 封面图片ID
  482. cover_image_file_url: '', // 封面图片URL
  483. },
  484. allNoteList: [],
  485. editDialogOpen: false,
  486. oldRichData: {},
  487. newSelectedInfo: null,
  488. allCottectList: [],
  489. bookChapterList: [],
  490. book_id: '',
  491. activeBookChapterId: '',
  492. multimediaLoadingStates: true,
  493. isFullScreen: false, // 是否全屏状态
  494. title_list: [],
  495. // 模拟答题权限控制
  496. permissionControl: {
  497. can_answer: true, // 可作答
  498. can_judge_correct: true, // 可判断对错(客观题)
  499. can_show_answer: true, // 可查看答案
  500. can_correct: false, // 可批改
  501. can_check_correct: false, // 可查看批改
  502. },
  503. };
  504. },
  505. computed: {
  506. disabled() {
  507. const result = this.loading || this.noMore;
  508. return result;
  509. },
  510. noMore() {
  511. const result = this.file_list.length >= this.total_count;
  512. return result;
  513. },
  514. drawerTitle() {
  515. const titleMap = {
  516. 0: '图片资源',
  517. 1: '音频资源',
  518. 2: '视频资源',
  519. 5: '文本资源',
  520. 11: '收藏列表',
  521. 12: '笔记列表',
  522. 13: '搜索结果',
  523. };
  524. return titleMap[this.drawerType] || '资源列表';
  525. },
  526. shouldMediaShowItem() {
  527. return (chapter, item) => {
  528. return this.activeBookChapterId === chapter.id && item && item.file_id;
  529. };
  530. },
  531. },
  532. watch: {
  533. isJudgeCorrect() {
  534. this.simulateAnswer();
  535. },
  536. curSelectId() {
  537. if (this.curToolbarIcon === 'note') {
  538. this.getNote();
  539. } else if (this.curToolbarIcon === 'collect') {
  540. this.getCollect();
  541. }
  542. },
  543. },
  544. mounted() {
  545. this.calcDrawerPosition();
  546. },
  547. created() {
  548. this.getBookBaseInfo();
  549. this.getBookChapterStructExpandList();
  550. this.getBookUnifiedAttr();
  551. this.getProjectInfo();
  552. // 监听全屏事件
  553. document.addEventListener('fullscreenchange', () => {
  554. if (document.fullscreenElement) {
  555. this.isFullScreen = true;
  556. } else {
  557. this.isFullScreen = false;
  558. }
  559. });
  560. },
  561. beforeDestroy() {
  562. document.removeEventListener('fullscreenchange', () => {});
  563. },
  564. methods: {
  565. selectFirstLeafNode() {
  566. if (!this.node_list || this.node_list.length === 0) return;
  567. let node = this.node_list.find((x) => this.isTrue(x.is_leaf_chapter));
  568. if (!node) return;
  569. this.selectChapterNode(node.id, true);
  570. },
  571. getBookBaseInfo() {
  572. GetBookBaseInfo({ id: this.projectId }).then(({ book_info }) => {
  573. this.courseware_info = { ...this.courseware_info, ...book_info, book_name: book_info.name };
  574. if (book_info.cover_image_file_id) {
  575. this.project.cover_image_file_url = book_info.cover_image_file_url;
  576. }
  577. if (book_info.editor) {
  578. this.project.editor = book_info.editor;
  579. }
  580. if (book_info.cover_image_file_url) {
  581. this.project.cover_image_file_url = book_info.cover_image_file_url;
  582. }
  583. });
  584. },
  585. getProjectInfo() {
  586. GetProjectInfo({ id: this.projectId }).then(({ project_info }) => {
  587. if (project_info.cover_image_file_url) {
  588. this.project = project_info;
  589. }
  590. });
  591. },
  592. /**
  593. * 得到教材课件信息
  594. * @param {string} id - 课件ID
  595. */
  596. getBookCoursewareInfo(id) {
  597. GetBookCoursewareInfo({ id, is_contain_producer: 'true', is_contain_auditor: 'true' }).then(
  598. ({ courseware_info }) => {
  599. this.courseware_info = { ...this.courseware_info, ...courseware_info };
  600. this.getLangList();
  601. },
  602. );
  603. },
  604. /**
  605. * 得到课件内容(展示内容)
  606. * @param {string} id - 课件ID
  607. */
  608. getCoursewareComponentContent_View(id) {
  609. ContentGetCoursewareContent_View({ id }).then(
  610. ({ content, component_list, content_group_row_list, title_list }) => {
  611. if (title_list) this.title_list = title_list || [];
  612. if (content) {
  613. const _content = JSON.parse(content);
  614. this.data = _content;
  615. this.background = {
  616. background_image_url: _content.background_image_url,
  617. background_position: _content.background_position,
  618. };
  619. } else {
  620. this.data = { row_list: [] };
  621. }
  622. if (component_list) this.component_list = component_list;
  623. this.component_list.forEach((x) => {
  624. if (x.component_type === 'audio') {
  625. let _c = JSON.parse(x.content);
  626. let p = _c.property || {};
  627. if (!p.file_name_display_mode) p.file_name_display_mode = 'true';
  628. if (p.view_method === 'independent' && !p.style_mode) {
  629. p.style_mode = 'middle';
  630. }
  631. if (!p.style_mode) p.style_mode = 'big';
  632. if (p.view_method === 'icon') {
  633. p.file_name_display_mode = 'false';
  634. p.view_method = 'independent';
  635. p.style_mode = 'small';
  636. }
  637. x.content = JSON.stringify(_c);
  638. } else if (x.component_type === 'richtext') {
  639. let _c = JSON.parse(x.content);
  640. let p = _c.property || {};
  641. let lev = Number(p.title_style_level);
  642. if (p.is_title !== 'true' || lev < 1 || !_c.content) return;
  643. let style = title_list.find((y) => y.level === lev) || {};
  644. if (style && style.style) {
  645. style = JSON.parse(style.style);
  646. let c_text = _c.content;
  647. const parser = new DOMParser();
  648. const doc = parser.parseFromString(c_text, 'text/html');
  649. const body = doc.body;
  650. const pElements = body.querySelectorAll('p');
  651. this.processHtmlString(pElements, style);
  652. _c.content = body.innerHTML;
  653. x.content = JSON.stringify(_c);
  654. }
  655. }
  656. });
  657. if (content_group_row_list) this.content_group_row_list = JSON.parse(content_group_row_list) || [];
  658. },
  659. );
  660. },
  661. processHtmlString(pElements, styleConfig, isClear) {
  662. pElements.forEach((pElement) => {
  663. if (isClear) {
  664. pElement.removeAttribute('style');
  665. } else {
  666. const style = pElement.style;
  667. if (styleConfig.font) style.fontFamily = styleConfig.font;
  668. if (styleConfig.font_size) style.fontSize = styleConfig.font_size;
  669. if (styleConfig.text_color) style.color = styleConfig.text_color;
  670. style.fontWeight = styleConfig.bold === 'true' ? 'bold' : 'normal';
  671. style.fontStyle = styleConfig.italic === 'true' ? 'italic' : 'normal';
  672. if (styleConfig.indent || styleConfig.indent === 0) style.marginLeft = `${styleConfig.indent}px`;
  673. }
  674. });
  675. },
  676. getLangList() {
  677. GetLanguageTypeList({ book_id: this.courseware_info.book_id, is_contain_zh: 'true' }).then(
  678. ({ language_type_list }) => {
  679. this.langList = language_type_list;
  680. },
  681. );
  682. },
  683. /**
  684. * 得到教材章节结构展开列表
  685. */
  686. getBookChapterStructExpandList() {
  687. ChapterGetBookChapterStructExpandList({
  688. book_id: this.projectId,
  689. node_deep_mode: 0,
  690. is_contain_producer: 'true',
  691. is_contain_auditor: 'true',
  692. }).then(({ node_list }) => {
  693. this.node_list = node_list;
  694. });
  695. },
  696. getBookUnifiedAttr() {
  697. GetBookUnifiedAttrib({ book_id: this.projectId }).then(({ content }) => {
  698. if (content) {
  699. this.unified_attrib = JSON.parse(content);
  700. }
  701. });
  702. },
  703. /**
  704. * 选择节点
  705. * @param {string} nodeId - 节点ID
  706. */
  707. selectNode(nodeId) {
  708. this.getCoursewareComponentContent_View(nodeId);
  709. this.getBookCoursewareInfo(nodeId);
  710. this.getCoursewareAuditRemarkList(nodeId);
  711. this.select_node = nodeId;
  712. },
  713. // 审校批注列表
  714. getCoursewareAuditRemarkList(id) {
  715. this.remark_list = [];
  716. let remarkListObj = {};
  717. GetCoursewareAuditRemarkList({
  718. courseware_id: id,
  719. }).then(({ remark_list }) => {
  720. this.remark_list = remark_list;
  721. if (!remark_list) return;
  722. remarkListObj = remark_list.reduce((acc, item) => {
  723. if (!acc[item.component_id]) {
  724. acc[item.component_id] = [];
  725. }
  726. acc[item.component_id].push(item);
  727. return acc;
  728. }, {});
  729. this.remark_list_obj = remarkListObj;
  730. });
  731. },
  732. dialogClose(type) {
  733. this[`visible${type}`] = false;
  734. },
  735. // 计算previewMain滑动距离
  736. computeScroll() {
  737. this.$refs.courserware.handleResult(
  738. this.$refs.previewMain.scrollTop,
  739. this.$refs.previewMain.scrollLeft,
  740. this.select_node,
  741. );
  742. },
  743. /**
  744. * 处理侧边栏图标点击事件
  745. * @param {string} handle - 处理函数名
  746. * @param {any} param - 处理函数参数
  747. * @param {string} icon - 图标名称
  748. */
  749. handleSidebarClick(handle, param, icon, children, barLevel) {
  750. if (typeof handle === 'string' && handle && typeof this[handle] === 'function') {
  751. this[handle](param);
  752. }
  753. if (barLevel === 2) {
  754. this.twoCurToolbarIcon = icon;
  755. } else {
  756. this.curToolbarIcon = icon;
  757. this.twoCurToolbarIcon = '';
  758. }
  759. if (children && children.length > 0 && Array.isArray(children)) {
  760. this.twoSidebarList = children;
  761. this.twoCurToolbarIcon = children[0].icon;
  762. this.openDrawer(children[0].param);
  763. }
  764. },
  765. /**
  766. * 打开知识图谱
  767. */
  768. openMindMap() {
  769. MangerGetBookMindMap({ book_id: this.projectId }).then(({ content }) => {
  770. if (content) {
  771. this.mindMapJsonData = JSON.parse(content);
  772. this.isChildDataLoad = true;
  773. }
  774. });
  775. this.visibleMindMap = true;
  776. },
  777. async handleNodeClick(data) {
  778. let [nodeId, componentId] = data.split('#');
  779. if (nodeId) this.selectNode(nodeId);
  780. if (componentId) {
  781. let node = await this.$refs.courserware.findChildComponentByKey(componentId);
  782. if (node) {
  783. await this.$nextTick();
  784. this.$refs.previewMain.scrollTo({
  785. top: node.$el.offsetTop - 50,
  786. left: node.$el.offsetLeft - 50,
  787. behavior: 'smooth',
  788. });
  789. }
  790. }
  791. this.visibleMindMap = false;
  792. this.visibleVisNetwork = false;
  793. },
  794. async openVisNetwork() {
  795. this.visibleVisNetwork = true;
  796. },
  797. // 计算抽屉滑出位置
  798. calcDrawerPosition() {
  799. const menu = this.$refs.sidebarMenu;
  800. if (menu) {
  801. const rect = menu.getBoundingClientRect();
  802. this.drawerStyle = {
  803. top: `${rect.top}px`,
  804. height: `${rect.height}px`,
  805. left: `${rect.right - 240}px`,
  806. };
  807. }
  808. },
  809. /**
  810. * 打开抽屉并初始化加载
  811. * @param {Object} param - 抽屉参数
  812. * @param {string} param.type - 抽屉类型(0: 图片, 1: 音频, 2: 视频, 3:H5 游戏,4:3D 模型,5:文本)
  813. */
  814. openDrawer({ type }) {
  815. if (this.drawerType === type) {
  816. this.drawerType = '';
  817. return;
  818. }
  819. // 重置所有加载状态
  820. this.activeBookChapterId = '';
  821. this.resetLoadState();
  822. this.drawerType = type;
  823. this.$nextTick(() => {
  824. // 确保DOM更新后触发加载
  825. // this.loadMore();
  826. this.loadBookChapterStructExpandList();
  827. });
  828. },
  829. openAudit() {
  830. this.drawerType = '';
  831. },
  832. resetLoadState() {
  833. this.cur_page = 1;
  834. this.file_list = [];
  835. this.total_count = 0;
  836. this.loading = false;
  837. this.lastLoadTime = 0; // 重置时间戳,允许立即加载
  838. this.loadCount = 0;
  839. },
  840. /**
  841. * 加载章节
  842. */
  843. async loadBookChapterStructExpandList() {
  844. const params = {
  845. book_id: this.projectId,
  846. node_deep_mode: 3, // 节点深度模式 0【全部】,1【只查询章节】2【只查询非叶子章节】3【只查询第一层】
  847. is_contain_root_node: 'false', // 是否包含根节点(把教材作为根节点)
  848. is_contain_producer: 'false', // 是否包含制作人信息
  849. is_contain_auditor: 'false', // 是否包含审核人信息
  850. };
  851. await GetBookChapterStructExpandList(params).then(({ node_list }) => {
  852. this.bookChapterList = node_list || [];
  853. });
  854. },
  855. /**
  856. * 加载章节下的资源
  857. */
  858. async loadmultimediaList() {
  859. const params = {
  860. page_capacity: this.page_capacity,
  861. cur_page: this.cur_page,
  862. book_id: this.projectId,
  863. book_chapter_node_id: this.activeBookChapterId,
  864. type: parseInt(this.drawerType),
  865. scope: 0,
  866. };
  867. await PageQueryBookResourceList(params)
  868. .then(({ total_count, resource_list }) => {
  869. this.total_count = total_count;
  870. this.file_list = resource_list || [];
  871. })
  872. .finally(() => {
  873. this.loading = false;
  874. });
  875. },
  876. /**
  877. * 点击章节,切换数据
  878. */
  879. async multimediaHandleChange() {
  880. const item = this.bookChapterList.find((item) => item.id === this.activeBookChapterId);
  881. if (item) {
  882. this.multimediaLoadingStates = true;
  883. if (!item.data && !item.error) {
  884. await this.loadmultimediaList();
  885. let tmpList = this.file_list && this.file_list.length > 0 ? [...this.file_list] : null;
  886. this.$set(item, 'data', tmpList);
  887. this.multimediaLoadingStates = false;
  888. } else {
  889. this.multimediaLoadingStates = false;
  890. }
  891. }
  892. },
  893. // 加载更多数据
  894. async loadMore() {
  895. const now = Date.now();
  896. // 只有当lastLoadTime不为0(不是第一次)且时间间隔太短时才return
  897. if (this.lastLoadTime > 0 && now - this.lastLoadTime < this.minLoadInterval) {
  898. return;
  899. }
  900. if (this.disabled || this.loading) {
  901. if (this.lastLoadTime > 0) {
  902. return;
  903. }
  904. }
  905. this.loading = true;
  906. const params = {
  907. page_capacity: this.page_capacity,
  908. cur_page: this.cur_page,
  909. book_id: this.projectId,
  910. book_chapter_node_id: this.activeBookChapterId,
  911. type: parseInt(this.drawerType),
  912. };
  913. await PageQueryBookResourceList(params)
  914. .then(({ total_count, resource_list }) => {
  915. this.total_count = total_count;
  916. // 记录加载前的滚动高度
  917. const scrollContainer = this.$el.querySelector('.scroll-container');
  918. const isAtBottom = this.isScrollAtBottom(scrollContainer);
  919. this.file_list = this.cur_page === 1 ? resource_list : [...this.file_list, ...resource_list];
  920. if (!resource_list || resource_list.length === 0) {
  921. return;
  922. }
  923. this.cur_page += 1;
  924. // 只有当前已经在底部时才微调滚动位置
  925. if (isAtBottom) {
  926. this.$nextTick(() => {
  927. // 轻微向上滚动,创造滚动空间
  928. scrollContainer.scrollTop -= 5;
  929. });
  930. }
  931. })
  932. .finally(() => {
  933. this.loading = false;
  934. this.lastLoadTime = now;
  935. });
  936. },
  937. isScrollAtBottom(container) {
  938. if (!container) return false;
  939. return container.scrollHeight - container.scrollTop <= container.clientHeight + 5;
  940. },
  941. async handleFileClick(courseware_id, component_id) {
  942. if (courseware_id) this.selectNode(courseware_id);
  943. if (component_id) {
  944. let node = await this.$refs.courserware.findChildComponentByKey(component_id);
  945. if (node) {
  946. await this.$nextTick();
  947. this.$refs.previewMain.scrollTo({
  948. top: node.offsetTop - 50,
  949. left: node.offsetLeft - 50,
  950. behavior: 'smooth',
  951. });
  952. }
  953. }
  954. },
  955. /**
  956. * 文本转换
  957. * @param {string} text - 要转换的文本
  958. * @returns {string} - 转换后的文本
  959. */
  960. convertText(text) {
  961. if (this.chinese === 'zh-Hant' && this.opencc) {
  962. try {
  963. if (/<[a-z][\s\S]*>/i.test(text)) {
  964. return this.convertHtmlPreserveAttributes(text);
  965. }
  966. } catch (e) {
  967. return text;
  968. }
  969. return this.opencc(text);
  970. }
  971. return text;
  972. },
  973. /**
  974. * 使用OpenCC解析HTML并仅转换文本节点,保留属性(包括内联样式/font-family)保持不变。防止字体名称像“微软雅黑' 正在转换为'微軟雅黑'.
  975. */
  976. convertHtmlPreserveAttributes(html) {
  977. try {
  978. const parser = new DOMParser();
  979. const doc = parser.parseFromString(html, 'text/html');
  980. // 跳过这些标记内的转换
  981. const skipTags = new Set(['SCRIPT', 'STYLE']);
  982. const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_TEXT, null, false);
  983. let node = walker.nextNode();
  984. while (node) {
  985. const parent = node.parentNode;
  986. if (parent && !skipTags.has(parent.nodeName)) {
  987. const v = node.nodeValue;
  988. if (v && v.trim()) {
  989. node.nodeValue = this.opencc(v);
  990. }
  991. }
  992. node = walker.nextNode();
  993. }
  994. return doc.body.innerHTML;
  995. } catch (err) {
  996. try {
  997. return this.opencc(html);
  998. } catch (e) {
  999. return html;
  1000. }
  1001. }
  1002. },
  1003. /**
  1004. * 模拟答题
  1005. * @param {boolean} [disabled=true] - 是否禁用
  1006. */
  1007. simulateAnswer(disabled = true) {
  1008. this.$refs.courserware.simulateAnswer(this.isJudgeCorrect, false, disabled);
  1009. },
  1010. /**
  1011. * 选择节点
  1012. * @param {string} nodeId - 节点ID
  1013. * @param {boolean} isLeaf - 是否是叶子节点
  1014. */
  1015. selectChapterNode(nodeId, isLeaf) {
  1016. if (!isLeaf) return;
  1017. if (this.curSelectId === nodeId) return;
  1018. this.curSelectId = nodeId;
  1019. this.selectNode(nodeId);
  1020. },
  1021. /**
  1022. * 计算章节名称样式
  1023. * @param {number} deep - 节点深度
  1024. * @param {boolean} isLeaf - 是否是叶子节点
  1025. * @returns {Object} - 样式对象
  1026. */
  1027. computedNameStyle(deep, isLeaf) {
  1028. return {
  1029. 'padding-left': `${(deep - 1) * 8}px`,
  1030. cursor: isLeaf ? 'pointer' : 'auto',
  1031. };
  1032. },
  1033. /**
  1034. * 切换左侧导航栏显示与隐藏
  1035. */
  1036. toggleNavigationShow() {
  1037. this.navigationShow = !this.navigationShow;
  1038. },
  1039. /**
  1040. * 切换右侧工具栏显示与隐藏
  1041. */
  1042. toggleSidebarShow() {
  1043. this.sidebarShow = !this.sidebarShow;
  1044. },
  1045. backTop() {
  1046. this.$refs.previewMain.scrollTo({
  1047. top: 0,
  1048. left: 0,
  1049. behavior: 'smooth',
  1050. });
  1051. },
  1052. /**
  1053. * 定位到对应位置
  1054. * @param {Object} item - 位置对象
  1055. * @param {number} type - 定位类型(11: 笔记定位, 12: 收藏定位, 0: 资源定位)
  1056. */
  1057. handleLocation(item, type) {
  1058. if (type === 0) {
  1059. let did = `${item.courseware_id}#${item.component_id}`;
  1060. this.handleNodeClick(did);
  1061. this.curSelectId = item.courseware_id;
  1062. return;
  1063. }
  1064. if (this.$refs.courserware && this.$refs.courserware.handleLocation) {
  1065. item.type = type;
  1066. this.$refs.courserware.handleLocation(item);
  1067. }
  1068. },
  1069. openFile(file) {
  1070. if (file && file.file_url) {
  1071. window.open(file.file_url);
  1072. }
  1073. },
  1074. /**
  1075. * 获取笔记列表
  1076. * @param {Object} params - 参数对象
  1077. */
  1078. async getNote(params) {
  1079. if (params && params.type) this.drawerType = Number(params.type);
  1080. this.allNoteList = [];
  1081. await GetMyNoteList({ courseware_id: this.curSelectId }).then((res) => {
  1082. if (res.status === 1) {
  1083. res.note_list.forEach((x) => {
  1084. if (x.note_desc) {
  1085. let n = JSON.parse(x.note_desc);
  1086. let obj = {
  1087. coursewareId: x.courseware_id,
  1088. id: x.id,
  1089. blockId: n.blockId,
  1090. startIndex: n.startIndex,
  1091. endIndex: n.endIndex,
  1092. text: n.text,
  1093. note: n.note,
  1094. };
  1095. this.allNoteList.push(obj);
  1096. }
  1097. });
  1098. }
  1099. });
  1100. },
  1101. async handEditNote(note) {
  1102. this.oldRichData = {};
  1103. if (this.allNoteList.length === 0) {
  1104. await this.getNote();
  1105. }
  1106. let old = this.allNoteList.find(
  1107. (x) =>
  1108. x.coursewareId === note.coursewareId &&
  1109. x.blockId === note.blockId &&
  1110. x.startIndex === note.startIndex &&
  1111. x.endIndex === note.endIndex,
  1112. );
  1113. if (old) {
  1114. this.oldRichData = old;
  1115. }
  1116. this.newSelectedInfo = note;
  1117. this.editDialogOpen = true;
  1118. },
  1119. saveNote(note) {
  1120. let noteInfo = {
  1121. blockId: this.newSelectedInfo.blockId,
  1122. startIndex: this.newSelectedInfo.startIndex,
  1123. endIndex: this.newSelectedInfo.endIndex,
  1124. note: note.note,
  1125. text: this.newSelectedInfo.text,
  1126. };
  1127. let reqData = {
  1128. courseware_id: this.newSelectedInfo.coursewareId, // 课件 ID
  1129. component_id: 'WHOLE',
  1130. note_desc: JSON.stringify(noteInfo), // 位置描述
  1131. };
  1132. if (note.id) {
  1133. if (!noteInfo.note) {
  1134. this.delNote(note.id);
  1135. return;
  1136. }
  1137. let upDate = {
  1138. id: note.id,
  1139. note_desc: reqData.note_desc,
  1140. };
  1141. UpdateMyNote(upDate).then(() => {
  1142. this.getNote();
  1143. });
  1144. } else {
  1145. AddMyNote(reqData).then(() => {
  1146. this.getNote();
  1147. });
  1148. }
  1149. this.editDialogOpen = false;
  1150. this.newSelectedInfo = null;
  1151. this.selectedInfo = null;
  1152. },
  1153. handDelNote(id) {
  1154. this.$confirm('确定要删除此条笔记吗?', '提示', {
  1155. confirmButtonText: '确定',
  1156. cancelButtonText: '取消',
  1157. type: 'warning',
  1158. })
  1159. .then(() => {
  1160. this.delNote(id);
  1161. })
  1162. .catch(() => {});
  1163. },
  1164. delNote(id) {
  1165. const noteId = id || (this.oldRichData && this.oldRichData.id);
  1166. if (!noteId) return;
  1167. DeleteMyNote({ id: noteId }).then(() => {
  1168. this.allNoteList = this.allNoteList.filter((x) => x.id !== noteId);
  1169. });
  1170. },
  1171. async getCollect(params) {
  1172. if (params && params.type) this.drawerType = Number(params.type);
  1173. this.allCottectList = [];
  1174. await GetMyCollectList({ courseware_id: this.curSelectId }).then((res) => {
  1175. if (res.status === 1) {
  1176. res.collect_list.forEach((x) => {
  1177. if (x.collect_desc) {
  1178. let n = JSON.parse(x.collect_desc);
  1179. let obj = {
  1180. coursewareId: x.courseware_id,
  1181. id: x.id,
  1182. blockId: n.blockId,
  1183. startIndex: n.startIndex,
  1184. endIndex: n.endIndex,
  1185. text: n.text,
  1186. };
  1187. this.allCottectList.push(obj);
  1188. }
  1189. });
  1190. }
  1191. });
  1192. },
  1193. async saveCollect(collect) {
  1194. if (this.allCottectList.length === 0) {
  1195. await this.getCollect();
  1196. }
  1197. let old = this.allCottectList.find(
  1198. (x) =>
  1199. x.coursewareId === collect.coursewareId &&
  1200. x.blockId === collect.blockId &&
  1201. x.startIndex === collect.startIndex &&
  1202. x.endIndex === collect.endIndex,
  1203. );
  1204. if (old) {
  1205. this.$message({
  1206. dangerouslyUseHTMLString: true,
  1207. message: "<i class='el-icon-check' />已收藏",
  1208. });
  1209. return;
  1210. }
  1211. this.newSelectedInfo = collect;
  1212. let collectInfo = {
  1213. blockId: this.newSelectedInfo.blockId,
  1214. startIndex: this.newSelectedInfo.startIndex,
  1215. endIndex: this.newSelectedInfo.endIndex,
  1216. text: this.newSelectedInfo.text,
  1217. };
  1218. let reqData = {
  1219. courseware_id: this.newSelectedInfo.coursewareId, // 课件 ID
  1220. component_id: 'WHOLE',
  1221. collect_desc: JSON.stringify(collectInfo), // 位置描述
  1222. };
  1223. AddMyCollect(reqData)
  1224. .then(() => {
  1225. this.getCollect();
  1226. })
  1227. .then(() => {
  1228. this.$message({
  1229. dangerouslyUseHTMLString: true,
  1230. message: "<i class='el-icon-check' />已收藏",
  1231. });
  1232. });
  1233. },
  1234. handDelCollect(id) {
  1235. this.$confirm('确定要删除此条收藏吗?', '提示', {
  1236. confirmButtonText: '确定',
  1237. cancelButtonText: '取消',
  1238. type: 'warning',
  1239. })
  1240. .then(() => {
  1241. DeleteMyCollect({ id }).then(() => {
  1242. this.allCottectList = this.allCottectList.filter((x) => x.id !== id);
  1243. });
  1244. })
  1245. .catch(() => {});
  1246. },
  1247. getSearch(params) {
  1248. if (params && params.type) this.drawerType = Number(params.type);
  1249. },
  1250. async querySearchList() {
  1251. this.searchList = [];
  1252. if (!this.searchContent) return;
  1253. await SearchBookContentText({ book_id: this.projectId, text: this.searchContent }).then((res) => {
  1254. if (res.status === 1) {
  1255. this.searchList = res.courseware_component_list;
  1256. }
  1257. });
  1258. },
  1259. fullScreen() {
  1260. toggleFullScreen(this.$refs.previewMain);
  1261. },
  1262. },
  1263. };
  1264. </script>
  1265. <style lang="scss" scoped>
  1266. @use '@/styles/mixin.scss' as *;
  1267. $total-width: $courseware-width + $courseware-left-margin + $courseware-right-margin;
  1268. .common-preview {
  1269. &__header {
  1270. position: sticky;
  1271. top: 0;
  1272. left: 0;
  1273. z-index: 9;
  1274. display: flex;
  1275. align-items: center;
  1276. height: 40px;
  1277. padding: 6px 4px;
  1278. margin-bottom: 5px;
  1279. background-color: #fff;
  1280. border-top: $border;
  1281. border-bottom: $border;
  1282. > .menu-container {
  1283. display: flex;
  1284. justify-content: space-between;
  1285. width: 360px;
  1286. padding: 4px 8px;
  1287. border-right: $border;
  1288. }
  1289. > .courseware {
  1290. display: flex;
  1291. flex-grow: 1;
  1292. column-gap: 16px;
  1293. align-items: center;
  1294. justify-content: space-between;
  1295. height: 40px;
  1296. .name-path {
  1297. min-width: 200px;
  1298. height: 40px;
  1299. padding: 4px 8px;
  1300. font-size: 14px;
  1301. line-height: 32px;
  1302. border-right: $border;
  1303. }
  1304. .lang-select {
  1305. :deep .el-input {
  1306. width: 100px;
  1307. }
  1308. :deep .el-input__inner {
  1309. height: 24px;
  1310. line-height: 24px;
  1311. background-color: #fff;
  1312. }
  1313. :deep .el-input__icon {
  1314. line-height: 24px;
  1315. }
  1316. }
  1317. .flow-nodename {
  1318. flex: 1;
  1319. }
  1320. .group {
  1321. display: flex;
  1322. align-items: center;
  1323. }
  1324. .operator {
  1325. display: flex;
  1326. column-gap: 8px;
  1327. align-items: center;
  1328. .link {
  1329. + .link {
  1330. margin-left: 0;
  1331. &::before {
  1332. margin-right: 8px;
  1333. color: #999;
  1334. content: '|';
  1335. }
  1336. }
  1337. }
  1338. }
  1339. }
  1340. }
  1341. .main-container {
  1342. position: relative;
  1343. flex: 1;
  1344. min-width: 1110px;
  1345. padding: 15px 0;
  1346. overflow: auto;
  1347. background-color: #ececec;
  1348. .catalogue-bar {
  1349. position: absolute;
  1350. top: 15px;
  1351. left: 0;
  1352. display: flex;
  1353. align-items: center;
  1354. justify-content: center;
  1355. width: 54px;
  1356. height: 54px;
  1357. margin: -9px 6px 0 240px;
  1358. cursor: pointer;
  1359. background-color: #fff;
  1360. border-radius: 2px;
  1361. box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 40%);
  1362. }
  1363. .sidebar-bar {
  1364. position: absolute;
  1365. top: 0;
  1366. right: 240px;
  1367. display: flex;
  1368. width: 60px;
  1369. height: calc(100vh - 166px);
  1370. .toolbar {
  1371. display: flex;
  1372. flex-direction: column;
  1373. align-items: center;
  1374. width: 60px;
  1375. height: 100%;
  1376. img {
  1377. cursor: pointer;
  1378. }
  1379. &-special {
  1380. display: flex;
  1381. flex-direction: column;
  1382. row-gap: 16px;
  1383. align-items: center;
  1384. width: 100%;
  1385. margin-bottom: 24px;
  1386. background-color: #fff;
  1387. img {
  1388. width: 36px;
  1389. height: 36px;
  1390. }
  1391. }
  1392. }
  1393. }
  1394. }
  1395. .back-top {
  1396. position: absolute;
  1397. right: 240px;
  1398. bottom: 0;
  1399. display: flex;
  1400. place-content: center center;
  1401. align-items: center;
  1402. width: 60px;
  1403. height: 60px;
  1404. cursor: pointer;
  1405. background-color: #fff;
  1406. }
  1407. main.preview-main {
  1408. display: flex;
  1409. flex: 1;
  1410. width: calc($total-width);
  1411. min-width: calc($total-width);
  1412. max-width: calc($total-width);
  1413. min-height: 100%;
  1414. margin: 0 auto;
  1415. background-color: #fff;
  1416. border-radius: 4px;
  1417. box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 40%);
  1418. .preview-left {
  1419. width: $courseware-left-margin;
  1420. min-width: $courseware-left-margin;
  1421. max-width: $courseware-left-margin;
  1422. background-color: $courseware-bgColor;
  1423. }
  1424. .preview-right {
  1425. width: $courseware-right-margin;
  1426. min-width: $courseware-right-margin;
  1427. max-width: $courseware-right-margin;
  1428. background-color: $courseware-bgColor;
  1429. }
  1430. &.no-audit {
  1431. margin: 0 auto;
  1432. }
  1433. }
  1434. .audit-content {
  1435. display: flex;
  1436. min-width: 1810px;
  1437. height: calc(100vh - 46px);
  1438. .left-menu {
  1439. display: flex;
  1440. flex-direction: column;
  1441. width: $catalogue-width;
  1442. font-family: 'Microsoft YaHei', 'Arial', sans-serif;
  1443. background-color: #fff;
  1444. .courseware-info {
  1445. display: flex;
  1446. column-gap: 18px;
  1447. width: 100%;
  1448. height: 186px;
  1449. padding: 6px 6px 24px;
  1450. border-bottom: $border;
  1451. .cover-image {
  1452. display: flex;
  1453. align-items: center;
  1454. justify-content: center;
  1455. width: 111px;
  1456. height: 157px;
  1457. background-color: rgba(229, 229, 229, 100%);
  1458. img {
  1459. max-width: 111px;
  1460. max-height: 157px;
  1461. }
  1462. }
  1463. .info-content {
  1464. display: flex;
  1465. flex-direction: column;
  1466. justify-content: space-between;
  1467. .catalogue-icon {
  1468. text-align: right;
  1469. .svg-icon {
  1470. cursor: pointer;
  1471. }
  1472. }
  1473. .courseware {
  1474. width: 159px;
  1475. height: 64px;
  1476. font-size: 16px;
  1477. .name {
  1478. font-weight: bold;
  1479. }
  1480. .editor {
  1481. display: -webkit-box;
  1482. overflow: hidden;
  1483. text-overflow: ellipsis;
  1484. word-break: break-word;
  1485. white-space: normal;
  1486. -webkit-line-clamp: 2; /* 多行省略行数,按需调整 */
  1487. -webkit-box-orient: vertical;
  1488. }
  1489. }
  1490. }
  1491. }
  1492. .courseware-tree {
  1493. display: flex;
  1494. flex: 1;
  1495. flex-direction: column;
  1496. row-gap: 8px;
  1497. padding: 12px;
  1498. margin-top: 12px;
  1499. overflow: auto;
  1500. .menu-item {
  1501. display: flex;
  1502. align-items: center;
  1503. &:not(.courseware) {
  1504. font-weight: bold;
  1505. }
  1506. &.courseware {
  1507. &:hover {
  1508. .name {
  1509. background-color: #f3f3f3;
  1510. }
  1511. }
  1512. }
  1513. .svg-icon {
  1514. margin-left: 4px;
  1515. &.my-edit-task {
  1516. color: $right-color;
  1517. }
  1518. }
  1519. .name {
  1520. flex: 1;
  1521. padding: 4px 8px 4px 4px;
  1522. border-radius: 4px;
  1523. }
  1524. &.active {
  1525. .name {
  1526. font-weight: bold;
  1527. color: #4095e5;
  1528. }
  1529. }
  1530. }
  1531. }
  1532. }
  1533. .sidebar {
  1534. position: relative;
  1535. display: flex;
  1536. width: $sidebar-width;
  1537. .toolbar {
  1538. display: flex;
  1539. flex-direction: column;
  1540. align-items: center;
  1541. width: 60px;
  1542. height: 100%;
  1543. background-color: rgba(247, 248, 250, 100%);
  1544. img {
  1545. cursor: pointer;
  1546. }
  1547. &-special {
  1548. display: flex;
  1549. flex-direction: column;
  1550. row-gap: 16px;
  1551. margin-bottom: 24px;
  1552. }
  1553. &-list {
  1554. display: flex;
  1555. flex-direction: column;
  1556. row-gap: 16px;
  1557. align-items: center;
  1558. width: 100%;
  1559. .sidebar-item {
  1560. width: 100%;
  1561. padding-top: 2px;
  1562. text-align: center;
  1563. .sidebar-icon {
  1564. width: 36px;
  1565. height: 36px;
  1566. cursor: pointer;
  1567. }
  1568. &.active {
  1569. background-color: #4095e5;
  1570. }
  1571. }
  1572. }
  1573. }
  1574. .content {
  1575. flex: 1;
  1576. background-color: #fff;
  1577. .resource_box {
  1578. height: 100%;
  1579. overflow-y: auto;
  1580. border: 1px solid #e5e5e5;
  1581. .source-toolbar-list {
  1582. position: fixed;
  1583. z-index: 999;
  1584. display: flex;
  1585. width: 240px;
  1586. background: #f2f3f5;
  1587. .sidebar-item {
  1588. width: 100%;
  1589. padding-top: 5px;
  1590. text-align: center;
  1591. border-right: 1px solid #ccc;
  1592. .sidebar-icon {
  1593. width: 26px;
  1594. height: 26px;
  1595. cursor: pointer;
  1596. }
  1597. &.active {
  1598. background-color: #4095e5;
  1599. }
  1600. }
  1601. }
  1602. h5 {
  1603. position: fixed;
  1604. z-index: 999;
  1605. width: 240px;
  1606. padding: 0 5px;
  1607. margin: 0;
  1608. font-size: 18px;
  1609. line-height: 40px;
  1610. background: #f2f3f5;
  1611. }
  1612. .scroll-container {
  1613. display: flex;
  1614. flex-direction: column;
  1615. row-gap: 8px;
  1616. margin: 6px;
  1617. .list-item {
  1618. // display: flex;
  1619. align-items: center;
  1620. // cursor: pointer;
  1621. border: 1px solid #ccc;
  1622. border-radius: 8px;
  1623. :deep .el-slider {
  1624. .el-slider__runway {
  1625. background-color: #eee;
  1626. }
  1627. }
  1628. .el-image {
  1629. display: flex;
  1630. width: 100%;
  1631. min-width: 100%;
  1632. height: 90px;
  1633. background-color: #ccc;
  1634. border-radius: 8px;
  1635. }
  1636. .video-play {
  1637. width: 100%;
  1638. min-width: 100%;
  1639. }
  1640. .text-box {
  1641. word-break: break-word;
  1642. }
  1643. }
  1644. }
  1645. p {
  1646. max-width: 140px;
  1647. color: #999;
  1648. text-align: center;
  1649. word-break: break-all;
  1650. }
  1651. .card-box li {
  1652. padding: 10px;
  1653. border-bottom: 1px solid #ccc;
  1654. .el-icon-notebook-2 {
  1655. display: block;
  1656. margin-bottom: 4px;
  1657. font-size: 12px;
  1658. color: grey;
  1659. }
  1660. }
  1661. .file-handle-info {
  1662. margin: 0 5px;
  1663. .mark {
  1664. display: flex;
  1665. align-items: center;
  1666. justify-content: space-between;
  1667. padding: 3px;
  1668. .linkLocation {
  1669. cursor: pointer;
  1670. }
  1671. }
  1672. .word {
  1673. flex: 1;
  1674. word-break: break-all;
  1675. }
  1676. }
  1677. ::v-deep .el-collapse-item__header {
  1678. margin-left: 5px;
  1679. }
  1680. .loading-text {
  1681. padding: 5px;
  1682. color: #999;
  1683. text-align: center;
  1684. }
  1685. .error-text {
  1686. padding: 5px;
  1687. color: #999;
  1688. text-align: center;
  1689. }
  1690. }
  1691. }
  1692. .back-top {
  1693. position: absolute;
  1694. bottom: 0;
  1695. left: 0;
  1696. display: flex;
  1697. place-content: center center;
  1698. align-items: center;
  1699. width: 60px;
  1700. height: 60px;
  1701. cursor: pointer;
  1702. }
  1703. }
  1704. }
  1705. }
  1706. :deep .scroll-container .audio-wrapper {
  1707. width: 100% !important;
  1708. .audio-middle {
  1709. width: 100% !important;
  1710. padding: 6px 8px !important;
  1711. margin-left: 0;
  1712. border: none;
  1713. border-radius: 8px;
  1714. .audio-name {
  1715. text-align: left;
  1716. }
  1717. .slider-area {
  1718. column-gap: 8px !important;
  1719. }
  1720. :deep .remark-dialog {
  1721. .el-dialog__body {
  1722. padding: 5px 20px;
  1723. }
  1724. }
  1725. :deep .audit-dialog {
  1726. .el-dialog__body {
  1727. height: calc(100vh - 260px);
  1728. padding: 5px 20px;
  1729. }
  1730. .mind-map-container .mind-map {
  1731. height: calc(100vh - 310px);
  1732. }
  1733. }
  1734. }
  1735. }
  1736. .mt10 {
  1737. margin: 10px 0 0 !important;
  1738. background-color: #eee;
  1739. }
  1740. .file-list {
  1741. display: flex;
  1742. flex-direction: column;
  1743. row-gap: 5px;
  1744. li {
  1745. align-items: center;
  1746. .file-name {
  1747. display: flex;
  1748. column-gap: 14px;
  1749. align-items: center;
  1750. justify-content: space-between;
  1751. max-width: 500px;
  1752. padding: 8px 12px;
  1753. font-size: 14px;
  1754. color: #1d2129;
  1755. background-color: #f7f8fa;
  1756. border-radius: 8px;
  1757. p {
  1758. margin: 0;
  1759. }
  1760. span,
  1761. div {
  1762. display: flex;
  1763. align-items: center;
  1764. }
  1765. }
  1766. .svg-icon {
  1767. cursor: pointer;
  1768. }
  1769. }
  1770. }
  1771. </style>
  1772. <style lang="scss">
  1773. .tox-tinymce-aux {
  1774. z-index: 9999 !important;
  1775. }
  1776. </style>