Browse Source

fix:修复仓库返回列表页重新请求问题

zhangxin 1 month ago
parent
commit
482f877734
1 changed files with 122 additions and 87 deletions
  1. 122 87
      pages/wareHouse/index.vue

+ 122 - 87
pages/wareHouse/index.vue

@@ -72,7 +72,7 @@
72 72
 				</view>
73 73
 			</view>
74 74
 
75
-			<scroll-view class="goods-list" scroll-y @scrolltolower="handleLoadMore" enable-back-to-top>
75
+			<scroll-view class="goods-list" scroll-y @scrolltolower="handleLoadMore" @scroll="handleScroll" :scroll-top="pageState.scrollTop" enable-back-to-top>
76 76
 				<view @click.stop="clickItem(goods)" class="goods-item" v-for="(goods, goodsIndex) in goodsList"
77 77
 					:key="`goods-${goodsIndex}`">
78 78
 					<u-swipe-action ref="swipeRef">
@@ -171,88 +171,95 @@ export default {
171 171
 		jtimePickerPopup
172 172
 	},
173 173
 	data() {
174
-		return {
175
-			searchString: '',//搜索编号、名称、品牌...
176
-			type: '',
177
-			searchInfo: {},
178
-			pageNum: 1,
179
-			pageSize: 10,
180
-			curSortType: {
181
-				id: 4,
182
-				label: '按入库最新',
183
-			},
184
-			wareHouseCard: {
185
-				totalCost: '-',
186
-				uploadCostToday: '-',
187
-				outStockToday: '-',
188
-				totalNum: '-'
189
-			},
190
-			tabList: [],
191
-			goodsList: [
192
-				// {
193
-				// 	id:'123456754',//商品库存id
194
-				// 	name:'Rolex',//商品名称
195
-				// 	model:'Submariner Date 126610LN',//型号
196
-				// 	costPrice:'12345',//成本价格
197
-				// 	salesPrice:'12345',//销售价格
198
-				// 	peerPrice:'12345',//同行价格
199
-				// 	agentPrice:'12345',//代理价格
200
-				// 	stock:'12345',//库存数量
201
-				// 	imgUrl:'https://xiaohulu-crm.oss-cn-shanghai.aliyuncs.com/crm/2026/01/06/1767677335839-1767677330379.jpg',//商品图片
202
-				// 	platform:[]//同步平台,此功能暂时不做,先定义一个字段
203
-				// }
204
-			],
205
-			sortPickerShow: false,
206
-			sortColumns: [[
207
-				{
208
-					label: '按最久未下载',
209
-					id: 1
210
-				},
211
-				{
212
-					label: '按最近更新',
213
-					id: 2
214
-				},
215
-				{
216
-					label: '按最久更新',
217
-					id: 3
218
-				},
219
-				{
174
+			return {
175
+				searchString: '',//搜索编号、名称、品牌...
176
+				type: '',
177
+				searchInfo: {},
178
+				pageNum: 1,
179
+				pageSize: 10,
180
+				curSortType: {
181
+					id: 4,
220 182
 					label: '按入库最新',
221
-					id: 4
222 183
 				},
223
-				{
224
-					label: '按入库最久',
225
-					id: 5
226
-				},
227
-				{
228
-					label: '按价格最高',
229
-					id: 6
230
-				},
231
-				{
232
-					label: '按价格最低',
233
-					id: 7
234
-				},
235
-			]],
236
-			priceVisible: true,
237
-			searchPopShow: false,
238
-			total: 0,
239
-			moreOptions: {},
240
-			moreOptionsShow: false,
241
-			isWareHouseRole: permissionCheck('WAREHOUSER', false),
242
-			swipeOptions: [
243
-				{
244
-					text: '删除',
245
-					style: {
246
-						backgroundColor: '#f56c6c'
247
-					}
184
+				wareHouseCard: {
185
+					totalCost: '-',
186
+					uploadCostToday: '-',
187
+					outStockToday: '-',
188
+					totalNum: '-'
248 189
 				},
249
-			],
250
-			isSwipeClick: false,
251
-			deptList: [],
252
-			deptId: '',
253
-			deptName: '',
254
-		};
255
-	},
190
+				tabList: [],
191
+				goodsList: [
192
+					// {
193
+					// 	id:'123456754',//商品库存id
194
+					// 	name:'Rolex',//商品名称
195
+					// 	model:'Submariner Date 126610LN',//型号
196
+					// 	costPrice:'12345',//成本价格
197
+					// 	salesPrice:'12345',//销售价格
198
+					// 	peerPrice:'12345',//同行价格
199
+					// 	agentPrice:'12345',//代理价格
200
+					// 	stock:'12345',//库存数量
201
+					// 	imgUrl:'https://xiaohulu-crm.oss-cn-shanghai.aliyuncs.com/crm/2026/01/06/1767677335839-1767677330379.jpg',//商品图片
202
+					// 	platform:[]//同步平台,此功能暂时不做,先定义一个字段
203
+					// }
204
+				],
205
+				sortPickerShow: false,
206
+				sortColumns: [[
207
+					{
208
+						label: '按最久未下载',
209
+						id: 1
210
+					},
211
+					{
212
+						label: '按最近更新',
213
+						id: 2
214
+					},
215
+					{
216
+						label: '按最久更新',
217
+						id: 3
218
+					},
219
+					{
220
+						label: '按入库最新',
221
+						id: 4
222
+					},
223
+					{
224
+						label: '按入库最久',
225
+						id: 5
226
+					},
227
+					{
228
+						label: '按价格最高',
229
+						id: 6
230
+					},
231
+					{
232
+						label: '按价格最低',
233
+						id: 7
234
+					},
235
+				]],
236
+				priceVisible: true,
237
+				searchPopShow: false,
238
+				total: 0,
239
+				moreOptions: {},
240
+				moreOptionsShow: false,
241
+				isWareHouseRole: permissionCheck('WAREHOUSER', false),
242
+				swipeOptions: [
243
+					{
244
+						text: '删除',
245
+						style: {
246
+							backgroundColor: '#f56c6c'
247
+						}
248
+					},
249
+				],
250
+				isSwipeClick: false,
251
+				deptList: [],
252
+				deptId: '',
253
+				deptName: '',
254
+				// 保存页面状态
255
+				pageState: {
256
+					pageNum: 1,
257
+					goodsList: [],
258
+					total: 0,
259
+					scrollTop: 0
260
+				}
261
+			};
262
+		},
256 263
 	onLoad() {
257 264
 		this.getTypeList();
258 265
 	},
@@ -400,14 +407,42 @@ export default {
400 407
 			});
