feat: 国际出港 出港组装 开始组装
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.lukouguoji.gjc.page.assemble
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
@@ -10,6 +11,7 @@ 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.common.Constant
|
||||
import com.lukouguoji.module_base.interfaces.IOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
@@ -115,4 +117,22 @@ class IntExpAssembleStartActivity :
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理扫码结果
|
||||
*/
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
|
||||
if (requestCode == Constant.RequestCode.WAYBILL && resultCode == Activity.RESULT_OK) {
|
||||
// 获取扫码结果
|
||||
val codedContent = data?.getStringExtra(Constant.Result.CODED_CONTENT)
|
||||
|
||||
// 更新搜索框内容
|
||||
viewModel.searchText.value = codedContent
|
||||
|
||||
// 自动触发查询
|
||||
viewModel.loadWaitingAssembleWaybills()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,12 @@ 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.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
|
||||
/**
|
||||
* 国际出港-开始组装ViewModel(静态数据)
|
||||
@@ -193,9 +196,57 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
||||
* 扫码运单
|
||||
*/
|
||||
fun scanWaybill() {
|
||||
showToast("扫码功能(静态页面暂不实现)")
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.WAYBILL)
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载待组装运单列表
|
||||
*/
|
||||
fun loadWaitingAssembleWaybills() {
|
||||
val wbNo = searchText.value?.trim() ?: ""
|
||||
|
||||
// 验证运单号不能为空
|
||||
if (wbNo.isEmpty()) {
|
||||
showToast("请输入运单号")
|
||||
return
|
||||
}
|
||||
|
||||
// 构建请求参数
|
||||
val params = mapOf("wbNo" to wbNo).toRequestBody()
|
||||
|
||||
// 发起网络请求
|
||||
launchLoadingCollect({ NetApply.api.queryWaitingAssemble(params) }) {
|
||||
onSuccess = { result ->
|
||||
// 数据转换: GjcWarehouse -> AssembleWaybillBean
|
||||
val warehouseList = result.data ?: mutableListOf()
|
||||
val waybillBeanList = warehouseList.map { warehouse ->
|
||||
AssembleWaybillBean().apply {
|
||||
waybillNo = warehouse.no
|
||||
pieces = warehouse.pc.toString()
|
||||
weight = String.format("%.1f", warehouse.weight)
|
||||
flight = warehouse.flight
|
||||
isMarked = false
|
||||
}
|
||||
}.toMutableList()
|
||||
|
||||
// 更新列表
|
||||
waybillList.value = waybillBeanList
|
||||
|
||||
// 结果反馈
|
||||
if (waybillBeanList.isEmpty()) {
|
||||
showToast("未找到待组装运单")
|
||||
} else {
|
||||
showToast("查询成功,共${waybillBeanList.size}条记录")
|
||||
}
|
||||
}
|
||||
onFailed = { code, message ->
|
||||
showToast("查询失败: $message")
|
||||
waybillList.value = mutableListOf()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 卸货按钮点击
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user