fix(gjj): 国际事故签证「发现时间」改为下拉选择,数据源 POST typeCode/searchDateType
- Api 新增 getSearchDateTypeList(POST 无参,返回 code 1~8 + 中英文 name), 与同路径的 GET 通用字典 getDictList 区分 - 编辑页 DATE → SPINNER,与 Web 端一致提交字典 name - 历史数据(日期值、带尾随换行的 name)不在字典内时补进下拉列表, 避免编辑/详情回显为空、保存时被清掉 - phone-adapt api-doc 记录该接口 GET/POST 语义 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -60,6 +60,8 @@ class IntImpAccidentVisaEditViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
val damageTypeList = MutableLiveData<List<KeyValue>>(emptyList())
|
||||
val contentTypeList = MutableLiveData<List<KeyValue>>(emptyList())
|
||||
val unusualTypeList = MutableLiveData<List<KeyValue>>(emptyList())
|
||||
val searchDateTypeList = MutableLiveData<List<KeyValue>>(emptyList())
|
||||
private var searchDateTypeDict = emptyList<KeyValue>()
|
||||
val photoList = MutableLiveData(
|
||||
listOf(KeyValue("是", "是"), KeyValue("否", "否"))
|
||||
)
|
||||
@@ -137,12 +139,33 @@ class IntImpAccidentVisaEditViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
} ?: emptyList()
|
||||
}
|
||||
}
|
||||
// 发现时间:与 Web 端一致提交字典 name(如"接收时 Cargo Acceptation")
|
||||
launchCollect({ NetApply.api.getSearchDateTypeList() }) {
|
||||
onSuccess = { result ->
|
||||
searchDateTypeDict = result.data?.mapNotNull { bean ->
|
||||
bean.name?.let { name -> KeyValue(name, name) }
|
||||
} ?: emptyList()
|
||||
refreshSearchDateTypeList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 历史数据的发现时间不一定在字典内(早期按日期录入如"2026-09-24",Web 端存值可能带尾随换行),
|
||||
* 编辑/详情时把原值补进下拉列表,避免回显为空、保存时被下拉清掉
|
||||
*/
|
||||
private fun refreshSearchDateTypeList() {
|
||||
val current = dataBean.value?.seachDate.orEmpty()
|
||||
searchDateTypeList.value =
|
||||
if (current.isEmpty() || searchDateTypeDict.any { it.value == current }) searchDateTypeDict
|
||||
else searchDateTypeDict + KeyValue(current.trim(), current)
|
||||
}
|
||||
|
||||
private fun loadDetail() {
|
||||
launchLoadingCollect({ NetApply.api.getGjAccidentVisaDetail(id) }) {
|
||||
onSuccess = {
|
||||
dataBean.value = it.data ?: GjAccidentVisaEditBean()
|
||||
refreshSearchDateTypeList()
|
||||
|
||||
// 渲染图片:path 取原图 URL 确保预览清晰,url 取缩略图用于提交
|
||||
val bean = dataBean.value!!
|
||||
|
||||
@@ -285,9 +285,10 @@
|
||||
android:layout_weight="1"
|
||||
enable="@{!viewModel.isDetailMode}"
|
||||
hint='@{"请选择发现时间"}'
|
||||
list="@{viewModel.searchDateTypeList}"
|
||||
title='@{"发现时间"}'
|
||||
titleLength="@{6}"
|
||||
type="@{DataLayoutType.DATE}"
|
||||
type="@{DataLayoutType.SPINNER}"
|
||||
value='@={viewModel.dataBean.seachDate}' />
|
||||
|
||||
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||
|
||||
Reference in New Issue
Block a user