chenrui 3 месяцев назад
Родитель
Сommit
784b1a2e0c
2 измененных файлов с 81 добавлено и 49 удалено
  1. 80 48
      pages/batchShelves/searchProduct.vue
  2. 1 1
      pages/index/index.vue

+ 80 - 48
pages/batchShelves/searchProduct.vue

@@ -18,46 +18,48 @@
 			</view>
 		</view>
 		<view class="productList-body">
-			<view v-if="status == 'loading'"><u-loadmore :status="status" :load-text="loadText" /></view>
-			<view class="partList-list-box" v-for="item in productList" :key="item.shelfCartSn">
-				<view class="flex align_center flex_1">
-					<view class="pimgs">
-						<u-image :src="item.images?item.images:`../../static/${$config('themePath')}/def_img@2x.png`" width="120" height="120" border-radius="10"></u-image>
-					</view>
-					<view class="pinfo">
-						<view class="pname">
-							<text v-if="item.shelfCartApi">{{item.shelfCartApi.shelfPlaceCode}}</text>
-							<text v-else-if="item.shelfProductApi">{{item.shelfProductApi.shelfPlaceCode}}</text>
-							{{item.productName}}
+			<scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
+				<view v-if="status == 'loading'"><u-loadmore :status="status" :load-text="loadText" /></view>
+				<view class="partList-list-box" v-for="item in productList" :key="item.shelfCartSn">
+					<view class="flex align_center flex_1">
+						<view class="pimgs">
+							<u-image :src="item.images?item.images:`../../static/${$config('themePath')}/def_img@2x.png`" width="120" height="120" border-radius="10"></u-image>
 						</view>
-						<view class="ptxt flex justify_between">
-							<text style="word-break: break-all;">{{item.code}}</text>
-							<view v-if="item.shelfProductApi&&item.shelfProductApi.enableFlag==1">
-								可用库存:<text>{{item.shelfProductApi.qty}}</text>{{item.unit}}
+						<view class="pinfo">
+							<view class="pname">
+								<text v-if="item.shelfCartApi">{{item.shelfCartApi.shelfPlaceCode}}</text>
+								<text v-else-if="item.shelfProductApi">{{item.shelfProductApi.shelfPlaceCode}}</text>
+								{{item.productName}}
+							</view>
+							<view class="ptxt flex justify_between">
+								<text style="word-break: break-all;">{{item.code}}</text>
+								<view v-if="item.shelfProductApi&&item.shelfProductApi.enableFlag==1">
+									可用库存:<text>{{item.shelfProductApi.qty}}</text>{{item.unit}}
+								</view>
 							</view>
 						</view>
 					</view>
-				</view>
-				<view class="ptools flex align_center justify_between">
-					<view></view>
-					<view class="pcurnums flex align_center">
-						<view class="u-ninput" v-if="item.shelfCartApi">
-							<u-number-box :long-press="false" :index="item.id" :input-height="60" @blur="updateNums" @minus="updateNums" @plus="updateNums" color="#000" bg-color="#fff" v-model="item.shelfCartApi.qty" :min="1"></u-number-box>
-						</view>
-						<view v-else>
-							<u-button :loading="status == 'loading'" @click="addItem(item)" plain style="height: 50rpx;line-height: 50rpx;" size="mini" shape="circle">
-								<u-icon name="plus"></u-icon> 添加
-							</u-button>
+					<view class="ptools flex align_center justify_between">
+						<view></view>
+						<view class="pcurnums flex align_center">
+							<view class="u-ninput" v-if="item.shelfCartApi">
+								<u-number-box :long-press="false" :index="item.id" :input-height="60" @blur="updateNums" @minus="updateNums" @plus="updateNums" color="#000" bg-color="#fff" v-model="item.shelfCartApi.qty" :min="1"></u-number-box>
+							</view>
+							<view v-else>
+								<u-button :loading="status == 'loading'" @click="addItem(item)" plain style="height: 50rpx;line-height: 50rpx;" size="mini" shape="circle">
+									<u-icon name="plus"></u-icon> 添加
+								</u-button>
+							</view>
 						</view>
 					</view>
 				</view>
