This commit is contained in:
2025-11-27 21:13:22 +08:00
parent f797767919
commit 35a9ee145a
17 changed files with 1189 additions and 19 deletions

View File

@@ -0,0 +1,27 @@
package com.lukouguoji.gjc.holder
import android.view.View
import com.lukouguoji.gjc.databinding.ItemIntExpMoveBinding
import com.lukouguoji.module_base.base.BaseViewHolder
import com.lukouguoji.module_base.bean.GjcMove
/**
* 国际出港移库列表项ViewHolder
*/
class IntExpMoveViewHolder(view: View) :
BaseViewHolder<GjcMove, ItemIntExpMoveBinding>(view) {
override fun onBind(item: Any?, position: Int) {
val bean = getItemBean(item) ?: return
binding.bean = bean
binding.position = position
// 点击整个item切换选中状态
binding.root.setOnClickListener {
bean.isSelected = !bean.isSelected
binding.bean = bean // 触发DataBinding更新
}
binding.executePendingBindings()
}
}

View File

@@ -0,0 +1,107 @@
package com.lukouguoji.gjc.page.move
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AlertDialog
import com.alibaba.android.arouter.facade.annotation.Route
import com.lukouguoji.gjc.R
import com.lukouguoji.gjc.databinding.ActivityIntExpMoveBinding
import com.lukouguoji.gjc.viewModel.IntExpMoveViewModel
import com.lukouguoji.module_base.base.BaseBindingActivity
import com.lukouguoji.module_base.common.Constant
import com.lukouguoji.module_base.ktx.addOnItemClickListener
import com.lukouguoji.module_base.ktx.showToast
import com.lukouguoji.module_base.model.ScanModel
import com.lukouguoji.module_base.router.ARouterConstants
/**
* 国际出港-出港移库
*/
@Route(path = ARouterConstants.ACTIVITY_URL_INT_EXP_MOVE)
class IntExpMoveActivity : BaseBindingActivity<ActivityIntExpMoveBinding, IntExpMoveViewModel>() {
override fun layoutId() = R.layout.activity_int_exp_move
override fun viewModelClass() = IntExpMoveViewModel::class.java
override fun initOnCreate(savedInstanceState: Bundle?) {
setBackArrow("出港移库")
binding.viewModel = viewModel
binding.activity = this
initRecyclerView()
initListeners()
}
/**
* 初始化RecyclerView
*/
private fun initRecyclerView() {
viewModel.pageModel.bindSmartRefreshLayout(
binding.srl,
binding.rv,
viewModel,
this
)
binding.rv.addOnItemClickListener(viewModel)
}
/**
* 初始化监听器
*/
private fun initListeners() {
// 移库按钮
binding.btnMove.setOnClickListener {
showMoveConfirmDialog()
}
}
/**
* 扫码运单号
*/
fun scanWaybill() {
ScanModel.startScan(this, Constant.RequestCode.WAYBILL)
}
/**
* 显示移库确认对话框
*/
private fun showMoveConfirmDialog() {
val selectedItems = viewModel.getSelectedItems()
if (selectedItems.isEmpty()) {
showToast("请至少选择一条运单")
return
}
AlertDialog.Builder(this)
.setTitle("移库确认")
.setMessage("确定要移库选中的 ${selectedItems.size} 条记录吗?")
.setPositiveButton("确定") { _, _ ->
viewModel.submitMove()
}
.setNegativeButton("取消", null)
.show()
}
/**
* 扫码回调
*/
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == Constant.RequestCode.WAYBILL && resultCode == Activity.RESULT_OK) {
val code = data?.getStringExtra(Constant.Result.CODED_CONTENT)
viewModel.waybillNo.value = code
viewModel.searchClick()
}
}
companion object {
@JvmStatic
fun start(context: Context) {
val starter = Intent(context, IntExpMoveActivity::class.java)
context.startActivity(starter)
}
}
}

View File

