replenishmentList.vue 6.0 KB

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