feat: 国际出港 出港运抵 状态重置
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package com.lukouguoji.gjc.dialog
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.DialogIntExpArriveResetBinding
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
/**
|
||||
* 国际出港运抵 - 状态重置对话框
|
||||
*/
|
||||
class IntExpArriveResetDialogModel(
|
||||
private val callback: (IntExpArriveResetDialogModel) -> Unit
|
||||
) : BaseDialogModel<DialogIntExpArriveResetBinding>(DIALOG_TYPE_CENTER) {
|
||||
|
||||
// 重置状态列表
|
||||
val resetStatusList = MutableLiveData<List<KeyValue>>()
|
||||
|
||||
// 选中的重置状态(存储的是value)
|
||||
val selectedResetStatus = MutableLiveData("")
|
||||
|
||||
// 重置状态code (传给后端的restStatus参数)
|
||||
var resetStatusCode: String? = null
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_int_exp_arrive_reset
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
initResetStatusList()
|
||||
|
||||
// 监听选择变化,更新resetStatusCode
|
||||
selectedResetStatus.observeForever { value ->
|
||||
resetStatusCode = when (value) {
|
||||
"01" -> "01" // 正常
|
||||
"02" -> null // 未申报
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化重置状态列表
|
||||
*/
|
||||
private fun initResetStatusList() {
|
||||
val list = listOf(
|
||||
KeyValue("正常", "01"),
|
||||
KeyValue("未申报", "02")
|
||||
)
|
||||
resetStatusList.value = list
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存按钮点击
|
||||
*/
|
||||
fun onSaveClick() {
|
||||
if (selectedResetStatus.value.verifyNullOrEmpty("请选择重置状态")) {
|
||||
return
|
||||
}
|
||||
dismiss()
|
||||
callback(this)
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.dialog.IntExpArriveDeleteDialogModel
|
||||
import com.lukouguoji.gjc.dialog.IntExpArriveResetDialogModel
|
||||
import com.lukouguoji.gjc.holder.IntExpArriveViewHolder
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GjcDeclareParam
|
||||
@@ -131,17 +132,32 @@ class IntExpArriveViewModel : BasePageViewModel() {
|
||||
return
|
||||
}
|
||||
|
||||
val requestData = mapOf("maWbList" to selectedItems).toRequestBody()
|
||||
// 创建并显示弹框
|
||||
val dialog = IntExpArriveResetDialogModel { dialogModel ->
|
||||
// 弹框确认后的回调
|
||||
val params = mutableMapOf<String, Any?>("maWbList" to selectedItems)
|
||||
|
||||
launchLoadingCollect({ NetApply.api.resetArriveDeclare(requestData) }) {
|
||||
onSuccess = {
|
||||
showToast("状态重置成功")
|
||||
viewModelScope.launch {
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
|
||||
// 根据选择添加restStatus参数
|
||||
// 选择"正常"时传递 "01",选择"未申报"时不传递此参数
|
||||
if (dialogModel.resetStatusCode != null) {
|
||||
params["restStatus"] = dialogModel.resetStatusCode
|
||||
}
|
||||
|
||||
val requestData = params.toRequestBody()
|
||||
|
||||
// 调用重置接口
|
||||
launchLoadingCollect({ NetApply.api.resetArriveDeclare(requestData) }) {
|
||||
onSuccess = {
|
||||
showToast("状态重置成功")
|
||||
viewModelScope.launch {
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user