feat: 国际出港板箱过磅通道号默认沿用上一次选择
称重提交成功后本地记住通道号,后续新增称重自动默认选中; 重置时不再清空通道号,编辑模式仍按记录自带通道号回填。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import com.lukouguoji.module_base.db.perference.SharedPreferenceUtil
|
||||
import com.lukouguoji.module_base.model.BluetoothDialogModel
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
@@ -34,6 +35,11 @@ import java.util.Date
|
||||
*/
|
||||
class GjcBoxWeighingAddViewModel : BaseViewModel() {
|
||||
|
||||
companion object {
|
||||
// 记录上一次称重完成时使用的通道号,后续称重默认选中
|
||||
private const val KEY_LAST_PASSAGEWAY_ID = "gjc_box_weighing_last_passageway_id"
|
||||
}
|
||||
|
||||
// 数据Bean
|
||||
val dataBean = MutableLiveData(GjcUldUseBean())
|
||||
|
||||
@@ -117,7 +123,9 @@ class GjcBoxWeighingAddViewModel : BaseViewModel() {
|
||||
loadPassagewayList(editBean.passagewayId)
|
||||
loadPlCloseList(editBean.plClose)
|
||||
} else {
|
||||
loadPassagewayList(null)
|
||||
// 新增模式:默认选中上一次称重使用的通道号
|
||||
val lastPassagewayId = SharedPreferenceUtil.getString(KEY_LAST_PASSAGEWAY_ID)
|
||||
loadPassagewayList(lastPassagewayId.ifEmpty { null })
|
||||
loadPlCloseList(null)
|
||||
}
|
||||
}
|
||||
@@ -338,7 +346,7 @@ class GjcBoxWeighingAddViewModel : BaseViewModel() {
|
||||
netWeight.value = "0"
|
||||
cargoWeight.value = "0"
|
||||
consumeWeight.value = "0"
|
||||
channel.value = ""
|
||||
// 通道号不清空:保留当前选择,与 Spinner 显示保持一致,后续称重沿用上一次的通道号
|
||||
printTag.value = false
|
||||
|
||||
// 重置独立字段
|
||||
@@ -441,6 +449,11 @@ class GjcBoxWeighingAddViewModel : BaseViewModel() {
|
||||
if (result.verifySuccess()) {
|
||||
showToast("完成复磅")
|
||||
|
||||
// 记住本次使用的通道号,后续称重默认选中
|
||||
if (bean.passagewayId.isNotEmpty()) {
|
||||
SharedPreferenceUtil.addString(KEY_LAST_PASSAGEWAY_ID, bean.passagewayId)
|
||||
}
|
||||
|
||||
// 如果勾选了打印挂签,则执行打印
|
||||
if (printTag.value == true) {
|
||||
executePrint()
|
||||
|
||||
Reference in New Issue
Block a user