feat: opt 开始组装

This commit is contained in:
2026-01-27 14:04:50 +08:00
parent a7b560b048
commit 9eb9278676
5 changed files with 98 additions and 18 deletions

View File

@@ -41,7 +41,7 @@ import me.jessyan.autosize.internal.CustomAdapt
* ========== 开发调试开关 ==========
* TODO: 正式发布前务必设置为 false
*/
private const val DEV_AUTO_LOGIN = true // 自动登录开关
private const val DEV_AUTO_LOGIN = false // 自动登录开关
@Route(path = ARouterConstants.ACTIVITY_URL_LOGIN)
class LoginActivity : BaseActivity(),

View File

@@ -33,11 +33,26 @@ class IntExpAssembleStartActivity :
private var waybillAdapter: CommonAdapter? = null
companion object {
private const val EXTRA_ULD_NO = "uld"
private const val EXTRA_EDIT_MODE = "edit_mode"
@JvmStatic
fun start(context: Context) {
val starter = Intent(context, IntExpAssembleStartActivity::class.java)
context.startActivity(starter)
}
/**
* 从列表页"修改"模式启动
* @param uldNo ULD编号将被锁定整个页面生命周期内不可编辑
*/
@JvmStatic
fun startForEdit(context: Context, uldNo: String) {
val starter = Intent(context, IntExpAssembleStartActivity::class.java)
.putExtra(EXTRA_ULD_NO, uldNo)
.putExtra(EXTRA_EDIT_MODE, true)
context.startActivity(starter)
}
}
override fun layoutId() = R.layout.activity_int_exp_assemble_start
@@ -70,6 +85,22 @@ class IntExpAssembleStartActivity :
// 观察数据变化
observeData()
// 处理修改模式(从列表页侧滑"修改"跳转)
handleEditModeIntent()
}
/**
* 处理修改模式的 Intent 参数
*/
private fun handleEditModeIntent() {
val isEditMode = intent.getBooleanExtra(EXTRA_EDIT_MODE, false)
if (isEditMode) {
val uldNo = intent.getStringExtra(EXTRA_ULD_NO) ?: ""
if (uldNo.isNotEmpty()) {
viewModel.initFromEditMode(uldNo)
}
}
}
/**

View File

@@ -79,10 +79,18 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
private var lastQueriedUldNo = ""
/**
* ULD编号锁定状态
* ULD编号锁定状态(页面内编辑模式)
*/
val isUldNoLocked = MutableLiveData(false)
/**
* 是否从列表页"修改"模式进入
* 与 isUldNoLocked 的区别:
* - isFromEditMode整个页面生命周期内 ULD 编号锁定,但不影响装货/卸货按钮
* - isUldNoLocked页面内编辑模式影响装货/卸货按钮
*/
val isFromEditMode = MutableLiveData(false)
/**
* 装货按钮启用状态(非编辑模式时启用)
*/
@@ -451,7 +459,7 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
val assembleCountInt = assembleCount.toLongOrNull() ?: 0L
val waybillPiecesInt = waybillPieces.toLongOrNull() ?: 0L
if (assembleCountInt > waybillPiecesInt) {
if (waybillPiecesInt > 0 && assembleCountInt > waybillPiecesInt) {
val errorMessage = if (isLoad) {
"装货件数不能大于运单件数"
} else {
@@ -462,7 +470,23 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
}
val assembleWeight = waybillInfo.value?.assembleWeight?.trim() ?: ""
// 组装重量为非必填,不进行验证
// 校验重量范围(如果填写了组装重量)
if (assembleWeight.isNotEmpty()) {
val waybillWeight = waybillInfo.value?.waybillWeight?.trim() ?: ""
val assembleWeightDouble = assembleWeight.toDoubleOrNull() ?: 0.0
val waybillWeightDouble = waybillWeight.toDoubleOrNull() ?: 0.0
if (waybillWeightDouble > 0 && assembleWeightDouble > waybillWeightDouble) {
val errorMessage = if (isLoad) {
"装货重量不能大于运单重量"
} else {
"卸货重量不能大于已装货重量"
}
showToast(errorMessage)
return
}
}
val operatorValue = operator.value?.trim() ?: ""
if (operatorValue.isEmpty()) {
@@ -670,8 +694,8 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
itemType = AssembleInfoBean.ItemType.WAYBILL_DETAIL
parentUldNo = uldItem.uldNo
wbNo = warehouse.wbNo
waybillPieces = warehouse.pc.toInt()
waybillWeight = warehouse.weight
waybillPieces = warehouse.checkInPc.toInt()
waybillWeight = warehouse.checkInWeight
showIndent = true
showIndex = false
@@ -684,6 +708,9 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
fno = warehouse.fno
fdate = warehouse.fdate
whId = warehouse.whId
// 设置原始运单件数/重量使用checkInPc/checkInWeight
originalPieces = warehouse.checkInPc.toString()
originalWeight = String.format("%.1f", warehouse.checkInWeight)
}
}
}
@@ -823,9 +850,9 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
uldBean.waybillDetails = warehouseList
}
// 计算总件数和总重量(从运单列表求和)
val calculatedPieces = warehouseList?.sumOf { it.pc.toInt() } ?: 0
val calculatedWeight = warehouseList?.sumOf { it.weight } ?: 0.0
// 计算总件数和总重量(从子列表的checkInPc、checkInWeight求和)
val calculatedPieces = warehouseList?.sumOf { it.checkInPc.toInt() } ?: 0
val calculatedWeight = warehouseList?.sumOf { it.checkInWeight } ?: 0.0
AssembleInfoBean().apply {
itemType = AssembleInfoBean.ItemType.ULD_HEADER
@@ -874,4 +901,28 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
fun clearCachedOperator() {
lastSelectedOperator = null
}
/**
* 从列表页"修改"模式初始化
* @param uldNo ULD编号
*/
fun initFromEditMode(uldNo: String) {
if (uldNo.isEmpty()) return
// 标记为修改模式(整个页面生命周期内 ULD 编号锁定)
isFromEditMode.value = true
// 填充 ULD 编号
uldInfo.value = uldInfo.value?.apply {
this.uldNo = uldNo
} ?: UldInfoBean().apply {
this.uldNo = uldNo
}
// 更新防抖标记,确保查询能触发
lastQueriedUldNo = ""
// 触发 ULD 编码查询
onUldNoInputComplete()
}
}

