trash.vue 3.9 KB

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