CommonPreview.vue 60 KB

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