list.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div class="hui-flex hui-content">
  3. <div class="hui-content-title">
  4. <div class="hui-title-item active">消息通知</div>
  5. </div>
  6. <div class="hui-flex-box hui-flex hui-table">
  7. <div class="hui-flex-box">
  8. <el-table :data="tableData" row-key="id" border height="100%">
  9. <el-table-column label="序号" width="50">
  10. <template slot-scope="scope">
  11. {{scope.$index + 1}}
  12. </template>
  13. </el-table-column>
  14. <el-table-column label="消息内容">
  15. <template slot-scope="scope">
  16. <div class="hui-ellipsis">
  17. {{scope.row.message}}
  18. </div>
  19. </template>
  20. </el-table-column>
  21. <el-table-column label="是否已读" width="180">
  22. <template slot-scope="scope">
  23. <div class="hui-table-tag">
  24. <div class="hui-tag hui-tag-info" v-if="scope.row.viewed">已读</div>
  25. <div class="hui-tag hui-tag-warning" v-else>未读</div>
  26. </div>
  27. </template>
  28. </el-table-column>
  29. <el-table-column label="时间" prop="sentTime" width="180"></el-table-column>
  30. <el-table-column label="消息类型" prop="messageType" width="150">
  31. <template slot-scope="scope">
  32. <div class="hui-table-tag">
  33. <div class="hui-tag">
  34. <div>{{messageType(scope.row.messageType).name}}</div>
  35. </div>
  36. </div>
  37. </template>
  38. </el-table-column>
  39. <el-table-column width="150" label="操作">
  40. <template slot-scope="scope">
  41. <span class="table-operation" @click="detail(scope.row)">
  42. 详情
  43. </span>
  44. </template>
  45. </el-table-column>
  46. <template slot="empty">
  47. <empty description="暂无数据"></empty>
  48. </template>
  49. </el-table>
  50. </div>
  51. <div class="hui-content-pagination">
  52. <el-pagination :page-size="pageSize" :pager-count="9" layout="prev, pager, next" :total="totalCount"
  53. @current-change="currentChange">
  54. </el-pagination>
  55. </div>
  56. </div>
  57. <el-drawer title="消息详情" :visible.sync="drawer" :size="400" :append-to-body="true">
  58. <detail v-if="drawer" :type="item.messageType" :detail="item" @close="drawer = false">
  59. </detail>
  60. </el-drawer>
  61. </div>
  62. </template>
  63. <script>
  64. import {
  65. getMessagePageListByQuery
  66. } from '@/httpApi/message'
  67. import detail from '@/components/message/detail'
  68. export default {
  69. data() {
  70. return {
  71. tableData: [],
  72. pageIndex: 1,
  73. pageSize: 15,
  74. totalCount: 0,
  75. item: {},
  76. drawer: false
  77. }
  78. },
  79. created() {
  80. this.init();
  81. },
  82. methods: {
  83. init() {
  84. let data = {
  85. projectId: this.$store.getters.project.id,
  86. organizationId: this.$store.getters.organization.id,
  87. userId: this.$store.getters.user.userId
  88. }
  89. getMessagePageListByQuery(this.pageIndex, this.pageSize, data).then(res => {
  90. if (res.state) {
  91. this.tableData = res.data.dataList.map(node => {
  92. return Object.assign(node, JSON.parse(node.json));
  93. });
  94. this.totalCount = res.data.totalCount;
  95. }
  96. })
  97. },
  98. detail(item) {
  99. if (!item.viewed) this.$msg.viewed(item.id, this.init);
  100. this.item = item;
  101. this.drawer = true;
  102. },
  103. messageType(type) {
  104. return this.$msg.messageType.filter(item => item.id === type)[0];
  105. },
  106. currentChange(pageIndex) {
  107. this.pageIndex = pageIndex;
  108. this.init();
  109. }
  110. },
  111. components: {
  112. detail
  113. },
  114. }
  115. </script>
  116. <style lang="scss">
  117. </style>