feat: opt 开始组装
This commit is contained in:
@@ -41,7 +41,7 @@ import me.jessyan.autosize.internal.CustomAdapt
|
|||||||
* ========== 开发调试开关 ==========
|
* ========== 开发调试开关 ==========
|
||||||
* TODO: 正式发布前务必设置为 false
|
* TODO: 正式发布前务必设置为 false
|
||||||
*/
|
*/
|
||||||
private const val DEV_AUTO_LOGIN = true // 自动登录开关
|
private const val DEV_AUTO_LOGIN = false // 自动登录开关
|
||||||
|
|
||||||
@Route(path = ARouterConstants.ACTIVITY_URL_LOGIN)
|
@Route(path = ARouterConstants.ACTIVITY_URL_LOGIN)
|
||||||
class LoginActivity : BaseActivity(),
|
class LoginActivity : BaseActivity(),
|
||||||
|
|||||||
@@ -33,11 +33,26 @@ class IntExpAssembleStartActivity :
|
|||||||
private var waybillAdapter: CommonAdapter? = null
|
private var waybillAdapter: CommonAdapter? = null
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private const val EXTRA_ULD_NO = "uld"
|
||||||
|
private const val EXTRA_EDIT_MODE = "edit_mode"
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun start(context: Context) {
|
fun start(context: Context) {
|
||||||
val starter = Intent(context, IntExpAssembleStartActivity::class.java)
|
val starter = Intent(context, IntExpAssembleStartActivity::class.java)
|
||||||
context.startActivity(starter)
|
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
|
override fun layoutId() = R.layout.activity_int_exp_assemble_start
|
||||||
@@ -70,6 +85,22 @@ class IntExpAssembleStartActivity :
|
|||||||
|
|
||||||
// 观察数据变化
|
// 观察数据变化
|
||||||
observeData()
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -79,10 +79,18 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
|||||||
private var lastQueriedUldNo = ""
|
private var lastQueriedUldNo = ""
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ULD编号锁定状态
|
* ULD编号锁定状态(页面内编辑模式)
|
||||||
*/
|
*/
|
||||||
val isUldNoLocked = MutableLiveData(false)
|
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 assembleCountInt = assembleCount.toLongOrNull() ?: 0L
|
||||||
val waybillPiecesInt = waybillPieces.toLongOrNull() ?: 0L
|
val waybillPiecesInt = waybillPieces.toLongOrNull() ?: 0L
|
||||||
|
|
||||||
if (assembleCountInt > waybillPiecesInt) {
|
if (waybillPiecesInt > 0 && assembleCountInt > waybillPiecesInt) {
|
||||||
val errorMessage = if (isLoad) {
|
val errorMessage = if (isLoad) {
|
||||||
"装货件数不能大于运单件数"
|
"装货件数不能大于运单件数"
|
||||||
} else {
|
} else {
|
||||||
@@ -462,7 +470,23 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val assembleWeight = waybillInfo.value?.assembleWeight?.trim() ?: ""
|
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() ?: ""
|
val operatorValue = operator.value?.trim() ?: ""
|
||||||
if (operatorValue.isEmpty()) {
|
if (operatorValue.isEmpty()) {
|
||||||
@@ -670,8 +694,8 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
|||||||
itemType = AssembleInfoBean.ItemType.WAYBILL_DETAIL
|
itemType = AssembleInfoBean.ItemType.WAYBILL_DETAIL
|
||||||
parentUldNo = uldItem.uldNo
|
parentUldNo = uldItem.uldNo
|
||||||
wbNo = warehouse.wbNo
|
wbNo = warehouse.wbNo
|
||||||
waybillPieces = warehouse.pc.toInt()
|
waybillPieces = warehouse.checkInPc.toInt()
|
||||||
waybillWeight = warehouse.weight
|
waybillWeight = warehouse.checkInWeight
|
||||||
showIndent = true
|
showIndent = true
|
||||||
showIndex = false
|
showIndex = false
|
||||||
|
|
||||||
@@ -684,6 +708,9 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
|||||||
fno = warehouse.fno
|
fno = warehouse.fno
|
||||||
fdate = warehouse.fdate
|
fdate = warehouse.fdate
|
||||||
whId = warehouse.whId
|
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
|
uldBean.waybillDetails = warehouseList
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算总件数和总重量(从运单列表求和)
|
// 计算总件数和总重量(从子列表的checkInPc、checkInWeight求和)
|
||||||
val calculatedPieces = warehouseList?.sumOf { it.pc.toInt() } ?: 0
|
val calculatedPieces = warehouseList?.sumOf { it.checkInPc.toInt() } ?: 0
|
||||||
val calculatedWeight = warehouseList?.sumOf { it.weight } ?: 0.0
|
val calculatedWeight = warehouseList?.sumOf { it.checkInWeight } ?: 0.0
|
||||||
|
|
||||||
AssembleInfoBean().apply {
|
AssembleInfoBean().apply {
|
||||||
itemType = AssembleInfoBean.ItemType.ULD_HEADER
|
itemType = AssembleInfoBean.ItemType.ULD_HEADER
|
||||||
@@ -874,4 +901,28 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
|||||||
fun clearCachedOperator() {
|
fun clearCachedOperator() {
|
||||||
lastSelectedOperator = null
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,17 +174,15 @@ class IntExpAssembleViewModel : BasePageViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改单个列表项 - 跳转到开始组装页面
|
* 修改单个列表项 - 跳转到开始组装页面(修改模式)
|
||||||
|
* ULD 编号将被锁定,整个页面生命周期内不可编辑
|
||||||
*/
|
*/
|
||||||
private fun onEditItem(position: Int) {
|
private fun onEditItem(position: Int) {
|
||||||
val bean = pageModel.rv?.commonAdapter()?.getItem(position) as? GjcUldUseBean ?: return
|
val bean = pageModel.rv?.commonAdapter()?.getItem(position) as? GjcUldUseBean ?: return
|
||||||
ARouter.getInstance()
|
com.lukouguoji.gjc.page.assemble.IntExpAssembleStartActivity.startForEdit(
|
||||||
.build(ARouterConstants.ACTIVITY_URL_INT_EXP_ASSEMBLE_START)
|
getTopActivity(),
|
||||||
.withLong("useId", bean.useId)
|
bean.uld
|
||||||
.withString("uld", bean.uld)
|
)
|
||||||
.withString("fdate", bean.fdate)
|
|
||||||
.withString("fno", bean.fno)
|
|
||||||
.navigation()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -254,7 +254,7 @@
|
|||||||
|
|
||||||
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
android:id="@+id/uldNoInput"
|
android:id="@+id/uldNoInput"
|
||||||
enable="@{!viewModel.isUldNoLocked}"
|
enable="@{!viewModel.isUldNoLocked && !viewModel.isFromEditMode}"
|
||||||
required="@{false}"
|
required="@{false}"
|
||||||
setRefreshCallBack="@{viewModel::onUldNoInputComplete}"
|
setRefreshCallBack="@{viewModel::onUldNoInputComplete}"
|
||||||
title='@{"ULD编号:"}'
|
title='@{"ULD编号:"}'
|
||||||
|
|||||||
Reference in New Issue
Block a user