阅行客电子档案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

278 lines
8.0 KiB

5 months ago
5 months ago
5 months ago
  1. <template>
  2. <!-- style="height: calc(100vh - 140px);" -->
  3. <div class="app-container row-container">
  4. <div class="custom-main">
  5. <!-- <el-card class="box-card" @click="goToHtml">
  6. 认证材料
  7. </el-card>
  8. <el-card class="box-card" @click="goToHtml">
  9. 学籍表测试
  10. </el-card>
  11. <el-card class="box-card" @click="goToHtml">
  12. 交接统计
  13. </el-card>
  14. <el-card class="box-card" @click="goToHtml">
  15. 单个电子文件大小统计
  16. </el-card>
  17. <el-card class="box-card" @click="goToHtml">
  18. 电子文件统计
  19. </el-card> -->
  20. <el-card class="box-card">
  21. <div @click="goToHtml">文书档案年度分类统计</div>
  22. </el-card>
  23. <el-card class="box-card">
  24. <div @click="goToHtml">文书档案年度保管期限统计</div>
  25. </el-card>
  26. <!-- <div v-katex:auto class="mdTextBox" v-html="renderMdText(markDownText)" /> -->
  27. <mavon-editor
  28. class="md"
  29. :value="markDownText"
  30. :subfield="false"
  31. :default-open="'preview'"
  32. :toolbars-flag="false"
  33. :editable="false"
  34. :scroll-style="true"
  35. :ishljs="true"
  36. />
  37. </div>
  38. </div>
  39. </template>
  40. <script>
  41. import MarkdownIt from 'markdown-it'
  42. import MarkdownItHighlightjs from 'markdown-it-highlightjs'
  43. import 'highlight.js/styles/a11y-dark.css'
  44. import katex from 'katex'
  45. import 'katex/dist/katex.min.css'
  46. // import MarkdownItAbbr from 'markdown-it-abbr'
  47. // import MarkdownItAnchor from 'markdown-it-anchor'
  48. // import MarkdownItFootnote from 'markdown-it-footnote'
  49. // import MarkdownItHighlightjs from 'markdown-it-highlightjs'
  50. // import MarkdownItSub from 'markdown-it-sub'
  51. // import MarkdownItSup from 'markdown-it-sup'
  52. // import MarkdownItTasklists from 'markdown-it-task-lists'
  53. // import MarkdownItTOC from 'markdown-it-toc-done-right'
  54. // import 'highlight.js/styles/default.css'
  55. import markdownText2 from '@/assets/test.md'
  56. export default {
  57. name: 'CustomDefinedStatistics',
  58. components: { },
  59. data() {
  60. return {
  61. markdownText2: markdownText2,
  62. // 渲染的文本
  63. markDownText: `## 项目背景
  64. > 描述项目或产品的现状让项目成员了解当前存在的问题与痛点
  65. >
  66. + 痛点1...
  67. + 痛点2...
  68. + 痛点3...
  69. ## 项目目标
  70. > 描述本项目期望达成的目标目标需满足Smart原则
  71. >
  72. > 1. 具体的Specific
  73. > 2. 可以衡量的Measurable
  74. > 3. 可以达到的Attainable
  75. > 4. 要与其他目标具有一定的相关性Relevant
  76. > 5. 有明确的截止期限Time-bound
  77. >
  78. ## 关键事项
  79. > 为达成上述目标需要完成哪些关键事项
  80. >
  81. + 关键事项1...
  82. + 关键事项2...
  83. + 关键事项3...
  84. ## 里程碑
  85. > 整个项目中关键节点的里程碑计划
  86. >
  87. ![画板](http://gips0.baidu.com/it/u=3602773692,1512483864&fm=3028&app=3028&f=JPEG&fmt=auto?w=960&h=1280)
  88. ## 人员安排
  89. > 输入项目的所有干系人包括内部和外部干系人
  90. >
  91. | **人员** | **岗位** |
  92. | --- | --- |
  93. | @<font style="color:#8C8C8C;background-color:#F5F5F5;">提及</font> | 项目经理 |
  94. | @<font style="color:#8C8C8C;background-color:#F5F5F5;">提及</font> | 技术负责人 |
  95. | @<font style="color:#8C8C8C;background-color:#F5F5F5;">提及</font> | 产品负责人 |
  96. ## 风险提示
  97. > 对公司战略项目结题法务风险问题进行提示并说明应对措施
  98. >
  99. `,
  100. markdownRender: new MarkdownIt({
  101. html: true,
  102. linkify: true,
  103. typographer: true,
  104. xhtmlOut: false
  105. }).use(MarkdownItHighlightjs),
  106. // .use(MarkdownItAbbr)
  107. // .use(MarkdownItAnchor)
  108. // .use(MarkdownItFootnote)
  109. // .use(MarkdownItHighlightjs)
  110. // .use(MarkdownItSub)
  111. // .use(MarkdownItSup)
  112. // .use(MarkdownItTasklists)
  113. // .use(MarkdownItTOC)
  114. markdownContent: ''
  115. }
  116. },
  117. updated() {
  118. const that = this
  119. this.$nextTick(() => {
  120. // 获取页面上的pre和code标签
  121. const codeBlocks = document.querySelectorAll('pre code')
  122. codeBlocks.forEach((block) => {
  123. let newDiv
  124. // 获取code标签
  125. const preElement = block
  126. // 获取code标签的父元素
  127. const parentElement = preElement.parentNode
  128. // 获取parentElement下的第一个div元素
  129. const firstDiv = parentElement.querySelector('div')
  130. // 检查是否找到了div元素
  131. if (!firstDiv) {
  132. // 创建一个div
  133. newDiv = document.createElement('div')
  134. // 给div添加文字内容
  135. newDiv.innerText = '复制代码'
  136. // 给div设置class样式
  137. newDiv.setAttribute('class', 'copyButton')
  138. // 把div插入到code标签前面
  139. parentElement.insertBefore(newDiv, preElement)
  140. // 给div添加点击事件
  141. newDiv.onclick = function() {
  142. const textArea = document.createElement('textarea')
  143. textArea.value = preElement.innerText
  144. document.body.appendChild(textArea)
  145. textArea.select()
  146. document.execCommand('copy')
  147. document.body.removeChild(textArea)
  148. that.$message.success('复制成功')
  149. }
  150. }
  151. })
  152. })
  153. },
  154. mounted() {
  155. // const md = new MarkdownIt()
  156. // console.log('md', md)
  157. // this.markdownContent = md.render(this.markdownText2)
  158. // console.log(' this.markdownContent', this.markdownContent)
  159. },
  160. methods: {
  161. // renderMdText(text) {
  162. // // 生成html
  163. // return this.markdownRender.render(text)
  164. // }
  165. renderMdText(text) {
  166. // markdown转html
  167. text = this.markdownRender.render(text)
  168. text = this.renderMath(text)
  169. // text = this.decodeHTMLEntities(text) // 手动解码 HTML 实体
  170. return text
  171. },
  172. // decodeHTMLEntities(text) {
  173. // const parser = new DOMParser()
  174. // const doc = parser.parseFromString(text, 'text/html')
  175. // return doc.documentElement.textContent
  176. // },
  177. // markdown转latex
  178. renderMath(html) {
  179. // 匹配 $$...$$, \[...\], \(...\), and $...$
  180. const regex = /(\$\$([\s\S]+?)\$\$)|(\\\[([\s\S]+?)\\\])|(\\\(([\s\S]+?)\\\))|(\$([^\$]+?)\$)/g
  181. return html.replace(regex, (match, p1, p2, p3, p4, p5, p6, p7, p8) => {
  182. let latex
  183. if (p2) {
  184. // $$...$$
  185. latex = p2
  186. } else if (p4) {
  187. // \[...\]
  188. latex = p4
  189. } else if (p6) {
  190. // \(...\)
  191. latex = p6
  192. } else if (p8) {
  193. // $...$
  194. latex = p8
  195. }
  196. console.log('latex', latex)
  197. if (latex) {
  198. try {
  199. return katex.renderToString(latex, {
  200. throwOnError: false
  201. })
  202. } catch (e) {
  203. console.error('KaTeX rendering error:', e)
  204. return match
  205. }
  206. }
  207. return match
  208. })
  209. },
  210. goToHtml() {
  211. // 这里的 'test.html' 是你放在 public 目录下的 HTML 文件名称
  212. // window.location.href = 'report/annual.htm'
  213. window.open('report/annual.htm', '_blank')
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. .custom-main{
  220. display: flex;
  221. justify-content: flex-start;
  222. flex-wrap: wrap;
  223. ::v-deep .el-card{
  224. margin: 0 20px 20px 0;
  225. width: calc(100% / 4 - 40px);
  226. height: 100px;
  227. line-height: 100px;
  228. text-align: center;
  229. cursor: pointer;
  230. }
  231. }
  232. // .mdTextBox{
  233. // width: 1400px;
  234. // ::v-deep h1{
  235. // font-size: 24px;
  236. // line-height: 48px;
  237. // font-weight: 800;
  238. // }
  239. // ::v-deep h2{
  240. // font-size: 22px;
  241. // line-height: 42px;
  242. // font-weight: 700;
  243. // }
  244. // ::v-deep h3{
  245. // font-size: 20px;
  246. // line-height: 36px;
  247. // font-weight: 600;
  248. // }
  249. // ::v-deep img{
  250. // width: 500px;
  251. // }
  252. // ::v-deep a{
  253. // color: #335fee;
  254. // line-height: 20px;
  255. // }
  256. // ::v-deep p {
  257. // line-height: 20px;
  258. // }
  259. // }
  260. </style>