list.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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" @click="filterShow = true">筛选</view>
  9. </view>
  10. <!-- <view class="status_tabs">
  11. <u-tabs bg-color="#5976ba" active-color="#fff" inactive-color="#fff" :list="tabList" :is-scroll="false"
  12. :current="current" @change="tabChange"></u-tabs>
  13. </view> -->
  14. <scroll-view :style="{paddingBottom: current == 0 ? '60px' : '10px'}" scroll-y class="scroll-box"
  15. @scrolltolower="handleLoadMore" @scroll="scroll" :refresher-enabled="scroll_refresher_enabled"
  16. :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white"
  17. @refresherrefresh="onRefresh" @refresherrestore="onRestore">
  18. <view class="card" v-for="(item, index) in tableList" :key="index">
  19. <view class="top">
  20. <view class="left">{{ item.packCode }}</view>
  21. <view class="right" style="color: #FF6600">待收集</view>
  22. </view>
  23. <view class="bottom">
  24. <view>科&emsp;&emsp;室:{{ item.positionName }}<span
  25. style="float: right">{{ item.packWeight }}kg</span></view>
  26. <view>医废分类:{{ item.rubbishCategoryStr }}</view>
  27. <view>暂&ensp;存&ensp;点:{{ item.provisionalName }}</view>
  28. <view>打包时间:{{ item.createTime }}</view>
  29. </view>
  30. </view>
  31. <view style="margin-top: 100px;text-align: center;" v-show="!tableList.length">暂无数据</view>
  32. </scroll-view>
  33. <view class="bottomButton" @click="toPackage" v-show="current == 0">
  34. <view>新增打包</view>
  35. </view>
  36. <u-picker :default-time="time" @confirm="fliterConfirm" @cancel="fliterCancel" mode="time" v-model="filterShow"
  37. :params="params">
  38. </u-picker>
  39. <u-toast ref="uToast" />
  40. </view>
  41. </template>
  42. <script>
  43. const NET = require('@/utils/request')
  44. const API = require('@/config/api')
  45. export default {
  46. data() {
  47. return {
  48. current: 0,
  49. tabList: [{
  50. name: '待收集'
  51. }, {
  52. name: '转运中'
  53. }, {
  54. name: '已完成'
  55. }],
  56. scroll_refresher_enabled: true,
  57. triggered: false,
  58. isOver: false,
  59. loading: false,
  60. pageIndex: 1,
  61. tableList: [],
  62. filterShow: false,
  63. isIphone: false,
  64. params: {
  65. year: true,
  66. month: true,
  67. day: true,
  68. hour: false,
  69. minute: false,
  70. second: false
  71. },
  72. time: "",
  73. }
  74. },
  75. onLoad() {
  76. uni.getSystemInfo({
  77. success: (res) => {
  78. console.log(res)
  79. if (res.model == 'iPhone') {
  80. this.isIphone = true;
  81. }
  82. },
  83. fail: (err) => {
  84. console.log(err)
  85. }
  86. })
  87. },
  88. onReady() {
  89. if (this.isIphone) {
  90. document.getElementsByClassName('scroll-box')[0].style.height = document.getElementsByClassName('scroll-box')[
  91. 0].clientHeight - 25 + 'px'
  92. }
  93. },
  94. onShow() {
  95. let date = new Date;
  96. //获取年份
  97. let yy = date.getFullYear();
  98. //获取月份
  99. let mm = date.getMonth() + 1;
  100. //如果月份小于10 前面加0
  101. mm = (mm < 10 ? "0" + mm : mm);
  102. let dd = date.getDate();
  103. dd = (dd < 10 ? "0" + dd : dd);
  104. //返回日期
  105. this.time = `${yy}-${mm}-${dd}`
  106. this.tabList[0].name = '待收集(0)'
  107. this.tabList[1].name = '转运中(0)'
  108. this.tabList[2].name = '已完成(0)'
  109. this.onRefresh();
  110. },
  111. methods: {
  112. goBack() {
  113. try {
  114. EbeiPlugins.onBackKeyDown();
  115. } catch (error) {}
  116. },
  117. toPackage() {
  118. uni.navigateTo({
  119. url: '/wastePack/package'
  120. });
  121. },
  122. tabChange(index) {
  123. this.current = index;
  124. },
  125. scroll(e) {
  126. if (e.detail.scrollTop <= 100) {
  127. this.scroll_refresher_enabled = true
  128. } else {
  129. this.scroll_refresher_enabled = false
  130. }
  131. },
  132. getTableList() {
  133. if (this.loading || this.isOver) {
  134. return false;
  135. }
  136. this.loading = true;
  137. let postData = {
  138. pageIndex: this.pageIndex,
  139. pageSize: 10,
  140. packState: 1,
  141. date: this.time,
  142. }
  143. NET.request(API.queryPackageList, postData, 'POST').then(res => {
  144. this.triggered = false;
  145. this.loading = false;
  146. if (res.data.records.length < 10) {
  147. this.isOver = true
  148. }
  149. for (let i in res.data.records) {
  150. this.tableList.push(res.data.records[i])
  151. }
  152. }).catch(error => {
  153. this.$refs.uToast.show({
  154. title: error.msg,
  155. type: 'warning',
  156. })
  157. })
  158. },
  159. // 下拉刷新
  160. onRefresh() {
  161. this.triggered = true
  162. this.isOver = false
  163. this.pageIndex = 1
  164. this.tableList = []
  165. this.getTableList()
  166. },
  167. // 重置下拉刷新状态
  168. onRestore() {
  169. this.triggered = 'restore'
  170. this.triggered = false
  171. },
  172. //获取更多数据
  173. handleLoadMore() {
  174. if (this.isOver) {
  175. } else if (this.loading) {
  176. } else {
  177. this.pageIndex++;
  178. this.getTableList()
  179. }
  180. },
  181. fliterConfirm(val) {
  182. let time = `${val.year}-${val.month}-${val.day}`
  183. console.log(time)
  184. this.time = time
  185. this.onRefresh()
  186. },
  187. filterCancel(val) {
  188. console.log(val)
  189. }
  190. }
  191. }
  192. </script>
  193. <style lang="scss">
  194. .scroll-box {
  195. height: calc(100% - 80rpx);
  196. padding: 10px 0 60px 0;
  197. box-sizing: border-box;
  198. }
  199. /deep/ .uni-scroll-view-refresher {
  200. background-color: #f5f5f9 !important;
  201. }
  202. </style>