feat: 开始组装 ui
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,9 +104,7 @@ class GjcWeighingViewModel : BasePageViewModel() {
|
||||
* 添加按钮点击(跳转到开始计重页面)
|
||||
*/
|
||||
fun addClick() {
|
||||
// showToast("请从列表中选择一条待计重运单")
|
||||
|
||||
GjcWeighingStartActivity.startForAdd(getTopActivity(), 123)
|
||||
GjcWeighingStartActivity.startForAdd(getTopActivity())
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码运单
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索按钮点击
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user