feat: 国际出港 装货交接 待配运
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package com.lukouguoji.gjc.dialog
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.DialogIntExpOutWaitingTransBinding
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
/**
|
||||
* 国际出港出库交接 - 待配运操作对话框
|
||||
*/
|
||||
class IntExpOutWaitingTransDialogModel(
|
||||
private val callback: (IntExpOutWaitingTransDialogModel) -> Unit
|
||||
) : BaseDialogModel<DialogIntExpOutWaitingTransBinding>(DIALOG_TYPE_CENTER) {
|
||||
|
||||
// 库位列表
|
||||
val locationList = MutableLiveData<List<KeyValue>>()
|
||||
|
||||
// 选中的库位(存储的是code)
|
||||
val selectedLocationCode = MutableLiveData("")
|
||||
|
||||
// 库位ID (后端需要的code)
|
||||
var locationId: String = ""
|
||||
|
||||
// 库位名称 (后端需要的name)
|
||||
var locationName: String = ""
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_int_exp_out_waiting_trans
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
loadLocationList()
|
||||
|
||||
// 监听选择变化,更新locationId和locationName
|
||||
selectedLocationCode.observeForever { code ->
|
||||
val selectedItem = locationList.value?.find { it.value == code }
|
||||
locationId = selectedItem?.value ?: ""
|
||||
locationName = selectedItem?.key ?: ""
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载库位列表
|
||||
*/
|
||||
private fun loadLocationList() {
|
||||
launchCollect({ NetApply.api.getLocationList(flag = 2) }) {
|
||||
onSuccess = { result ->
|
||||
val list = result.data?.map { it.toKeyValue() } ?: emptyList()
|
||||
locationList.value = list
|
||||
}
|
||||
onFailed = { _, msg ->
|
||||
showToast(msg ?: "加载库位列表失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存按钮点击
|
||||
*/
|
||||
fun onSaveClick() {
|
||||
if (selectedLocationCode.value.verifyNullOrEmpty("请选择库位")) {
|
||||
return
|
||||
}
|
||||
dismiss()
|
||||
callback(this)
|
||||
}
|
||||
}
|
||||
@@ -223,7 +223,7 @@ class IntExpArriveViewModel : BasePageViewModel() {
|
||||
val filterParams = mapOf(
|
||||
"fdate" to flightDate.value?.ifEmpty { null },
|
||||
"fno" to flightNo.value?.ifEmpty { null },
|
||||
"likeNo" to waybillNo.value?.ifEmpty { null },
|
||||
"wbNo" to waybillNo.value?.ifEmpty { null },
|
||||
"hno" to hno.value?.ifEmpty { null }
|
||||
)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.app.Activity
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.dialog.IntExpOutWaitingTransDialogModel
|
||||
import com.lukouguoji.gjc.holder.IntExpOutHandoverViewHolder
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GjcUldUseBean
|
||||
@@ -18,7 +19,7 @@ import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import dev.utils.common.DateUtils
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
@@ -105,6 +106,59 @@ class IntExpOutHandoverViewModel : BasePageViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 待配运按钮点击
|
||||
*/
|
||||
fun waitingTransClick() {
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcUldUseBean> ?: return
|
||||
val selectedItems = list.filter { it.isSelected }
|
||||
|
||||
if (selectedItems.isEmpty()) {
|
||||
showToast("请选择要待配运的ULD")
|
||||
return
|
||||
}
|
||||
|
||||
// 显示待配运弹框
|
||||
showWaitingTransDialog(selectedItems)
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示待配运弹框
|
||||
*/
|
||||
private fun showWaitingTransDialog(selectedItems: List<GjcUldUseBean>) {
|
||||
val dialog = IntExpOutWaitingTransDialogModel { model ->
|
||||
// 弹框确定回调
|
||||
performWaitingTrans(selectedItems, model.locationId, model.locationName)
|
||||
}
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行待配运操作
|
||||
*/
|
||||
private fun performWaitingTrans(
|
||||
selectedItems: List<GjcUldUseBean>,
|
||||
locationId: String,
|
||||
locationName: String
|
||||
) {
|
||||
// 构建请求参数
|
||||
val params = mapOf(
|
||||
"location" to locationName,
|
||||
"locationId" to locationId.toLongOrNull(),
|
||||
"uldUseList" to selectedItems
|
||||
).toRequestBody()
|
||||
|
||||
launchLoadingCollect({ NetApply.api.waitingTrans(params) }) {
|
||||
onSuccess = {
|
||||
showToast("待配运操作成功")
|
||||
viewModelScope.launch {
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据 (重写BasePageViewModel)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user