message.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <section>
  3. <!--工具条-->
  4. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  5. <el-form :inline="true">
  6. <el-col :span="2">
  7. <el-form-item>消息中心</el-form-item>
  8. </el-col>
  9. </el-form>
  10. </el-col>
  11. <!--选项卡-->
  12. <el-col :span="24">
  13. <el-tabs v-model="activePage" @tab-click="handleClick" type="card">
  14. <el-tab-pane name="0" label="审批">
  15. <div class="message-div" v-for="item in messages[0]">
  16. <p>
  17. <span
  18. class="message-title"
  19. @click="locationHerf(item.refId, item.noticeType)"
  20. >{{item.projectName}}</span>
  21. <span class="message-time">{{item.indate}}</span>
  22. </p>
  23. <p class="message-article">{{item.content}}</p>
  24. </div>
  25. </el-tab-pane>
  26. <el-tab-pane name="1" label="警告">
  27. <div class="message-div" v-for="item in messages[1]">
  28. <p>
  29. <span
  30. class="message-title"
  31. @click="locationHerf(item.refId, item.noticeType)"
  32. >{{item.projectName}}</span>
  33. <span class="message-time">{{item.indate}}</span>
  34. </p>
  35. <p class="message-article">{{item.content}}</p>
  36. </div>
  37. </el-tab-pane>
  38. <el-tab-pane name="2" label="保养">
  39. <div class="message-div" v-for="item in messages[2]">
  40. <p>
  41. <span
  42. class="message-title"
  43. @click="locationHerf(item.refId, item.noticeType)"
  44. >{{item.projectName}}</span>
  45. <span class="message-time">{{item.indate}}</span>
  46. </p>
  47. <p class="message-article">{{item.content}}</p>
  48. </div>
  49. </el-tab-pane>
  50. </el-tabs>
  51. </el-col>
  52. <!--工具条-->
  53. <el-col :span="24" class="toolbar">
  54. <el-pagination
  55. @size-change="handleSizeChange"
  56. @current-change="handleCurrentChange"
  57. :page-sizes="[20 , 50 , 80 , 100 , 200]"
  58. :page-size="20"
  59. layout="total, sizes, prev, pager, next"
  60. :total="total"
  61. style="float:right;"
  62. ></el-pagination>
  63. </el-col>
  64. </section>
  65. </template>
  66. <script>
  67. import util from "../common/js/util";
  68. export default {
  69. data() {
  70. return {
  71. messages: [],
  72. page: 1,
  73. size: 20,
  74. total: 0,
  75. tableHeight: 0,
  76. activePage: 0
  77. };
  78. },
  79. methods: {
  80. //分页
  81. handleCurrentChange(val) {
  82. this.page = val;
  83. this.loadNotice();
  84. },
  85. handleSizeChange(val) {
  86. this.size = val;
  87. this.loadNotice();
  88. },
  89. //标签页面切换时
  90. handleClick(tab, event) {
  91. this.activeTab = tab.name;
  92. },
  93. //读取消息提示
  94. loadNotice() {
  95. this.http.post(
  96. this.port.notice.list,
  97. {
  98. pageNum: this.page,
  99. pageSize: this.size
  100. },
  101. res => {
  102. if (res.code == "ok") {
  103. this.messages = [];
  104. this.messages.push(res.data[0].emergencyList.list);
  105. this.messages.push(res.data[1].emergencyList.list);
  106. this.messages.push(res.data[2].emergencyList.list);
  107. } else {
  108. this.$message({
  109. message: res.msg,
  110. type: "error"
  111. });
  112. }
  113. },
  114. error => {
  115. this.$message({
  116. message: error,
  117. type: "error"
  118. });
  119. }
  120. );
  121. },
  122. //点击消息的跳转
  123. locationHerf(id, type) {
  124. this.http.post(
  125. this.port.notice.read,
  126. {
  127. id: id
  128. },
  129. res => {
  130. if (res.code == "ok") {
  131. } else {
  132. this.$message({
  133. message: res.msg,
  134. type: "error"
  135. });
  136. }
  137. },
  138. error => {
  139. this.$message({
  140. message: error,
  141. type: "error"
  142. });
  143. }
  144. );
  145. if (type == 0) {
  146. //审批 跳转到模具详情
  147. this.$router.push("/moldList/" + id);
  148. } else if (type == 1) {
  149. //警告 跳转到运行监测
  150. this.$router.push("/detection");
  151. } else if (type == 2) {
  152. //保养 跳转到运行监测详情
  153. this.$router.push("/detection/" + id);
  154. }
  155. }
  156. },
  157. created() {
  158. let height = window.innerHeight;
  159. this.tableHeight = height - 260;
  160. },
  161. mounted() {
  162. this.loadNotice();
  163. }
  164. };
  165. </script>
  166. <style scoped>
  167. .message-div {
  168. padding: 5px 0;
  169. }
  170. .message-div > p {
  171. line-height: 25px;
  172. margin: 0;
  173. }
  174. .message-type {
  175. font-weight: 700;
  176. }
  177. .message-time {
  178. padding-left: 30px;
  179. color: #777;
  180. }
  181. .message-title {
  182. cursor: pointer;
  183. color: #409eff;
  184. }
  185. .message-article {
  186. color: #555;
  187. }
  188. </style>