feat: 开始计重 calc vol

This commit is contained in:
2025-12-08 16:14:27 +08:00
parent ee2bfe02a7
commit 424755298a

View File

@@ -86,6 +86,18 @@ class GjcWeighingStartViewModel : BaseViewModel() {
diBangModel.key = it ?: "" diBangModel.key = it ?: ""
} }
// 监听运抵重量变化,自动计算运抵体积
arriveWeight.observe(activity as LifecycleOwner) { weightStr ->
// 将字符串转换为 Double如果转换失败或为空则使用 0.0
val weight = weightStr?.toDoubleOrNull() ?: 0.0
// 计算体积:运抵体积 = 运抵重量 / 220
val volume = if (weight > 0) weight / 220.0 else 0.0
// 格式化为两位小数并更新 LiveData
arriveVolume.value = String.format("%.2f", volume)
}
// 加载下拉列表数据 // 加载下拉列表数据
loadChannelList() loadChannelList()
loadAgentList() loadAgentList()