SiteMessageHome.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <main-layout>
  3. <i-breadcrumb
  4. style="text-align: left; padding-left: 20px; height: 40px; line-height: 40px;
  5. background-color: #fafafa;"
  6. >
  7. 当前所在位置:
  8. <BreadcrumbItem>{{ locationTitle }}</BreadcrumbItem>
  9. </i-breadcrumb>
  10. <div class="home">
  11. <div style="font-size: 18px; font-weight: 500; color: #222C32;">
  12. 公告通知
  13. </div>
  14. <i-button>
  15. <div class="mark-read-block" @click="markRead">
  16. <img src="./svgs/sms-read.svg" /> &nbsp;标记为已读
  17. </div>
  18. </i-button>
  19. </div>
  20. <div class="site-message-container">
  21. <div style="text-align: left; color: #999; margin-bottom: 5px;">
  22. *仅保留近1年的公告通知。
  23. </div>
  24. <Table
  25. ref="selection"
  26. border
  27. :columns="columns"
  28. :data="siteMessagesComputed"
  29. ></Table>
  30. <Page
  31. :total="siteMessages.length"
  32. :page-size="pageSize"
  33. :current.sync="page"
  34. style="text-align: right; margin-top: 10px;"
  35. />
  36. </div>
  37. </main-layout>
  38. </template>
  39. <script>
  40. // import moment from "moment";
  41. import { mapState, mapMutations } from "vuex";
  42. export default {
  43. name: "SiteMessageHome",
  44. data() {
  45. return {
  46. columns: [
  47. {
  48. type: "selection",
  49. width: 60,
  50. align: "center",
  51. },
  52. {
  53. title: "标题",
  54. key: "title",
  55. render: (h, params) => {
  56. return (
  57. <router-link
  58. to={"/site-message/" + params.row.id + "?fromPage=" + this.page}
  59. style="display: flex"
  60. ondragstart="return false;"
  61. >
  62. <img
  63. class={
  64. params.row.hasRead
  65. ? "mhome-message-read"
  66. : "mhome-message-unread"
  67. }
  68. />
  69. <span class="mhome-message-title">{params.row.title}</span>
  70. </router-link>
  71. );
  72. },
  73. },
  74. {
  75. title: "发送时间",
  76. key: "publishTime",
  77. width: "150",
  78. },
  79. ],
  80. page: 1,
  81. pageSize: 10,
  82. };
  83. },
  84. computed: {
  85. ...mapState(["user", "siteMessages", "siteMessagesTimeStamp", "menus"]),
  86. locationTitle() {
  87. return (
  88. this.menus.find(
  89. v => v.link.toUpperCase() === this.$route.path.toUpperCase()
  90. ) || {}
  91. ).name;
  92. },
  93. siteMessagesComputed() {
  94. return this.siteMessages.slice(
  95. (this.page - 1) * this.pageSize,
  96. this.page * this.pageSize
  97. );
  98. },
  99. },
  100. async mounted() {
  101. window._hmt.push(["_trackEvent", "站内消息列表页面", "进入页面"]);
  102. this.logger({ page: "站内消息列表页面", action: "进入页面" });
  103. await this.getList();
  104. if (this.$route.query.fromPage) {
  105. this.page = +this.$route.query.fromPage;
  106. }
  107. },
  108. methods: {
  109. ...mapMutations(["updateSiteMessages", "updateSiteMessagesTimeStamp"]),
  110. async getList() {
  111. try {
  112. const noticeRes = (await this.$http.get(
  113. "/api/ecs_exam_work/notice/getUserNoticeList?" +
  114. this.user.id +
  115. this.siteMessagesTimeStamp
  116. )).data;
  117. this.updateSiteMessages(noticeRes);
  118. } catch (error) {
  119. console.log(error);
  120. this.$Message.error({
  121. content: "获取公告通知异常",
  122. duration: 15,
  123. closable: true,
  124. });
  125. }
  126. },
  127. async markRead() {
  128. // console.log(this.$refs.selection.getSelection());
  129. const selectIds = this.$refs.selection.getSelection().map(v => v.id);
  130. if (selectIds.length === 0) {
  131. this.$Message.warning({
  132. content: "请先选择消息",
  133. duration: 10,
  134. closable: true,
  135. });
  136. return;
  137. }
  138. await this.$http.post(
  139. "/api/ecs_exam_work/notice/updateNoticeReadStatus?noticeId=" +
  140. selectIds.join(",")
  141. );
  142. window._hmt.push(["_trackEvent", "站内消息详情页面", "发送已读成功"]);
  143. this.updateSiteMessagesTimeStamp(Date.now());
  144. await this.getList();
  145. },
  146. },
  147. };
  148. </script>
  149. <style scoped>
  150. .home {
  151. margin: 20px;
  152. display: flex;
  153. justify-content: space-between;
  154. }
  155. .mark-read-block {
  156. line-height: 16px;
  157. /* border-radius: 6px;
  158. border: 1px solid rgba(238, 238, 238, 1); */
  159. /* padding: 0 10px; */
  160. display: flex;
  161. align-items: center;
  162. }
  163. .site-message-container {
  164. display: flex;
  165. flex-direction: column;
  166. margin: 20px;
  167. padding: 20px;
  168. border: 1px solid #eeeeee;
  169. border-radius: 6px;
  170. }
  171. </style>
  172. <style>
  173. .mhome-message-read {
  174. width: 16px;
  175. height: 14px;
  176. background-image: url(./svgs/sms-read.svg);
  177. }
  178. .mhome-message-unread {
  179. width: 16px;
  180. height: 14px;
  181. background-image: url(./svgs/sms-unread.svg);
  182. }
  183. .mhome-message-title {
  184. line-height: 14px;
  185. margin-left: 8px;
  186. }
  187. </style>