feat: 国际出港 收运检查 退回 list
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.lukouguoji.gjc.dialog
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.DialogGjcInspectionRejectBinding
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
|
||||
/**
|
||||
* 国际出港收运检查 - 退回原因对话框
|
||||
*/
|
||||
class GjcInspectionRejectDialogModel(
|
||||
private val callback: (String) -> Unit // 回调传递退回原因
|
||||
) : BaseDialogModel<DialogGjcInspectionRejectBinding>(DIALOG_TYPE_CENTER) {
|
||||
|
||||
// 退回原因
|
||||
val rejectReason = MutableLiveData("")
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_gjc_inspection_reject
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存按钮点击
|
||||
*/
|
||||
fun onConfirmClick() {
|
||||
// 验证退回原因
|
||||
if (rejectReason.value.verifyNullOrEmpty("请输入退回原因")) {
|
||||
return
|
||||
}
|
||||
|
||||
dismiss()
|
||||
callback(rejectReason.value!!)
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.dialog.GjcInspectionRejectDialogModel
|
||||
import com.lukouguoji.gjc.holder.GjcInspectionViewHolder
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GjcInspectionBean
|
||||
@@ -157,7 +158,7 @@ class GjcInspectionViewModel : BasePageViewModel() {
|
||||
return
|
||||
}
|
||||
getTopActivity().showConfirmDialog("确定要通过选中的 ${filter.size} 条数据吗?") {
|
||||
performAudit(filter, true, "通过")
|
||||
performAudit(filter, true, "通过", "")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,13 +168,25 @@ class GjcInspectionViewModel : BasePageViewModel() {
|
||||
fun auditRejectClick() {
|
||||
val list = pageModel.rv!!.commonAdapter()!!.items as List<GjcInspectionBean>
|
||||
val filter = list.filter { it.checked.get() }
|
||||
|
||||
// 验证是否选择了数据
|
||||
if (filter.isEmpty()) {
|
||||
showToast("请选择数据")
|
||||
return
|
||||
}
|
||||
getTopActivity().showConfirmDialog("确定要退回选中的 ${filter.size} 条数据吗?") {
|
||||
performAudit(filter, false, "退回")
|
||||
|
||||
// 验证只能选择一个单据
|
||||
if (filter.size > 1) {
|
||||
showToast("退回时只能选择一个单据")
|
||||
return
|
||||
}
|
||||
|
||||
// 弹出退回原因对话框
|
||||
val dialog = GjcInspectionRejectDialogModel { reason ->
|
||||
// 用户填写完退回原因后,执行退回操作
|
||||
performAudit(filter, false, "退回", reason)
|
||||
}
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,8 +194,9 @@ class GjcInspectionViewModel : BasePageViewModel() {
|
||||
* @param items 选中的数据列表
|
||||
* @param isPass true:通过, false:退回
|
||||
* @param action 操作名称(用于提示)
|
||||
* @param reason 退回原因(仅退回时使用)
|
||||
*/
|
||||
private fun performAudit(items: List<GjcInspectionBean>, isPass: Boolean, action: String) {
|
||||
private fun performAudit(items: List<GjcInspectionBean>, isPass: Boolean, action: String, reason: String) {
|
||||
// 构建请求参数:数组对象,包含 maWbId、wbNo、prefix、no、reviewStatus(必传)
|
||||
// 使用数据自身的 reviewStatus 值
|
||||
val requestData = items.map {
|
||||
@@ -200,8 +214,7 @@ class GjcInspectionViewModel : BasePageViewModel() {
|
||||
if (isPass) {
|
||||
NetApply.api.passGjcInspection(requestData)
|
||||
} else {
|
||||
// TODO: impl reason dialog
|
||||
NetApply.api.backGjcInspection("test reason", requestData)
|
||||
NetApply.api.backGjcInspection(reason, requestData)
|
||||
}
|
||||
}) {
|
||||
onSuccess = {
|
||||
|
||||
Reference in New Issue
Block a user