replenishmentList.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view class="pagesCons">
  3. <view class="utabs">
  4. <u-tabs-swiper ref="uTabs" :list="tabList" name="dispName" :current="current" @change="tabsChange" :is-scroll="false" swiperWidth="750"></u-tabs-swiper>
  5. </view>
  6. <swiper class="check-list" :current="swiperCurrent" @transition="transition" @change="swiperChange" @animationfinish="animationfinish">
  7. <swiper-item class="swiper-item" v-for="(tabs, index) in tabList" :key="index">
  8. <scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
  9. <view
  10. class="check-order-list"
  11. v-if="index==current"
  12. v-for="(item,sindex) in 20"
  13. :key="item.id+'-'+sindex"
  14. @click="viewRow(item)" >
  15. <view class="check-row">
  16. <view>西安车领主常青二路数字货架</view>
  17. <view>
  18. <text :style="{color:$config('errorColor')}">待退库</text>
  19. </view>
  20. </view>
  21. <view class="check-col">
  22. <view>补货单号:BH202101010001</view>
  23. <view>应发数量:33</view>
  24. <view>2021-08-20 15:40:57</view>
  25. </view>
  26. </view>
  27. <u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="240" :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'" mode="list"></u-empty>
  28. <view v-if="index==current" style="padding: 20upx;">
  29. <u-loadmore :load-text="$config('loadText')" v-if="total>pageSize || status=='loading'" :status="status" />
  30. </view>
  31. </scroll-view>
  32. </swiper-item>
  33. </swiper>
  34. </view>
  35. </template>
  36. <script>
  37. import { shelfReplenishList } from '@/api/shelfReplenish.js'
  38. export default {
  39. components: {
  40. },
  41. data() {
  42. return {
  43. status: 'loadmore',
  44. noDataText: '暂无数据',
  45. tabList: [
  46. {
  47. dispName: '全部',
  48. typeId: 0,
  49. status: ''
  50. },
  51. {
  52. dispName: '待确认',
  53. typeId: 1,
  54. status: '',
  55. count: 12
  56. },
  57. {
  58. dispName: '待出库',
  59. typeId: 2,
  60. status: ''
  61. },
  62. {
  63. dispName: '待签收',
  64. typeId: 3,
  65. status: ''
  66. },
  67. {
  68. dispName: '已完成',
  69. typeId: 4,
  70. status: ''
  71. },
  72. {
  73. dispName: '已取消',
  74. typeId: 5,
  75. status: ''
  76. },
  77. ],
  78. current: 0,
  79. swiperCurrent: 0,
  80. pageNo: 1,
  81. pageSize: 6,
  82. list: [],
  83. total: 0,
  84. action:'swiperChange', // 操作类型,上划分页,或左右滑动
  85. }
  86. },
  87. onLoad() {
  88. // 监听整改完成后刷新事件
  89. uni.$on('refreshBL',this.getRow)
  90. this.getRow(1)
  91. },
  92. onUnload() {
  93. uni.$off('refreshBL',this.getRow)
  94. },
  95. methods:{
  96. // tabs通知swiper切换
  97. tabsChange(index) {
  98. this.swiperCurrent = index;
  99. },
  100. swiperChange(event){
  101. this.action = 'swiperChange'
  102. this.status = 'loading'
  103. },
  104. // swiper-item左右移动,通知tabs的滑块跟随移动
  105. transition(e) {
  106. let dx = e.detail.dx;
  107. this.$refs.uTabs.setDx(dx);
  108. },
  109. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  110. // swiper滑动结束,分别设置tabs和swiper的状态
  111. animationfinish(e) {
  112. let current = e.detail.current;
  113. let isCurtab = this.current == current
  114. if(this.status!="nomore"){
  115. let loadData = this.action == 'swiperChange' ? !isCurtab : isCurtab;
  116. if(loadData){
  117. this.$refs.uTabs.setFinishCurrent(current);
  118. this.swiperCurrent = current;
  119. this.current = current;
  120. this.resetPage();
  121. }
  122. }
  123. },
  124. // scroll-view到底部加载更多
  125. onreachBottom() {
  126. this.action = 'onreachBottom'
  127. if(this.list.length < this.total){
  128. this.resetPage()
  129. }else{
  130. this.status = "nomore"
  131. }
  132. },
  133. // 查询列表
  134. getRow (pageNo) {
  135. if (pageNo) {
  136. this.pageNo = pageNo
  137. }
  138. let params = {
  139. pageNo: this.pageNo,
  140. pageSize: this.pageSize,
  141. billState: this.tabList[this.current].status,
  142. }
  143. this.status = "loading"
  144. shelfReplenishList(params).then(res => {
  145. if (res.status == 200) {
  146. if(this.pageNo>1){
  147. this.list = this.list.concat(res.data.list || [])
  148. }else{
  149. this.list = res.data.list || []
  150. }
  151. this.total = res.data.count || 0
  152. } else {
  153. this.list = []
  154. this.total = 0
  155. this.noDataText = res.message
  156. }
  157. this.status = "loadmore"
  158. })
  159. },
  160. resetPage(){
  161. this.status = 'loading';
  162. // 上划分页
  163. if(this.action == 'onreachBottom'){
  164. this.pageNo += 1
  165. this.getRow()
  166. }
  167. // 左右切换tab
  168. if(this.action == 'swiperChange'){
  169. this.list = [];
  170. this.getRow(1);
  171. }
  172. },
  173. // 详细页
  174. viewRow(item){
  175. // 已完成的
  176. uni.navigateTo({
  177. url: "/pages/toDoList/backlogDetail?id="+item.id
  178. })
  179. },
  180. // 状态颜色处理
  181. clsStatus(status){
  182. if(status == 'CHECK_PENDING'){
  183. return 'dsh'
  184. }
  185. if(status == 'PENDING'){
  186. return 'dzg'
  187. }
  188. if(status == 'FINISHED'){
  189. return 'ywc'
  190. }
  191. if(status == 'EXPIRED'){
  192. return 'ygq'
  193. }
  194. }
  195. }
  196. }
  197. </script>
  198. <style lang="scss">
  199. page {
  200. height: 100%;
  201. }
  202. .pagesCons{
  203. width: 100%;
  204. height: 100%;
  205. display: flex;
  206. flex-direction: column;
  207. .text-right {
  208. text-align: right;
  209. }
  210. .utabs{
  211. border-bottom: 1px solid #eee;
  212. }
  213. .check-list{
  214. flex: 1;
  215. .swiper-item{
  216. width: 100%;
  217. height: 100%;
  218. overflow: hidden;
  219. .scroll-view {
  220. width: 100%;
  221. height: 100%;
  222. overflow: auto;
  223. }
  224. }
  225. }
  226. // 列表样式
  227. .check-order-list{
  228. background: #ffffff;
  229. padding: 25upx 35upx;
  230. margin: 25upx;
  231. border-radius: 25upx;
  232. box-shadow: 1px 1px 3px #EEEEEE;
  233. .check-row{
  234. display: flex;
  235. justify-content: space-between;
  236. margin-bottom: 10rpx;
  237. >view{
  238. &:first-child{
  239. color: #222;
  240. font-size: 32rpx;
  241. width: 80%;
  242. }
  243. &:last-child{
  244. font-size: 28rpx;
  245. margin-top: 5rpx;
  246. }
  247. }
  248. }
  249. .check-col{
  250. > view{
  251. padding: 2rpx 0;
  252. color: #707070;
  253. font-size: 26rpx;
  254. }
  255. }
  256. }
  257. }
  258. </style>