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.noNull
|
||||||
import com.lukouguoji.module_base.ktx.showToast
|
import com.lukouguoji.module_base.ktx.showToast
|
||||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||||
|
import com.lukouguoji.module_base.util.DictUtils
|
||||||
import dev.DevUtils
|
import dev.DevUtils
|
||||||
import dev.utils.app.info.KeyValue
|
import dev.utils.app.info.KeyValue
|
||||||
|
|
||||||
@@ -29,16 +30,8 @@ class UldEditViewModel : BaseViewModel() {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
// 所属航司下拉列表(mock,后续替换为接口)
|
// 所属航司下拉列表(数据源:POST /typeCode/intCarrier)
|
||||||
val carrierList = MutableLiveData<List<KeyValue>>(
|
val carrierList = MutableLiveData<List<KeyValue>>(emptyList())
|
||||||
listOf(
|
|
||||||
KeyValue("MU - 东方航空", "MU"),
|
|
||||||
KeyValue("CA - 国航", "CA"),
|
|
||||||
KeyValue("CZ - 南方航空", "CZ"),
|
|
||||||
KeyValue("HO - 吉祥航空", "HO"),
|
|
||||||
KeyValue("FM - 上海航空", "FM"),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
fun initOnCreate(intent: Intent) {
|
fun initOnCreate(intent: Intent) {
|
||||||
id = intent.getStringExtra(Constant.Key.ID) ?: ""
|
id = intent.getStringExtra(Constant.Key.ID) ?: ""
|
||||||
@@ -46,7 +39,12 @@ class UldEditViewModel : BaseViewModel() {
|
|||||||
pageType.value = if (id.isEmpty()) DetailsPageType.Add
|
pageType.value = if (id.isEmpty()) DetailsPageType.Add
|
||||||
else if (modify) DetailsPageType.Modify else DetailsPageType.Details
|
else if (modify) DetailsPageType.Modify else DetailsPageType.Details
|
||||||
|
|
||||||
getData()
|
if (id.isEmpty()) {
|
||||||
|
// 新增:直接加载航司列表
|
||||||
|
loadCarrierList(null)
|
||||||
|
} else {
|
||||||
|
getData()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getData() {
|
private fun getData() {
|
||||||
@@ -56,10 +54,18 @@ class UldEditViewModel : BaseViewModel() {
|
|||||||
}) {
|
}) {
|
||||||
onSuccess = {
|
onSuccess = {
|
||||||
uldBean.value = it.data ?: ULDBean()
|
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() {
|
fun onSaveClick() {
|
||||||
val bean = uldBean.value ?: return
|
val bean = uldBean.value ?: return
|
||||||
if (bean.uld.isBlank()) {
|
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.model.ConfirmDialogModel
|
||||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||||
import com.lukouguoji.module_base.model.ScanModel
|
import com.lukouguoji.module_base.model.ScanModel
|
||||||
|
import com.lukouguoji.module_base.util.DictUtils
|
||||||
import dev.DevUtils
|
import dev.DevUtils
|
||||||
import dev.utils.app.info.KeyValue
|
import dev.utils.app.info.KeyValue
|
||||||
|
|
||||||
@@ -35,17 +36,8 @@ class UldListViewModel : BasePageViewModel() {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
// 所属航司下拉列表(mock,后续替换为接口)
|
// 所属航司下拉列表(数据源:POST /typeCode/intCarrier)
|
||||||
val carrierList = MutableLiveData<List<KeyValue>>(
|
val carrierList = MutableLiveData<List<KeyValue>>(listOf(KeyValue("全部", "")))
|
||||||
listOf(
|
|
||||||
KeyValue("全部", ""),
|
|
||||||
KeyValue("MU - 东方航空", "MU"),
|
|
||||||
KeyValue("CA - 国航", "CA"),
|
|
||||||
KeyValue("CZ - 南方航空", "CZ"),
|
|
||||||
KeyValue("HO - 吉祥航空", "HO"),
|
|
||||||
KeyValue("FM - 上海航空", "FM"),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
// 合计数量
|
// 合计数量
|
||||||
val count = MutableLiveData(0L)
|
val count = MutableLiveData(0L)
|
||||||
@@ -53,6 +45,13 @@ class UldListViewModel : BasePageViewModel() {
|
|||||||
val itemLayoutId = R.layout.item_uld_list
|
val itemLayoutId = R.layout.item_uld_list
|
||||||
val itemViewHolder = UldListViewHolder::class.java
|
val itemViewHolder = UldListViewHolder::class.java
|
||||||
|
|
||||||
|
init {
|
||||||
|
// 加载所属航司列表(addAll=true 保留“全部”作为筛选默认项)
|
||||||
|
DictUtils.getIntCarrierList(addAll = true) {
|
||||||
|
carrierList.value = it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun getData() {
|
override fun getData() {
|
||||||
launchLoadingCollect({
|
launchLoadingCollect({
|
||||||
NetApply.api.getUldList(
|
NetApply.api.getUldList(
|
||||||
|
|||||||
@@ -320,6 +320,12 @@ interface Api {
|
|||||||
@POST("typeCode/communicateType")
|
@POST("typeCode/communicateType")
|
||||||
suspend fun getCommunicateTypeList(): DictListBean
|
suspend fun getCommunicateTypeList(): DictListBean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所属航司列表(国际)
|
||||||
|
*/
|
||||||
|
@POST("typeCode/intCarrier")
|
||||||
|
suspend fun getIntCarrierList(): DictListBean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询平板车信息
|
* 查询平板车信息
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -84,6 +84,24 @@ object DictUtils {
|
|||||||
KeyValue("出港库存至库区", "3"),
|
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