feat: 国际出港板箱过磅新增耗材重量并计入货重
- 过磅表单新增只读的耗材重量,数据随列表项 Bean 带入,扫码新增时 取 queryUsingUldByUld 返回的 consumeWeight - 货重公式由「装机重 - ULD自重」改为「装机重 - ULD自重 - 耗材自重」 - queryUsingUldByUld 返回后补触发重量计算,此前该接口异步返回时 耗材重量不会参与计算 - 表单保持每行三列:第三列自上而下为总重、装机重、耗材重量、货重, 目的港单独占一行三分之一宽,备注换行整行撑满 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,7 @@ class GjcBoxWeighingAddViewModel : BaseViewModel() {
|
|||||||
val totalWeight = MutableLiveData("0") // 总重(红色)
|
val totalWeight = MutableLiveData("0") // 总重(红色)
|
||||||
val netWeight = MutableLiveData("0") // 装机重(蓝色)
|
val netWeight = MutableLiveData("0") // 装机重(蓝色)
|
||||||
val cargoWeight = MutableLiveData("0") // 货重(绿色)
|
val cargoWeight = MutableLiveData("0") // 货重(绿色)
|
||||||
|
val consumeWeight = MutableLiveData("0") // 耗材重量(只读,随 ULD 记录带出)
|
||||||
|
|
||||||
// 需要自动查询的独立字段(用于监听输入变化)
|
// 需要自动查询的独立字段(用于监听输入变化)
|
||||||
val carId = MutableLiveData("") // 架子车号
|
val carId = MutableLiveData("") // 架子车号
|
||||||
@@ -138,6 +139,7 @@ class GjcBoxWeighingAddViewModel : BaseViewModel() {
|
|||||||
totalWeight.value = bean.totalWeight.toString()
|
totalWeight.value = bean.totalWeight.toString()
|
||||||
netWeight.value = bean.netWeight.toString()
|
netWeight.value = bean.netWeight.toString()
|
||||||
cargoWeight.value = bean.cargoWeight.toString()
|
cargoWeight.value = bean.cargoWeight.toString()
|
||||||
|
consumeWeight.value = bean.consumeWeight.toString()
|
||||||
diBangWeight.value = bean.totalWeight.toString()
|
diBangWeight.value = bean.totalWeight.toString()
|
||||||
|
|
||||||
// 通道号 Spinner 绑定到 channel(KeyValue.value 即 passagewayId)
|
// 通道号 Spinner 绑定到 channel(KeyValue.value 即 passagewayId)
|
||||||
@@ -273,15 +275,16 @@ class GjcBoxWeighingAddViewModel : BaseViewModel() {
|
|||||||
/**
|
/**
|
||||||
* 计算重量字段
|
* 计算重量字段
|
||||||
* 装机重 = 总重 - 架子车自重
|
* 装机重 = 总重 - 架子车自重
|
||||||
* 货重 = 装机重 - ULD自重
|
* 货重 = 装机重 - ULD自重 - 耗材自重
|
||||||
*/
|
*/
|
||||||
private fun calculateWeights() {
|
private fun calculateWeights() {
|
||||||
val total = totalWeight.value?.toDoubleOrNull() ?: 0.0
|
val total = totalWeight.value?.toDoubleOrNull() ?: 0.0
|
||||||
val carW = dataBean.value?.carWeight ?: 0.0
|
val carW = dataBean.value?.carWeight ?: 0.0
|
||||||
val uldW = dataBean.value?.uldWeight ?: 0.0
|
val uldW = dataBean.value?.uldWeight ?: 0.0
|
||||||
|
val consumeW = consumeWeight.value?.toDoubleOrNull() ?: 0.0
|
||||||
|
|
||||||
val net = total - carW
|
val net = total - carW
|
||||||
val cargo = net - uldW
|
val cargo = net - uldW - consumeW
|
||||||
|
|
||||||
netWeight.value = if (net > 0) net.toString() else "0"
|
netWeight.value = if (net > 0) net.toString() else "0"
|
||||||
cargoWeight.value = if (cargo > 0) cargo.toString() else "0"
|
cargoWeight.value = if (cargo > 0) cargo.toString() else "0"
|
||||||
@@ -334,6 +337,7 @@ class GjcBoxWeighingAddViewModel : BaseViewModel() {
|
|||||||
totalWeight.value = "0"
|
totalWeight.value = "0"
|
||||||
netWeight.value = "0"
|
netWeight.value = "0"
|
||||||
cargoWeight.value = "0"
|
cargoWeight.value = "0"
|
||||||
|
consumeWeight.value = "0"
|
||||||
channel.value = ""
|
channel.value = ""
|
||||||
printTag.value = false
|
printTag.value = false
|
||||||
|
|
||||||
@@ -519,6 +523,9 @@ class GjcBoxWeighingAddViewModel : BaseViewModel() {
|
|||||||
if (usingData != null && usingData.useId > 0) {
|
if (usingData != null && usingData.useId > 0) {
|
||||||
// 保存返回的数据,用于提交时传递
|
// 保存返回的数据,用于提交时传递
|
||||||
usingUldData = usingData
|
usingUldData = usingData
|
||||||
|
// 耗材重量随该记录带回,需要重新参与货重计算
|
||||||
|
consumeWeight.value = usingData.consumeWeight.toString()
|
||||||
|
calculateWeights()
|
||||||
} else {
|
} else {
|
||||||
// 没有 useId,说明未组装,不可复磅
|
// 没有 useId,说明未组装,不可复磅
|
||||||
usingUldData = null
|
usingUldData = null
|
||||||
|
|||||||
@@ -259,7 +259,7 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- 第5行:架子车自重、ULD自重、货重(绿色只读) -->
|
<!-- 第5行:架子车自重、ULD自重、耗材重量(只读) -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -289,10 +289,10 @@
|
|||||||
|
|
||||||
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
enable="@{false}"
|
enable="@{false}"
|
||||||
title='@{"货重"}'
|
title='@{"耗材重量"}'
|
||||||
titleLength="@{5}"
|
titleLength="@{5}"
|
||||||
type="@{DataLayoutType.INPUT}"
|
type="@{DataLayoutType.INPUT}"
|
||||||
value='@{viewModel.cargoWeight}'
|
value='@{viewModel.consumeWeight}'
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="15dp"
|
android:layout_marginStart="15dp"
|
||||||
@@ -300,7 +300,7 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- 第6行:航班日期、航班号、目的港 -->
|
<!-- 第6行:航班日期、航班号、货重(绿色只读) -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -331,11 +331,11 @@
|
|||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
hint='@{"请输入目的港"}'
|
enable="@{false}"
|
||||||
title='@{"目的港"}'
|
title='@{"货重"}'
|
||||||
titleLength="@{5}"
|
titleLength="@{5}"
|
||||||
type="@{DataLayoutType.INPUT}"
|
type="@{DataLayoutType.INPUT}"
|
||||||
value='@={viewModel.dataBean.fdest}'
|
value='@{viewModel.cargoWeight}'
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="15dp"
|
android:layout_marginStart="15dp"
|
||||||
@@ -343,7 +343,32 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- 第7行:备注 -->
|
<!-- 第7行:目的港(占 1/3 宽度) -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
|
hint='@{"请输入目的港"}'
|
||||||
|
title='@{"目的港"}'
|
||||||
|
titleLength="@{5}"
|
||||||
|
type="@{DataLayoutType.INPUT}"
|
||||||
|
value='@={viewModel.dataBean.fdest}'
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<!-- 占位:保持目的港与上方各行第一列同宽 -->
|
||||||
|
<Space
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="2" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- 第8行:备注(整行) -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|||||||
Reference in New Issue
Block a user