feat: 开始组装 ui

This commit is contained in:
2025-12-09 16:37:49 +08:00
parent 249b5a4e87
commit 2871cbf784
13 changed files with 200 additions and 72 deletions

View File

@@ -561,6 +561,13 @@ interface Api {
@POST("IntExpAssemble/backfillWeight")
suspend fun backfillIntExpAssembleWeight(@Body data: RequestBody): BaseResultBean<SimpleResultBean>
/**
* 国际出港组装 - 获取组装人列表
* 接口路径: /IntExpAssemble/pageQueryAssembler
*/
@GET("IntExpAssemble/pageQueryAssembler")
suspend fun getIntExpAssemblerList(): BaseResultBean<List<String>>
/**
* 国际出港出库交接-分页查询
* 接口路径: /IntExpOutHandover/pageQuery

View File

@@ -2,6 +2,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#999999" />
<solid android:color="@color/color_f2" />
</shape>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/colorPrimary" />
</shape>

View File

@@ -32,10 +32,10 @@ class GjcWeighingStartActivity :
/**
* 启动开始计重页面
* @param context 上下文
* @param maWbId 运单ID
* @param maWbId 运单ID默认为0新增模式
*/
@JvmStatic
fun startForAdd(context: Context, maWbId: Long) {
fun startForAdd(context: Context, maWbId: Long = 0) {
val starter = Intent(context, GjcWeighingStartActivity::class.java)
.putExtra(Constant.Key.MAWB_ID, maWbId)
context.startActivity(starter)

View File

@@ -26,6 +26,9 @@ class IntExpAssembleActivity :
setBackArrow("出港组装")
binding.viewModel = viewModel
// 初始化组装人下拉列表
viewModel.initAssemblerList()
// 绑定分页
viewModel.pageModel.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, this)
@@ -36,5 +39,8 @@ class IntExpAssembleActivity :
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).observe(this) {
viewModel.refresh()
}
// 首次加载数据
viewModel.refresh()
}
}

View File

@@ -10,6 +10,8 @@ import com.lukouguoji.gjc.databinding.ActivityIntExpAssembleStartBinding
import com.lukouguoji.gjc.viewModel.IntExpAssembleStartViewModel
import com.lukouguoji.module_base.base.BaseBindingActivity
import com.lukouguoji.module_base.base.CommonAdapter
import com.lukouguoji.module_base.interfaces.IOnItemClickListener
import com.lukouguoji.module_base.ktx.addOnItemClickListener
import com.lukouguoji.module_base.router.ARouterConstants
/**
@@ -17,7 +19,8 @@ import com.lukouguoji.module_base.router.ARouterConstants
*/
@Route(path = ARouterConstants.ACTIVITY_URL_INT_EXP_ASSEMBLE_START)
class IntExpAssembleStartActivity :
BaseBindingActivity<ActivityIntExpAssembleStartBinding, IntExpAssembleStartViewModel>() {
BaseBindingActivity<ActivityIntExpAssembleStartBinding, IntExpAssembleStartViewModel>(),
IOnItemClickListener {
private var assembleInfoAdapter: CommonAdapter? = null
private var assemblePositionAdapter: CommonAdapter? = null
@@ -45,6 +48,9 @@ class IntExpAssembleStartActivity :
// 加载模拟数据
viewModel.initMockData()
// 加载组装位置数据从API
viewModel.loadAssemblePosition()
// 观察数据变化
observeData()
}
@@ -70,6 +76,8 @@ class IntExpAssembleStartActivity :
)
binding.rvAssemblePosition.layoutManager = LinearLayoutManager(this)
binding.rvAssemblePosition.adapter = assemblePositionAdapter
// 添加点击监听器
binding.rvAssemblePosition.addOnItemClickListener(this)
// 右侧运单列表
waybillAdapter = CommonAdapter(
@@ -97,4 +105,14 @@ class IntExpAssembleStartActivity :
waybillAdapter?.refresh(list)
}
}
/**
* 列表项点击事件
*/
override fun onItemClick(position: Int, type: Int) {
when (type) {
0 -> viewModel.onPositionItemClick(position) // 组装位置点击
else -> {}
}
}
}

View File

