myNotifyList.vue 3.9 KB

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