index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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="'客户姓名或身份证号'" @setSearch="setSearch"></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. delDraft,
  39. getDraftList
  40. } from "@/api/task";
  41. import EnBlank from "@/components/en-utils/en-blank/en-blank.vue";
  42. export default {
  43. components: {
  44. EnBlank
  45. },
  46. data() {
  47. return {
  48. list: [],
  49. page: 1,
  50. total: null,
  51. isAjax: false,
  52. selectText:''
  53. };
  54. },
  55. mounted() {
  56. uni.$on('setNewDraft', () => {
  57. if (this.$refs.draftRef) {
  58. this.startList()
  59. }
  60. })
  61. this.startList()
  62. },
  63. methods: {
  64. setSearch(selectText){
  65. this.selectText=selectText
  66. this.startList()
  67. },
  68. startList() {
  69. this.total = 999;
  70. this.list = [];
  71. this.page = 1;
  72. this.isAjax = false;
  73. this.getDraftList();
  74. },
  75. delDraft(draftId, index) {
  76. uni.showModal({
  77. title: '警告',
  78. content: '是否删除当前草稿!',
  79. success: (res) => {
  80. if (res.confirm) {
  81. delDraft({
  82. 'draftId': draftId
  83. }).then((res) => {
  84. this.list.splice(index, 1)
  85. })
  86. }
  87. }
  88. });
  89. },
  90. editDraft(id) {
  91. uni.navigateTo({
  92. url: '/page_task/information/information?draftId=' + id
  93. });
  94. },
  95. getDraftList() {
  96. if (this.isAjax || (this.total <= this.list.length)) {
  97. return;
  98. }
  99. this.isAjax = true;
  100. getDraftList({
  101. 'selectText': this.selectText,
  102. 'page': this.page,
  103. }).then((res) => {
  104. if (res.code === 1) {
  105. this.list.push(...res.data.items)
  106. this.total = res.data.total
  107. this.isAjax = false
  108. ++this.page;
  109. }
  110. })
  111. },
  112. // 下拉刷新
  113. onRefresh() {
  114. // uni.showLoading({
  115. // title: '数据加载中'
  116. // })
  117. // setTimeout(() => {
  118. // uni.showToast({
  119. // title: '加载完成',
  120. // icon: 'none'
  121. // })
  122. // this.$refs.scroll.onEndPulling()
  123. // }, 1000)
  124. console.log("下拉刷新");
  125. this.startList()
  126. },
  127. // 滚动到底部
  128. onScrollBottom() {
  129. this.getDraftList();
  130. console.log("到底部了");
  131. },
  132. },
  133. }
  134. </script>
  135. <style lang="scss">
  136. .draft-item {
  137. margin: 20rpx 32rpx 0;
  138. padding: 25rpx 30rpx;
  139. display: flex;
  140. justify-content: space-between;
  141. .item-left {
  142. .left-item {
  143. display: flex;
  144. justify-content: left;
  145. align-items: center;
  146. }
  147. .left-top {
  148. height: 52rpx;
  149. .top-product {
  150. background-color: rgba(15, 177, 96, 0.1);
  151. padding: 9rpx 22rpx;
  152. margin-left: 20rpx;
  153. }
  154. }
  155. .left-content {
  156. margin-top: 24rpx;
  157. height: 40rpx;
  158. }
  159. .left-bottom {
  160. margin-top: 24rpx;
  161. height: 34rpx;
  162. }
  163. }
  164. .item-right {
  165. padding-top: 20rpx;
  166. .but-item {
  167. width: 172rpx;
  168. height: 70rpx;
  169. text-align: center;
  170. line-height: 70rpx;
  171. }
  172. .but-del {
  173. margin-top: 15rpx;
  174. box-sizing: border-box;
  175. border-radius: 99rpx 99rpx 99rpx 99rpx;
  176. border: 1rpx solid #666666;
  177. }
  178. }
  179. }
  180. </style>