index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view class="total-page page-box page-env-20 scroll_content task-bg">
  3. <Nav :title="'草稿箱'" :genre="1" :back="true" is_fixed></Nav>
  4. <view>
  5. <Search :placeholder="'客户姓名或电话'"></Search>
  6. </view>
  7. <EnScroll ref="scroll" :navHeight="0" is_tabHeight @onRefresh="onRefresh" @onScrollBottom="onScrollBottom">
  8. <view class="draft-item r-40 sys-background-fff" v-for="(item,index) in list">
  9. <view class="item-left">
  10. <view class="left-top left-item">
  11. <view class="top-name sys-weight-600 size-30 text-color-12">{{item.name}}</view>
  12. <view class="top-product sys-weight-400 size-24 text-color-009 r-10">{{item.product_name}}
  13. </view>
  14. </view>
  15. <view class="left-content left-item">
  16. <view class="sys-weight-400 size-24 text-color-12">身份证:</view>
  17. <view class="sys-weight-600 sys-size-28 text-color-12">{{item.id_number}}</view>
  18. </view>
  19. <view class="left-bottom left-item">
  20. <view class=" size-24 text-color-999">保存时间:</view>
  21. <view class=" size-24 text-color-999">{{item.created_at}}</view>
  22. </view>
  23. </view>
  24. <view class="item-right">
  25. <view
  26. class="but-item but-edit size-28 sys-weight-500 text-color-fff button-background sys-radius-100"
  27. @click.stop="editDraft(item.id)">编辑</view>
  28. <view class="but-item but-del size-28 sys-weight-500 text-color-666 "
  29. @click.stop="delDraft(item.id,index)">删除</view>
  30. </view>
  31. </view>
  32. <en-blank v-if="list.length<=0"></en-blank>
  33. </EnScroll>
  34. </view>
  35. </template>
  36. <script>
  37. import {
  38. getDraftList
  39. } from "@/api/task";
  40. import EnBlank from "@/components/en-utils/en-blank/en-blank.vue";
  41. export default {
  42. components: {
  43. EnBlank
  44. },
  45. data() {
  46. return {
  47. list: [],
  48. page: 1,
  49. total: null,
  50. isAjax: false,
  51. };
  52. },
  53. mounted() {
  54. uni.$on('setNewDraft', () => {
  55. if (this.$refs.draftRef) {
  56. this.startList()
  57. }
  58. })
  59. this.startList()
  60. },
  61. methods: {
  62. startList() {
  63. this.total = 999;
  64. this.list = [];
  65. this.page = 1;
  66. this.isAjax = false;
  67. this.getDraftList();
  68. },
  69. delDraft(draftId, index) {
  70. uni.showModal({
  71. title: '警告',
  72. content: '是否删除当前草稿!',
  73. success: (res) => {
  74. if (res.confirm) {
  75. delDraft({
  76. 'draftId': draftId
  77. }).then((res) => {
  78. this.$refs.draftRef.list.splice(index, 1)
  79. })
  80. }
  81. }
  82. });
  83. },
  84. editDraft(id) {
  85. uni.navigateTo({
  86. url: '/page_task/information/information?draftId=' + id
  87. });
  88. },
  89. getDraftList() {
  90. if (this.isAjax || (this.total <= this.list.length)) {
  91. return;
  92. }
  93. this.isAjax = true;
  94. getDraftList({
  95. 'page': this.page
  96. }).then((res) => {
  97. if (res.code === 1) {
  98. this.list.push(...res.data.items)
  99. this.total = res.data.total
  100. this.isAjax = false
  101. ++this.page;
  102. }
  103. })
  104. },
  105. // 下拉刷新
  106. onRefresh() {
  107. // uni.showLoading({
  108. // title: '数据加载中'
  109. // })
  110. // setTimeout(() => {
  111. // uni.showToast({
  112. // title: '加载完成',
  113. // icon: 'none'
  114. // })
  115. // this.$refs.scroll.onEndPulling()
  116. // }, 1000)
  117. console.log("下拉刷新");
  118. this.startList()
  119. },
  120. // 滚动到底部
  121. onScrollBottom() {
  122. this.getDraftList();
  123. console.log("到底部了");
  124. },
  125. },
  126. }
  127. </script>
  128. <style lang="scss">
  129. .draft-item {
  130. margin: 20rpx 32rpx 0;
  131. padding: 25rpx 30rpx;
  132. display: flex;
  133. justify-content: space-between;
  134. .item-left {
  135. .left-item {
  136. display: flex;
  137. justify-content: left;
  138. align-items: center;
  139. }
  140. .left-top {
  141. height: 52rpx;
  142. .top-product {
  143. background-color: rgba(15, 177, 96, 0.1);
  144. padding: 9rpx 22rpx;
  145. margin-left: 20rpx;
  146. }
  147. }
  148. .left-content {
  149. margin-top: 24rpx;
  150. height: 40rpx;
  151. }
  152. .left-bottom {
  153. margin-top: 24rpx;
  154. height: 34rpx;
  155. }
  156. }
  157. .item-right {
  158. padding-top: 20rpx;
  159. .but-item {
  160. width: 172rpx;
  161. height: 70rpx;
  162. text-align: center;
  163. line-height: 70rpx;
  164. }
  165. .but-del {
  166. margin-top: 15rpx;
  167. box-sizing: border-box;
  168. border-radius: 99rpx 99rpx 99rpx 99rpx;
  169. border: 1rpx solid #666666;
  170. }
  171. }
  172. }
  173. </style>