message.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-blue" backUrl="/pages/index/index?id=apps" :isBack="false">
  4. <block slot="content"> 消息</block>
  5. </cu-custom>
  6. <u-search :show-action="false" v-model="searchForm.title" @change="inputWord" margin="20rpx 50rpx"></u-search>
  7. <view>
  8. <u-swipe-action>
  9. <view
  10. v-for="(notify, index) in dataList"
  11. :key="index">
  12. <u-swipe-action-item @click="del(notify.id)" :key="notify.id" :threshold="60" duration="500"
  13. :options="[ {
  14. text: '删除',
  15. style: {
  16. backgroundColor: '#f56c6c'
  17. }
  18. }]">
  19. <u-cell-group>
  20. <u-cell @click="toDetail(notify)">
  21. <u-avatar slot="icon" icon="bell-fill" fontSize="22" randomBgColor></u-avatar>
  22. <view slot="title" class="content">
  23. <view class="text-bold text-grey">
  24. <view class="ellipsis-description">
  25. 标题:{{notify.title}}
  26. </view>
  27. </view>
  28. <view class="text-gray text-sm">
  29. <view class="ellipsis-description">
  30. 发布者:{{notify.createBy.name}}, 所属行政村:{{notify.createBy.officeDTO.name}}
  31. </view>
  32. </view>
  33. <view class="text-sm">
  34. <view class="ellipsis-description">
  35. 发布时间:{{notify.createTime}}
  36. </view>
  37. </view>
  38. </view>
  39. <view slot="right-icon">
  40. <u-tag :text="$dictUtils.getDictLabel('oa_notify_read', notify.readFlag ,'')" v-if="notify.readFlag === '1'" plain shape="circle"></u-tag>
  41. <u-tag :text="$dictUtils.getDictLabel('oa_notify_read', notify.readFlag ,'')" v-else plain type="error" shape="circle"></u-tag>
  42. </view>
  43. </u-cell>
  44. </u-cell-group>
  45. </u-swipe-action-item>
  46. </view>
  47. </u-swipe-action>
  48. </view>
  49. <u-loadmore :status="status" @loadmore="loadmore" :line="true" />
  50. <u-gap height="100" bgColor="#fff"></u-gap>
  51. <u-back-top :scrollTop="0" mode="square"></u-back-top>
  52. </view>
  53. </template>
  54. <script>
  55. import notifyService from "@/api/notify/notifyService";
  56. import { EventBus } from '@/store/eventBus.js';
  57. export default {
  58. data() {
  59. return {
  60. status: 'loadmore',
  61. searchForm: {
  62. title: ''
  63. },
  64. dataList: [],
  65. tablePage: {
  66. pages: 0,
  67. currentPage: 0,
  68. pageSize: 10,
  69. orders: [{ column: "a.create_time", asc: false }],
  70. },
  71. loading: false,
  72. }
  73. },
  74. created() {
  75. this.loadmore()
  76. },
  77. methods: {
  78. // 跳转到详细页面
  79. toDetail (notify) {
  80. if(notify.status === '1'){
  81. uni.navigateTo({
  82. url: '/pages/apps/notification/notificationDetail?id='+notify.id
  83. })
  84. this.loadmore()
  85. }else{
  86. this.toEdit(notify)
  87. }
  88. },
  89. toEdit (notify) {
  90. uni.navigateTo({
  91. url: '/pages/apps/notification/oaNotifyForm?id='+notify.id
  92. })
  93. },
  94. toAdd (){
  95. uni.navigateTo({
  96. url: '/pages/apps/notification/oaNotifyForm'
  97. })
  98. },
  99. // 输入监听
  100. inputWord(e){
  101. this.searchTimer && clearTimeout(this.searchTimer)
  102. this.searchTimer = setTimeout(()=>{
  103. this.doSearch()
  104. },300)
  105. },
  106. // 搜索
  107. doSearch(){
  108. this.dataList = [];
  109. this.tablePage.currentPage = 0;
  110. this.tablePage.pageSize = 10;
  111. this.tablePage.pages = 0;
  112. this.loadmore()
  113. },
  114. onReachBottom() {
  115. this.loadmore()
  116. },
  117. async loadmore() {
  118. if(this.tablePage.currentPage!==0 && this.tablePage.pages <= this.tablePage.currentPage ) {
  119. this.status = 'nomore';
  120. return;
  121. }
  122. this.tablePage.currentPage = ++ this.tablePage.currentPage;
  123. //联网加载数据
  124. this.status = 'loading';
  125. notifyService.list({
  126. isSelf: true,
  127. current: this.tablePage.currentPage,
  128. size: this.tablePage.pageSize,
  129. orders: this.tablePage.orders,
  130. ...this.searchForm
  131. }).then((data)=>{
  132. //追加新数据
  133. this.dataList=this.dataList.concat(data.records);
  134. this.tablePage.pages = data.pages;
  135. if(this.tablePage.pages <= this.tablePage.currentPage){
  136. this.status = 'nomore'
  137. } else {
  138. this.status = 'loadmore'
  139. }
  140. })
  141. notifyService.getUnreadCountByIsSelf({
  142. isSelf: true,
  143. ...this.searchForm
  144. }).then((data)=>{
  145. EventBus.$emit('dataFromMessage', data); // 触发事件,传递参数
  146. })
  147. },
  148. del (id) {
  149. notifyService.delete(id).then((data)=>{
  150. this.doSearch()
  151. uni.showToast({
  152. title: data,
  153. icon:"success"
  154. })
  155. })
  156. },
  157. }
  158. }
  159. </script>