SiteMessageHome.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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 v-if="scope.row.hasRecalled == true" slot-scope="scope">
  55. <img
  56. :class="
  57. scope.row.hasRead
  58. ? 'mhome-message-read'
  59. : 'mhome-message-unread'
  60. "
  61. />
  62. <span class="mhome-message-title">{{ scope.row.title }}</span>
  63. </span>
  64. <span
  65. v-if="
  66. scope.row.hasRecalled == null || scope.row.hasRecalled == false
  67. "
  68. slot-scope="scope"
  69. >
  70. <router-link
  71. :to="'/home/site-message/' + scope.row.id"
  72. style="display: flex"
  73. >
  74. <img
  75. :class="
  76. scope.row.hasRead
  77. ? 'mhome-message-read'
  78. : 'mhome-message-unread'
  79. "
  80. />
  81. <span class="mhome-message-title">{{ scope.row.title }}</span>
  82. </router-link>
  83. </span>
  84. </el-table-column>
  85. <el-table-column width="180" prop="publishTime" label="发送时间">
  86. </el-table-column>
  87. </el-table>
  88. <div class="page pull-right">
  89. <el-pagination v-if="paginationShow" layout="total" :total="total" />
  90. </div>
  91. </div>
  92. </div>
  93. </section>
  94. </template>
  95. <script>
  96. import { EXAM_WORK_API } from "@/constants/constants.js";
  97. import { mapState } from "vuex";
  98. export default {
  99. name: "Project",
  100. data() {
  101. return {
  102. loading: false,
  103. selectedIds: [],
  104. paginationShow: false,
  105. tableData: [],
  106. total: 10,
  107. };
  108. },
  109. computed: {
  110. ...mapState({ user: (state) => state.user }),
  111. ids() {
  112. var ids = "";
  113. for (let id of this.selectedIds) {
  114. if (!ids) {
  115. ids += id;
  116. } else {
  117. ids += "," + id;
  118. }
  119. }
  120. return ids;
  121. },
  122. noBatchSelected() {
  123. return this.selectedIds.length === 0;
  124. },
  125. },
  126. //初始化查询
  127. created() {
  128. this.searchForm();
  129. },
  130. methods: {
  131. back() {
  132. this.$router.push({ path: "/home/overview" });
  133. },
  134. setRead() {
  135. var ids = this.checkIds();
  136. if (!ids) return;
  137. var url =
  138. EXAM_WORK_API + "/notice/updateNoticeReadStatus?noticeId=" + ids;
  139. this.$httpWithMsg.post(url).then(() => {
  140. this.$notify({
  141. type: "success",
  142. message: "操作成功",
  143. });
  144. this.searchForm();
  145. });
  146. },
  147. checkIds() {
  148. if (this.ids.length == 0) {
  149. this.$notify({
  150. type: "warning",
  151. message: "请选择通知",
  152. });
  153. return "";
  154. } else {
  155. return this.ids;
  156. }
  157. },
  158. selectChange(row) {
  159. this.selectedIds = [];
  160. row.forEach((element) => {
  161. this.selectedIds.push(element.id);
  162. });
  163. },
  164. handleSearchBtn() {
  165. this.currentPage = 0;
  166. this.searchForm();
  167. },
  168. //查询
  169. searchForm() {
  170. this.loading = true;
  171. var url = EXAM_WORK_API + "/notice/getUserNoticeList";
  172. this.$httpWithMsg
  173. .get(url)
  174. .then((response) => {
  175. this.$eventHub.$emit("UnreadNoticeChange");
  176. this.tableData = response.data;
  177. this.total = response.data.length;
  178. this.loading = false;
  179. this.$nextTick(function () {
  180. this.paginationShow = true;
  181. });
  182. })
  183. .finally(() => (this.loading = false));
  184. },
  185. },
  186. };
  187. </script>
  188. <style scoped>
  189. .page {
  190. margin-top: 10px;
  191. }
  192. .pull-length {
  193. width: 300px;
  194. }
  195. .pull-center {
  196. margin-top: 20px;
  197. }
  198. .editForm .el-form-item {
  199. margin-bottom: 12px;
  200. }
  201. .mhome-message-read {
  202. width: 16px;
  203. height: 14px;
  204. background-image: url(./svgs/sms-read.svg);
  205. }
  206. .mhome-message-unread {
  207. width: 16px;
  208. height: 14px;
  209. background-image: url(./svgs/sms-unread.svg);
  210. }
  211. .mhome-message-title {
  212. line-height: 14px;
  213. margin-left: 8px;
  214. }
  215. </style>