@@ -0,0 +1,168 @@
package com.lukouguoji.gjc.viewModel
import androidx.lifecycle.MutableLiveData
import com.lukouguoji.gjc.R
import com.lukouguoji.gjc.holder.IntExpMoveViewHolder
import com.lukouguoji.module_base.base.BasePageViewModel
import com.lukouguoji.module_base.bean.GjcMove
import com.lukouguoji.module_base.http.net.NetApply
import com.lukouguoji.module_base.interfaces.IOnItemClickListener
import com.lukouguoji.module_base.ktx.commonAdapter
import com.lukouguoji.module_base.ktx.launchCollect
import com.lukouguoji.module_base.ktx.launchLoadingCollect
import com.lukouguoji.module_base.ktx.noNull
import com.lukouguoji.module_base.ktx.showToast
import com.lukouguoji.module_base.ktx.toRequestBody
import dev.utils.app.info.KeyValue
/**
* 国际出港移库ViewModel
*/
class IntExpMoveViewModel : BasePageViewModel(), IOnItemClickListener {
// ========== 搜索字段 ==========
val awbType = MutableLiveData("") // 运单类型
val by1 = MutableLiveData("") // 承运人
val dest1 = MutableLiveData("") // 卸货站
val moveState = MutableLiveData("") // 移库状态
val waybillNo = MutableLiveData("") // 运单号
// ========== 运单类型下拉数据 ==========
val awbTypeList = MutableLiveData<List<KeyValue>>().apply {
value = listOf(
KeyValue("", "全部"),
KeyValue("IOCO", "国际出港(经国内航班出境)"),
KeyValue("IOSO", "国际出港(国际航班出境)")
)
}
// ========== 移库状态下拉数据 ==========
val moveStateList = MutableLiveData<List<KeyValue>>().apply {
value = listOf(
KeyValue("", "全部"),
KeyValue("0", "未移交"),
KeyValue("1", "已移交")
)
}
// ========== 底部统计 ==========
val totalCount = MutableLiveData("0") // 合计票数
val totalPieces = MutableLiveData("0") // 总件数
val totalWeight = MutableLiveData("0") // 总重量
// ========== 适配器配置 ==========
val itemViewHolder = IntExpMoveViewHolder::class.java
val itemLayoutId = R.layout.item_int_exp_move
/**
* 搜索按钮点击
*/
fun searchClick() {
refresh()
}
/**
* 扫码运单号在Activity中实现
*/
fun scanWaybill() {
// 由Activity处理扫码逻辑
}
/**
* 全选/取消全选
*/
fun toggleSelectAll() {
val adapter = pageModel.rv?.commonAdapter() ?: return
val list = adapter.items.filterIsInstance<GjcMove>()
val allSelected = list.all { it.isSelected }
list.forEach { it.isSelected = !allSelected }
adapter.notifyDataSetChanged()
}
/**
* 获取选中的运单
*/
fun getSelectedItems(): List<GjcMove> {
val adapter = pageModel.rv?.commonAdapter() ?: return emptyList()
return adapter.items.filterIsInstance<GjcMove>().filter { it.isSelected }
}
/**
* 提交移库在Activity中显示确认对话框后调用
*/
fun submitMove() {
val selectedItems = getSelectedItems()
if (selectedItems.isEmpty()) {
showToast("请至少选择一条运单")
return
}
val params = selectedItems.toRequestBody()
launchLoadingCollect({ NetApply.api.submitIntExpMove(params) }) {
onSuccess = {
showToast("移库成功")
refresh() // 刷新列表
}
onFailed = { _, msg ->
showToast(msg.noNull("移库失败"))
}
}
}
/**
* 获取列表数据
*/
override fun getData() {
// 构建筛选参数
val filterParams = mapOf(
"awbType" to awbType.value.noNull(),
"by1" to by1.value.noNull(),
"dest1" to dest1.value.noNull(),
"moveState" to moveState.value.noNull(),
"likeNo" to waybillNo.value.noNull()
)
// 列表参数(含分页)
val listParams = (filterParams + mapOf(
"pageNum" to pageModel.page,
"pageSize" to pageModel.limit
)).toRequestBody()
// 统计参数(无分页)
val totalParams = filterParams.toRequestBody()
// 获取列表显示loading
launchLoadingCollect({ NetApply.api.getIntExpMoveList(listParams) }) {
onSuccess = { pageModel.handleListBean(it) }
}
// 获取统计(后台调用)
getTotalData(totalParams)
}
/**
* 获取统计数据无Loading
*/
private fun getTotalData(params: okhttp3.RequestBody) {
launchCollect({ NetApply.api.getIntExpMoveTotal(params) }) {
onSuccess = { result ->
val data = result.data
totalCount.value = (data?.wbNumber ?: 0).toString()
totalPieces.value = (data?.totalPc ?: 0L).toString()
totalWeight.value = (data?.totalWeight ?: 0.0).toString()
}
}
}
/**
* Item点击事件处理用于单选CheckBox
*/
override fun onItemClick(position: Int, type: Int) {
val bean = pageModel.rv?.commonAdapter()?.getItem(position) as? GjcMove ?: return
bean.isSelected = !bean.isSelected
pageModel.rv?.commonAdapter()?.notifyItemChanged(position)
}
}

