SiteMessageHome.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <section class="content">
  3. <div class="box box-info">
  4. <div
  5. v-loading.body="loading"
  6. v-loading.fullscreen="loading"
  7. class="box-body"
  8. element-loading-text="请稍后..."
  9. >
  10. <!-- 表单 -->
  11. <el-form inline>
  12. <el-form-item>
  13. <el-button
  14. size="small"
  15. type="primary"
  16. icon="el-icon-arrow-left"
  17. @click="back"
  18. >
  19. 返回
  20. </el-button>
  21. <el-button
  22. size="small"
  23. type="primary"
  24. icon="el-icon-refresh"
  25. @click="searchForm"
  26. >
  27. 刷新
  28. </el-button>
  29. <el-button
  30. size="small"
  31. type="primary"
  32. :disabled="noBatchSelected"
  33. @click="setRead()"
  34. >
  35. 标记为已读
  36. </el-button>
  37. </el-form-item>
  38. </el-form>
  39. <div class="block-seperator"></div>
  40. <!-- 页面列表 -->
  41. <el-table
  42. :data="tableData"
  43. border
  44. resizable
  45. stripe
  46. style="width: 100%"
  47. @selection-change="selectChange"
  48. >
  49. <el-table-column type="selection" width="50"></el-table-column>
  50. <el-table-column width="100" label="ID">
  51. <span slot-scope="scope">{{ scope.row.id }}</span>
  52. </el-table-column>
  53. <el-table-column label="标题"
  54. ><span slot-scope="scope">
  55. <router-link
  56. v-if="scope.row.hasRecalled == true"
  57. style="display: flex"
  58. >
  59. <img
  60. :class="
  61. scope.row.hasRead
  62. ? 'mhome-message-read'
  63. : 'mhome-message-unread'
  64. "
  65. />
  66. <span class="mhome-message-title">{{ scope.row.title }}</span>
  67. </router-link>
  68. <router-link
  69. v-if="
  70. scope.row.hasRecalled == null ||
  71. scope.row.hasRecalled === false
  72. "
  73. :to="'/home/site-message/' + scope.row.id"
  74. style="display: flex"
  75. >
  76. <img
  77. :class="
  78. scope.row.hasRead
  79. ? 'mhome-message-read'
  80. : 'mhome-message-unread'
  81. "
  82. />
  83. <span class="mhome-message-title">{{ scope.row.title }}</span>
  84. </router-link>
  85. </span></el-table-column
  86. >
  87. <el-table-column width="180" prop="publishTime" label="发送时间">
  88. </el-table-column>
  89. </el-table>
  90. <div class="page pull-right">
  91. <el-pagination v-if="paginationShow" layout="total" :total="total" />
  92. </div>
  93. </div>
  94. </div>
  95. </section>
  96. </template>
  97. <script>
  98. import { EXAM_WORK_API } from "@/constants/constants.js";
  99. import { mapState } from "vuex";
  100. export default {
  101. name: "Project",
  102. data() {
  103. return {
  104. loading: false,
  105. selectedIds: [],
  106. paginationShow: false,
  107. tableData: [],
  108. total: 10,
  109. };
  110. },
  111. computed: {
  112. ...mapState({ user: (state) => state.user }),
  113. ids() {
  114. var ids = "";
  115. for (let id of this.selectedIds) {
  116. if (!ids) {
  117. ids += id;
  118. } else {
  119. ids += "," + id;
  120. }
  121. }
  122. return ids;
  123. },
  124. noBatchSelected() {
  125. return this.selectedIds.length === 0;
  126. },
  127. },
  128. //初始化查询
  129. created() {
  130. this.searchForm();
  131. },
  132. methods: {
  133. back() {
  134. this.$router.push({ path: "/home/overview" });
  135. },
  136. setRead() {
  137. var ids = this.checkIds();
  138. if (!ids) return;
  139. var url =
  140. EXAM_WORK_API + "/notice/updateNoticeReadStatus?noticeId=" + ids;
  141. this.$httpWithMsg.post(url).then(() => {
  142. this.$notify({
  143. type: "success",
  144. message: "操作成功",
  145. });
  146. this.searchForm();
  147. });
  148. },
  149. checkIds() {
  150. if (this.ids.length == 0) {
  151. this.$notify({
  152. type: "warning",
  153. message: "请选择通知",
  154. });
  155. return "";
  156. } else {
  157. return this.ids;
  158. }
  159. },
  160. selectChange(row) {
  161. this.selectedIds = [];
  162. row.forEach((element) => {
  163. this.selectedIds.push(element.id);
  164. });
  165. },
  166. handleSearchBtn() {
  167. this.currentPage = 0;
  168. this.searchForm();
  169. },
  170. //查询
  171. searchForm() {
  172. this.loading = true;
  173. var url = EXAM_WORK_API + "/notice/getUserNoticeList";
  174. this.$httpWithMsg
  175. .get(url)
  176. .then((response) => {
  177. this.$eventHub.$emit("UnreadNoticeChange");
  178. this.tableData = response.data;
  179. this.total = response.data.length;
  180. this.loading = false;
  181. this.$nextTick(function () {
  182. this.paginationShow = true;
  183. });
  184. })
  185. .finally(() => (this.loading = false));
  186. },
  187. },
  188. };
  189. </script>
  190. <style scoped>
  191. .page {
  192. margin-top: 10px;
  193. }
  194. .pull-length {
  195. width: 300px;
  196. }
  197. .pull-center {
  198. margin-top: 20px;
  199. }
  200. .editForm .el-form-item {
  201. margin-bottom: 12px;
  202. }
  203. .mhome-message-read {
  204. width: 16px;
  205. height: 14px;
  206. background-image: url(./svgs/sms-read.svg);
  207. }
  208. .mhome-message-unread {
  209. width: 16px;
  210. height: 14px;
  211. background-image: url(./svgs/sms-unread.svg);
  212. }
  213. .mhome-message-title {
  214. line-height: 14px;
  215. margin-left: 8px;
  216. }
  217. </style>