feat: 开始组装 opt

This commit is contained in:
2025-12-16 15:58:37 +08:00
parent 644c937476
commit 2664cc7c69
7 changed files with 104 additions and 53 deletions

View File

@@ -16,9 +16,9 @@ class AssembleWaybillViewHolder(view: View) :
binding.bean = bean
binding.position = position
// 点击运单
// 点击整行触发选择事件(单选模式,通过回调处理)
itemView.setOnClickListener {
clickListener?.onItemClick(position, 0)
clickListener?.onItemClick(position, 1) // type=1表示运单列表点击
}
binding.executePendingBindings()

View File

@@ -92,6 +92,8 @@ class IntExpAssembleStartActivity :
)
binding.rvWaybillList.layoutManager = LinearLayoutManager(this)
binding.rvWaybillList.adapter = waybillAdapter
// 添加点击监听器
binding.rvWaybillList.addOnItemClickListener(this)
}
/**
@@ -117,6 +119,7 @@ class IntExpAssembleStartActivity :
override fun onItemClick(position: Int, type: Int) {
when (type) {
0 -> viewModel.onPositionItemClick(position) // 组装位置点击
1 -> viewModel.onWaybillItemClick(position) // 运单列表点击
else -> {}
}
}

View File

@@ -100,6 +100,36 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
assemblePositionList.value = list
}
/**
* 运单点击(单选切换)
*/
fun onWaybillItemClick(position: Int) {
val list = waybillList.value ?: return
// 取消所有运单的选中状态
list.forEach { it.isSelected.set(false) }
// 选中当前运单
if (position in list.indices) {
val selectedWaybill = list[position]
selectedWaybill.isSelected.set(true)
// 同步运单信息到表单
waybillInfo.value = WaybillInfoBean().apply {
waybillNo = selectedWaybill.waybillNo
waybillPieces = selectedWaybill.pieces
waybillWeight = selectedWaybill.weight
// 保留当前的组装件数、组装重量、组装人
assembleCount = waybillInfo.value?.assembleCount ?: ""
assembleWeight = waybillInfo.value?.assembleWeight ?: ""
operator = waybillInfo.value?.operator ?: ""
}
}
// 刷新列表
waybillList.value = list
}
/**
* 扫码运单
*/
@@ -126,7 +156,7 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
val warehouseList = result.data ?: mutableListOf()
val waybillBeanList = warehouseList.map { warehouse ->
AssembleWaybillBean().apply {
waybillNo = warehouse.no
waybillNo = warehouse.wbNo
pieces = warehouse.pc.toString()
weight = String.format("%.1f", warehouse.weight)
flight = warehouse.flight