添加了供应商列表和搜索物品分页功能
This commit is contained in:
@@ -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>()
|
||||
|
||||
Reference in New Issue
Block a user