NoticeWrap.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <script setup>
  2. import { apiSystemMessage } from '@/api/system'
  3. import { useRouter } from 'vue-router'
  4. const router=useRouter()
  5. const emits=defineEmits(['change'])
  6. const tableQuery = reactive({
  7. currentPage:1,
  8. pageSize:10,
  9. totals:0,
  10. })
  11. const list = ref([])
  12. function getMsgList() {
  13. apiSystemMessage.list({
  14. CurrentIndex:tableQuery.currentPage,
  15. PageSize:tableQuery.pageSize,
  16. }).then(res => {
  17. if (res.Ret === 200) {
  18. list.value = res.Data.List || []
  19. list.value.map(item=>{
  20. // item.isTrue = item.Message.substr(item.Message.length - 5) === '退款成功!' ? true : false
  21. item.isTrue = item.Message.search("退款成功") != -1
  22. })
  23. tableQuery.totals = res.Data.Paging.Totals||0
  24. const hasUnRead=list.value.some(item=>item.Status === 'UNREAD')
  25. emits('change',hasUnRead)
  26. }
  27. })
  28. }
  29. getMsgList()
  30. function handlePageChange(page){
  31. tableQuery.currentPage = page
  32. getMsgList()
  33. }
  34. function handleGoCustomerDetail(e){
  35. handleReadNotice(e.Id)
  36. // router.push('/order/orderList')
  37. }
  38. // 阅读消息
  39. function handleReadNotice(id){
  40. apiSystemMessage.msgRead({
  41. messageId: id
  42. }).then(res=>{
  43. if(res.Ret===200){
  44. router.push('/order/orderList')
  45. }
  46. })
  47. }
  48. </script>
  49. <template>
  50. <div class="notice-wrap">
  51. <div class="title">消息提醒</div>
  52. <div class="list-wrap">
  53. <div
  54. :class="['item', item.Status !=='UNREAD' ? 'item-read' : '']"
  55. v-for="item in list"
  56. :key="item.SysMessageReportId"
  57. @click="handleGoCustomerDetail(item)"
  58. >
  59. <svg-icon name="success" size="16px" v-if="item.isTrue"></svg-icon>
  60. <svg-icon name="failure" size="16px" v-if="!item.isTrue"></svg-icon>
  61. <span style="margin-left: 10px">{{ item.Message }}</span>
  62. <span style="margin-left: 20px">{{ item.CreatedTime }}</span>
  63. <!-- <div v-html="item.Message"></div> -->
  64. </div>
  65. <el-pagination
  66. background
  67. layout="total,prev,pager,next,jumper"
  68. :current-page="tableQuery.currentPage"
  69. :page-size="tableQuery.pageSize"
  70. :total="tableQuery.totals"
  71. @current-change="handlePageChange"
  72. style=" justify-content: flex-end;"
  73. />
  74. </div>
  75. </div>
  76. </template>
  77. <style lang="scss" scoped>
  78. .notice-wrap {
  79. .title {
  80. padding: 15px 0;
  81. border-bottom: 1px solid #e7e7e7;
  82. }
  83. .list-wrap {
  84. max-height: 500px;
  85. overflow-y: auto;
  86. .item {
  87. padding: 10px;
  88. cursor: pointer;
  89. display: flex;
  90. align-items: center;
  91. span {
  92. display: inline-block;
  93. }
  94. }
  95. .item-read {
  96. color: #999;
  97. }
  98. }
  99. }
  100. </style>