msg.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div class="msg">
  3. <div class="msg-title">通知消息
  4. <el-button round size="small" @click="setAllRead()">全部已读</el-button>
  5. </div>
  6. <div class="msg-type">
  7. <div class="msg-type-item" v-for="(item, index) in msgType" @click="getMsgList(item.msgType)">
  8. <el-badge :value="item.total" :max="99" :hidden="item.total==0" class="item" >
  9. <el-button round size="small">{{item.msgTypeName}}</el-button>
  10. </el-badge>
  11. </div>
  12. </div>
  13. <div class="mst-list">
  14. <el-timeline >
  15. <el-timeline-item :timestamp="item.createTime" placement="top" v-for="(item, index) in list">
  16. <el-card>
  17. <h4>{{item.title}}</h4>
  18. <p>{{item.content}}</p>
  19. <div><el-button type="text" v-if="item.isRead==0" @click="setRead(item)">标记为已读</el-button></div>
  20. </el-card>
  21. </el-timeline-item>
  22. </el-timeline>
  23. <div v-if="isMore" class="more" @click="loadMore()"><el-button type="text">加载更多</el-button></div>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import { setAllRead,getMsg,getMsgList,getMsgCount,setRead } from "@/api/crm/msg";
  29. export default {
  30. name: "msg",
  31. components: { },
  32. data() {
  33. return {
  34. isMore:false,
  35. currentTypeId:undefined,
  36. msgType:[],
  37. // 遮罩层
  38. loading: true,
  39. // 选中数组
  40. ids: [],
  41. // 非单个禁用
  42. single: true,
  43. // 非多个禁用
  44. multiple: true,
  45. // 显示搜索条件
  46. showSearch: true,
  47. // 总条数
  48. total: 0,
  49. // 产品表格数据
  50. list: [],
  51. queryParams: {
  52. pageNum: 1,
  53. pageSize: 10,
  54. },
  55. };
  56. },
  57. created() {
  58. this.getMsg();
  59. },
  60. mounted() {
  61. },
  62. methods: {
  63. loadMore () {
  64. this.queryParams.pageNum += 1;
  65. this.getList();
  66. },
  67. getMsg(){
  68. getMsg().then(response => {
  69. this.msgType = response.counts;
  70. if(this.currentTypeId==undefined){
  71. this.currentTypeId=this.msgType[0].msgType;
  72. }
  73. this.list =[];
  74. this.getList();
  75. });
  76. },
  77. setAllRead(){
  78. setAllRead().then(response => {
  79. this.getMsg();
  80. //更新父组件的数量
  81. this.$emit('update-count');
  82. });
  83. },
  84. setRead(row){
  85. row.isRead=1;
  86. setRead(row).then(response => {
  87. this.getMsg();
  88. //更新父组件的数量
  89. this.$emit('update-count');
  90. });
  91. },
  92. getMsgList(typeId){
  93. this.currentTypeId=typeId;
  94. this.queryParams.pageNum=1;
  95. this.list =[];
  96. this.getList();
  97. },
  98. getList() {
  99. this.loading = true;
  100. this.queryParams.type=this.currentTypeId;
  101. getMsgList(this.queryParams).then(response => {
  102. this.list=this.list.concat( response.data.list);
  103. this.total = response.data.total;
  104. this.loading = false;
  105. this.isMore=response.data.hasNextPage;
  106. });
  107. },
  108. getMsgType() {
  109. getMsg().then(response => {
  110. this.msgType = response.counts;
  111. });
  112. },
  113. }
  114. };
  115. </script>
  116. <style scoped>
  117. .msg{
  118. padding:15px;
  119. }
  120. .dialog-footer{
  121. margin-top: 30px;
  122. float: right;
  123. }
  124. .msg-type{
  125. display: flex;
  126. flex-direction: row;
  127. flex-wrap: wrap;
  128. }
  129. .msg-type-item {
  130. margin: 10px;
  131. }
  132. .mst-list{
  133. margin: 10px 0px;
  134. }
  135. </style>
  136. <style >
  137. .el-drawer__header{
  138. margin-bottom: 10px;
  139. }
  140. .more{
  141. text-align: center;
  142. font-size: 14px;
  143. color: #909399;
  144. }
  145. .msg-title{
  146. margin: 10px 10px 20px 10px;
  147. font-size: 16px;
  148. }
  149. </style>