message.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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="options">
  14. <u-cell-group>
  15. <u-cell @click="toDetail(notify)">
  16. <u-avatar slot="icon" icon="bell-fill" fontSize="22" randomBgColor></u-avatar>
  17. <view slot="title" class="content">
  18. <view class="text-bold text-grey">
  19. <view class="ellipsis-description">
  20. 标题:{{notify.title}}
  21. </view>
  22. </view>
  23. <view class="text-gray text-sm">
  24. <view class="ellipsis-description">
  25. 发布者:{{notify.createBy.name}}, {{notify.createTime}}
  26. </view>
  27. </view>
  28. <view class="text-sm">
  29. <view class="ellipsis-description">
  30. 内容:{{notify.content}}
  31. </view>
  32. </view>
  33. </view>
  34. <view slot="right-icon">
  35. <u-tag :text="$dictUtils.getDictLabel('oa_notify_read', notify.readFlag ,'')" v-if="notify.readFlag === '1'" plain shape="circle"></u-tag>
  36. <u-tag :text="$dictUtils.getDictLabel('oa_notify_read', notify.readFlag ,'')" v-else plain type="error" shape="circle"></u-tag>
  37. </view>
  38. </u-cell>
  39. </u-cell-group>
  40. </u-swipe-action-item>
  41. </view>
  42. </u-swipe-action>
  43. </view>
  44. <u-loadmore :status="status" @loadmore="loadmore" :line="true" />
  45. <u-gap height="100" bgColor="#fff"></u-gap>
  46. <u-back-top :scrollTop="0" mode="square"></u-back-top>
  47. </view>
  48. </template>
  49. <script>
  50. import notifyService from "@/api/notify/notifyService";
  51. export default {
  52. data() {
  53. return {
  54. status: 'loadmore',
  55. searchForm: {
  56. title: ''
  57. },
  58. dataList: [],
  59. tablePage: {
  60. pages: 0,
  61. currentPage: 0,
  62. pageSize: 10,
  63. orders: [{ column: "a.create_time", asc: false }],
  64. },
  65. loading: false,
  66. options: [ {
  67. text: '删除',
  68. style: {
  69. backgroundColor: '#f56c6c'
  70. }
  71. }]
  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. }else{
  85. this.toEdit(notify)
  86. }
  87. },
  88. toEdit (notify) {
  89. uni.navigateTo({
  90. url: '/pages/apps/notification/oaNotifyForm?id='+notify.id
  91. })
  92. },
  93. toAdd (){
  94. uni.navigateTo({
  95. url: '/pages/apps/notification/oaNotifyForm'
  96. })
  97. },
  98. // 输入监听
  99. inputWord(e){
  100. this.searchTimer && clearTimeout(this.searchTimer)
  101. this.searchTimer = setTimeout(()=>{
  102. this.doSearch()
  103. },300)
  104. },
  105. // 搜索
  106. doSearch(){
  107. this.dataList = [];
  108. this.tablePage.currentPage = 0;
  109. this.tablePage.pageSize = 10;
  110. this.tablePage.pages = 0;
  111. this.loadmore()
  112. },
  113. onReachBottom() {
  114. this.loadmore()
  115. },
  116. loadmore() {
  117. if(this.tablePage.currentPage!==0 && this.tablePage.pages <= this.tablePage.currentPage ) {
  118. this.status = 'nomore';
  119. return;
  120. }
  121. this.tablePage.currentPage = ++ this.tablePage.currentPage;
  122. //联网加载数据
  123. this.status = 'loading';
  124. notifyService.list({
  125. isSelf: true,
  126. current: this.tablePage.currentPage,
  127. size: this.tablePage.pageSize,
  128. orders: this.tablePage.orders,
  129. ...this.searchForm
  130. }).then((data)=>{
  131. //追加新数据
  132. this.dataList=this.dataList.concat(data.records);
  133. this.tablePage.pages = data.pages;
  134. if(this.tablePage.pages <= this.tablePage.currentPage){
  135. this.status = 'nomore'
  136. } else {
  137. this.status = 'loadmore'
  138. }
  139. })
  140. },
  141. del (id) {
  142. notifyService.delete(id).then((data)=>{
  143. this.doSearch()
  144. uni.showToast({
  145. title: data,
  146. icon:"success"
  147. })
  148. })
  149. },
  150. }
  151. }
  152. </script>