fix: 计重明细托盘自重改取托盘重量并支持编辑联动

托盘自重原误取托盘车重(carWeight),改为托盘重量(trayTotalWeight)。
编辑模式下托盘自重可编辑,重量按编辑前后差值同步浮动,底部统计随之更新。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-02 11:59:13 +08:00
parent 4e6e654558
commit b57a3cd133
2 changed files with 32 additions and 4 deletions

View File

@@ -22,7 +22,9 @@ data class GjcCheckInRecord(
var weight: Double = 0.0, // 运抵重量
var volume: Double = 0.0, // 运抵体积
var whId: Long = 0, // GJC_WAREHOUSE.ID
var carWeight: String = "" // 托盘
var carWeight: String = "", // 托盘
var trayNumber: Int = 0, // 托盘数量
var trayTotalWeight: Double = 0.0 // 托盘重量(托盘自重)
) : BaseObservable() {
// 数据变化回调
@@ -53,4 +55,28 @@ data class GjcCheckInRecord(
onDataChanged?.invoke()
}
}
// 托盘自重编辑过程中的原始输入串(保持回显与输入一致,避免光标跳位)
// 不作为构造参数data class copy 备份/恢复时自动丢弃,回退到 trayTotalWeight 显示
// @Transient仅界面内部状态不参与 Gson 序列化提交
@Transient
private var trayTotalWeightInput: String? = null
// 托盘自重的字符串表示(用于双向绑定)
// 业务规则:重量包含托盘自重,托盘自重编辑后,重量同步增减相同差值
@get:Bindable
var trayTotalWeightStr: String
get() = trayTotalWeightInput
?: if (trayTotalWeight == 0.0) "" else trayTotalWeight.toString()
set(value) {
trayTotalWeightInput = value
val newTrayWeight = value.toDoubleOrNull() ?: 0.0
if (trayTotalWeight != newTrayWeight) {
weight = Math.round((weight + newTrayWeight - trayTotalWeight) * 100) / 100.0
trayTotalWeight = newTrayWeight
notifyPropertyChanged(BR.trayTotalWeightStr)
notifyPropertyChanged(BR.weightStr)
onDataChanged?.invoke()
}
}
}