index.vue 57 KB

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