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

@@ -1,5 +1,7 @@
package com.lukouguoji.module_base.bean package com.lukouguoji.module_base.bean
import androidx.databinding.ObservableBoolean
/** /**
* 运单列表Bean右侧运单列表 * 运单列表Bean右侧运单列表
*/ */
@@ -15,4 +17,7 @@ class AssembleWaybillBean {
val fLightInfo: String val fLightInfo: String
get() = "$fno/${fdate.replace("-", "")}" get() = "$fno/${fdate.replace("-", "")}"
// ========== UI扩展字段 ==========
val isSelected: ObservableBoolean = ObservableBoolean(false) // 选中状态
} }

View File

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

View File

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

View File

@@ -100,6 +100,36 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
assemblePositionList.value = list 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 warehouseList = result.data ?: mutableListOf()
val waybillBeanList = warehouseList.map { warehouse -> val waybillBeanList = warehouseList.map { warehouse ->
AssembleWaybillBean().apply { AssembleWaybillBean().apply {
waybillNo = warehouse.no waybillNo = warehouse.wbNo
pieces = warehouse.pc.toString() pieces = warehouse.pc.toString()
weight = String.format("%.1f", warehouse.weight) weight = String.format("%.1f", warehouse.weight)
flight = warehouse.flight flight = warehouse.flight

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -163,7 +163,7 @@
android:orientation="horizontal" android:orientation="horizontal"
android:paddingHorizontal="8dp"> android:paddingHorizontal="8dp">
<!-- 序号 --> <!-- 选择列占位 -->
<Space <Space
android:layout_width="64dp" android:layout_width="64dp"
@@ -248,7 +248,6 @@
android:orientation="horizontal"> android:orientation="horizontal">
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
enable="@{false}"
required="@{false}" required="@{false}"
title='@{"ULD编号"}' title='@{"ULD编号"}'
titleLength="@{5}" titleLength="@{5}"

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"> <layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data> <data>
@@ -16,58 +17,71 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="36dp"
android:background="@color/white" android:orientation="vertical">
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingHorizontal="8dp"
android:paddingVertical="4dp">
<!-- 序号 --> <LinearLayout
<TextView android:layout_width="match_parent"
android:layout_width="64dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:background="@color/white"
android:text="@{String.valueOf(position + 1)}" android:gravity="center_vertical"
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}" android:orientation="horizontal"
android:textSize="14sp" /> android:paddingHorizontal="8dp"
android:paddingVertical="4dp">
<!-- 运单号 --> <!-- 选择标记 -->
<TextView <ImageView
android:layout_width="0dp" android:id="@+id/iv_select_icon"
android:layout_height="wrap_content" android:layout_width="20dp"
android:layout_weight="1" android:layout_height="20dp"
android:gravity="center" android:layout_marginStart="22dp"
android:text="@{bean.waybillNo}" android:layout_marginEnd="22dp"
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}" android:src="@{bean.isSelected.get() ? @drawable/ic_red_checkbox : @drawable/bg_circle_gray}" />
android:textSize="14sp" />
<!-- 件数 --> <!-- 运单号 -->
<TextView <TextView
android:layout_width="120dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:layout_weight="1"
android:text="@{bean.pieces}" android:gravity="center"
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}" android:text="@{bean.waybillNo}"
android:textSize="14sp" /> android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}"
android:textSize="14sp" />
<!-- 重量 --> <!-- 件数 -->
<TextView <TextView
android:layout_width="120dp" android:layout_width="120dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:text="@{bean.weight}" android:text="@{bean.pieces}"
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}" android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}"
android:textSize="14sp" /> android:textSize="14sp" />
<!-- 重量 -->
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@{bean.weight}"
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}"
android:textSize="14sp" />
<!-- 配载航班 -->
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.2"
android:gravity="center"
android:text="@{bean.fLightInfo}"
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}"
android:textSize="14sp" />
</LinearLayout>
<!-- 分割线 -->
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/line" />
<!-- 配载航班 -->
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.2"
android:gravity="center"
android:text="@{bean.fLightInfo}"
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}"
android:textSize="14sp" />
</LinearLayout> </LinearLayout>
</layout> </layout>