RightContent.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <!--
  2. * @Author: wanglj wanglijie@dashoo.cn
  3. * @Date: 2025-01-09 10:52:48
  4. * @LastEditors: wanglj
  5. * @LastEditTime: 2025-01-09 19:55:04
  6. * @Description: file content
  7. * @FilePath: \labsop_website\src\components\RightContent.vue
  8. -->
  9. <template>
  10. <el-card class="right-content">
  11. <div slot="header"
  12. class="header">
  13. <h4>{{ selectTab.name }}</h4>
  14. <el-breadcrumb separator-class="el-icon-d-arrow-right">
  15. <el-breadcrumb-item v-for="(item, index) in breadList"
  16. :key="index"
  17. :to="item.path ? { path: item.path } : null">{{ item.name }} </el-breadcrumb-item>
  18. </el-breadcrumb>
  19. </div>
  20. <div v-if="pageType === 'list'"
  21. class="link-list">
  22. <ul>
  23. <li v-for="(item, index) in list"
  24. :key="index">
  25. <div @click="getDetails(item)">
  26. <img src=""
  27. alt="" />
  28. {{ item.docName }}
  29. </div>
  30. <span>{{ parseTime(item.updatedTime, "{y}-{m}-{d}") }}</span>
  31. </li>
  32. </ul>
  33. <el-pagination background
  34. @size-change="handleSizeChange"
  35. @current-change="handleCurrentChange"
  36. :current-page.sync="pageOptions.pageNum"
  37. :page-size.sync="pageOptions.pageSize"
  38. :total="pageOptions.total"
  39. layout="total, prev, pager, next">
  40. </el-pagination>
  41. </div>
  42. <div class="article"
  43. v-else-if="pageType === 'details'">
  44. <h4>{{ article.docName }}</h4>
  45. <div class="snd-title">
  46. <p>
  47. <strong>发布人:</strong><span>{{ article.updatedName }}</span>
  48. </p>
  49. <p>
  50. <strong>发布时间:</strong><span>{{ parseTime(article.updatedTime, "{y}-{m}-{d}") }}</span>
  51. </p>
  52. <p>
  53. <strong>点击量:</strong><span>{{ article.clickCount }}</span>
  54. </p>
  55. </div>
  56. <el-divider class="mt6"></el-divider>
  57. <div class="text"
  58. v-html="article.remark"></div>
  59. <div slot="footer" class="card-footer">
  60. 附件【
  61. <el-link @click="toDownload(article)">{{ article.docUrlName }}</el-link>
  62. 】已下载{{article.downloadCount}}次
  63. </div>
  64. </div>
  65. </el-card>
  66. </template>
  67. <script>
  68. import to from "await-to-js";
  69. import {
  70. getDocListByClassId,
  71. updateClickCountById,
  72. updateDownloadCountById,
  73. } from "@/api/document";
  74. import {parseTime} from "@/utils/ruoyi";
  75. export default {
  76. name: "CaseRightContent",
  77. props: {
  78. selectTab: {
  79. type: Object,
  80. default: () => {},
  81. },
  82. breadList: {
  83. type: Array,
  84. default: () => [],
  85. },
  86. },
  87. data() {
  88. return {
  89. article: {
  90. id: 0,
  91. docName: "平台简介",
  92. docUrl: 'www.baidu.com',
  93. docUrlName: '.docx',
  94. docClassName: "A类",
  95. updatedName: "张佳乐",
  96. updatedTime: "2024-04-28 14:13:53",
  97. clickCount: 100,
  98. downloadCount: 100,
  99. remark: "<strong>文章内容</strong>",
  100. },
  101. pageOptions: {
  102. pageSize: 10,
  103. pageNum: 1,
  104. total: 0,
  105. },
  106. list: [],
  107. pageType: 'list', // list details
  108. };
  109. },
  110. watch: {
  111. selectTab() {
  112. this.init();
  113. },
  114. },
  115. methods: {
  116. parseTime,
  117. async init() {
  118. this.pageType = 'list'
  119. await this.getInstitutionList(this.selectTab.id);
  120. },
  121. // 获取资料下载列表
  122. async getInstitutionList(classId) {
  123. this.list = []
  124. let params = {
  125. docClassId: classId,
  126. pageNum: this.pageOptions.pageNum,
  127. pageSize: this.pageOptions.pageSize,
  128. }
  129. const [err, res] = await to(getDocListByClassId(params));
  130. if (err) return;
  131. this.pageOptions.total = res.data.total
  132. this.list = res.data.list
  133. },
  134. handleSizeChange () {
  135. this.init()
  136. },
  137. handleCurrentChange () {
  138. this.init()
  139. },
  140. // 获取详情
  141. async getDetails(item) {
  142. this.pageType = "details"
  143. // 更新点击量
  144. const [err, res] = await to(updateClickCountById({ id: item.id }))
  145. if (err) return;
  146. this.article = res.data
  147. },
  148. // 下载
  149. async toDownload(item) {
  150. const [err, res] = await to(updateDownloadCountById({ id: item.id }))
  151. if (err) return;
  152. this.article = res.data
  153. window.open(res.data.docUrl, '_blank')
  154. },
  155. },
  156. };
  157. </script>
  158. <style lang="scss" scoped>
  159. .right-content {
  160. flex: 1;
  161. border-radius: 8px;
  162. overflow: hidden;
  163. height: 550px;
  164. box-shadow: 0px 3px 6px 1px rgba(1, 64, 100, 0.16);
  165. ::v-deep .el-card__body {
  166. height: calc(100% - 100px);
  167. }
  168. .header {
  169. display: flex;
  170. align-items: center;
  171. justify-content: space-between;
  172. h4 {
  173. font-weight: bold;
  174. font-size: 18px;
  175. color: #2c405e;
  176. }
  177. }
  178. .article {
  179. h4 {
  180. //text-align: center;
  181. //font-weight: bold;
  182. //font-size: 30px;
  183. //line-height: 50px;
  184. //color: #cc3333;
  185. text-align: center;
  186. font-weight: bold;
  187. font-size: 24px;
  188. color: #386afe;
  189. }
  190. .snd-title {
  191. font-weight: 400;
  192. line-height: 35px;
  193. font-size: 14px;
  194. color: #666666;
  195. background: #f5f5f5;
  196. display: flex;
  197. justify-content: center;
  198. margin: 15px auto 0 auto;
  199. p {
  200. margin: 8px;
  201. }
  202. }
  203. .text {
  204. height: 250px + 50px;
  205. }
  206. .card-footer {
  207. text-align: left; /* 根据需要调整对齐方式 */
  208. padding: 10px; /* 根据需要调整内边距 */
  209. }
  210. }
  211. .link-list {
  212. display: flex;
  213. flex-direction: column;
  214. height: 100%;
  215. overflow-y: auto;
  216. ul {
  217. flex: 1;
  218. li {
  219. display: flex;
  220. justify-content: space-between;
  221. padding: 12px;
  222. border-bottom: 1px dashed #ebf1f6;
  223. cursor: pointer;
  224. transition: all 0.3s;
  225. &:hover {
  226. background-color: #e7f1ff;
  227. }
  228. div {
  229. font-weight: 400;
  230. font-size: 16px;
  231. color: #585858;
  232. }
  233. span {
  234. font-weight: 400;
  235. font-size: 16px;
  236. color: #b5c1d8;
  237. }
  238. }
  239. }
  240. .el-pagination {
  241. display: flex;
  242. justify-content: center;
  243. }
  244. }
  245. }
  246. </style>