fix: 国际进港舱单编辑页下拉框回填及移除404接口
- 使用 DictUtils checkedValue 机制回填编辑模式下拉框选中项 - 移除已404的 searchCargoType 接口调用 - PadDataLayoutNew 增加 updateSpinnerSilently 防止 adapter 重建覆盖值 - CLAUDE.md 补充编辑表单 SPINNER 回填规范 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -153,51 +153,13 @@ class GjjManifestAddViewModel : BaseViewModel() {
|
||||
val specialCodeList = MutableLiveData<List<KeyValue>>()
|
||||
val specialCode = MutableLiveData("")
|
||||
|
||||
// 货物类型
|
||||
val goodsTypeList = MutableLiveData<List<KeyValue>>()
|
||||
// 货物类型(无下拉列表,仅用于编辑模式回传)
|
||||
val goodsType = MutableLiveData("")
|
||||
|
||||
// 运单类型
|
||||
val waybillTypeList = MutableLiveData<List<KeyValue>>()
|
||||
val waybillType = MutableLiveData("")
|
||||
|
||||
init {
|
||||
DictUtils.getIntImpAgentList(addAll = false) {
|
||||
agentList.postValue(listOf(KeyValue("", "")) + it)
|
||||
}
|
||||
DictUtils.getSpecialCodeList(addAll = false, flag = 1, ieFlag = "") {
|
||||
val list = arrayListOf<KeyValue>()
|
||||
it.find { b -> b.key.contains("普通货物") }?.let { b ->
|
||||
list.add(b)
|
||||
}
|
||||
list.addAll(it.filter { b -> !b.key.contains("普通货物") })
|
||||
specialCodeList.postValue(list)
|
||||
}
|
||||
DictUtils.getBusinessTypeList(addAll = false) {
|
||||
businessTypeList.postValue(it)
|
||||
// 新增模式下默认选中"普通货物运输"
|
||||
if (pageType.value == DetailsPageType.Add && businessType.value.isNullOrEmpty()) {
|
||||
it.find { b -> b.key.contains("普通货物运输") }?.let { b ->
|
||||
businessType.postValue(b.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
DictUtils.getShouYunPackageTypeList {
|
||||
packageTypeList.postValue(listOf(KeyValue("", "")) + it)
|
||||
}
|
||||
DictUtils.getGjjGoodsTypeList(addAll = false) {
|
||||
goodsTypeList.postValue(it)
|
||||
}
|
||||
DictUtils.getWaybillTypeList(type = "II", addAll = false) {
|
||||
val list = arrayListOf<KeyValue>()
|
||||
it.find { b -> b.key.contains("干线") }?.let { b ->
|
||||
list.add(b)
|
||||
}
|
||||
list.addAll(it.filter { b -> !b.key.contains("干线") })
|
||||
waybillTypeList.postValue(list)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化(从Intent获取参数)
|
||||
*/
|
||||
@@ -235,6 +197,71 @@ class GjjManifestAddViewModel : BaseViewModel() {
|
||||
loadManifestFromImportBean(bean)
|
||||
}
|
||||
}
|
||||
|
||||
// 加载下拉列表(在编辑数据加载之后,以便使用 checkedValue 将选中项置顶)
|
||||
loadDictLists()
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载下拉列表数据
|
||||
* 编辑模式下传入 checkedValue,handleCallBack 会将匹配项置于列表首位,
|
||||
* Spinner 默认显示首项即完成回填
|
||||
*/
|
||||
private fun loadDictLists() {
|
||||
val isModify = pageType.value == DetailsPageType.Modify
|
||||
|
||||
DictUtils.getIntImpAgentList(
|
||||
addAll = false,
|
||||
checkedValue = if (isModify) agent.value else null
|
||||
) {
|
||||
agentList.postValue(if (isModify) it else listOf(KeyValue("", "")) + it)
|
||||
}
|
||||
|
||||
DictUtils.getSpecialCodeList(
|
||||
addAll = false, flag = 1, ieFlag = "",
|
||||
checkedValue = if (isModify) specialCode.value else null
|
||||
) {
|
||||
if (isModify) {
|
||||
specialCodeList.postValue(it)
|
||||
} else {
|
||||
val list = arrayListOf<KeyValue>()
|
||||
it.find { b -> b.key.contains("普通货物") }?.let { b -> list.add(b) }
|
||||
list.addAll(it.filter { b -> !b.key.contains("普通货物") })
|
||||
specialCodeList.postValue(list)
|
||||
}
|
||||
}
|
||||
|
||||
DictUtils.getBusinessTypeList(
|
||||
addAll = false,
|
||||
checkedValue = if (isModify) businessType.value else null
|
||||
) {
|
||||
businessTypeList.postValue(it)
|
||||
if (!isModify && businessType.value.isNullOrEmpty()) {
|
||||
it.find { b -> b.key.contains("普通货物运输") }?.let { b ->
|
||||
businessType.postValue(b.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DictUtils.getShouYunPackageTypeList(
|
||||
checkedValue = if (isModify) packageType.value else null
|
||||
) {
|
||||
packageTypeList.postValue(if (isModify) it else listOf(KeyValue("", "")) + it)
|
||||
}
|
||||
|
||||
DictUtils.getWaybillTypeList(
|
||||
type = "II", addAll = false,
|
||||
checkedValue = if (isModify) waybillType.value else null
|
||||
) {
|
||||
if (isModify) {
|
||||
waybillTypeList.postValue(it)
|
||||
} else {
|
||||
val list = arrayListOf<KeyValue>()
|
||||
it.find { b -> b.key.contains("干线") }?.let { b -> list.add(b) }
|
||||
list.addAll(it.filter { b -> !b.key.contains("干线") })
|
||||
waybillTypeList.postValue(list)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user