-			</view>
-			<view v-if="productList && productList.length == 0 && status == 'nomore'">
-				<u-empty :text="noDataText" mode="list" :img-width="200" :margin-top="60"></u-empty>
-			</view>
-			<view style="padding: 20upx;" v-if="productList.length && status != 'nomore'">
-				<u-loadmore :status="status" :load-text="loadText" />
-			</view>
+				<view v-if="productList && productList.length == 0 && status == 'nomore'">
+					<u-empty :text="noDataText" mode="list" :img-width="200" :margin-top="60"></u-empty>
+				</view>
+				<view style="padding: 20upx;" v-if="productList.length && status != 'nomore'">
+					<u-loadmore :status="status" :load-text="loadText" />
+				</view>
+			</scroll-view>
 		</view>
 	</view>
 </template>
@@ -72,6 +74,8 @@
 				layer:'',
 				queryWord: '',
 				productList: [],
+				pageNo:1,
+				pageSize: 10,
 				total: 0, // 列表总数
 				noDataText: '暂无产品',
 				status: 'nomore',
@@ -79,7 +83,7 @@
 				fromPage: null,
 				loadText: {
 					loading: '努力加载中',
-					loadmore: '最多显示前20条匹配产品,请尝试输入更多内容'
+					loadmore: '没有更多了'
 				}
 			}
 		},
@@ -111,6 +115,15 @@
 			 this.scanProduct()
 		},
 		methods: {
+			// 加载更多
+			onreachBottom () {
+				if(this.productList.length <this.total ){
+					this.pageNo++
+					this.getProductList()
+				}else{
+					this.status = "nomore"
+				}
+			},
 			scanProduct(){
 				uni.redirectTo({
 					url: "/pages/batchShelves/scanProduct?shelfSn="+this.shelfSn+'&layer='+this.layer+'&shelfName='+this.shelfName+'&customerSn='+this.customerSn+'&from='+this.fromPage
@@ -128,8 +141,8 @@
 					return
 				}
 				let params = {
-					pageNo:1,
-					pageSize:20,
+					pageNo:this.pageNo,
+					pageSize:this.pageSize,
 					code: this.$u.trim(this.queryWord),
 					shelfSn: this.shelfSn,
 					shelfTierCode: this.layer
@@ -137,20 +150,36 @@
 				console.log(params)
 				this.status = 'loading'
 				queryProductPage(params).then(res => {
-					console.log(res)
 					if(res.status == 200&&res.data&&res.data.page&&res.data.page.list&&res.data.page.list.length){
-						this.productList = res.data.page.list
-						this.shelfPlaceCode = res.data.shelfPlaceCode
-						this.total = res.data.page.count
-						this.status = 'loadmore'
+						_this.shelfPlaceCode = res.data.shelfPlaceCode
+						let list = res.data.page.list
+						console.log(list)
+						if (list && list.length){
+							// 分页 拼接数据
+							if (_this.pageNo != 1) {
+								_this.productList = _this.productList ? _this.productList.concat(list) : list
+							} else {
+								_this.productList = list
+							}
+							_this.total = res.data.page.count
+							if (_this.productList.length == res.data.page.count) {
+								_this.status = 'nomore'
+							} else {
+								_this.status = 'loadmore'
+							}
+						} else {
+							_this.productList = list || []
+							_this.total = 0
+							_this.status = 'nomore'
+						}
+						_this.noDataText = '暂无匹配产品'
 					}else{
-						this.productList = []
-						this.shelfPlaceCode = ''
-						this.total = 0
-						this.noDataText = '没有搜索到相关产品'
-						this.status = 'nomore'
+						_this.status = 'nomore'
+						_this.productList = []
+						_this.shelfPlaceCode = ''
+						_this.total = 0
+						_this.noDataText = '没有搜索到相关产品'
 					}
-					console.log(this.status)
 				})
 			},
 			// 新增
@@ -230,7 +259,10 @@
 			flex-grow: 1;
 			background-color: #fff;
 			padding: 0 40upx;
-			overflow: auto;
+			.scroll-view{
+				height: calc(100vh - 180rpx);
+				box-sizing: border-box;
+			}
 			.partList-list-box{
 				padding: 10px 0;
 				border-bottom: 2rpx solid #f5f5f5;

+ 1 - 1
pages/index/index.vue

@@ -20,7 +20,7 @@
 					 </div>
 					 <div class="title">补打贴签</div>
 				 </div>
-				 <div class="graid-box-1" @click="toPage('/pages/shelfSetting/shelfList')" v-if="$hasPermissions('M_shelfSetting_mobile')">
+				 <div class="graid-box-1" @click="toPage('/pages/shelfSetting/shelfList')" >
 					 <div class="icon">
 						<u-icon name="ison_shelf" custom-prefix="iscm-icon" size="65"></u-icon>
 					 </div>