RightContent.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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.label }}</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="selectTab.type == 'institution' && 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" v-else-if="selectTab.type == 'institution' && pageType === 'details'">
  43. <h4>{{ document.docName }}</h4>
  44. <div class="snd-title">
  45. <p>
  46. <strong>发布人:</strong><span>{{ document.updatedName }}</span>
  47. </p>
  48. <p>
  49. <strong>发布时间:</strong><span>{{ parseTime(document.updatedTime, "{y}-{m}-{d}") }}</span>
  50. </p>
  51. <p>
  52. <strong>点击量:</strong><span>{{ document.clickCount }}</span>
  53. </p>
  54. </div>
  55. <el-divider class="mt6"></el-divider>
  56. <div class="text"
  57. v-html="document.remark"></div>
  58. <div slot="footer" class="card-footer">
  59. 附件【
  60. <el-link type="primary" @click="toDownload(document)">{{ document.docUrlName }}</el-link>
  61. 】已下载{{document.downloadCount}}次
  62. </div>
  63. </div>
  64. <div class="article"
  65. v-else-if="selectTab.type == 'intro'">
  66. <h4>{{ article.centerName }}</h4>
  67. <div class="snd-title">
  68. <p>
  69. <strong>发布人:</strong><span>{{ article.updatedName }}</span>
  70. </p>
  71. <p>
  72. <strong>发布时间:</strong><span>{{ article.updatedTime }}</span>
  73. </p>
  74. <p>
  75. <strong>点击量:</strong><span>{{ article.clickNum }}</span>
  76. </p>
  77. </div>
  78. <el-divider class="mt6"></el-divider>
  79. <div class="text"
  80. v-html="article.centerDesc"></div>
  81. </div>
  82. <div class="article"
  83. v-else-if="selectTab.type == 'staff'">
  84. <h4>{{ article.staffName }}</h4>
  85. <div class="text"
  86. v-html="article.staffDesc"></div>
  87. </div>
  88. </el-card>
  89. </template>
  90. <script>
  91. import to from "await-to-js";
  92. import {
  93. getCenterIntroduction,
  94. viewCenterIntroduction,
  95. getCenterStaff,
  96. viewCenterStaff,
  97. getCenterPlatformList
  98. } from "@/api/introduce";
  99. import {
  100. getEntityByClassName,
  101. updateClickCountById,
  102. updateDownloadCountById,
  103. } from "@/api/document";
  104. import {parseTime} from "@/utils/ruoyi";
  105. export default {
  106. name: "RightContent",
  107. props: {
  108. selectTab: {
  109. type: Object,
  110. default: () => {},
  111. },
  112. breadList: {
  113. type: Array,
  114. default: () => [],
  115. },
  116. },
  117. data() {
  118. return {
  119. article: {
  120. title: "平台简介",
  121. createUser: "张佳乐",
  122. createTime: "2024-04-28 14:13:53",
  123. clickCount: 222,
  124. content: "<strong>文章内容</strong>",
  125. },
  126. pageOptions: {
  127. pageSize: 10,
  128. pageNum: 1,
  129. total: 100,
  130. },
  131. list: [],
  132. pageType: 'list', // list details
  133. document: {
  134. id: 0,
  135. docName: "平台简介",
  136. docUrl: 'www.baidu.com',
  137. docUrlName: '.docx',
  138. docClassName: "A类",
  139. updatedName: "张佳乐",
  140. updatedTime: "2024-04-28 14:13:53",
  141. clickCount: 100,
  142. downloadCount: 100,
  143. remark: "<strong>文章内容</strong>",
  144. },
  145. };
  146. },
  147. watch: {
  148. selectTab() {
  149. this.init();
  150. },
  151. },
  152. methods: {
  153. parseTime,
  154. async init() {
  155. if (this.selectTab.type == "intro") this.getIntro();
  156. else if (this.selectTab.type == "staff") this.getStaff();
  157. else if (this.selectTab.type == "institution") this.getInstitution();
  158. },
  159. handleSizeChange () {
  160. this.init()
  161. },
  162. handleCurrentChange () {
  163. this.init()
  164. },
  165. // 获取平台简介
  166. async getIntro() {
  167. const [err, res] = await to(getCenterIntroduction());
  168. if (err) return;
  169. this.article = res.data;
  170. viewCenterIntroduction();
  171. },
  172. // 获取人员
  173. async getStaff() {
  174. const [err, res] = await to(getCenterStaff());
  175. if (err) return;
  176. this.article = res.data;
  177. viewCenterStaff();
  178. },
  179. // 获取规章制度
  180. async getInstitution() {
  181. this.pageType = 'list'
  182. let params = {
  183. docClassName: '规章制度',
  184. pageNum: this.pageOptions.pageNum,
  185. pageSize: this.pageOptions.pageSize,
  186. }
  187. const [err, res] = await to(getEntityByClassName(params));
  188. if (err) return;
  189. this.list = res.data.list
  190. this.pageOptions.total = res.data.total
  191. },
  192. // 获取详情
  193. async getDetails(item) {
  194. this.pageType = "details"
  195. // 更新点击量
  196. const [err, res] = await to(updateClickCountById({ id: item.id }))
  197. if (err) return;
  198. this.document = res.data
  199. },
  200. // 下载
  201. async toDownload(item) {
  202. const [err, res] = await to(updateDownloadCountById({ id: item.id }))
  203. if (err) return;
  204. this.document = res.data
  205. window.open(res.data.docUrl, '_blank')
  206. },
  207. },
  208. };
  209. </script>
  210. <style lang="scss" scoped>
  211. .right-content {
  212. flex: 1;
  213. border-radius: 8px;
  214. overflow: hidden;
  215. min-height: 550px;
  216. box-shadow: 0px 3px 6px 1px rgba(1, 64, 100, 0.16);
  217. ::v-deep .el-card__body {
  218. height: calc(100% - 100px);
  219. }
  220. .header {
  221. display: flex;
  222. align-items: center;
  223. justify-content: space-between;
  224. h4 {
  225. font-weight: bold;
  226. font-size: 18px;
  227. color: #2c405e;
  228. }
  229. }
  230. .article {
  231. h4 {
  232. text-align: center;
  233. font-weight: bold;
  234. font-size: 24px;
  235. color: #386afe;
  236. }
  237. .snd-title {
  238. font-weight: 400;
  239. font-size: 14px;
  240. color: #565656;
  241. display: flex;
  242. justify-content: center;
  243. p {
  244. margin: 8px;
  245. }
  246. }
  247. }
  248. .link-list {
  249. display: flex;
  250. flex-direction: column;
  251. height: 100%;
  252. overflow-y: auto;
  253. ul {
  254. flex: 1;
  255. li {
  256. display: flex;
  257. justify-content: space-between;
  258. padding: 12px;
  259. border-bottom: 1px dashed #ebf1f6;
  260. cursor: pointer;
  261. transition: all 0.3s;
  262. &:hover {
  263. background-color: #e7f1ff;
  264. }
  265. div {
  266. font-weight: 400;
  267. font-size: 16px;
  268. color: #585858;
  269. }
  270. span {
  271. font-weight: 400;
  272. font-size: 16px;
  273. color: #b5c1d8;
  274. }
  275. }
  276. }
  277. }
  278. }
  279. </style>