list2.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="content">
  3. <view class="topbar" v-show="isIphone">
  4. </view>
  5. <view class="status_bar">
  6. <view class="left" @click="goBack"><u-icon name="arrow-left"></u-icon>返回</view>
  7. <span style="font-size: 36rpx;">批次列表</span>
  8. <view class="right"></view>
  9. </view>
  10. <scroll-view :style="{paddingBottom: '10px'}" scroll-y class="scroll-box mainCont"
  11. @scrolltolower="handleLoadMore" @scroll="scroll" :refresher-enabled="scroll_refresher_enabled"
  12. :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white"
  13. @refresherrefresh="onRefresh" @refresherrestore="onRestore">
  14. <view class="pcTop" v-show="tableList.length">{{ text }}<span style="float: right">{{ weight }}kg</span>
  15. </view>
  16. <view class="card" @click="goInfo(item.packageId)" v-for="(item, index) in tableList" :key="index">
  17. <view class="top">
  18. <view class="left">{{ item.packCode }}</view>
  19. </view>
  20. <view class="bottom">
  21. <view>科&emsp;&emsp;室:{{ item.positionName }}<span
  22. style="float: right">{{ item.packWeight }}kg</span></view>
  23. <view>医废分类:{{ item.rubbishCategoryStr }}</view>
  24. <view>打&ensp;包&ensp;人:{{ item.createUserName }}<span
  25. style="float: right">{{ item.createTime }}</span></view>
  26. </view>
  27. </view>
  28. <view style="margin-top: 100px;text-align: center;" v-show="!tableList.length">暂无数据</view>
  29. </scroll-view>
  30. <u-toast ref="uToast" />
  31. </view>
  32. </template>
  33. <script>
  34. const NET = require('@/utils/request')
  35. const API = require('@/config/api')
  36. export default {
  37. data() {
  38. return {
  39. triggered: false,
  40. isOver: false,
  41. tableList: [],
  42. pageIndex: 1,
  43. scroll_refresher_enabled: true,
  44. loading: false,
  45. id: "",
  46. isIphone: false,
  47. weight: "",
  48. text: "",
  49. }
  50. },
  51. onLoad(options) {
  52. uni.getSystemInfo({
  53. success: (res) => {
  54. console.log(res)
  55. if (res.model == 'iPhone') {
  56. this.isIphone = true;
  57. }
  58. },
  59. fail: (err) => {
  60. console.log(err)
  61. }
  62. })
  63. this.id = options.id
  64. this.text = options.text
  65. this.weight = options.weight
  66. this.onRefresh()
  67. },
  68. onReady() {
  69. if (this.isIphone) {
  70. document.getElementsByClassName('mainCont')[0].style.height = document.getElementsByClassName('mainCont')[
  71. 0].clientHeight - 45 + 'px'
  72. }
  73. },
  74. methods: {
  75. goBack() {
  76. uni.navigateBack({
  77. delta: 1
  78. });
  79. },
  80. getTableList() {
  81. if (this.loading || this.isOver) {
  82. return false;
  83. }
  84. this.loading = true;
  85. let postData = {
  86. pageIndex: this.pageIndex,
  87. pageSize: 10,
  88. batchId: this.id
  89. }
  90. NET.request(API.getPackageListByBatchId, postData, 'POST').then(res => {
  91. this.triggered = false;
  92. this.loading = false;
  93. if (res.data.records.length < 10) {
  94. this.isOver = true
  95. }
  96. for (let i in res.data.records) {
  97. this.tableList.push(res.data.records[i])
  98. }
  99. }).catch(error => {
  100. this.$refs.uToast.show({
  101. title: error.msg,
  102. type: 'warning',
  103. })
  104. })
  105. },
  106. scroll(e) {
  107. if (e.detail.scrollTop === 0) {
  108. this.scroll_refresher_enabled = true
  109. } else {
  110. this.scroll_refresher_enabled = false
  111. }
  112. },
  113. // 下拉刷新
  114. onRefresh() {
  115. this.triggered = true
  116. this.isOver = false
  117. this.pageIndex = 1
  118. this.tableList = []
  119. this.getTableList()
  120. },
  121. // 重置下拉刷新状态
  122. onRestore() {
  123. this.triggered = 'restore'
  124. this.triggered = false
  125. },
  126. //获取更多数据
  127. handleLoadMore() {
  128. if (this.isOver) {
  129. } else if (this.loading) {
  130. } else {
  131. this.pageIndex++;
  132. this.getTableList()
  133. }
  134. },
  135. goInfo(id) {
  136. uni.navigateTo({
  137. url: `/collection/infor2?id=${id}`
  138. });
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="scss">
  144. .mainCont {
  145. height: calc(100% - 80rpx);
  146. padding-bottom: 60px;
  147. overflow-y: scroll;
  148. }
  149. .pcTop {
  150. width: calc(100% - 20px);
  151. padding: 0 10px;
  152. height: 20px;
  153. line-height: 20px;
  154. margin: 0 auto;
  155. margin-top: 10px;
  156. margin-bottom: 10px;
  157. position: relative;
  158. &:after {
  159. content: '';
  160. position: absolute;
  161. height: 20px;
  162. top: 0;
  163. left: 0;
  164. width: 2px;
  165. background-color: #6aa0f7;
  166. }
  167. }
  168. .bottomButtons {
  169. box-shadow: 0px -5px 5px #d0cece;
  170. position: fixed;
  171. display: flex;
  172. justify-content: space-between;
  173. width: 100%;
  174. height: 40px;
  175. line-height: 40px;
  176. bottom: 0;
  177. left: 0;
  178. view {
  179. width: 50%;
  180. height: 40px;
  181. line-height: 40px;
  182. text-align: center;
  183. }
  184. }
  185. </style>