View File

@@ -174,17 +174,15 @@ class IntExpAssembleViewModel : BasePageViewModel() {
}
/**
* 修改单个列表项 - 跳转到开始组装页面
* 修改单个列表项 - 跳转到开始组装页面(修改模式)
* ULD 编号将被锁定,整个页面生命周期内不可编辑
*/
private fun onEditItem(position: Int) {
val bean = pageModel.rv?.commonAdapter()?.getItem(position) as? GjcUldUseBean ?: return
ARouter.getInstance()
.build(ARouterConstants.ACTIVITY_URL_INT_EXP_ASSEMBLE_START)
.withLong("useId", bean.useId)
.withString("uld", bean.uld)
.withString("fdate", bean.fdate)
.withString("fno", bean.fno)
.navigation()
com.lukouguoji.gjc.page.assemble.IntExpAssembleStartActivity.startForEdit(
getTopActivity(),
bean.uld
)
}
/**

View File

@@ -254,7 +254,7 @@
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
android:id="@+id/uldNoInput"
enable="@{!viewModel.isUldNoLocked}"
enable="@{!viewModel.isUldNoLocked &amp;&amp; !viewModel.isFromEditMode}"
required="@{false}"
setRefreshCallBack="@{viewModel::onUldNoInputComplete}"
title='@{"ULD编号"}'