index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view class="reportLog-v">
  3. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :sticky="true"
  4. :down="downOption" :up="upOption" :bottombar="false">
  5. <view class="search-box_sticky">
  6. <u-tabs :list="tabsList" :current="current" @change="change" :is-scroll='false'>
  7. </u-tabs>
  8. <view class="search-box">
  9. <u-search :placeholder="$t('app.apply.pleaseKeyword')" v-model="keyword" height="72"
  10. :show-action="false" @change="search" bg-color="#f0f2f6" shape="square">
  11. </u-search>
  12. </view>
  13. </view>
  14. <view class="log-list" v-for="(item, index) in list" :key="index">
  15. <u-swipe-action :index="index" :show="item.show" @click="handleClick" @open="open" :options="options"
  16. @content-click="goDetail(item.id)">
  17. <view class="log-list-txt u-flex-col">
  18. <view class="u-font-30 u-flex u-m-b-10 log-title">
  19. <text class="title u-line-1">{{item.title}}</text>
  20. <text>{{jnpf.toDate(item.creatorTime ,'MM-dd')}}</text>
  21. </view>
  22. <text class="u-m-t-10">{{userInfo.userName}}/{{userInfo.userAccount}}</text>
  23. </view>
  24. </u-swipe-action>
  25. </view>
  26. </mescroll-body>
  27. <view class="com-addBtn" @click="goDetail()">
  28. <u-icon name="plus" size="48" color="#fff" />
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import {
  34. getSendList,
  35. getReceiveList,
  36. delLog
  37. } from '@/api/apply/reportLog.js'
  38. import resources from '@/libs/resources.js'
  39. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  40. export default {
  41. mixins: [MescrollMixin],
  42. data() {
  43. return {
  44. downOption: {
  45. use: true,
  46. auto: true
  47. },
  48. upOption: {
  49. page: {
  50. num: 0,
  51. size: 20,
  52. time: null
  53. },
  54. empty: {
  55. use: true,
  56. icon: resources.message.nodata,
  57. tip: this.$t('common.noData'),
  58. fixed: true,
  59. top: "300rpx",
  60. },
  61. textNoMore: this.$t('app.apply.noMoreData'),
  62. },
  63. current: 0,
  64. tabsList: [{
  65. name: '我发出的'
  66. },
  67. {
  68. name: '我收到的'
  69. }
  70. ],
  71. keyword: '',
  72. list: [],
  73. userInfo: {},
  74. options: [{
  75. text: '删除',
  76. style: {
  77. backgroundColor: '#dd524d'
  78. }
  79. }]
  80. }
  81. },
  82. onLoad() {
  83. this.userInfo = uni.getStorageSync('userInfo') || {}
  84. uni.$on('refresh', () => {
  85. this.list = [];
  86. this.current = 0
  87. this.mescroll.resetUpScroll();
  88. })
  89. },
  90. onUnload() {
  91. uni.$off('refresh')
  92. },
  93. methods: {
  94. upCallback(page) {
  95. let query = {
  96. currentPage: page.num,
  97. pageSize: page.size,
  98. keyword: this.keyword
  99. }
  100. const method = this.current ? getReceiveList : getSendList
  101. method(query, {
  102. load: page.num == 1
  103. }).then(res => {
  104. this.mescroll.endSuccess(res.data.list.length);
  105. if (page.num == 1) this.list = [];
  106. const list = res.data.list.map(o => ({
  107. show: false,
  108. ...o
  109. }));
  110. this.list = this.list.concat(list);
  111. }).catch(() => {
  112. this.mescroll.endErr();
  113. })
  114. },
  115. open(index) {
  116. this.list[index].show = true;
  117. this.list.map((val, idx) => {
  118. if (index != idx) this.list[idx].show = false;
  119. })
  120. },
  121. handleClick(index, index1) {
  122. const item = this.list[index]
  123. delLog(item.id).then(res => {
  124. this.$u.toast(res.msg)
  125. this.list.splice(index, 1)
  126. if (!this.list.length) this.mescroll.resetUpScroll()
  127. })
  128. },
  129. goDetail(id) {
  130. const url = './form?type=' + this.current + (id ? '&id=' + id : '')
  131. uni.navigateTo({
  132. url: url
  133. })
  134. },
  135. change(index) {
  136. this.current = index;
  137. this.mescroll.resetUpScroll()
  138. },
  139. search() {
  140. this.searchTimer && clearTimeout(this.searchTimer)
  141. this.searchTimer = setTimeout(() => {
  142. this.list = [];
  143. this.mescroll.resetUpScroll();
  144. }, 300)
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss">
  150. page {
  151. background-color: #f0f2f6;
  152. }
  153. .reportLog-v {
  154. .log-list {
  155. width: 100%;
  156. margin-bottom: 20rpx;
  157. color: #9a9a9a;
  158. .log-list-txt {
  159. padding: 16rpx 32rpx;
  160. .log-title {
  161. justify-content: space-between;
  162. .title {
  163. color: #333333;
  164. width: 500rpx;
  165. }
  166. }
  167. }
  168. }
  169. }
  170. </style>