RightContent.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. <!-- 中心新闻 -->
  21. <div v-if="selectTab.type == 'newsInfo' && pageType === 'list'"
  22. class="link-list">
  23. <ul>
  24. <li v-for="(item, index) in list"
  25. :key="index">
  26. <div @click="getDetails(item)">
  27. <img src=""
  28. alt="" />
  29. {{ item.newsTitle }}
  30. </div>
  31. <span>{{ parseTime(item.updatedTime, "{y}-{m}-{d}") }}</span>
  32. </li>
  33. </ul>
  34. <el-pagination background
  35. @size-change="handleSizeChange"
  36. @current-change="handleCurrentChange"
  37. :current-page.sync="pageOptions.pageNum"
  38. :page-size.sync="pageOptions.pageSize"
  39. :total="pageOptions.total"
  40. layout="total, prev, pager, next">
  41. </el-pagination>
  42. </div>
  43. <div class="article" v-else-if="selectTab.type == 'newsInfo' && pageType === 'details'">
  44. <h4>{{ news.newsTitle }}</h4>
  45. <div class="snd-title">
  46. <p>
  47. <strong>发布人:</strong><span>{{ news.updatedName }}</span>
  48. </p>
  49. <p>
  50. <strong>发布时间:</strong><span>{{ parseTime(news.updatedTime, "{y}-{m}-{d}") }}</span>
  51. </p>
  52. <p>
  53. <strong>来源:</strong><span>{{ news.newsSource }}</span>
  54. </p>
  55. <p>
  56. <strong>点击量:</strong><span>{{ news.clickNum }}</span>
  57. </p>
  58. </div>
  59. <el-divider class="mt6"></el-divider>
  60. <div class="text"
  61. v-html="news.newsContent"></div>
  62. </div>
  63. <!-- 通知公告 -->
  64. <div v-if="selectTab.type == 'notice' && pageType === 'list'"
  65. class="link-list">
  66. <ul>
  67. <li v-for="(item, index) in list"
  68. :key="index">
  69. <div @click="getDetails(item)">
  70. <img v-if="item.isTop === '10'" src="@/assets/img/isTop.png" alt />
  71. 【{{ item.noticeType === '10' ? '公告' : '通知' }}】{{ item.noticeTitle }}
  72. </div>
  73. <span>{{ parseTime(item.noticeTime, "{y}-{m}-{d}") }}</span>
  74. </li>
  75. </ul>
  76. <el-pagination background
  77. @size-change="handleSizeChange"
  78. @current-change="handleCurrentChange"
  79. :current-page.sync="pageOptions.pageNum"
  80. :page-size.sync="pageOptions.pageSize"
  81. :total="pageOptions.total"
  82. layout="total, prev, pager, next">
  83. </el-pagination>
  84. </div>
  85. <div class="article" v-else-if="selectTab.type == 'notice' && pageType === 'details'">
  86. <h4>{{ notice.noticeTitle }}</h4>
  87. <div class="snd-title">
  88. <p>
  89. <strong>发布人:</strong><span>{{ notice.createdName }}</span>
  90. </p>
  91. <p>
  92. <strong>发布时间:</strong><span>{{ parseTime(notice.noticeTime, "{y}-{m}-{d}") }}</span>
  93. </p>
  94. </div>
  95. <el-divider class="mt6"></el-divider>
  96. <div class="text"
  97. v-html="notice.noticeContent"></div>
  98. <div slot="footer" class="card-footer">
  99. 附件【
  100. <el-link type="primary"
  101. class="mr5"
  102. target="_blank"
  103. v-for="item in notice.sysNoticeFile"
  104. :key="item.id"
  105. :href="item.fileUrl">{{item.fileName}}
  106. </el-link>
  107. </div>
  108. </div>
  109. </el-card>
  110. </template>
  111. <script>
  112. import to from "await-to-js";
  113. import {
  114. getNewsInformationList,
  115. getNewsInformation,
  116. viewNewsInformation,
  117. getNoticeList,
  118. getNoticeEntity,
  119. } from "@/api/news";
  120. import { parseTime } from "@/utils/ruoyi";
  121. export default {
  122. name: "NewsRightContent",
  123. props: {
  124. selectTab: {
  125. type: Object,
  126. default: () => {},
  127. },
  128. breadList: {
  129. type: Array,
  130. default: () => [],
  131. },
  132. },
  133. data() {
  134. return {
  135. pageOptions: {
  136. pageSize: 10,
  137. pageNum: 1,
  138. total: 100,
  139. },
  140. list: [],
  141. pageType: 'list', // list details
  142. news: {
  143. id: 0,
  144. newsTitle: "平台简介",
  145. newsContent: 'www.baidu.com',
  146. newsSource: '.docx',
  147. clickNum: 100,
  148. remark: "<strong>文章内容</strong>",
  149. },
  150. notice: {
  151. id: 100011,
  152. isTop: "10",
  153. noticeType: "10",
  154. fileType: "",
  155. imageUrl: "http://192.168.0.218:9390/4,0d84095983bbd6",
  156. noticeContent: "<p>1</p>",
  157. noticeLevel: "10",
  158. noticeStatus: "10",
  159. noticeTime: "2024-11-28 11:46:48",
  160. noticeTitle: "2",
  161. platId: 100001,
  162. platName: "仪器共享",
  163. readTime: "2024-11-28 11:21:09",
  164. redirectUrl: "",
  165. createdName: '',
  166. },
  167. };
  168. },
  169. watch: {
  170. selectTab() {
  171. this.init();
  172. },
  173. },
  174. methods: {
  175. parseTime,
  176. async init() {
  177. if (this.selectTab.type == "newsInfo") this.getNewsInfoList()
  178. else if (this.selectTab.type == "notice") this.getNoticeList()
  179. },
  180. handleSizeChange () {
  181. this.init()
  182. },
  183. handleCurrentChange () {
  184. this.init()
  185. },
  186. // 获取详情
  187. async getDetails(item) {
  188. this.pageType = "details"
  189. if (this.selectTab.type == "newsInfo") {
  190. const [err, res] = await to(getNewsInformation({ id: item.id }))
  191. if (err) return;
  192. // 修改点击量
  193. const [e] = await to(viewNewsInformation({ id: item.id }))
  194. if (e) return
  195. this.news = res.data
  196. } else if (this.selectTab.type == "notice") {
  197. const [err, res] = await to(getNoticeEntity({ id: item.id }))
  198. if (err) return;
  199. this.notice = res.data
  200. }
  201. },
  202. // 获取中心新闻
  203. async getNewsInfoList() {
  204. this.pageType = 'list'
  205. let params = {
  206. pageNum: this.pageOptions.pageNum,
  207. pageSize: this.pageOptions.pageSize,
  208. }
  209. const [err, res] = await to(getNewsInformationList(params));
  210. if (err) return;
  211. this.list = res.data.list
  212. this.pageOptions.total = res.data.total
  213. },
  214. // 获取通知公告
  215. async getNoticeList() {
  216. this.pageType = 'list'
  217. let params = {
  218. pageNum: this.pageOptions.pageNum,
  219. pageSize: this.pageOptions.pageSize,
  220. }
  221. const [err, res] = await to(getNoticeList(params));
  222. if (err) return;
  223. this.list = res.data.list
  224. this.pageOptions.total = res.data.total
  225. },
  226. },
  227. };
  228. </script>
  229. <style lang="scss" scoped>
  230. .right-content {
  231. flex: 1;
  232. border-radius: 8px;
  233. overflow: hidden;
  234. min-height: 550px;
  235. box-shadow: 0px 3px 6px 1px rgba(1, 64, 100, 0.16);
  236. ::v-deep .el-card__body {
  237. height: calc(100% - 100px);
  238. }
  239. .header {
  240. display: flex;
  241. align-items: center;
  242. justify-content: space-between;
  243. h4 {
  244. font-weight: bold;
  245. font-size: 18px;
  246. color: #2c405e;
  247. }
  248. }
  249. .article {
  250. h4 {
  251. text-align: center;
  252. font-weight: bold;
  253. font-size: 24px;
  254. color: #386afe;
  255. }
  256. .snd-title {
  257. font-weight: 400;
  258. font-size: 14px;
  259. color: #565656;
  260. display: flex;
  261. justify-content: center;
  262. p {
  263. margin: 8px;
  264. }
  265. }
  266. .text {
  267. height: 250px + 50px;
  268. }
  269. .card-footer {
  270. text-align: left; /* 根据需要调整对齐方式 */
  271. padding: 10px; /* 根据需要调整内边距 */
  272. }
  273. }
  274. .link-list {
  275. display: flex;
  276. flex-direction: column;
  277. height: 100%;
  278. overflow-y: auto;
  279. ul {
  280. flex: 1;
  281. li {
  282. display: flex;
  283. justify-content: space-between;
  284. padding: 12px;
  285. border-bottom: 1px dashed #ebf1f6;
  286. cursor: pointer;
  287. transition: all 0.3s;
  288. &:hover {
  289. background-color: #e7f1ff;
  290. }
  291. div {
  292. font-weight: 400;
  293. font-size: 16px;
  294. color: #585858;
  295. }
  296. span {
  297. font-weight: 400;
  298. font-size: 16px;
  299. color: #b5c1d8;
  300. }
  301. }
  302. }
  303. }
  304. }
  305. </style>