SiteMessageHome.vue 4.6 KB

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