feat: 国际出港开始组装运单列表首次装货后显示剩余/总数
首次装货成功前件数、重量列显示总数;成功后表头切换为 「剩余件数/总件数」「剩余重量/总重量」,剩余值由 pc 减 checkInPc、weight 减 checkInWeight 得出。三处接口数据转 Bean 的重复代码合并为扩展函数。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,27 @@ class AssembleWaybillBean {
|
||||
var originalPieces: String = "" // 原始运单件数
|
||||
var originalWeight: String = "" // 原始运单重量
|
||||
|
||||
// ========== 剩余/总数显示(开始组装页首次装货成功后切换) ==========
|
||||
var checkInPieces: Long = 0 // 已组装件数(接口 checkInPc)
|
||||
var checkInWeight: Double = 0.0 // 已组装重量(接口 checkInWeight)
|
||||
var showRemaining: Boolean = false // 是否以“剩余/总数”形式显示
|
||||
|
||||
/** 件数列显示:首次装货成功前为总件数,之后为“剩余件数/总件数”(剩余 = pc − checkInPc) */
|
||||
val piecesDisplay: String
|
||||
get() {
|
||||
if (!showRemaining) return pieces
|
||||
val total = pieces.toLongOrNull() ?: return pieces
|
||||
return "${total - checkInPieces}/$pieces"
|
||||
}
|
||||
|
||||
/** 重量列显示:首次装货成功前为总重量,之后为“剩余重量/总重量”(剩余 = weight − checkInWeight) */
|
||||
val weightDisplay: String
|
||||
get() {
|
||||
if (!showRemaining) return weight
|
||||
val total = weight.toDoubleOrNull() ?: return weight
|
||||
return String.format("%.1f", total - checkInWeight) + "/" + weight
|
||||
}
|
||||
|
||||
val fLightInfo: String
|
||||
get() = "$fno/${fdate.replace("-", "")}"
|
||||
|
||||
|
||||
@@ -107,6 +107,12 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
||||
*/
|
||||
val isLoadEnabled = MutableLiveData(true)
|
||||
|
||||
/**
|
||||
* 本页面是否已至少一次装货成功
|
||||
* 首次装货成功前,运单列表件数/重量列显示总数;成功后显示“剩余/总数”
|
||||
*/
|
||||
val hasLoadedOnce = MutableLiveData(false)
|
||||
|
||||
/**
|
||||
* 卸货按钮启用状态(编辑模式时启用)
|
||||
*/
|
||||
@@ -274,6 +280,27 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.WAYBILL)
|
||||
}
|
||||
|
||||
/**
|
||||
* 待组装运单接口数据转右侧运单列表 Bean
|
||||
* 同时带上已组装件数/重量与“剩余/总数”显示开关(首次装货成功后生效)
|
||||
*/
|
||||
private fun GjcWarehouse.toAssembleWaybillBean(): AssembleWaybillBean {
|
||||
val warehouse = this
|
||||
return AssembleWaybillBean().apply {
|
||||
waybillNo = warehouse.wbNo
|
||||
pieces = warehouse.pc.toString()
|
||||
weight = String.format("%.1f", warehouse.weight)
|
||||
flight = warehouse.flight
|
||||
fno = warehouse.fno
|
||||
fdate = warehouse.fdate
|
||||
whId = warehouse.whId // 运单ID(用于接口调用)
|
||||
isMarked = false
|
||||
checkInPieces = warehouse.checkInPc
|
||||
checkInWeight = warehouse.checkInWeight
|
||||
showRemaining = hasLoadedOnce.value == true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载待组装运单列表
|
||||
*/
|
||||
@@ -285,18 +312,7 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
||||
onSuccess = { result ->
|
||||
// 数据转换: GjcWarehouse -> AssembleWaybillBean
|
||||
val warehouseList = result.data ?: mutableListOf()
|
||||
val waybillBeanList = warehouseList.map { warehouse ->
|
||||
AssembleWaybillBean().apply {
|
||||
waybillNo = warehouse.wbNo
|
||||
pieces = warehouse.pc.toString()
|
||||
weight = String.format("%.1f", warehouse.weight)
|
||||
flight = warehouse.flight
|
||||
fno = warehouse.fno
|
||||
fdate = warehouse.fdate
|
||||
whId = warehouse.whId // 添加运单ID
|
||||
isMarked = false
|
||||
}
|
||||
}.toMutableList()
|
||||
val waybillBeanList = warehouseList.map { it.toAssembleWaybillBean() }.toMutableList()
|
||||
|
||||
// 更新列表
|
||||
waybillList.value = waybillBeanList
|
||||
@@ -335,18 +351,7 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
||||
launchLoadingCollect({ NetApply.api.queryWaitingAssemble("") }) {
|
||||
onSuccess = { result ->
|
||||
val warehouseList = result.data ?: mutableListOf()
|
||||
val waybillBeanList = warehouseList.map { warehouse ->
|
||||
AssembleWaybillBean().apply {
|
||||
waybillNo = warehouse.wbNo
|
||||
pieces = warehouse.pc.toString()
|
||||
weight = String.format("%.1f", warehouse.weight)
|
||||
flight = warehouse.flight
|
||||
fno = warehouse.fno
|
||||
fdate = warehouse.fdate
|
||||
whId = warehouse.whId // 添加运单ID
|
||||
isMarked = false
|
||||
}
|
||||
}.toMutableList()
|
||||
val waybillBeanList = warehouseList.map { it.toAssembleWaybillBean() }.toMutableList()
|
||||
|
||||
waybillList.value = waybillBeanList
|
||||
|
||||
@@ -724,6 +729,11 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
||||
) {
|
||||
showToast("${operationName}成功")
|
||||
|
||||
// 首次装货成功后,运单列表件数/重量列切换为“剩余/总数”显示
|
||||
if (isLoad) {
|
||||
hasLoadedOnce.value = true
|
||||
}
|
||||
|
||||
// 发送刷新事件,通知出港组装列表页面更新数据
|
||||
viewModelScope.launch {
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
|
||||
@@ -780,18 +790,7 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
||||
launchLoadingCollect({ NetApply.api.queryWaitingAssemble(wbNo) }) {
|
||||
onSuccess = { result ->
|
||||
val warehouseList = result.data ?: mutableListOf()
|
||||
val waybillBeanList = warehouseList.map { warehouse ->
|
||||
AssembleWaybillBean().apply {
|
||||
waybillNo = warehouse.wbNo
|
||||
pieces = warehouse.pc.toString()
|
||||
weight = String.format("%.1f", warehouse.weight)
|
||||
flight = warehouse.flight
|
||||
fno = warehouse.fno
|
||||
fdate = warehouse.fdate
|
||||
whId = warehouse.whId
|
||||
isMarked = false
|
||||
}
|
||||
}.toMutableList()
|
||||
val waybillBeanList = warehouseList.map { it.toAssembleWaybillBean() }.toMutableList()
|
||||
|
||||
waybillList.value = waybillBeanList
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="件数"
|
||||
android:text='@{viewModel.hasLoadedOnce ? "剩余件数/总件数" : "件数"}'
|
||||
android:textColor="@color/text_normal"
|
||||
android:textSize="13sp" />
|
||||
|
||||
@@ -199,7 +199,7 @@
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="重量"
|
||||
android:text='@{viewModel.hasLoadedOnce ? "剩余重量/总重量" : "重量"}'
|
||||
android:textColor="@color/text_normal"
|
||||
android:textSize="13sp" />
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@{bean.pieces}"
|
||||
android:text="@{bean.piecesDisplay}"
|
||||
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}"
|
||||
android:textSize="14sp" />
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@{bean.weight}"
|
||||
android:text="@{bean.weightDisplay}"
|
||||
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}"
|
||||
android:textSize="14sp" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user