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

@@ -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
}
}
}
/**
* 搜索按钮点击
*/