refactor: 国际进港舱单列表项布局优化及分单按需加载
- 主列表项从4行改为2行5列标准KV布局 - 展开按钮移入白色卡片内,始终显示 - 分单数据改为点击展开时按需加载 - 子列表列宽调整,品名支持goodsCn优先显示 - 子列表所有列加单行省略号 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -40,9 +40,14 @@ class IntImpManifestViewHolder(view: View) :
|
||||
clickListener?.onItemClick(position, 102) // 102=删除
|
||||
}
|
||||
|
||||
// 展开按钮点击事件
|
||||
// 展开按钮点击事件 - 先加载分单数据,再切换展开状态
|
||||
binding.ivShow.setOnClickListener {
|
||||
bean.showMore.set(!bean.showMore.get())
|
||||
if (!bean.showMore.get() && bean.haWbList.isNullOrEmpty()) {
|
||||
// 首次展开且无数据,通知 ViewModel 加载分单
|
||||
clickListener?.onItemClick(position, 103) // 103=加载分单
|
||||
} else {
|
||||
bean.showMore.set(!bean.showMore.get())
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化分单子列表 RecyclerView
|
||||
|
||||
@@ -69,13 +69,18 @@ class IntArrSupplementInfoViewModel : BaseViewModel() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载通讯方式下拉列表(本地固定值)
|
||||
* 加载通讯方式下拉列表
|
||||
*/
|
||||
private fun loadComTypeList() {
|
||||
comTypeList.value = listOf(
|
||||
KeyValue("电话(TE)", "TE"),
|
||||
KeyValue("传真(FX)", "FX")
|
||||
)
|
||||
launchCollect({ NetApply.api.getCommunicateTypeList() }) {
|
||||
onSuccess = { result ->
|
||||
comTypeList.value = result.data?.mapNotNull { bean ->
|
||||
if (bean.code != null && bean.name != null) {
|
||||
KeyValue(bean.name, bean.code)
|
||||
} else null
|
||||
} ?: emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,12 +34,13 @@ class IntImpManifestViewModel : BasePageViewModel() {
|
||||
val flightNo = MutableLiveData("") // 航班号
|
||||
val sendAddress = MutableLiveData("") // 始发站
|
||||
val sendAddressList = MutableLiveData<List<KeyValue>>(emptyList())
|
||||
val fdep = MutableLiveData("") // 目的站
|
||||
val fdest = MutableLiveData("") // 目的站
|
||||
val waybillNo = MutableLiveData("") // 运单号
|
||||
|
||||
// ========== 航班级联查询 ==========
|
||||
private var lastQueriedFlight = ""
|
||||
private var fid = ""
|
||||
private var fdep = "" // 航班始发港(用于列表查询参数)
|
||||
|
||||
fun onFlightDateInputComplete() {
|
||||
lastQueriedFlight = ""
|
||||
@@ -72,7 +73,8 @@ class IntImpManifestViewModel : BasePageViewModel() {
|
||||
if (it.verifySuccess() && it.data != null) {
|
||||
val flight = it.data!!
|
||||
fid = flight.fid.noNull()
|
||||
fdep.value = flight.fdest.noNull()
|
||||
fdep = flight.fdep.noNull()
|
||||
fdest.value = flight.fdest.noNull()
|
||||
|
||||
// 构建始发站下拉列表:fdep + jtz(经停港)
|
||||
val list = mutableListOf(
|
||||
@@ -85,7 +87,8 @@ class IntImpManifestViewModel : BasePageViewModel() {
|
||||
sendAddress.value = flight.fdep.noNull()
|
||||
} else {
|
||||
fid = ""
|
||||
fdep.value = ""
|
||||
fdep = ""
|
||||
fdest.value = ""
|
||||
sendAddressList.value = emptyList()
|
||||
sendAddress.value = ""
|
||||
showToast(it.msg.noNull("获取航班信息失败"))
|
||||
@@ -94,7 +97,8 @@ class IntImpManifestViewModel : BasePageViewModel() {
|
||||
|
||||
onFailed = { _, _ ->
|
||||
fid = ""
|
||||
fdep.value = ""
|
||||
fdep = ""
|
||||
fdest.value = ""
|
||||
sendAddressList.value = emptyList()
|
||||
sendAddress.value = ""
|
||||
}
|
||||
@@ -153,7 +157,8 @@ class IntImpManifestViewModel : BasePageViewModel() {
|
||||
if (it.verifySuccess() && it.data != null) {
|
||||
val flight = it.data!!
|
||||
fid = flight.fid.noNull()
|
||||
fdep.value = flight.fdest.noNull()
|
||||
fdep = flight.fdep.noNull()
|
||||
fdest.value = flight.fdest.noNull()
|
||||
val list = mutableListOf(
|
||||
KeyValue(flight.fdep.noNull(), flight.fdep.noNull()),
|
||||
)
|
||||
@@ -164,7 +169,8 @@ class IntImpManifestViewModel : BasePageViewModel() {
|
||||
sendAddress.value = flight.fdep.noNull()
|
||||
} else {
|
||||
fid = ""
|
||||
fdep.value = ""
|
||||
fdep = ""
|
||||
fdest.value = ""
|
||||
sendAddressList.value = emptyList()
|
||||
sendAddress.value = ""
|
||||
showToast(it.msg.noNull("获取航班信息失败"))
|
||||
@@ -173,7 +179,8 @@ class IntImpManifestViewModel : BasePageViewModel() {
|
||||
}
|
||||
onFailed = { _, _ ->
|
||||
fid = ""
|
||||
fdep.value = ""
|
||||
fdep = ""
|
||||
fdest.value = ""
|
||||
sendAddressList.value = emptyList()
|
||||
sendAddress.value = ""
|
||||
refresh()
|
||||
@@ -184,6 +191,7 @@ class IntImpManifestViewModel : BasePageViewModel() {
|
||||
}
|
||||
} else {
|
||||
fid = ""
|
||||
fdep = ""
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
@@ -212,10 +220,19 @@ class IntImpManifestViewModel : BasePageViewModel() {
|
||||
val shouldExpand = !isAllExpanded.value!!
|
||||
isAllExpanded.value = shouldExpand
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjjManifest> ?: return
|
||||
list.forEach {
|
||||
if (!it.haWbList.isNullOrEmpty()) {
|
||||
it.showMore.set(shouldExpand)
|
||||
|
||||
if (shouldExpand) {
|
||||
// 展开:对没有分单数据的项按需加载
|
||||
list.forEach { bean ->
|
||||
if (bean.haWbList.isNullOrEmpty()) {
|
||||
loadHaWbList(bean)
|
||||
} else {
|
||||
bean.showMore.set(true)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 收起
|
||||
list.forEach { it.showMore.set(false) }
|
||||
}
|
||||
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
|
||||
}
|
||||
@@ -235,7 +252,7 @@ class IntImpManifestViewModel : BasePageViewModel() {
|
||||
context = getTopActivity(),
|
||||
fid = fid,
|
||||
dep = sendAddress.value ?: "",
|
||||
dest = fdep.value ?: ""
|
||||
dest = fdest.value ?: ""
|
||||
)
|
||||
}
|
||||
|
||||
@@ -254,6 +271,10 @@ class IntImpManifestViewModel : BasePageViewModel() {
|
||||
// 删除
|
||||
deleteManifest(bean)
|
||||
}
|
||||
103 -> {
|
||||
// 展开 - 加载分单数据
|
||||
loadHaWbList(bean)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +335,7 @@ class IntImpManifestViewModel : BasePageViewModel() {
|
||||
.withString("fdate", flightDate.value ?: "")
|
||||
.withString("fno", flightNo.value ?: "")
|
||||
.withString("sendAddress", sendAddress.value ?: "")
|
||||
.withString("fdest", fdep.value ?: "")
|
||||
.withString("fdest", fdest.value ?: "")
|
||||
.navigation()
|
||||
}
|
||||
|
||||
@@ -333,8 +354,7 @@ class IntImpManifestViewModel : BasePageViewModel() {
|
||||
// 构建搜索条件(使用FID代替fdate/fno)
|
||||
val filterParams = mapOf(
|
||||
"fid" to fid.ifEmpty { null },
|
||||
"sendAddress" to sendAddress.value?.ifEmpty { null },
|
||||
"fdep" to fdep.value?.ifEmpty { null },
|
||||
"fdep" to fdep.ifEmpty { null },
|
||||
"wbNo" to waybillNo.value?.ifEmpty { null }
|
||||
)
|
||||
|
||||
@@ -350,15 +370,7 @@ class IntImpManifestViewModel : BasePageViewModel() {
|
||||
// 获取列表(带Loading)
|
||||
launchLoadingCollect({ NetApply.api.getIntImpManifestList(listParams) }) {
|
||||
onSuccess = { result ->
|
||||
pageModel.handleListBean(result.data?.toBaseListBean())
|
||||
|
||||
// 列表加载完成后,加载分单数据
|
||||
val items = pageModel.rv?.commonAdapter()?.items as? List<GjjManifest>
|
||||
items?.forEach { bean ->
|
||||
if (bean.haWbNum > 0) {
|
||||
loadHaWbList(bean)
|
||||
}
|
||||
}
|
||||
pageModel.handleListBean(result.toBaseListBean())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,18 +386,21 @@ class IntImpManifestViewModel : BasePageViewModel() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载主单下的分单列表
|
||||
* 加载主单下的分单列表(按需加载,加载完成后自动展开)
|
||||
*/
|
||||
private fun loadHaWbList(bean: GjjManifest) {
|
||||
val params = mapOf(
|
||||
"mfId" to bean.mfId
|
||||
).toRequestBody()
|
||||
|
||||
launchCollect({ NetApply.api.getIntImpManifestHaWbList(params) }) {
|
||||
launchLoadingCollect({ NetApply.api.getIntImpManifestHaWbList(params) }) {
|
||||
onSuccess = { result ->
|
||||
if (result.verifySuccess() && !result.data.isNullOrEmpty()) {
|
||||
bean.haWbList = result.data
|
||||
bean.showMore.set(true)
|
||||
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
|
||||
} else {
|
||||
showToast("暂无分单数据")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user