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
import androidx.databinding.ObservableBoolean
/**
* 运单列表Bean右侧运单列表
*/
@@ -15,4 +17,7 @@ class AssembleWaybillBean {
val fLightInfo: String
get() = "$fno/${fdate.replace("-", "")}"
// ========== UI扩展字段 ==========
val isSelected: ObservableBoolean = ObservableBoolean(false) // 选中状态
}

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

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

View File

@@ -1,5 +1,6 @@
<?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>
@@ -16,58 +17,71 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingHorizontal="8dp"
android:paddingVertical="4dp">
android:layout_height="36dp"
android:orientation="vertical">
<!-- 序号 -->
<TextView
android:layout_width="64dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@{String.valueOf(position + 1)}"
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}"
android:textSize="14sp" />
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingHorizontal="8dp"
android:paddingVertical="4dp">
<!-- 运单号 -->
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@{bean.waybillNo}"
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}"
android:textSize="14sp" />
<!-- 选择标记 -->
<ImageView
android:id="@+id/iv_select_icon"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginStart="22dp"
android:layout_marginEnd="22dp"
android:src="@{bean.isSelected.get() ? @drawable/ic_red_checkbox : @drawable/bg_circle_gray}" />
<!-- 件数 -->
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@{bean.pieces}"
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"
android:gravity="center"
android:text="@{bean.waybillNo}"
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}"
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="120dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@{bean.pieces}"
android:textColor="@{bean.isMarked ? @color/text_red : @color/text_normal}"
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>
</layout>