feat: 国际出港 出港计重 opt
This commit is contained in:
@@ -30,6 +30,11 @@ class GjcWeighingListActivity :
|
||||
|
||||
binding.viewModel = viewModel
|
||||
|
||||
// 观察全选状态,更新图标透明度
|
||||
viewModel.isAllChecked.observe(this) { isAllChecked ->
|
||||
binding.checkIcon.alpha = if (isAllChecked) 1.0f else 0.5f
|
||||
}
|
||||
|
||||
// 初始化代理人列表(从API获取)
|
||||
viewModel.initAgentList()
|
||||
|
||||
|
||||
@@ -15,6 +15,17 @@ class GjcWeighingViewHolder(view: View) :
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)!!
|
||||
binding.bean = bean
|
||||
binding.position = position
|
||||
binding.executePendingBindings()
|
||||
|
||||
// 选择图标点击事件 - 切换选择状态
|
||||
binding.ivIcon.setOnClickListener {
|
||||
// 反转checked状态
|
||||
bean.checked.set(!bean.checked.get())
|
||||
|
||||
// 立即更新UI (图片自动切换)
|
||||
binding.executePendingBindings()
|
||||
}
|
||||
|
||||
// 整行点击跳转到开始计重页面
|
||||
binding.ll.setOnClickListener {
|
||||
|
||||
@@ -45,11 +45,11 @@ class GjcWeighingStartViewModel : BaseViewModel() {
|
||||
// 航班日期(格式化为字符串用于DataBinding)
|
||||
val flightDate = MutableLiveData<String>(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
// 地磅集成
|
||||
val diBangModel = DiBangWeightModel()
|
||||
val channel = MutableLiveData("") // 通道号(用于控制地磅key)
|
||||
// 地磅集成(已改为手动输入,暂时注释)
|
||||
// val diBangModel = DiBangWeightModel()
|
||||
val channel = MutableLiveData("") // 通道号
|
||||
|
||||
// 地磅称重显示
|
||||
// 地磅称重显示(手动输入,单向同步到运抵重量)
|
||||
val diBangWeight = MutableLiveData("0") // 地磅重量(右上角黄色显示区域)
|
||||
|
||||
// 可编辑字段(用于双向绑定)
|
||||
@@ -78,15 +78,10 @@ class GjcWeighingStartViewModel : BaseViewModel() {
|
||||
// 获取传入的运单ID
|
||||
maWbId = intent.getLongExtra(Constant.Key.MAWB_ID, 0)
|
||||
|
||||
// 监听地磅重量变化
|
||||
diBangModel.weight.observe(activity as LifecycleOwner) { weight ->
|
||||
val w = weight?.toDoubleOrNull() ?: 0.0
|
||||
diBangWeight.value = if (w > 0) String.format("%.0f", w) else "0"
|
||||
}
|
||||
|
||||
// 监听通道号变化,设置地磅的key
|
||||
channel.observe(activity as LifecycleOwner) {
|
||||
diBangModel.key = it ?: ""
|
||||
// 监听地磅称重输入,单向同步到运抵重量
|
||||
diBangWeight.observe(activity as LifecycleOwner) { weight ->
|
||||
// 同步到运抵重量(单向,不做反向同步)
|
||||
arriveWeight.value = weight ?: "0"
|
||||
}
|
||||
|
||||
// 监听运抵重量变化,自动计算运抵体积
|
||||
@@ -415,6 +410,6 @@ class GjcWeighingStartViewModel : BaseViewModel() {
|
||||
*/
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
diBangModel.cancelLooperGet()
|
||||
// diBangModel.cancelLooperGet() // 已改为手动输入,不再使用地磅自动读取
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,22 +3,30 @@ package com.lukouguoji.gjc.viewModel
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.activity.GjcWeighingRecordListActivity
|
||||
import com.lukouguoji.gjc.activity.GjcWeighingStartActivity
|
||||
import com.lukouguoji.gjc.holder.GjcWeighingViewHolder
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GjcMaWb
|
||||
import com.lukouguoji.module_base.bean.GjcWeighingBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
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.formatDate
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
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 kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* 国际出港计重 ViewModel
|
||||
@@ -45,6 +53,18 @@ class GjcWeighingViewModel : BasePageViewModel() {
|
||||
val totalPc = MutableLiveData("0") // 总件数
|
||||
val totalWeight = MutableLiveData("0") // 总重量
|
||||
|
||||
// 全选状态
|
||||
val isAllChecked = MutableLiveData(false)
|
||||
|
||||
init {
|
||||
// 监听全选状态,自动更新所有列表项
|
||||
isAllChecked.observeForever { checked ->
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcWeighingBean> ?: return@observeForever
|
||||
list.forEach { it.checked.set(checked) }
|
||||
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -109,11 +129,56 @@ class GjcWeighingViewModel : BasePageViewModel() {
|
||||
GjcWeighingRecordListActivity.start(getTopActivity())
|
||||
}
|
||||
|
||||
/**
|
||||
* 全选按钮点击 (切换全选状态)
|
||||
*/
|
||||
fun checkAllClick() {
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcWeighingBean> ?: return
|
||||
|
||||
// 切换全选状态
|
||||
val shouldCheckAll = !isAllChecked.value!!
|
||||
list.forEach { it.checked.set(shouldCheckAll) }
|
||||
isAllChecked.value = shouldCheckAll
|
||||
|
||||
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
/**
|
||||
* 提前运抵
|
||||
*/
|
||||
fun arrivedAhead() {
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcWeighingBean> ?: return
|
||||
val selectedItems = list.filter { it.isSelected }
|
||||
|
||||
if (selectedItems.isEmpty()) {
|
||||
showToast("请选择要提前运抵的运单")
|
||||
return
|
||||
}
|
||||
|
||||
// 转换为GjcMaWb对象列表(只传递必要字段)
|
||||
val maWbList = selectedItems.map { bean ->
|
||||
GjcMaWb(
|
||||
maWbId = bean.maWbId,
|
||||
no = bean.no,
|
||||
prefix = bean.prefix,
|
||||
wbNo = bean.wbNo,
|
||||
arriveFlag = "1" // 设置提前运抵标识
|
||||
)
|
||||
}
|
||||
|
||||
launchLoadingCollect({ NetApply.api.preArrive(maWbList) }) {
|
||||
onSuccess = {
|
||||
showToast("提前运抵成功")
|
||||
// 发送刷新事件
|
||||
viewModelScope.launch {
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
onFailed = { code, msg ->
|
||||
showToast(msg.noNull("提前运抵失败"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user