添加了供应商列表和搜索物品分页功能

This commit is contained in:
zxj
2025-07-11 15:53:17 +08:00
parent 7459bd205a
commit f1283ba11e
8 changed files with 182 additions and 19 deletions
@@ -77,6 +77,18 @@ class SelfProcurementViewModel @Inject constructor(
*/
private val _amountUserInput = MutableStateFlow<Boolean>(false)
/**
* 是否可以加载更多
*/
private val _canLoadMore = MutableStateFlow(true)
val canLoadMore: StateFlow<Boolean> = _canLoadMore
/**
* 是否显示进度条
*/
private val _isMoreLoading = MutableStateFlow(false)
val isMoreLoading = _isMoreLoading
/**
* 更新全局仓库
*/
@@ -237,15 +249,24 @@ class SelfProcurementViewModel @Inject constructor(
fun searchGoodsInfoList(
goodsName: String,
pageNo: Int = 0,
pageNo: Int = 1,
pageSize: Int = 10
) {
launch {
if (pageNo > 1) {
_isMoreLoading.value = true
}
val response = repository.searchGoodsInfoList(goodsName, pageNo, pageSize)
_isMoreLoading.value = false
if (response.isSuccess()) {
val data = response.data
if (data != null) {
_searchListItems.value = data.records ?: emptyList<SearchGoodsInfo.Record>()
data?.records?.let {
_canLoadMore.value = data.records.size >= pageSize
if (pageNo > 1) {
_searchListItems.value = _searchListItems.value + data.records
} else {
_searchListItems.value = data.records
}
}
} else {
_searchListItems.value = emptyList<SearchGoodsInfo.Record>()