myNotifyList.vue 3.9 KB

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