feat: 出港计重 ui
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package com.lukouguoji.gjc.activity
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.ActivityGjcWeighingListBinding
|
||||
import com.lukouguoji.gjc.viewModel.GjcWeighingViewModel
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.impl.observe
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
/**
|
||||
* 国际出港计重列表页
|
||||
*/
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GJC_WEIGHING_LIST)
|
||||
class GjcWeighingListActivity :
|
||||
BaseBindingActivity<ActivityGjcWeighingListBinding, GjcWeighingViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gjc_weighing_list
|
||||
|
||||
override fun viewModelClass() = GjcWeighingViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("出港计重")
|
||||
|
||||
binding.viewModel = viewModel
|
||||
|
||||
// 绑定分页逻辑
|
||||
viewModel.pageModel
|
||||
.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, getLifecycleOwner())
|
||||
|
||||
// 监听刷新事件
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH)
|
||||
.observe(this) {
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
// 初始加载
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, GjcWeighingListActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.lukouguoji.gjc.holder
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.gjc.databinding.ItemGjcWeighingBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GjcWeighingBean
|
||||
|
||||
/**
|
||||
* 国际出港计重列表 ViewHolder
|
||||
*/
|
||||
class GjcWeighingViewHolder(view: View) :
|
||||
BaseViewHolder<GjcWeighingBean, ItemGjcWeighingBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)!!
|
||||
binding.bean = bean
|
||||
|
||||
// 整行点击跳转到详情页(暂未实现)
|
||||
binding.ll.setOnClickListener {
|
||||
// TODO: 跳转到详情页(待实现)
|
||||
// GjcWeighingDetailsActivity.start(it.context, bean.whId)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.lukouguoji.gjc.viewModel
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.holder.GjcWeighingViewHolder
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
|
||||
/**
|
||||
* 国际出港计重 ViewModel
|
||||
*/
|
||||
class GjcWeighingViewModel : BasePageViewModel() {
|
||||
|
||||
// 搜索条件
|
||||
val flightDate = MutableLiveData("") // 航班日期
|
||||
val flightNo = MutableLiveData("") // 航班号
|
||||
val agentCode = MutableLiveData("") // 代理人
|
||||
val spCode = MutableLiveData("") // 特码
|
||||
val waybillNo = MutableLiveData("") // 运单号
|
||||
|
||||
// 适配器配置
|
||||
val itemViewHolder = GjcWeighingViewHolder::class.java
|
||||
val itemLayoutId = R.layout.item_gjc_weighing
|
||||
|
||||
// 统计数据
|
||||
val totalCount = MutableLiveData("0") // 合计票数
|
||||
val totalPc = MutableLiveData("0") // 总件数
|
||||
val totalWeight = MutableLiveData("0") // 总重量
|
||||
val cargoWeight = MutableLiveData("0") // 总货重
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 扫码输入航班号
|
||||
*/
|
||||
fun flightNoScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.FLIGHT_NO)
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码输入运单号
|
||||
*/
|
||||
fun waybillNoScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.WAYBILL)
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索按钮点击
|
||||
*/
|
||||
fun searchClick() {
|
||||
refresh()
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加按钮点击(暂未实现)
|
||||
*/
|
||||
fun addClick() {
|
||||
// TODO: 跳转到添加页面(待实现)
|
||||
}
|
||||
|
||||
/**
|
||||
* 计重记录按钮点击(暂未实现)
|
||||
*/
|
||||
fun recordClick() {
|
||||
// TODO: 跳转到计重记录页面(待实现)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表数据
|
||||
*/
|
||||
override fun getData() {
|
||||
// 构建查询参数(列表接口)
|
||||
val listParams = mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"fdate" to flightDate.value!!.ifEmpty { null },
|
||||
"fno" to flightNo.value!!.ifEmpty { null },
|
||||
"agentCode" to agentCode.value!!.ifEmpty { null },
|
||||
"spCode" to spCode.value!!.ifEmpty { null },
|
||||
"likeNo" to waybillNo.value!!.ifEmpty { null },
|
||||
).toRequestBody()
|
||||
|
||||
// 构建查询参数(统计接口 - 使用相同的搜索条件)
|
||||
val totalParams = mapOf(
|
||||
"fdate" to flightDate.value!!.ifEmpty { null },
|
||||
"fno" to flightNo.value!!.ifEmpty { null },
|
||||
"agentCode" to agentCode.value!!.ifEmpty { null },
|
||||
"spCode" to spCode.value!!.ifEmpty { null },
|
||||
"likeNo" to waybillNo.value!!.ifEmpty { null },
|
||||
).toRequestBody()
|
||||
|
||||
// 获取列表数据(显示loading)
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGjcWeighingList(listParams)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取统计数据(后台调用,不显示loading)
|
||||
launchCollect({
|
||||
NetApply.api.getGjcWeighingStatistics(totalParams)
|
||||
}) {
|
||||
onSuccess = { result ->
|
||||
val data = result.data
|
||||
totalCount.value = (data?.wbNumber ?: 0).toString()
|
||||
totalPc.value = (data?.totalPc ?: 0).toString()
|
||||
totalWeight.value = (data?.totalWeight ?: 0.0).toString()
|
||||
cargoWeight.value = (data?.cargoWeight ?: 0.0).toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理扫码结果
|
||||
*/
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.FLIGHT_NO -> {
|
||||
flightNo.value = data.getStringExtra(Constant.Result.CODED_CONTENT)
|
||||
refresh()
|
||||
}
|
||||
Constant.RequestCode.WAYBILL -> {
|
||||
waybillNo.value = data.getStringExtra(Constant.Result.CODED_CONTENT)
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user