oaNotifyList.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <view>
  3. <uni-fab
  4. horizontal="right"
  5. vertical="bottom"
  6. @fabClick="toAdd"
  7. ></uni-fab>
  8. <u-search :show-action="false" v-model="searchForm.title" @change="inputWord" margin="20rpx 50rpx"></u-search>
  9. <view>
  10. <u-swipe-action>
  11. <view
  12. v-for="(notify, index) in dataList"
  13. :key="index">
  14. <u-swipe-action-item @click="del(notify.id)" :key="notify.id" :threshold="60" duration="500"
  15. :options="options">
  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_status', notify.status ,'')" v-if="notify.status === '1'" plain shape="circle"></u-tag>
  38. <u-tag :text="$dictUtils.getDictLabel('oa_notify_status', notify.status ,'')" 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. options: [ {
  68. text: '删除',
  69. style: {
  70. backgroundColor: '#f56c6c'
  71. }
  72. }]
  73. }
  74. },
  75. created() {
  76. this.loadmore()
  77. },
  78. methods: {
  79. // 跳转到详细页面
  80. toDetail (notify) {
  81. if(notify.status === '1'){
  82. uni.navigateTo({
  83. url: '/pages/apps/notification/notificationDetail?id='+notify.id
  84. })
  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. 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. 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>