trash.vue 3.9 KB

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