feat: 国际进港原始舱单补充信息页按始发站/目的站自动匹配国家代码
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -308,6 +308,12 @@ interface Api {
|
|||||||
@POST("typeCode/countryCode")
|
@POST("typeCode/countryCode")
|
||||||
suspend fun getCountryCodeList(): DictListBean
|
suspend fun getCountryCodeList(): DictListBean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取国家代码(带始发站筛选)
|
||||||
|
*/
|
||||||
|
@POST("typeCode/countryCode")
|
||||||
|
suspend fun getCountryCodeListByFdep(@Query("fDep") fDep: String): DictListBean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取通讯方式类型
|
* 获取通讯方式类型
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -65,6 +65,51 @@ class IntArrSupplementInfoViewModel : BaseViewModel() {
|
|||||||
} else null
|
} else null
|
||||||
} ?: emptyList()
|
} ?: emptyList()
|
||||||
countryCodeList.value = keyValueList
|
countryCodeList.value = keyValueList
|
||||||
|
|
||||||
|
// 全量加载完成后,按始发站过滤查询,若唯一则自动选中
|
||||||
|
autoMatchCountryCodeByFdep()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据始发站/目的站自动匹配国家代码
|
||||||
|
* - 始发站(fdep) → 匹配发货人国家代码
|
||||||
|
* - 目的站(fdest) → 匹配收货人国家代码
|
||||||
|
*/
|
||||||
|
private fun autoMatchCountryCodeByFdep() {
|
||||||
|
val manifest = manifestList.firstOrNull() ?: return
|
||||||
|
val bean = dataBean.value ?: return
|
||||||
|
|
||||||
|
// 始发站 → 发货人国家代码
|
||||||
|
if (manifest.fdep.isNotEmpty() && bean.consignorCountryCode.isEmpty()) {
|
||||||
|
launchCollect({ NetApply.api.getCountryCodeListByFdep(manifest.fdep) }) {
|
||||||
|
onSuccess = { result ->
|
||||||
|
val filtered = result.data?.mapNotNull { dictBean ->
|
||||||
|
if (dictBean.code != null && dictBean.name != null) KeyValue(dictBean.name, dictBean.code) else null
|
||||||
|
} ?: emptyList()
|
||||||
|
if (filtered.size == 1) {
|
||||||
|
dataBean.value?.let { current ->
|
||||||
|
dataBean.value = current.copy(consignorCountryCode = filtered.first().value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 目的站 → 收货人国家代码
|
||||||
|
if (manifest.fdest.isNotEmpty() && bean.consigneeCountryCode.isEmpty()) {
|
||||||
|
launchCollect({ NetApply.api.getCountryCodeListByFdep(manifest.fdest) }) {
|
||||||
|
onSuccess = { result ->
|
||||||
|
val filtered = result.data?.mapNotNull { dictBean ->
|
||||||
|
if (dictBean.code != null && dictBean.name != null) KeyValue(dictBean.name, dictBean.code) else null
|
||||||
|
} ?: emptyList()
|
||||||
|
if (filtered.size == 1) {
|
||||||
|
dataBean.value?.let { current ->
|
||||||
|
dataBean.value = current.copy(consigneeCountryCode = filtered.first().value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user