message.vue 7.3 KB

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