message.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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 :style="heightString">
  16. <span v-if="messages[0].length == 0">目前暂无消息</span>
  17. <div
  18. class="message-div"
  19. v-for="item in messages[0]"
  20. @click="locationHerf(item.id, item.refId, item.noticeType, item.belongType)"
  21. >
  22. <p>
  23. <span class="message-title isRead" v-if="item.isRead == 1">{{item.projectName}}</span>
  24. <span class="message-title" v-else>{{item.projectName}}</span>
  25. <span class="message-time">{{item.indate}}</span>
  26. </p>
  27. <p class="message-article">{{item.content}}</p>
  28. </div>
  29. </div>
  30. <!--分页1-->
  31. <el-col :span="24" class="toolbar">
  32. <el-pagination
  33. @size-change="handleSizeChange0"
  34. @current-change="handleCurrentChange0"
  35. :page-sizes="[20 , 50 , 80 , 100 , 200]"
  36. :page-size="20"
  37. layout="total, sizes, prev, pager, next"
  38. :total="total[0]"
  39. style="float:right;"
  40. ></el-pagination>
  41. </el-col>
  42. </el-tab-pane>
  43. <el-tab-pane name="1" label="警告">
  44. <div :style="heightString">
  45. <span v-if="messages[1].length == 0">目前暂无消息</span>
  46. <div
  47. class="message-div"
  48. v-for="item in messages[1]"
  49. @click="locationHerf(item.id, item.refId, item.noticeType, null)"
  50. >
  51. <p>
  52. <span class="message-title isRead" v-if="item.isRead == 1">{{item.projectName}}</span>
  53. <span class="message-title" v-else>{{item.projectName}}</span>
  54. <span class="message-time">{{item.indate}}</span>
  55. </p>
  56. <p class="message-article">{{item.content}}</p>
  57. </div>
  58. </div>
  59. <!--分页2-->
  60. <el-col :span="24" class="toolbar">
  61. <el-pagination
  62. @size-change="handleSizeChange1"
  63. @current-change="handleCurrentChange1"
  64. :page-sizes="[20 , 50 , 80 , 100 , 200]"
  65. :page-size="20"
  66. layout="total, sizes, prev, pager, next"
  67. :total="total[1]"
  68. style="float:right;"
  69. ></el-pagination>
  70. </el-col>
  71. </el-tab-pane>
  72. <el-tab-pane name="2" label="保养">
  73. <div :style="heightString">
  74. <span v-if="messages[2].length == 0">目前暂无消息</span>
  75. <div
  76. class="message-div"
  77. v-for="item in messages[2]"
  78. @click="locationHerf(item.id, item.refId, item.noticeType, null)"
  79. >
  80. <p>
  81. <span class="message-title isRead" v-if="item.isRead == 1">{{item.projectName}}</span>
  82. <span class="message-title" v-else>{{item.projectName}}</span>
  83. <span class="message-time">{{item.indate}}</span>
  84. </p>
  85. <p class="message-article">{{item.content}}</p>
  86. </div>
  87. </div>
  88. <!--分页3-->
  89. <el-col :span="24" class="toolbar">
  90. <el-pagination
  91. @size-change="handleSizeChange2"
  92. @current-change="handleCurrentChange2"
  93. :page-sizes="[20 , 50 , 80 , 100 , 200]"
  94. :page-size="20"
  95. layout="total, sizes, prev, pager, next"
  96. :total="total[2]"
  97. style="float:right;"
  98. ></el-pagination>
  99. </el-col>
  100. </el-tab-pane>
  101. </el-tabs>
  102. </el-col>
  103. </section>
  104. </template>
  105. <script>
  106. import util from "../common/js/util";
  107. export default {
  108. data() {
  109. return {
  110. messages: [[], [], []],
  111. page0: 1,
  112. page1: 1,
  113. page2: 1,
  114. size: 20,
  115. total: [0, 0, 0],
  116. tableHeight: 0,
  117. activePage: 0,
  118. heightString: ""
  119. };
  120. },
  121. methods: {
  122. //分页1
  123. handleCurrentChange0(val) {
  124. this.page0 = val;
  125. this.loadNotice();
  126. },
  127. handleSizeChange0(val) {
  128. this.size1 = val;
  129. this.loadNotice();
  130. },
  131. //分页2
  132. handleCurrentChange1(val) {
  133. this.page2 = val;
  134. this.loadNotice();
  135. },
  136. handleSizeChange1(val) {
  137. this.size = val;
  138. this.loadNotice();
  139. },
  140. //分页3
  141. handleCurrentChange2(val) {
  142. this.page = val;
  143. this.loadNotice();
  144. },
  145. handleSizeChange2(val) {
  146. this.size = val;
  147. this.loadNotice();
  148. },
  149. //标签页面切换时
  150. handleClick(tab, event) {
  151. this.activeTab = tab.name;
  152. },
  153. //读取消息提示
  154. loadNotice() {
  155. this.http.post(
  156. this.port.notice.list,
  157. {
  158. pageNum: this.page,
  159. pageSize: this.size
  160. },
  161. res => {
  162. if (res.code == "ok") {
  163. this.messages = [];
  164. this.messages.push(res.data[0].approvelList.list);
  165. this.messages.push(res.data[1].matainList.list);
  166. this.messages.push(res.data[2].emergencyList.list);
  167. this.total[0] = res.data[0].approvelList.total;
  168. this.total[1] = res.data[1].matainList.total;
  169. this.total[2] = res.data[2].emergencyList.total;
  170. } else {
  171. this.$message({
  172. message: res.msg,
  173. type: "error"
  174. });
  175. }
  176. },
  177. error => {
  178. this.$message({
  179. message: error,
  180. type: "error"
  181. });
  182. }
  183. );
  184. },
  185. //点击消息的跳转
  186. locationHerf(id, refid, type, approval) {
  187. this.http.post(
  188. this.port.notice.read,
  189. {
  190. id: id
  191. },
  192. res => {
  193. if (res.code == "ok") {
  194. } else {
  195. this.$message({
  196. message: res.msg,
  197. type: "error"
  198. });
  199. }
  200. },
  201. error => {
  202. this.$message({
  203. message: error,
  204. type: "error"
  205. });
  206. }
  207. );
  208. if (type == 0) {
  209. //审批 跳转到模具详情
  210. this.$router.push("/moldList/" + refid + "/" + approval);
  211. } else if (type == 1) {
  212. //警告 跳转到运行监测
  213. this.$router.push("/detection");
  214. } else if (type == 2) {
  215. //保养 跳转到运行监测详情
  216. this.$router.push("/detection/" + refid);
  217. }
  218. }
  219. },
  220. created() {
  221. let height = window.innerHeight;
  222. this.tableHeight = height - 260;
  223. this.heightString = "height: " + this.tableHeight + "px";
  224. },
  225. mounted() {
  226. this.loadNotice();
  227. }
  228. };
  229. </script>
  230. <style scoped>
  231. .message-div {
  232. cursor: pointer;
  233. padding: 5px 0;
  234. }
  235. .message-div > p {
  236. line-height: 25px;
  237. margin: 0;
  238. }
  239. .message-type {
  240. font-weight: 700;
  241. }
  242. .message-time {
  243. padding-left: 30px;
  244. color: #777;
  245. }
  246. .message-title {
  247. color: #409eff;
  248. }
  249. .message-article {
  250. color: #555;
  251. }
  252. .isRead {
  253. color: #999 !important;
  254. }
  255. </style>