401 408
 		},
402 409
 		openOrderList() {
403
-			this.$refs.orderListRef.openList();
410
+				this.$refs.orderListRef.openList();
411
+			},
412
+			handleScroll(e) {
413
+				this.pageState.scrollTop = e.detail.scrollTop;
414
+			},
415
+			// 保存当前页面状态
416
+			savePageState() {
417
+				this.pageState.pageNum = this.pageNum;
418
+				this.pageState.goodsList = [...this.goodsList];
419
+				this.pageState.total = this.total;
420
+			},
421
+			// 恢复页面状态
422
+			restorePageState() {
423
+				if (this.pageState.goodsList.length > 0) {
424
+					this.pageNum = this.pageState.pageNum;
425
+					this.goodsList = [...this.pageState.goodsList];
426
+					this.total = this.pageState.total;
427
+					// 滚动位置会通过scroll-top属性自动恢复
428
+					return true;
429
+				}
430
+				return false;
431
+			},
432
+		},
433
+		onShow() {
434
+			// 尝试恢复页面状态
435
+			if (!this.restorePageState()) {
436
+				// 如果没有保存的状态,重新加载第一页
437
+				this.pageNum = 1;
438
+				this.getList();
439
+			}
440
+			this.getCard();
441
+		},
442
+		onHide() {
443
+			// 页面隐藏时保存状态
444
+			this.savePageState();
404 445
 		},
405
-	},
406
-	onShow() {
407
-		this.pageNum = 1;
408
-		this.getList();
409
-		this.getCard();
410
-	},
411 446
 	onPullDownRefresh() {
412 447
 		this.pageNum = 1;
413 448
 		this.getList();