View File

@@ -33,16 +33,14 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.3"
android:layout_marginEnd="8dp"
android:background="@drawable/bg_white_radius_8"
android:orientation="vertical">
<!-- 搜索框 -->
<com.lukouguoji.module_base.ui.weight.search.layout.PadSearchLayout
<com.lukouguoji.module_base.ui.weight.search.layout.PadSearchLayoutNew
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:background="@color/color_f2"
android:layout_margin="4dp"
hint='@{"请输入搜索内容"}'
type="@{SearchLayoutType.INPUT}"
value="@={viewModel.searchText}" />
@@ -53,7 +51,7 @@
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:padding="16dp">
android:padding="8dp">
<!-- 组装信息标题 -->
<TextView
@@ -108,7 +106,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.7"
android:layout_marginStart="8dp"
android:layout_marginStart="10dp"
android:orientation="vertical">
<!-- 运单列表 -->
@@ -116,23 +114,24 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
android:layout_marginBottom="16dp"
android:layout_marginBottom="8dp"
android:background="@drawable/bg_white_radius_8"
android:orientation="vertical"
android:padding="16dp">
android:paddingBottom="8dp"
android:paddingHorizontal="8dp">
<TextView
android:layout_width="wrap_content"
<!-- 搜索框 -->
<com.lukouguoji.module_base.ui.weight.search.layout.PadSearchLayoutNew
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="运单列表"
android:textColor="@color/text_normal"
android:textSize="16sp"
android:textStyle="bold" />
android:layout_margin="4dp"
hint='@{"请输入搜索内容"}'
type="@{SearchLayoutType.INPUT}"
value="@={viewModel.searchText}" />
<com.google.android.material.divider.MaterialDivider
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:dividerColor="@color/line" />
@@ -147,10 +146,10 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginBottom="8dp"
android:background="@drawable/bg_white_radius_8"
android:orientation="vertical"
android:padding="12dp">
android:padding="8dp">
<TextView
android:layout_width="wrap_content"
@@ -214,7 +213,7 @@
android:layout_height="wrap_content"
android:background="@drawable/bg_white_radius_8"
android:orientation="vertical"
android:padding="12dp">
android:padding="8dp">
<TextView
android:layout_width="wrap_content"

View File

