SiteMessageHome.vue 5.0 KB

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