修复货位分页:使用真实page_size+解析total实现上拉加载
This commit is contained in:
parent
1413010c16
commit
6705a6a560
@ -886,6 +886,7 @@ export default {
|
|||||||
popupLocLoadingMore: false,
|
popupLocLoadingMore: false,
|
||||||
popupLocationSearch: '',
|
popupLocationSearch: '',
|
||||||
popupAllLocationList: [],
|
popupAllLocationList: [],
|
||||||
|
popupLocTotal: 0,
|
||||||
popupRefreshing: false,
|
popupRefreshing: false,
|
||||||
_pendingPreselectWh: null,
|
_pendingPreselectWh: null,
|
||||||
_pendingPreselectLoc: null,
|
_pendingPreselectLoc: null,
|
||||||
@ -1378,31 +1379,46 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async loadPopupLocations(warehouseId) {
|
async loadPopupLocations(warehouseId, keepExisting = false) {
|
||||||
|
if (!keepExisting) {
|
||||||
this.popupLoadingLocation = true
|
this.popupLoadingLocation = true
|
||||||
this.popupLocPage = 1
|
this.popupLocPage = 1
|
||||||
this.popupLocHasMore = true
|
this.popupLocHasMore = true
|
||||||
this.popupAllLocationList = []
|
this.popupAllLocationList = []
|
||||||
|
this.popupLocTotal = 0
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const res = await getLocationList({
|
const res = await getLocationList({
|
||||||
warehouse_id: warehouseId, type: 1, status: 1,
|
warehouse_id: warehouseId, type: 1, status: 1,
|
||||||
page: 1, page_size: 999
|
page: this.popupLocPage, page_size: this.popupLocPageSize
|
||||||
})
|
})
|
||||||
console.log('【货位列表】load响应:', JSON.stringify(res))
|
console.log('【货位列表】load响应:', JSON.stringify(res))
|
||||||
// 兼容多种响应格式
|
// 兼容多种响应格式:{ code:0, data:{ list:[], total:100 } } 或直接 { list:[], total:100 }
|
||||||
let list = []
|
let newList = []
|
||||||
|
let totalCount = 0
|
||||||
if (res.code === 0 && res.data) {
|
if (res.code === 0 && res.data) {
|
||||||
list = res.data.list || res.data.records || []
|
newList = res.data.list || res.data.records || []
|
||||||
|
totalCount = res.data.total || 0
|
||||||
|
} else if (res.list || res.records) {
|
||||||
|
newList = res.list || res.records || []
|
||||||
|
totalCount = res.total || 0
|
||||||
}
|
}
|
||||||
if (list.length === 0) {
|
if (newList.length > 0) {
|
||||||
list = res.list || res.records || []
|
if (keepExisting) {
|
||||||
}
|
this.popupLocationList = [...this.popupLocationList, ...newList]
|
||||||
if (list.length > 0) {
|
this.popupAllLocationList = [...this.popupAllLocationList, ...newList]
|
||||||
this.popupLocationList = list
|
|
||||||
this.popupAllLocationList = list
|
|
||||||
this.popupLocHasMore = false
|
|
||||||
} else {
|
} else {
|
||||||
console.warn('货位列表为空', JSON.stringify(res))
|
this.popupLocationList = newList
|
||||||
|
this.popupAllLocationList = newList
|
||||||
|
}
|
||||||
|
this.popupLocTotal = totalCount
|
||||||
|
this.popupLocHasMore = this.popupLocPage * this.popupLocPageSize < totalCount
|
||||||
|
} else {
|
||||||
|
if (!keepExisting) {
|
||||||
|
this.popupLocationList = []
|
||||||
|
this.popupAllLocationList = []
|
||||||
|
}
|
||||||
|
this.popupLocHasMore = false
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('加载货位失败:', e)
|
console.error('加载货位失败:', e)
|
||||||
@ -1418,8 +1434,10 @@ export default {
|
|||||||
this.popupLocationList = this.popupAllLocationList
|
this.popupLocationList = this.popupAllLocationList
|
||||||
this.popupLocHasMore = false
|
this.popupLocHasMore = false
|
||||||
} finally {
|
} finally {
|
||||||
|
if (!keepExisting) {
|
||||||
this.popupLoadingLocation = false
|
this.popupLoadingLocation = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
selectPopupWarehouse(idx) {
|
selectPopupWarehouse(idx) {
|
||||||
@ -1481,25 +1499,8 @@ export default {
|
|||||||
this.popupLocLoadingMore = true
|
this.popupLocLoadingMore = true
|
||||||
this.popupLocPage++
|
this.popupLocPage++
|
||||||
const wh = this.popupWarehouseList[this.popupActiveWhIndex]
|
const wh = this.popupWarehouseList[this.popupActiveWhIndex]
|
||||||
if (!wh) return
|
if (!wh) { this.popupLocLoadingMore = false; return }
|
||||||
getLocationList({
|
this.loadPopupLocations(wh.id, true).catch(() => {
|
||||||
warehouse_id: wh.id, type: 1, status: 1,
|
|
||||||
page: this.popupLocPage, page_size: this.popupLocPageSize
|
|
||||||
}).then(res => {
|
|
||||||
if (res.code === 0 && res.data && res.data.list) {
|
|
||||||
const newList = res.data.list
|
|
||||||
if (newList.length === 0) {
|
|
||||||
this.popupLocHasMore = false
|
|
||||||
} else {
|
|
||||||
this.popupLocationList = [...this.popupLocationList, ...newList]
|
|
||||||
this.popupAllLocationList = [...this.popupAllLocationList, ...newList]
|
|
||||||
const total = res.data.total || 0
|
|
||||||
this.popupLocHasMore = this.popupLocPage * this.popupLocPageSize < total
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.popupLocHasMore = false
|
|
||||||
}
|
|
||||||
}).catch(() => {
|
|
||||||
this.popupLocPage--
|
this.popupLocPage--
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.popupLocLoadingMore = false
|
this.popupLocLoadingMore = false
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user