feat: 国际出港 出港运抵、理货 状态重置
This commit is contained in:
@@ -126,9 +126,22 @@ class IntExpArriveViewModel : BasePageViewModel() {
|
||||
*/
|
||||
fun resetDeclareClick() {
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcMaWb> ?: return
|
||||
val selectedItems = list.filter { it.isSelected }
|
||||
|
||||
if (selectedItems.isEmpty()) {
|
||||
// 收集选中的主单
|
||||
val selectedMaWbList = list.filter { it.isSelected }
|
||||
|
||||
// 收集选中的分单
|
||||
val selectedHaWbList = mutableListOf<GjcHaWb>()
|
||||
list.forEach { maWb ->
|
||||
maWb.haWbList?.forEach { haWb ->
|
||||
if (haWb.isSelected) {
|
||||
selectedHaWbList.add(haWb)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否有选中项
|
||||
if (selectedMaWbList.isEmpty() && selectedHaWbList.isEmpty()) {
|
||||
showToast("请选择要重置的运单")
|
||||
return
|
||||
}
|
||||
@@ -136,7 +149,14 @@ class IntExpArriveViewModel : BasePageViewModel() {
|
||||
// 创建并显示弹框
|
||||
val dialog = IntExpArriveResetDialogModel { dialogModel ->
|
||||
// 弹框确认后的回调
|
||||
val params = mutableMapOf<String, Any?>("maWbList" to selectedItems)
|
||||
// 构建请求参数(区分主单和分单)
|
||||
val params = mutableMapOf<String, Any?>()
|
||||
if (selectedMaWbList.isNotEmpty()) {
|
||||
params["maWbList"] = selectedMaWbList
|
||||
}
|
||||
if (selectedHaWbList.isNotEmpty()) {
|
||||
params["haWbList"] = selectedHaWbList
|
||||
}
|
||||
|
||||
// 根据选择添加restStatus参数
|
||||
// 选择"正常"时传递 "01",选择"未申报"时不传递此参数
|
||||
|
||||
@@ -4,10 +4,12 @@ import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.dialog.IntExpTallyDeleteDialogModel
|
||||
import com.lukouguoji.gjc.dialog.IntExpTallyResetDialogModel
|
||||
import com.lukouguoji.gjc.holder.IntExpTallyViewHolder
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GjcCheckInPage
|
||||
import com.lukouguoji.module_base.bean.GjcDeclareParam
|
||||
import com.lukouguoji.module_base.bean.GjcHaWb
|
||||
import com.lukouguoji.module_base.bean.GjcMaWb
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
@@ -134,24 +136,58 @@ class IntExpTallyViewModel : BasePageViewModel() {
|
||||
*/
|
||||
fun resetDeclare() {
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcMaWb> ?: return
|
||||
val selectedItems = list.filter { it.isSelected }
|
||||
|
||||
if (selectedItems.isEmpty()) {
|
||||
// 收集选中的主单
|
||||
val selectedMaWbList = list.filter { it.isSelected }
|
||||
|
||||
// 收集选中的分单
|
||||
val selectedHaWbList = mutableListOf<GjcHaWb>()
|
||||
list.forEach { maWb ->
|
||||
maWb.haWbList?.forEach { haWb ->
|
||||
if (haWb.isSelected) {
|
||||
selectedHaWbList.add(haWb)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否有选中项
|
||||
if (selectedMaWbList.isEmpty() && selectedHaWbList.isEmpty()) {
|
||||
showToast("请选择要重置的记录")
|
||||
return
|
||||
}
|
||||
|
||||
val requestData = selectedItems.toRequestBody()
|
||||
// 创建并显示弹框
|
||||
val dialog = IntExpTallyResetDialogModel { dialogModel ->
|
||||
// 弹框确认后的回调
|
||||
// 构建请求参数(区分主单和分单)
|
||||
val params = mutableMapOf<String, Any?>()
|
||||
if (selectedMaWbList.isNotEmpty()) {
|
||||
params["maWbList"] = selectedMaWbList
|
||||
}
|
||||
if (selectedHaWbList.isNotEmpty()) {
|
||||
params["haWbList"] = selectedHaWbList
|
||||
}
|
||||
|
||||
launchLoadingCollect({ NetApply.api.resetTallyDeclare(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.resetTallyDeclare(requestData) }) {
|
||||
onSuccess = {
|
||||
showToast("状态重置成功")
|
||||
viewModelScope.launch {
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user