message.vue 3.1 KB

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