From d6be019c3a6b9f05fff7d155b8ae70a5fa33e9ec Mon Sep 17 00:00:00 2001 From: YANGJIANKUAN Date: Sat, 17 Jan 2026 20:40:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9B=BD=E9=99=85=E5=87=BA=E6=B8=AF=20?= =?UTF-8?q?=E5=87=BA=E6=B8=AF=E8=AE=A1=E9=87=8D=20opt=20v?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module_base/bean/GjcWeighingRecordBean.kt | 9 +++++ .../src/main/res/drawable/bg_item_green.xml | 10 +++--- .../gjc/activity/IntExpArriveActivity.kt | 21 +++++++++-- .../gjc/holder/GjcWeighingRecordViewHolder.kt | 10 ++++++ .../viewModel/GjcWeighingRecordViewModel.kt | 36 ++++++++++++++++--- .../viewModel/GjcWeighingStartViewModel.kt | 23 ++++++++++-- .../src/main/res/layout/item_gjc_weighing.xml | 2 +- .../res/layout/item_gjc_weighing_record.xml | 1 + 8 files changed, 97 insertions(+), 15 deletions(-) diff --git a/module_base/src/main/java/com/lukouguoji/module_base/bean/GjcWeighingRecordBean.kt b/module_base/src/main/java/com/lukouguoji/module_base/bean/GjcWeighingRecordBean.kt index 19e44fa..87e8625 100644 --- a/module_base/src/main/java/com/lukouguoji/module_base/bean/GjcWeighingRecordBean.kt +++ b/module_base/src/main/java/com/lukouguoji/module_base/bean/GjcWeighingRecordBean.kt @@ -1,5 +1,6 @@ package com.lukouguoji.module_base.bean +import androidx.databinding.ObservableBoolean import java.io.Serializable /** @@ -98,4 +99,12 @@ class GjcWeighingRecordBean : Serializable { var haWbList: List? = null // 分单列表 var storageUseList: List? = null // 库位使用列表 var attachList: List? = null // 附件列表 + + // ========== UI扩展字段 ========== + val checked: ObservableBoolean = ObservableBoolean(false) // 选中状态 + + // 兼容现有API的isSelected属性 + var isSelected: Boolean + get() = checked.get() + set(value) = checked.set(value) } diff --git a/module_base/src/main/res/drawable/bg_item_green.xml b/module_base/src/main/res/drawable/bg_item_green.xml index fb196de..6505637 100644 --- a/module_base/src/main/res/drawable/bg_item_green.xml +++ b/module_base/src/main/res/drawable/bg_item_green.xml @@ -1,5 +1,5 @@ - - - - - \ No newline at end of file + + + + + diff --git a/module_gjc/src/main/java/com/lukouguoji/gjc/activity/IntExpArriveActivity.kt b/module_gjc/src/main/java/com/lukouguoji/gjc/activity/IntExpArriveActivity.kt index 724154c..7bfc42e 100644 --- a/module_gjc/src/main/java/com/lukouguoji/gjc/activity/IntExpArriveActivity.kt +++ b/module_gjc/src/main/java/com/lukouguoji/gjc/activity/IntExpArriveActivity.kt @@ -3,7 +3,9 @@ package com.lukouguoji.gjc.activity import android.app.Activity import android.content.Intent import android.os.Bundle +import com.alibaba.android.arouter.facade.annotation.Autowired import com.alibaba.android.arouter.facade.annotation.Route +import com.alibaba.android.arouter.launcher.ARouter import com.lukouguoji.gjc.R import com.lukouguoji.gjc.databinding.ActivityIntExpArriveBinding import com.lukouguoji.gjc.viewModel.IntExpArriveViewModel @@ -22,13 +24,26 @@ import com.lukouguoji.module_base.router.ARouterConstants class IntExpArriveActivity : BaseBindingActivity() { + @JvmField + @Autowired + var wbNoParam: String? = null + override fun layoutId() = R.layout.activity_int_exp_arrive override fun viewModelClass() = IntExpArriveViewModel::class.java override fun initOnCreate(savedInstanceState: Bundle?) { + // 注入 ARouter 参数 + ARouter.getInstance().inject(this) + setBackArrow("出港运抵") binding.viewModel = viewModel + // 如果有传入运单号,自动填充并触发搜索 + if (!wbNoParam.isNullOrEmpty()) { + viewModel.waybillNo.value = wbNoParam + viewModel.searchClick() + } + // 观察全选状态,更新图标透明度 viewModel.isAllChecked.observe(this) { isAllChecked -> binding.checkIcon.alpha = if (isAllChecked) 1.0f else 0.5f @@ -45,8 +60,10 @@ class IntExpArriveActivity : viewModel.refresh() } - // 初始加载数据 - viewModel.refresh() + // 初始加载数据(如果没有传入运单号,才执行初始加载) + if (wbNoParam.isNullOrEmpty()) { + viewModel.refresh() + } } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { diff --git a/module_gjc/src/main/java/com/lukouguoji/gjc/holder/GjcWeighingRecordViewHolder.kt b/module_gjc/src/main/java/com/lukouguoji/gjc/holder/GjcWeighingRecordViewHolder.kt index e69a1bf..93b41e5 100644 --- a/module_gjc/src/main/java/com/lukouguoji/gjc/holder/GjcWeighingRecordViewHolder.kt +++ b/module_gjc/src/main/java/com/lukouguoji/gjc/holder/GjcWeighingRecordViewHolder.kt @@ -15,6 +15,16 @@ class GjcWeighingRecordViewHolder(view: View) : override fun onBind(item: Any?, position: Int) { val bean = getItemBean(item)!! binding.bean = bean + binding.executePendingBindings() + + // 图标点击 - 切换选择状态 + binding.ivIcon.setOnClickListener { + // 反转checked状态 + bean.checked.set(!bean.checked.get()) + + // 立即更新UI (图片自动切换) + binding.executePendingBindings() + } // 整行点击跳转到计重明细页 binding.ll.setOnClickListener { diff --git a/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/GjcWeighingRecordViewModel.kt b/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/GjcWeighingRecordViewModel.kt index c1fa0a3..52025b1 100644 --- a/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/GjcWeighingRecordViewModel.kt +++ b/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/GjcWeighingRecordViewModel.kt @@ -7,15 +7,18 @@ import com.lukouguoji.gjc.R import com.lukouguoji.gjc.holder.GjcWeighingRecordViewHolder import com.lukouguoji.module_base.base.BasePageViewModel import com.lukouguoji.module_base.common.Constant +import com.lukouguoji.module_base.bean.GjcWeighingRecordBean import com.lukouguoji.module_base.http.net.NetApply +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.showToast import com.lukouguoji.module_base.ktx.toRequestBody import com.lukouguoji.module_base.model.ScanModel import com.lukouguoji.module_base.util.DictUtils import dev.utils.app.info.KeyValue import dev.utils.common.DateUtils -import com.lukouguoji.module_base.ktx.formatDate +import com.lukouguoji.module_base.ktx.formatDate /** * 国际出港计重记录 ViewModel @@ -92,10 +95,33 @@ class GjcWeighingRecordViewModel : BasePageViewModel() { } /** - * 运抵申报按钮点击(暂未实现) + * 运抵申报按钮点击 */ fun declareClick() { - // TODO: 跳转到运抵申报页面(待实现) + // 获取列表数据 + val list = pageModel.rv?.commonAdapter()?.items as? List ?: return + + // 过滤选中项 + val selectedItems = list.filter { it.isSelected } + + when (selectedItems.size) { + 0 -> { + // 没有选择单据:Toast 提示 + showToast("请选择要申报的单据") + } + 1 -> { + // 选择一个单据:跳转到出港运抵页面,携带运单号 + val waybillNo = selectedItems[0].wbNo + com.alibaba.android.arouter.launcher.ARouter.getInstance() + .build(com.lukouguoji.module_base.router.ARouterConstants.ACTIVITY_URL_INT_EXP_ARRIVE) + .withString("wbNoParam", waybillNo) + .navigation() + } + else -> { + // 选择多个单据:Toast 提示 + showToast("只能选择一个单据") + } + } } /** @@ -110,7 +136,7 @@ class GjcWeighingRecordViewModel : BasePageViewModel() { "fno" to flightNo.value!!.ifEmpty { null }, "agentCode" to agentCode.value!!.ifEmpty { null }, "spCode" to spCode.value!!.ifEmpty { null }, - "likeNo" to waybillNo.value!!.ifEmpty { null }, + "wbNo" to waybillNo.value!!.ifEmpty { null }, ).toRequestBody() // 构建查询参数(统计接口 - 使用相同的搜索条件) @@ -119,7 +145,7 @@ class GjcWeighingRecordViewModel : BasePageViewModel() { "fno" to flightNo.value!!.ifEmpty { null }, "agentCode" to agentCode.value!!.ifEmpty { null }, "spCode" to spCode.value!!.ifEmpty { null }, - "likeNo" to waybillNo.value!!.ifEmpty { null }, + "wbNo" to waybillNo.value!!.ifEmpty { null }, ).toRequestBody() // 获取列表数据(显示loading) diff --git a/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/GjcWeighingStartViewModel.kt b/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/GjcWeighingStartViewModel.kt index 90e6136..3c8c23c 100644 --- a/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/GjcWeighingStartViewModel.kt +++ b/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/GjcWeighingStartViewModel.kt @@ -258,7 +258,17 @@ class GjcWeighingStartViewModel : BaseViewModel() { if (bean.fno.verifyNullOrEmpty("请输入航班号")) return if (channel.value.verifyNullOrEmpty("请选择通道号")) return - // 2. 收集当前表单数据,更新到 bean + // 2. 校验件数: 运抵件数 + 实时件数 不能大于 预配件数 + val realTimePcVal = realTimePc.value?.toLongOrNull() ?: 0L + val arrivePcVal = arrivePc.value?.toLongOrNull() ?: bean.arrivePc ?: 0L + val preallocatedPc = bean.pc ?: 0L + + if (arrivePcVal + realTimePcVal > preallocatedPc) { + showToast("运抵件数 + 实时件数不能大于预配件数") + return + } + + // 3. 收集当前表单数据,更新到 bean bean.apply { // 更新运抵数据(如果用户已编辑) arrivePc = this@GjcWeighingStartViewModel.arrivePc.value?.toLongOrNull() ?: arrivePc @@ -321,8 +331,17 @@ class GjcWeighingStartViewModel : BaseViewModel() { if (bean.fno.verifyNullOrEmpty("请输入航班号")) return if (channel.value.verifyNullOrEmpty("请选择通道号")) return + // 校验件数: 运抵件数 + 实时件数 不能大于 预配件数 + val realTimePcVal = realTimePc.value?.toLongOrNull() ?: 0L + val arrivePcVal = arrivePc.value?.toLongOrNull() ?: bean.arrivePc ?: 0L + val preallocatedPc = bean.pc ?: 0L + + if (arrivePcVal + realTimePcVal > preallocatedPc) { + showToast("运抵件数 + 实时件数不能大于预配件数") + return + } + // 从编辑字段获取数值 - val arrivePcVal = arrivePc.value?.toLongOrNull() ?: bean.arrivePc val arriveWeightVal = arriveWeight.value?.toDoubleOrNull() ?: bean.arriveWeight val arriveVolumeVal = arriveVolume.value?.toDoubleOrNull() ?: bean.arriveVolume diff --git a/module_gjc/src/main/res/layout/item_gjc_weighing.xml b/module_gjc/src/main/res/layout/item_gjc_weighing.xml index f8fce61..def4fe2 100644 --- a/module_gjc/src/main/res/layout/item_gjc_weighing.xml +++ b/module_gjc/src/main/res/layout/item_gjc_weighing.xml @@ -21,7 +21,7 @@ android:layout_height="wrap_content" android:layout_marginHorizontal="15dp" android:layout_marginVertical="5dp" - android:background="@drawable/bg_item" + android:background="@{bean.checkIn.equals(`2`) ? @drawable/bg_item_green : @drawable/bg_item}" android:orientation="horizontal" android:padding="10dp"> diff --git a/module_gjc/src/main/res/layout/item_gjc_weighing_record.xml b/module_gjc/src/main/res/layout/item_gjc_weighing_record.xml index 14b8077..51cd0e8 100644 --- a/module_gjc/src/main/res/layout/item_gjc_weighing_record.xml +++ b/module_gjc/src/main/res/layout/item_gjc_weighing_record.xml @@ -25,6 +25,7 @@ android:layout_width="40dp" android:layout_height="40dp" android:layout_gravity="center" + loadImage="@{bean.checked.get() ? @drawable/img_plane_s : @drawable/img_plane}" android:src="@drawable/img_plane" />