feat: 出港计重 ui

This commit is contained in:
2025-11-21 15:02:52 +08:00
parent 45adb8d2b4
commit 361c583e5e
12 changed files with 791 additions and 0 deletions

View File

@@ -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)
}
}
}

View File

@@ -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)
}
}
}

View File

@@ -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()
}
}
}
}
}

View File

@@ -0,0 +1,191 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="com.lukouguoji.module_base.ui.weight.search.layout.SearchLayoutType" />
<variable
name="viewModel"
type="com.lukouguoji.gjc.viewModel.GjcWeighingViewModel" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_f2"
android:orientation="vertical">
<include layout="@layout/title_tool_bar" />
<!-- 搜索区域 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<!-- 航班日期 -->
<com.lukouguoji.module_base.ui.weight.search.layout.PadSearchLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
hint='@{"请选择航班日期"}'
icon="@{@drawable/img_date}"
type="@{SearchLayoutType.DATE}"
value="@={viewModel.flightDate}" />
<!-- 航班号 -->
<com.lukouguoji.module_base.ui.weight.search.layout.PadSearchLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
hint='@{"请输入航班号"}'
icon="@{@drawable/img_scan}"
setOnIconClickListener="@{()-> viewModel.flightNoScanClick()}"
type="@{SearchLayoutType.INPUT}"
value="@={viewModel.flightNo}" />
<!-- 择代理 -->
<com.lukouguoji.module_base.ui.weight.search.layout.PadSearchLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
hint='@{"请选择代理"}'
type="@{SearchLayoutType.SPINNER}"
value="@={viewModel.agentCode}" />
<!-- 择特码 -->
<com.lukouguoji.module_base.ui.weight.search.layout.PadSearchLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
hint='@{"请选择特码"}'
type="@{SearchLayoutType.SPINNER}"
value="@={viewModel.spCode}" />
<!-- 运单号 -->
<com.lukouguoji.module_base.ui.weight.search.layout.PadSearchLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
hint='@{"请输入运单号"}'
icon="@{@drawable/img_scan}"
setOnIconClickListener="@{()-> viewModel.waybillNoScanClick()}"
type="@{SearchLayoutType.INPUT}"
value="@={viewModel.waybillNo}" />
<!-- 搜索和添加按钮 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center">
<ImageView
style="@style/iv_search_action"
android:onClick="@{()-> viewModel.searchClick()}"
android:src="@drawable/img_search" />
<!-- 添加按钮 -->
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:onClick="@{()-> viewModel.addClick()}"
android:padding="5dp"
android:src="@drawable/img_add" />
</LinearLayout>
</LinearLayout>
<!-- 列表 -->
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/srl"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="match_parent"
itemLayoutId="@{viewModel.itemLayoutId}"
viewHolder="@{viewModel.itemViewHolder}"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_gjc_weighing" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
<!-- 底部统计和按钮 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/color_bottom_layout"
android:gravity="center_vertical"
android:paddingHorizontal="15dp">
<!-- 统计信息 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@{"合计:"+viewModel.totalCount+"票"}'
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
tools:text="合计1票" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text='@{"总件数:"+viewModel.totalPc}'
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
tools:text="总件数100" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text='@{"总重量:"+viewModel.totalWeight}'
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
tools:text="总重量100" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text='@{"总货重:"+viewModel.cargoWeight}'
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
tools:text="总货重100" />
</LinearLayout>
<!-- 计重记录按钮 -->
<TextView
style="@style/tv_bottom_btn"
android:onClick="@{()-> viewModel.recordClick()}"
android:text="计重记录" />
</LinearLayout>
</LinearLayout>
</layout>

View File

@@ -0,0 +1,274 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="bean"
type="com.lukouguoji.module_base.bean.GjcWeighingBean" />
</data>
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="5dp"
android:background="@drawable/bg_item"
android:orientation="horizontal"
android:padding="10dp">
<!-- 飞机图标 -->
<ImageView
android:id="@+id/iv_icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:src="@drawable/img_plane" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:orientation="vertical">
<!-- 第一行数据 -->
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- 运单号 -->
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.2"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
completeSpace="@{4}"
android:text="运单号:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{bean.no}"
android:textColor="@color/colorPrimary"
tools:text="78109081212" />
</androidx.appcompat.widget.LinearLayoutCompat>
<!-- 代理人 -->
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
completeSpace="@{4}"
android:text="代理人:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@{bean.agentName}'
tools:text="SF" />
</androidx.appcompat.widget.LinearLayoutCompat>
<!-- 特码 -->
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
completeSpace="@{3}"
android:text="特码:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{bean.spCode}"
tools:text="NOR" />
</androidx.appcompat.widget.LinearLayoutCompat>
<!-- 预配件数 -->
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
completeSpace="@{5}"
android:text="预配件数:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@{String.valueOf(bean.pc)}'
tools:text="11" />
</androidx.appcompat.widget.LinearLayoutCompat>
<!-- 预配重量 -->
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
completeSpace="@{5}"
android:text="预配重量:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@{String.valueOf(bean.weight)}'
tools:text="12" />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
<!-- 第二行数据 -->
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<!-- 计划航班 -->
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.2"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
completeSpace="@{5}"
android:text="计划航班:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{bean.flight}"
tools:text="20240216/MU2026" />
</androidx.appcompat.widget.LinearLayoutCompat>
<!-- 航程 -->
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
completeSpace="@{3}"
android:text="航程:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@{bean.range}'
tools:text="HFE - PEK" />
</androidx.appcompat.widget.LinearLayoutCompat>
<!-- 预计起飞 -->
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
completeSpace="@{5}"
android:text="预计起飞:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{bean.fdate}"
tools:text="09:12" />
</androidx.appcompat.widget.LinearLayoutCompat>
<!-- 业务类型 -->
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
completeSpace="@{5}"
android:text="业务类型:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@{bean.businessType}'
tools:text="普通货物运输" />
</androidx.appcompat.widget.LinearLayoutCompat>
<!-- 品名 -->
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
completeSpace="@{3}"
android:text="品名(中)" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@{bean.goodsCn}'
tools:text="电子元器件" />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
</LinearLayout>
<!-- 右侧箭头 -->
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:src="@drawable/img_pda_right"
android:layout_marginLeft="10dp" />
</androidx.appcompat.widget.LinearLayoutCompat>
</layout>