fix: 计重明细托盘自重改取托盘重量并支持编辑联动
托盘自重原误取托盘车重(carWeight),改为托盘重量(trayTotalWeight)。 编辑模式下托盘自重可编辑,重量按编辑前后差值同步浮动,底部统计随之更新。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,7 +22,9 @@ data class GjcCheckInRecord(
|
|||||||
var weight: Double = 0.0, // 运抵重量
|
var weight: Double = 0.0, // 运抵重量
|
||||||
var volume: Double = 0.0, // 运抵体积
|
var volume: Double = 0.0, // 运抵体积
|
||||||
var whId: Long = 0, // GJC_WAREHOUSE.ID
|
var whId: Long = 0, // GJC_WAREHOUSE.ID
|
||||||
var carWeight: String = "" // 托盘自重
|
var carWeight: String = "", // 托盘车重
|
||||||
|
var trayNumber: Int = 0, // 托盘数量
|
||||||
|
var trayTotalWeight: Double = 0.0 // 托盘重量(托盘自重)
|
||||||
) : BaseObservable() {
|
) : BaseObservable() {
|
||||||
|
|
||||||
// 数据变化回调
|
// 数据变化回调
|
||||||
@@ -53,4 +55,28 @@ data class GjcCheckInRecord(
|
|||||||
onDataChanged?.invoke()
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,17 +67,19 @@
|
|||||||
type="@{DataLayoutType.INPUT}"
|
type="@{DataLayoutType.INPUT}"
|
||||||
value="@={record.weightStr}" />
|
value="@={record.weightStr}" />
|
||||||
|
|
||||||
<!-- 托盘自重字段(只读) -->
|
<!-- 托盘自重字段(取托盘重量 trayTotalWeight,可编辑) -->
|
||||||
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
enable="@{false}"
|
enable="@{isEditMode}"
|
||||||
|
hint="@{`托盘自重`}"
|
||||||
|
inputType="@{android.text.InputType.TYPE_CLASS_NUMBER | android.text.InputType.TYPE_NUMBER_FLAG_DECIMAL}"
|
||||||
title="@{`托盘自重`}"
|
title="@{`托盘自重`}"
|
||||||
titleLength="@{4}"
|
titleLength="@{4}"
|
||||||
type="@{DataLayoutType.INPUT}"
|
type="@{DataLayoutType.INPUT}"
|
||||||
value="@{record.carWeight}" />
|
value="@={record.trayTotalWeightStr}" />
|
||||||
|
|
||||||
<!-- 计重时间字段(只读) -->
|
<!-- 计重时间字段(只读) -->
|
||||||
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
|
|||||||
Reference in New Issue
Block a user