@@ -0,0 +1,182 @@
<?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="android.view.View" />
<import type="com.lukouguoji.module_base.ui.weight.search.layout.SearchLayoutType" />
<variable
name="viewModel"
type="com.lukouguoji.gjc.viewModel.IntExpMoveViewModel" />
<variable
name="activity"
type="com.lukouguoji.gjc.page.move.IntExpMoveActivity" />
</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='@{"请选择运单类型"}'
list="@{viewModel.awbTypeList}"
type="@{SearchLayoutType.SPINNER}"
value="@={viewModel.awbType}" />
<!-- 承运人 -->
<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.INPUT}"
value="@={viewModel.by1}" />
<!-- 卸货站 -->
<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.INPUT}"
value="@={viewModel.dest1}" />
<!-- 移库状态 -->
<com.lukouguoji.module_base.ui.weight.search.layout.PadSearchLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
hint='@{"请选择移库状态"}'
list="@{viewModel.moveStateList}"
type="@{SearchLayoutType.SPINNER}"
value="@={viewModel.moveState}" />
<!-- 运单号 -->
<com.lukouguoji.module_base.ui.weight.search.layout.PadSearchLayout
android:id="@+id/searchWaybillNo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
hint='@{"请输入运单号"}'
icon="@{@drawable/img_scan}"
setOnIconClickListener="@{(v)-> activity.scanWaybill()}"
type="@{SearchLayoutType.INPUT}"
value="@={viewModel.waybillNo}" />
<!-- 搜索按钮 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<ImageView
style="@style/iv_search_action"
android:onClick="@{()-> viewModel.searchClick()}"
android:src="@drawable/img_search" />
</LinearLayout>
</LinearLayout>
<!-- 列表 -->
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/srl"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:itemCount="3"
tools:listitem="@layout/item_int_exp_move" />
</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">
<!-- 全选 -->
<CheckBox
android:id="@+id/cbSelectAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="@{()-> viewModel.toggleSelectAll()}"
android:text="全选"
android:textColor="@color/white"
android:textSize="16sp" />
<!-- 统计信息 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
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" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text='@{"总件数:"+viewModel.totalPieces}'
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<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" />
</LinearLayout>
<!-- 移库按钮 -->
<TextView
android:id="@+id/btnMove"
style="@style/tv_bottom_btn"
android:text="移库"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
</layout>

View File

@@ -0,0 +1,155 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<import type="android.view.View" />
<variable
name="bean"
type="com.lukouguoji.module_base.bean.GjcMove" />
<variable
name="position"
type="Integer" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/bg_white_radius_8"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:padding="15dp"
android:gravity="center_vertical">
<!-- 左侧CheckBox -->
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="@{bean.isSelected}"
android:clickable="false"
android:focusable="false" />
<!-- 中间:飞机图标 -->
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="10dp"
android:src="@drawable/img_plane"
android:contentDescription="@string/app_name" />
<!-- 右侧:信息区域 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="15dp"
android:orientation="vertical">
<!-- 第一行 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{`运单号:` + (bean.prefix.isEmpty() ? bean.wbNo : bean.prefix + `-` + bean.wbNo)}"
android:textSize="16sp"
android:textColor="@color/text_normal"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="@{`件数:` + bean.pc}"
android:textSize="14sp"
android:textColor="@color/text_gray" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="@{`重量:` + bean.weight}"
android:textSize="14sp"
android:textColor="@color/text_gray" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="@{`承运人:` + bean.by1}"
android:textSize="14sp"
android:textColor="@color/text_gray" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="@{`特码:` + bean.spCode}"
android:textSize="14sp"
android:textColor="@color/text_gray"
android:visibility="@{bean.spCode != null &amp;&amp; !bean.spCode.isEmpty() ? View.VISIBLE : View.GONE}" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="@{`代理人:` + bean.agentName}"
android:textSize="14sp"
android:textColor="@color/text_gray" />
</LinearLayout>
<!-- 第二行 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@{`出运路径:` + (bean.dep.isEmpty() ? "" : bean.dep + `—`) + (bean.dest1.isEmpty() ? "" : bean.dest1 + `—`) + (bean.dest2.isEmpty() ? "" : bean.dest2 + `—`) + bean.dest}'
android:textSize="14sp"
android:textColor="@color/text_gray" />
<!-- 移交状态标签 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:background="@drawable/bg_green_radius_4"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:text="@{bean.moveState == 1 ? `已移交` : `未移交`}"
android:textSize="12sp"
android:textColor="@color/white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="@{`运单类型:` + bean.awbTypeName}"
android:textSize="14sp"
android:textColor="@color/text_gray" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="@{`品名:` + (bean.goodsCn.isEmpty() ? bean.goods : bean.goodsCn)}"
android:textSize="14sp"
android:textColor="@color/text_gray" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</layout>