CommonPreview.vue 73 KB

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