Index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <script setup>
  2. import subMenuBox from "./components/subMenuBox.vue"
  3. import menuBox from "./components/menubox.vue"
  4. import {apiGetHelpDocClassify,apiGetHelpDocDetail} from "@/api/helpApi.js"
  5. import {ref,nextTick,onMounted,onUnmounted } from 'vue'
  6. import {useRoute} from 'vue-router'
  7. const route = useRoute()
  8. const documentData=ref([])
  9. // const anchorData=ref([])
  10. const currentNodeKey=ref('')
  11. const defaultActiveId=ref(0)
  12. const isRightFold=ref(false)
  13. const helpDocument=ref({})
  14. const Content=ref('')
  15. let isFirstLoad=true
  16. let videoList=[]
  17. const businessCode = route.query.bus_code || ''
  18. const treeProp={
  19. label:'text',
  20. children: 'Child'
  21. }
  22. const getDocumentData=()=>{
  23. apiGetHelpDocClassify({bus_code:businessCode}).then(res=>{
  24. if(res.code == 200){
  25. documentData.value=res.data || []
  26. getFirstId(documentData.value[0])
  27. getDocument(defaultActiveId.value)
  28. }
  29. })
  30. }
  31. // 获取第一个分类
  32. const getFirstId=(item)=>{
  33. if(item.Children && item.Children.length>0){
  34. getFirstId(item.Children[0])
  35. }else{
  36. defaultActiveId.value = item.ClassifyId
  37. }
  38. }
  39. const menuChange=(data,node)=>{
  40. currentNodeKey.value = data.AnchorId
  41. }
  42. const getDocument=(id)=>{
  43. apiGetHelpDocDetail({bus_code:businessCode,classify_id:id}).then(res=>{
  44. if(res.code == 200){
  45. helpDocument.value=res.data || {}
  46. Content.value = helpDocument.value.Content + createBottomHref(helpDocument.value.Recommend)
  47. if(!(helpDocument.value.Anchor && helpDocument.value.Anchor.length>0)) isRightFold.value=true
  48. isRightFold.value=false
  49. nextTick(()=>{
  50. getScrollTopList(helpDocument.value.Anchor || [])
  51. videoList=document.getElementsByTagName('video') || []
  52. if(videoList && videoList.length>0){
  53. for (let i = 0; i < videoList.length; i++) {
  54. const element = videoList[i];
  55. element.addEventListener('play',setVideosStatus(i))
  56. }
  57. }
  58. })
  59. window.scrollTo(0, document.getElementById('operation-document-body').offsetTop)
  60. }else if(res.code == 4001){
  61. helpDocument.value={}
  62. isRightFold.value=true
  63. }
  64. if(isFirstLoad){
  65. isFirstLoad=false
  66. return
  67. }
  68. })
  69. }
  70. const setVideosStatus=(i)=>{
  71. return ()=>{
  72. // 暂停其他播放的视频,只能播放一个
  73. for (let j = 0; j < videoList.length; j++) {
  74. if(j==i) continue;
  75. if(!videoList[j].paused){
  76. videoList[j].pause()
  77. }
  78. }
  79. }
  80. }
  81. // 生成底部的两个链接
  82. const createBottomHref=(RecommendData)=>{
  83. if(!(RecommendData && RecommendData.length>0)) return ''
  84. let hrefStringBuiler='<ul style="margin-top:40px">'
  85. RecommendData.map(item =>{
  86. if(item.Name){
  87. hrefStringBuiler+=`<li><a href="${item.Url}" target="_blank" style="text-decoration: underline;">${item.Name}</a></li>`
  88. }
  89. })
  90. return hrefStringBuiler+"</ul>"
  91. }
  92. getDocumentData()
  93. const headerHeight = ref(0)
  94. const scrollTopList=ref([])
  95. const stop=ref(false)
  96. onMounted(() => {
  97. document.addEventListener('scroll',scrollChange)
  98. headerHeight.value=document.getElementById("operation-document-body").offsetTop
  99. })
  100. onUnmounted(() => {
  101. document.removeEventListener('scroll',scrollChange)
  102. if(videoList && videoList.length>0){
  103. for (let i = 0; i < videoList.length; i++) {
  104. const element = videoList[i];
  105. element.removeEventListener('play',setVideosStatus(i))
  106. }
  107. }
  108. })
  109. const getScrollTopList=(list)=>{
  110. list.map(item =>{
  111. scrollTopList.value.push({key:item.AnchorId,clientRectTop:document.getElementById(item.Anchor).offsetTop+headerHeight.value})
  112. if(item.Child && item.Child.length>0) getScrollTopList(item.Child || [])
  113. })
  114. }
  115. const navigate = (e,id)=>{
  116. // 阻止滚动监听,防止右侧节点的定位 被滚动监听干扰
  117. stop.value=true
  118. e.preventDefault();
  119. document.querySelector(id).scrollIntoView(true)
  120. nextTick(()=>{
  121. // 放开滚动监听
  122. stop.value=false
  123. })
  124. }
  125. const scrollChange=()=>{
  126. if(stop.value) return
  127. let scrollTop = document.documentElement.scrollTop || document.body.scrollTop
  128. let hashit=false
  129. for (let i = scrollTopList.value.length ; i > 0; i--) {
  130. const element = scrollTopList.value[i-1];
  131. if(scrollTop - element.clientRectTop>-5){
  132. hashit=true
  133. currentNodeKey.value = element.key
  134. break;
  135. }
  136. }
  137. if(!hashit){
  138. currentNodeKey.value=''
  139. }
  140. }
  141. </script>
  142. <template>
  143. <div class="operation-document-container" id="operation-document-container">
  144. <div class="operation-document-neck">
  145. <div class="banner-image">
  146. <img src="@/assets/img//help/data.png">
  147. <div class="banner-text">
  148. <div class="text">数据源</div>
  149. <div class="text">数据录入、更新</div>
  150. </div>
  151. </div>
  152. <img src="@/assets/img/icon/line-arrow-blue.png" class="banner-line">
  153. <div class="banner-image">
  154. <img src="@/assets/img/help/database.png">
  155. <div class="banner-text">
  156. <div class="text">ETA指标库</div>
  157. <div class="text">添加指标</div>
  158. </div>
  159. </div>
  160. <img src="@/assets/img/icon/line-arrow-blue.png" class="banner-line">
  161. <div class="banner-image">
  162. <img src="@/assets/img/help/chart.png">
  163. <div class="banner-text">
  164. <div class="text">ETA图库</div>
  165. <div class="text">指标作图</div>
  166. </div>
  167. </div>
  168. <img src="@/assets/img/icon/line-arrow-blue.png" class="banner-line">
  169. <div class="banner-image">
  170. <img src="@/assets/img/help/report.png">
  171. <div class="banner-text">
  172. <div class="text">研报</div>
  173. <div class="text">编辑研报/插入图表</div>
  174. </div>
  175. </div>
  176. </div>
  177. <div class="operation-document-body" id="operation-document-body">
  178. <div class="document-body-left">
  179. <el-scrollbar style="height: 100%;">
  180. <el-menu class="docuemnt-menu" text-color="#333333" :default-active="defaultActiveId+''">
  181. <template v-for="menuItem in documentData" :key="menuItem.ClassifyId">
  182. <subMenuBox @getDocument="getDocument" v-if="menuItem.Children && menuItem.Children.length>0"
  183. :item="menuItem"></subMenuBox>
  184. <menuBox @getDocument="getDocument" :item="menuItem" v-else></menuBox>
  185. </template>
  186. </el-menu>
  187. </el-scrollbar>
  188. </div>
  189. <div class="document-body-center" id="document-body-center" :style="{'border-right':isRightFold?'none':'solid 1px #DCDFE6'}">
  190. <template v-if="helpDocument.Title">
  191. <div class="body-center-title">
  192. <div class="body-center-title-text">{{ helpDocument.Title }}</div>
  193. <div class="body-center-title-signature">最后更新时间:{{ helpDocument.Author }} {{ helpDocument.ModifyTime }}</div>
  194. </div>
  195. <div class="rich-text-box fr-view" id="rich-text-box" v-html="Content">
  196. </div>
  197. </template>
  198. <template v-else>
  199. <div class="nodata" style="text-align: center;">
  200. <img src="~@/assets/img/nodata.png" style="width: 300px;"/>
  201. <p>暂无信息</p>
  202. </div>
  203. </template>
  204. </div>
  205. <div class="document-body-right" :style="{'max-width': isRightFold?'0':'300px'}">
  206. <div class="body-right-box">
  207. <el-tree :data="helpDocument.Anchor" node-key="AnchorId" @current-change="menuChange" class="right-anchor-tree"
  208. ref="rightTreeRef" :props="treeProp" :current-node-key="currentNodeKey" icon="none" empty-text="暂无数据"
  209. default-expand-all :expand-on-click-node="false" >
  210. <template #default="{ node, data }">
  211. <a @click="(e)=>navigate(e,'#'+data.Anchor)" class="custom-tree-node" v-html="data.AnchorName"
  212. :class="currentNodeKey==data.AnchorId?'active-node':''" :style="!node.isLeaf?'margin-top:12px':''" ></a>
  213. </template>
  214. </el-tree>
  215. </div>
  216. </div>
  217. <div class="fold-right-icon" @click="isRightFold=!isRightFold">
  218. <img src="@/assets/img/icon/fold.png" />
  219. </div>
  220. </div>
  221. </div>
  222. </template>
  223. <style lang="scss" scoped>
  224. .operation-document-container{
  225. min-width: 1000px;
  226. width: 100%;
  227. .operation-document-neck{
  228. padding: 60px 20px;
  229. height: 140px;
  230. display: flex;
  231. align-items: center;
  232. justify-content: center;
  233. .banner-image{
  234. height: 140px;
  235. width: 250px;
  236. min-width: 200px;
  237. position: relative;
  238. .banner-text{
  239. position: absolute;
  240. top: 24px;
  241. left: 24px;
  242. .text{
  243. color: white;
  244. font-weight: 400;
  245. line-height: 28px;
  246. font-size: 20px;
  247. &:last-child{
  248. margin-top: 20px;
  249. line-height: 22px;
  250. font-size: 16px;
  251. }
  252. }
  253. }
  254. img{
  255. height:100%;
  256. width:100%;
  257. }
  258. }
  259. .banner-line{
  260. width: 40px;
  261. margin: 0 10px;
  262. }
  263. }
  264. .operation-document-body{
  265. width: 100%;
  266. // min-height:100vh;
  267. display: flex;
  268. position: relative;
  269. .document-body-left{
  270. max-width: 300px;
  271. flex:1;
  272. max-height: 100vh;
  273. position: sticky;
  274. top: 0;
  275. padding: 24px 24px 24px 12px;
  276. box-sizing: border-box;
  277. align-self: flex-start;
  278. .docuemnt-menu{
  279. border-right: none;
  280. }
  281. }
  282. .document-body-center{
  283. flex: 3;
  284. min-height: 100%;
  285. padding: 20px;
  286. border-left: solid 1px #DCDFE6;
  287. // border-right: solid 1px #DCDFE6;
  288. box-sizing: border-box;
  289. min-height:100vh;
  290. .body-center-title{
  291. border-bottom: solid 1px #C0C4CC;
  292. margin-bottom: 30px;
  293. .body-center-title-text{
  294. font-size: 34px;
  295. line-height: 48px;
  296. text-align: center;
  297. }
  298. .body-center-title-signature{
  299. font-size: 14px;
  300. color: #666666;
  301. padding: 10px 0 10px 10px;
  302. }
  303. }
  304. }
  305. .document-body-right{
  306. flex: 1;
  307. max-width: 300px;
  308. max-height: 100vh;
  309. position: sticky;
  310. top: 0;
  311. overflow: hidden;
  312. transition: all 0.1s ease;
  313. box-sizing: border-box;
  314. align-self: flex-start;
  315. .body-right-box{
  316. padding: 12px 24px 24px;
  317. box-sizing: border-box;
  318. .custom-tree-node{
  319. padding: 8px 12px;
  320. font-size: 14px;
  321. line-height: 20px;
  322. color: #333333;
  323. overflow: hidden;
  324. text-overflow: ellipsis;
  325. white-space: nowrap;
  326. width: 100%;
  327. }
  328. }
  329. }
  330. .fold-right-icon{
  331. width: 20px;
  332. height: 20px;
  333. position: sticky;
  334. right: 10px;
  335. top: 0;
  336. cursor: pointer;
  337. }
  338. }
  339. }
  340. </style>
  341. <style lang="scss">
  342. // froala-editor 预览时的样式,如需使用在展示富文本的节点上加上 fr-view 的类
  343. @import '/public/froala_style.min.css';
  344. // 因为富文本编辑的地方在hz_crm_web 项目,加入后台的样式保持两边看起来一致
  345. @import '/public/reset.min.css';
  346. p[data-f-id="pbf"] {
  347. display: none;
  348. }
  349. .el-scrollbar__wrap {
  350. overflow-x: hidden;
  351. }
  352. .el-sub-menu .el-menu-item{
  353. padding-left:12px !important;
  354. }
  355. a{
  356. text-decoration: none;
  357. }
  358. .el-tree-node:focus > .el-tree-node__content {
  359. background-color: transparent !important;
  360. }
  361. .el-tree-node__content{
  362. height: unset!important;
  363. }
  364. .el-tree-node__content:hover {
  365. background-color: transparent;
  366. .custom-tree-node{
  367. color: #366EF4!important;
  368. }
  369. }
  370. .active-node{
  371. color: #366EF4!important;
  372. }
  373. .el-tree-node__children{
  374. .active-node{
  375. color: #666666!important;
  376. text-decoration:underline;
  377. }
  378. .custom-tree-node{
  379. color: #666666!important;
  380. padding: 0 8px!important;
  381. }
  382. }
  383. .el-tree-node__children{
  384. .el-tree-node__content:hover{
  385. background-color: transparent;
  386. text-decoration: underline;
  387. .custom-tree-node{
  388. color: #666666!important;
  389. }
  390. }
  391. }
  392. .el-tree-node__expand-icon{
  393. display: none;
  394. }
  395. </style>