feat: ULD 管理所属航司下拉接入接口
列表页/编辑页所属航司下拉由 mock 改为接口数据源 POST /typeCode/intCarrier, 编辑页按已选航司置顶回填 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
@@ -29,16 +30,8 @@ class UldEditViewModel : BaseViewModel() {
|
||||
)
|
||||
)
|
||||
|
||||
// 所属航司下拉列表(mock,后续替换为接口)
|
||||
val carrierList = MutableLiveData<List<KeyValue>>(
|
||||
listOf(
|
||||
KeyValue("MU - 东方航空", "MU"),
|
||||
KeyValue("CA - 国航", "CA"),
|
||||
KeyValue("CZ - 南方航空", "CZ"),
|
||||
KeyValue("HO - 吉祥航空", "HO"),
|
||||
KeyValue("FM - 上海航空", "FM"),
|
||||
)
|
||||
)
|
||||
// 所属航司下拉列表(数据源:POST /typeCode/intCarrier)
|
||||
val carrierList = MutableLiveData<List<KeyValue>>(emptyList())
|
||||
|
||||
fun initOnCreate(intent: Intent) {
|
||||
id = intent.getStringExtra(Constant.Key.ID) ?: ""
|
||||
@@ -46,8 +39,13 @@ class UldEditViewModel : BaseViewModel() {
|
||||
pageType.value = if (id.isEmpty()) DetailsPageType.Add
|
||||
else if (modify) DetailsPageType.Modify else DetailsPageType.Details
|
||||
|
||||
if (id.isEmpty()) {
|
||||
// 新增:直接加载航司列表
|
||||
loadCarrierList(null)
|
||||
} else {
|
||||
getData()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getData() {
|
||||
if (id.isEmpty()) return
|
||||
@@ -56,10 +54,18 @@ class UldEditViewModel : BaseViewModel() {
|
||||
}) {
|
||||
onSuccess = {
|
||||
uldBean.value = it.data ?: ULDBean()
|
||||
// 编辑/详情:数据加载完成后再加载字典,将已选航司置顶回填
|
||||
loadCarrierList(uldBean.value?.carrier)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadCarrierList(checkedValue: String?) {
|
||||
DictUtils.getIntCarrierList(checkedValue = checkedValue?.ifEmpty { null }) {
|
||||
carrierList.value = it
|
||||
}
|
||||
}
|
||||
|
||||
fun onSaveClick() {
|
||||
val bean = uldBean.value ?: return
|
||||
if (bean.uld.isBlank()) {
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.model.ConfirmDialogModel
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
@@ -35,17 +36,8 @@ class UldListViewModel : BasePageViewModel() {
|
||||
)
|
||||
)
|
||||
|
||||
// 所属航司下拉列表(mock,后续替换为接口)
|
||||
val carrierList = MutableLiveData<List<KeyValue>>(
|
||||
listOf(
|
||||
KeyValue("全部", ""),
|
||||
KeyValue("MU - 东方航空", "MU"),
|
||||
KeyValue("CA - 国航", "CA"),
|
||||
KeyValue("CZ - 南方航空", "CZ"),
|
||||
KeyValue("HO - 吉祥航空", "HO"),
|
||||
KeyValue("FM - 上海航空", "FM"),
|
||||
)
|
||||
)
|
||||
// 所属航司下拉列表(数据源:POST /typeCode/intCarrier)
|
||||
val carrierList = MutableLiveData<List<KeyValue>>(listOf(KeyValue("全部", "")))
|
||||
|
||||
// 合计数量
|
||||
val count = MutableLiveData(0L)
|
||||
@@ -53,6 +45,13 @@ class UldListViewModel : BasePageViewModel() {
|
||||
val itemLayoutId = R.layout.item_uld_list
|
||||
val itemViewHolder = UldListViewHolder::class.java
|
||||
|
||||
init {
|
||||
// 加载所属航司列表(addAll=true 保留“全部”作为筛选默认项)
|
||||
DictUtils.getIntCarrierList(addAll = true) {
|
||||
carrierList.value = it
|
||||
}
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getUldList(
|
||||
|
||||
@@ -320,6 +320,12 @@ interface Api {
|
||||
@POST("typeCode/communicateType")
|
||||
suspend fun getCommunicateTypeList(): DictListBean
|
||||
|
||||
/**
|
||||
* 获取所属航司列表(国际)
|
||||
*/
|
||||
@POST("typeCode/intCarrier")
|
||||
suspend fun getIntCarrierList(): DictListBean
|
||||
|
||||
/**
|
||||
* 查询平板车信息
|
||||
*/
|
||||
|
||||
@@ -84,6 +84,24 @@ object DictUtils {
|
||||
KeyValue("出港库存至库区", "3"),
|
||||
)
|
||||
|
||||
/**
|
||||
* 获取所属航司列表(国际)
|
||||
*/
|
||||
fun getIntCarrierList(
|
||||
addAll: Boolean = false,
|
||||
checkedValue: String? = null,
|
||||
callBack: (List<KeyValue>) -> Unit
|
||||
) {
|
||||
launchCollect({
|
||||
NetApply.api
|
||||
.getIntCarrierList()
|
||||
}) {
|
||||
onSuccess = {
|
||||
handleCallBack(it, checkedValue, addAll, callBack)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取代理列表
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user