feat: 国际出港板箱过磅挂签支持多选批量打印

多选时逐张串行发送,张间节流留出出纸时间,写入失败即中止
并提示已打印张数与失败的 ULD 号;单选与详情页打印路径不变。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-02 10:44:25 +08:00
parent a1b55f656f
commit 39b5cc3689
2 changed files with 73 additions and 12 deletions

View File

@@ -3,6 +3,7 @@ package com.lukouguoji.gjc.viewModel
import android.app.Activity
import android.content.Intent
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.lukouguoji.gjc.R
import com.lukouguoji.gjc.holder.GjcBoxWeighingViewHolder
import com.lukouguoji.module_base.base.BasePageViewModel
@@ -20,6 +21,7 @@ import com.lukouguoji.module_base.util.PrinterUtils
import dev.utils.app.info.KeyValue
import dev.utils.common.DateUtils
import com.lukouguoji.module_base.ktx.formatDate
import kotlinx.coroutines.launch
/**
* 国际出港板箱过磅 ViewModel
@@ -96,16 +98,19 @@ class GjcBoxWeighingViewModel : BasePageViewModel() {
return
}
// 校验多选
if (selectedItems.size > 1) {
showToast("只能选择一条记录进行打印")
return
}
// 执行打印
val bean = selectedItems.first()
BluetoothDialogModel().showCallBack {
PrinterUtils.printGjcBoxWeighing(bean)
if (selectedItems.size == 1) {
// 单条:保持原有打印路径
val bean = selectedItems.first()
BluetoothDialogModel().showCallBack {
PrinterUtils.printGjcBoxWeighing(bean)
}
} else {
// 多条:逐张串行批量打印
BluetoothDialogModel().showCallBack {
viewModelScope.launch {
PrinterUtils.printGjcBoxWeighingBatch(selectedItems)
}
}
}
}