@@ -104,9 +104,7 @@ class GjcWeighingViewModel : BasePageViewModel() {
* 添加按钮点击(跳转到开始计重页面)
*/
fun addClick() {
// showToast("请从列表中选择一条待计重运单")
GjcWeighingStartActivity.startForAdd(getTopActivity(), 123)
GjcWeighingStartActivity.startForAdd(getTopActivity())
}
/**

View File

@@ -7,6 +7,8 @@ import com.lukouguoji.gjc.holder.AssemblePositionViewHolder
import com.lukouguoji.gjc.holder.AssembleWaybillViewHolder
import com.lukouguoji.module_base.base.BaseViewModel
import com.lukouguoji.module_base.bean.*
import com.lukouguoji.module_base.http.net.NetApply
import com.lukouguoji.module_base.ktx.launchLoadingCollect
import com.lukouguoji.module_base.ktx.showToast
/**
@@ -27,6 +29,9 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
val assemblePositionLayoutId = R.layout.item_assemble_position
val assemblePositionViewHolder = AssemblePositionViewHolder::class.java
// ========== 选中的组装位置 ==========
val selectedPosition = MutableLiveData<AssemblePositionBean?>()
// ========== 右侧运单列表 ==========
val waybillList = MutableLiveData<MutableList<AssembleWaybillBean>>()
val waybillLayoutId = R.layout.item_assemble_waybill
@@ -99,25 +104,25 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
}
)
// 组装位置列表(左侧)
assemblePositionList.value = mutableListOf(
AssemblePositionBean().apply {
positionName = "组装区001"
isSelected = true
},
AssemblePositionBean().apply {
positionName = "组装区002"
isSelected = false
},
AssemblePositionBean().apply {
positionName = "组装区003"
isSelected = false
},
AssemblePositionBean().apply {
positionName = "组装区004"
isSelected = false
}
)
// 组装位置列表(左侧)- 已改为从API加载不再使用模拟数据
// assemblePositionList.value = mutableListOf(
// AssemblePositionBean().apply {
// positionName = "组装区001"
// isSelected = true
// },
// AssemblePositionBean().apply {
// positionName = "组装区002"
// isSelected = false
// },
// AssemblePositionBean().apply {
// positionName = "组装区003"
// isSelected = false
// },
// AssemblePositionBean().apply {
// positionName = "组装区004"
// isSelected = false
// }
// )
// 运单列表(右侧)
waybillList.value = mutableListOf(
@@ -142,6 +147,48 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
)
}
/**
* 加载组装位置列表
*/
fun loadAssemblePosition() {
launchLoadingCollect({ NetApply.api.getDictListByLocation("GJCLOAD") }) {
onSuccess = { result ->
val list = result.data?.mapIndexed { index, dictBean ->
AssemblePositionBean().apply {
positionName = dictBean.name
isSelected = (index == 0) // 默认选中第一项
}
}?.toMutableList() ?: mutableListOf()
assemblePositionList.value = list
// 保存默认选中的第一项
if (list.isNotEmpty()) {
selectedPosition.value = list[0]
}
}
}
}
/**
* 组装位置点击(单选切换)
*/
fun onPositionItemClick(position: Int) {
val list = assemblePositionList.value ?: return
// 取消所有选中状态
list.forEach { it.isSelected = false }
// 选中当前项
if (position in list.indices) {
list[position].isSelected = true
selectedPosition.value = list[position]
}
// 刷新列表
assemblePositionList.value = list
}
/**
* 扫码运单
*/

View File

@@ -39,6 +39,7 @@ class IntExpAssembleViewModel : BasePageViewModel() {
)
)
val assembler = MutableLiveData("") // 组装人
val assemblerList = MutableLiveData<List<KeyValue>>(emptyList()) // 组装人列表
// ========== 适配器配置 ==========
val itemViewHolder = IntExpAssembleViewHolder::class.java
@@ -49,6 +50,21 @@ class IntExpAssembleViewModel : BasePageViewModel() {
val totalPieces = MutableLiveData("0") // 总件数
val totalWeight = MutableLiveData("0") // 总重量
/**
* 初始化组装人下拉列表
*/
fun initAssemblerList() {
launchCollect({ NetApply.api.getIntExpAssemblerList() }) {
onSuccess = { result ->
val list = mutableListOf<KeyValue>()
result.data?.forEach { name ->
list.add(KeyValue(name, name))
}
assemblerList.value = list
}
}
}
/**
* 搜索按钮点击
*/

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -73,11 +73,12 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
hint='@{"请输入组装人"}'
type="@{SearchLayoutType.INPUT}"
hint='@{"请选择组装人"}'
list="@{viewModel.assemblerList}"
type="@{SearchLayoutType.SPINNER}"
value="@={viewModel.assembler}" />
<!-- 搜索按钮 -->
<!-- 操作按钮 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
@@ -85,27 +86,31 @@
android:gravity="center"
android:orientation="horizontal">
<!-- 搜索按钮 -->
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_width="36dp"
android:layout_height="36dp"
android:onClick="@{()-> viewModel.searchClick()}"
android:padding="2dp"
android:src="@drawable/img_search" />
<!-- 加号按钮 -->
<!-- 新增按钮 -->
<ImageView
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginLeft="16dp"
android:onClick="@{()-> viewModel.onAddClick()}"
android:src="@drawable/img_add"
android:layout_marginLeft="15dp" />
android:padding="4dp"
android:src="@drawable/img_add" />
<!-- 删除按钮 -->
<ImageView
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginLeft="16dp"
android:onClick="@{()-> viewModel.onDeleteClick()}"
android:src="@drawable/img_delete"
android:layout_marginLeft="15dp" />
android:padding="4dp"
android:src="@drawable/img_delete" />
</LinearLayout>

View File

@@ -1,11 +1,15 @@
<?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:tools="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
<variable
name="bean"
type="com.lukouguoji.module_base.bean.AssembleInfoBean" />
<variable
name="position"
type="Integer" />
@@ -14,23 +18,25 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingVertical="12dp"
android:paddingHorizontal="8dp">
android:orientation="horizontal"
android:paddingHorizontal="8dp"
android:paddingVertical="6dp">
<!-- 序号圆圈 -->
<TextView
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_marginEnd="12dp"
android:background="@drawable/bg_circle_gray"
android:gravity="center"
android:minWidth="20dp"
android:paddingHorizontal="4dp"
android:text="@{String.valueOf(position + 1)}"
android:textColor="@color/white"
android:textSize="14sp"
android:textStyle="bold"
android:visibility="@{bean.showIndex ? View.VISIBLE : View.GONE}" />
android:textColor="@color/text_normal"
android:textSize="13sp"
android:visibility="@{bean.showIndex ? View.VISIBLE : View.GONE}"
tools:text="1" />
<!-- ULD编号 -->
<TextView
@@ -39,7 +45,7 @@
android:layout_weight="1"
android:text="@{bean.uldNo}"
android:textColor="@color/text_normal"
android:textSize="15sp" />
android:textSize="14sp" />
<!-- 重量信息 -->
<TextView
@@ -48,14 +54,14 @@
android:layout_marginStart="12dp"
android:text="@{bean.weightInfo}"
android:textColor="@{bean.isOrange ? @color/text_orange : @color/colorPrimary}"
android:textSize="15sp" />
android:textSize="14sp" />
<!-- 箭头图标 -->
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginStart="8dp"
android:src="@drawable/ic_arrow_right"
android:src="@drawable/img_pda_right"
android:visibility="@{bean.hasArrow ? View.VISIBLE : View.GONE}" />
</LinearLayout>
</layout>

View File

@@ -1,11 +1,15 @@
<?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/android">
<data>
<import type="android.view.View" />
<variable
name="bean"
type="com.lukouguoji.module_base.bean.AssemblePositionBean" />
<variable
name="position"
type="Integer" />
@@ -14,26 +18,40 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:gravity="center_vertical"
android:paddingVertical="12dp"
android:orientation="horizontal"
android:paddingHorizontal="8dp"
android:background="@{bean.isSelected ? @drawable/bg_green_light : @drawable/bg_white}">
android:paddingVertical="12dp">
<!-- Radio Button 圆形图标 -->
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginEnd="8dp"
android:src="@{bean.isSelected ? @drawable/ic_success_circle : @drawable/bg_circle_gray}" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@{bean.positionName}"
android:textColor="@{bean.isSelected ? @color/colorPrimary : @color/text_normal}"
android:textColor="@color/text_normal"
android:textSize="14sp"
android:textStyle="normal" />
<!-- 选中图标 -->
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_check_green"
android:visibility="@{bean.isSelected ? View.VISIBLE : View.GONE}" />
</LinearLayout>
<!-- 分割线 -->
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/line" />
</LinearLayout>
</layout>