feat: 国际出港 装货卸货
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.lukouguoji.gjc.viewModel
|
package com.lukouguoji.gjc.viewModel
|
||||||
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.lukouguoji.gjc.R
|
import com.lukouguoji.gjc.R
|
||||||
import com.lukouguoji.gjc.holder.AssembleInfoViewHolder
|
import com.lukouguoji.gjc.holder.AssembleInfoViewHolder
|
||||||
import com.lukouguoji.gjc.holder.AssemblePositionViewHolder
|
import com.lukouguoji.gjc.holder.AssemblePositionViewHolder
|
||||||
@@ -8,14 +9,17 @@ import com.lukouguoji.gjc.holder.AssembleWaybillViewHolder
|
|||||||
import com.lukouguoji.module_base.base.BaseViewModel
|
import com.lukouguoji.module_base.base.BaseViewModel
|
||||||
import com.lukouguoji.module_base.bean.*
|
import com.lukouguoji.module_base.bean.*
|
||||||
import com.lukouguoji.module_base.common.Constant
|
import com.lukouguoji.module_base.common.Constant
|
||||||
|
import com.lukouguoji.module_base.common.ConstantEvent
|
||||||
import com.lukouguoji.module_base.db.perference.SharedPreferenceUtil
|
import com.lukouguoji.module_base.db.perference.SharedPreferenceUtil
|
||||||
import com.lukouguoji.module_base.http.net.NetApply
|
import com.lukouguoji.module_base.http.net.NetApply
|
||||||
|
import com.lukouguoji.module_base.impl.FlowBus
|
||||||
import com.lukouguoji.module_base.ktx.launchCollect
|
import com.lukouguoji.module_base.ktx.launchCollect
|
||||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||||
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.model.ScanModel
|
import com.lukouguoji.module_base.model.ScanModel
|
||||||
import dev.utils.app.info.KeyValue
|
import dev.utils.app.info.KeyValue
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 国际出港-开始组装ViewModel(静态数据)
|
* 国际出港-开始组装ViewModel(静态数据)
|
||||||
@@ -437,17 +441,23 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
|||||||
|
|
||||||
val assembleCount = waybillInfo.value?.assembleCount?.trim() ?: ""
|
val assembleCount = waybillInfo.value?.assembleCount?.trim() ?: ""
|
||||||
if (assembleCount.isEmpty()) {
|
if (assembleCount.isEmpty()) {
|
||||||
showToast("请输入组装件数")
|
val countFieldName = if (isLoad) "装货件数" else "卸货件数"
|
||||||
|
showToast("请输入${countFieldName}")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 校验组装件数不能大于运单件数
|
// 校验件数范围
|
||||||
val waybillPieces = waybillInfo.value?.waybillPieces?.trim() ?: ""
|
val waybillPieces = waybillInfo.value?.waybillPieces?.trim() ?: ""
|
||||||
val assembleCountInt = assembleCount.toLongOrNull() ?: 0L
|
val assembleCountInt = assembleCount.toLongOrNull() ?: 0L
|
||||||
val waybillPiecesInt = waybillPieces.toLongOrNull() ?: 0L
|
val waybillPiecesInt = waybillPieces.toLongOrNull() ?: 0L
|
||||||
|
|
||||||
if (assembleCountInt > waybillPiecesInt) {
|
if (assembleCountInt > waybillPiecesInt) {
|
||||||
showToast("组装件数不能大于运单件数")
|
val errorMessage = if (isLoad) {
|
||||||
|
"装货件数不能大于运单件数"
|
||||||
|
} else {
|
||||||
|
"卸货件数不能大于已装货件数"
|
||||||
|
}
|
||||||
|
showToast(errorMessage)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,6 +569,11 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
|||||||
) {
|
) {
|
||||||
showToast("${operationName}成功")
|
showToast("${operationName}成功")
|
||||||
|
|
||||||
|
// 发送刷新事件,通知出港组装列表页面更新数据
|
||||||
|
viewModelScope.launch {
|
||||||
|
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
|
||||||
|
}
|
||||||
|
|
||||||
// 重新查询组装信息列表(刷新数据)
|
// 重新查询组装信息列表(刷新数据)
|
||||||
loadAssembledList()
|
loadAssembledList()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user