feat: 国际出港 出港计重 opt
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.lukouguoji.module_base.bean
|
package com.lukouguoji.module_base.bean
|
||||||
|
|
||||||
|
import androidx.databinding.ObservableBoolean
|
||||||
import com.lukouguoji.module_base.ktx.noNull
|
import com.lukouguoji.module_base.ktx.noNull
|
||||||
import dev.utils.DevFinal
|
import dev.utils.DevFinal
|
||||||
import dev.utils.common.DateUtils
|
import dev.utils.common.DateUtils
|
||||||
@@ -96,6 +97,14 @@ class GjcWeighingBean {
|
|||||||
var storageUseList: List<Any>? = null // 库位使用列表
|
var storageUseList: List<Any>? = null // 库位使用列表
|
||||||
var attachList: List<Any>? = null // 附件列表
|
var attachList: List<Any>? = null // 附件列表
|
||||||
|
|
||||||
|
// ========== UI扩展字段 ==========
|
||||||
|
val checked: ObservableBoolean = ObservableBoolean(false) // 选中状态
|
||||||
|
|
||||||
|
// 兼容现有API的isSelected属性
|
||||||
|
var isSelected: Boolean
|
||||||
|
get() = checked.get()
|
||||||
|
set(value) = checked.set(value)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预计起飞时间 - 仅时分格式 (HH:mm)
|
* 预计起飞时间 - 仅时分格式 (HH:mm)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -958,6 +958,14 @@ interface Api {
|
|||||||
@POST("IntExpCheckIn/updateRecordList")
|
@POST("IntExpCheckIn/updateRecordList")
|
||||||
suspend fun updateGjcCheckInRecordList(@Body data: List<GjcCheckInRecord>): BaseResultBean<Boolean>
|
suspend fun updateGjcCheckInRecordList(@Body data: List<GjcCheckInRecord>): BaseResultBean<Boolean>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 国际出港待计重-提前运抵
|
||||||
|
* 接口路径: /IntExpCheckIn/preArrive
|
||||||
|
* 参数: List<GjcMaWb> - 运单列表
|
||||||
|
*/
|
||||||
|
@POST("IntExpCheckIn/preArrive")
|
||||||
|
suspend fun preArrive(@Body data: List<GjcMaWb>): BaseResultBean<String>
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// 国际进-电报解析
|
// 国际进-电报解析
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -30,6 +30,11 @@ class GjcWeighingListActivity :
|
|||||||
|
|
||||||
binding.viewModel = viewModel
|
binding.viewModel = viewModel
|
||||||
|
|
||||||
|
// 观察全选状态,更新图标透明度
|
||||||
|
viewModel.isAllChecked.observe(this) { isAllChecked ->
|
||||||
|
binding.checkIcon.alpha = if (isAllChecked) 1.0f else 0.5f
|
||||||
|
}
|
||||||
|
|
||||||
// 初始化代理人列表(从API获取)
|
// 初始化代理人列表(从API获取)
|
||||||
viewModel.initAgentList()
|
viewModel.initAgentList()
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,17 @@ class GjcWeighingViewHolder(view: View) :
|
|||||||
override fun onBind(item: Any?, position: Int) {
|
override fun onBind(item: Any?, position: Int) {
|
||||||
val bean = getItemBean(item)!!
|
val bean = getItemBean(item)!!
|
||||||
binding.bean = bean
|
binding.bean = bean
|
||||||
|
binding.position = position
|
||||||
|
binding.executePendingBindings()
|
||||||
|
|
||||||
|
// 选择图标点击事件 - 切换选择状态
|
||||||
|
binding.ivIcon.setOnClickListener {
|
||||||
|
// 反转checked状态
|
||||||
|
bean.checked.set(!bean.checked.get())
|
||||||
|
|
||||||
|
// 立即更新UI (图片自动切换)
|
||||||
|
binding.executePendingBindings()
|
||||||
|
}
|
||||||
|
|
||||||
// 整行点击跳转到开始计重页面
|
// 整行点击跳转到开始计重页面
|
||||||
binding.ll.setOnClickListener {
|
binding.ll.setOnClickListener {
|
||||||
|
|||||||
@@ -45,11 +45,11 @@ class GjcWeighingStartViewModel : BaseViewModel() {
|
|||||||
// 航班日期(格式化为字符串用于DataBinding)
|
// 航班日期(格式化为字符串用于DataBinding)
|
||||||
val flightDate = MutableLiveData<String>(DateUtils.getCurrentTime().formatDate())
|
val flightDate = MutableLiveData<String>(DateUtils.getCurrentTime().formatDate())
|
||||||
|
|
||||||
// 地磅集成
|
// 地磅集成(已改为手动输入,暂时注释)
|
||||||
val diBangModel = DiBangWeightModel()
|
// val diBangModel = DiBangWeightModel()
|
||||||
val channel = MutableLiveData("") // 通道号(用于控制地磅key)
|
val channel = MutableLiveData("") // 通道号
|
||||||
|
|
||||||
// 地磅称重显示
|
// 地磅称重显示(手动输入,单向同步到运抵重量)
|
||||||
val diBangWeight = MutableLiveData("0") // 地磅重量(右上角黄色显示区域)
|
val diBangWeight = MutableLiveData("0") // 地磅重量(右上角黄色显示区域)
|
||||||
|
|
||||||
// 可编辑字段(用于双向绑定)
|
// 可编辑字段(用于双向绑定)
|
||||||
@@ -78,15 +78,10 @@ class GjcWeighingStartViewModel : BaseViewModel() {
|
|||||||
// 获取传入的运单ID
|
// 获取传入的运单ID
|
||||||
maWbId = intent.getLongExtra(Constant.Key.MAWB_ID, 0)
|
maWbId = intent.getLongExtra(Constant.Key.MAWB_ID, 0)
|
||||||
|
|
||||||
// 监听地磅重量变化
|
// 监听地磅称重输入,单向同步到运抵重量
|
||||||
diBangModel.weight.observe(activity as LifecycleOwner) { weight ->
|
diBangWeight.observe(activity as LifecycleOwner) { weight ->
|
||||||
val w = weight?.toDoubleOrNull() ?: 0.0
|
// 同步到运抵重量(单向,不做反向同步)
|
||||||
diBangWeight.value = if (w > 0) String.format("%.0f", w) else "0"
|
arriveWeight.value = weight ?: "0"
|
||||||
}
|
|
||||||
|
|
||||||
// 监听通道号变化,设置地磅的key
|
|
||||||
channel.observe(activity as LifecycleOwner) {
|
|
||||||
diBangModel.key = it ?: ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监听运抵重量变化,自动计算运抵体积
|
// 监听运抵重量变化,自动计算运抵体积
|
||||||
@@ -415,6 +410,6 @@ class GjcWeighingStartViewModel : BaseViewModel() {
|
|||||||
*/
|
*/
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
diBangModel.cancelLooperGet()
|
// diBangModel.cancelLooperGet() // 已改为手动输入,不再使用地磅自动读取
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,22 +3,30 @@ package com.lukouguoji.gjc.viewModel
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.lukouguoji.gjc.R
|
import com.lukouguoji.gjc.R
|
||||||
import com.lukouguoji.gjc.activity.GjcWeighingRecordListActivity
|
import com.lukouguoji.gjc.activity.GjcWeighingRecordListActivity
|
||||||
import com.lukouguoji.gjc.activity.GjcWeighingStartActivity
|
import com.lukouguoji.gjc.activity.GjcWeighingStartActivity
|
||||||
import com.lukouguoji.gjc.holder.GjcWeighingViewHolder
|
import com.lukouguoji.gjc.holder.GjcWeighingViewHolder
|
||||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
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.Constant
|
||||||
|
import com.lukouguoji.module_base.common.ConstantEvent
|
||||||
import com.lukouguoji.module_base.http.net.NetApply
|
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.launchCollect
|
||||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||||
import com.lukouguoji.module_base.ktx.formatDate
|
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.showToast
|
||||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||||
import com.lukouguoji.module_base.model.ScanModel
|
import com.lukouguoji.module_base.model.ScanModel
|
||||||
import com.lukouguoji.module_base.util.DictUtils
|
import com.lukouguoji.module_base.util.DictUtils
|
||||||
import dev.utils.app.info.KeyValue
|
import dev.utils.app.info.KeyValue
|
||||||
import dev.utils.common.DateUtils
|
import dev.utils.common.DateUtils
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 国际出港计重 ViewModel
|
* 国际出港计重 ViewModel
|
||||||
@@ -45,6 +53,18 @@ class GjcWeighingViewModel : BasePageViewModel() {
|
|||||||
val totalPc = MutableLiveData("0") // 总件数
|
val totalPc = MutableLiveData("0") // 总件数
|
||||||
val totalWeight = 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())
|
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() {
|
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("提前运抵失败"))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -141,13 +141,36 @@
|
|||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingHorizontal="15dp">
|
android:paddingHorizontal="15dp">
|
||||||
|
|
||||||
|
<!-- 全选按钮 (图标+文字) -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:onClick="@{()-> viewModel.checkAllClick()}">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/checkIcon"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:src="@drawable/img_check_all" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="全选"
|
||||||
|
android:textColor="@color/bottom_tool_tips_text_color"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- 统计信息 -->
|
<!-- 统计信息 -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:paddingStart="20dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
@@ -153,13 +153,18 @@
|
|||||||
android:background="@drawable/bg_shouyun_dbzl"
|
android:background="@drawable/bg_shouyun_dbzl"
|
||||||
android:minHeight="60dp">
|
android:minHeight="60dp">
|
||||||
|
|
||||||
<TextView
|
<EditText
|
||||||
android:id="@+id/tvWeight"
|
android:id="@+id/etWeight"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:text="@{viewModel.diBangWeight}"
|
android:background="@null"
|
||||||
|
android:gravity="center"
|
||||||
|
android:hint="0"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:text="@={viewModel.diBangWeight}"
|
||||||
android:textColor="@color/text_red"
|
android:textColor="@color/text_red"
|
||||||
|
android:textColorHint="@color/text_red"
|
||||||
android:textSize="45sp"
|
android:textSize="45sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
tools:text="1655" />
|
tools:text="1655" />
|
||||||
@@ -167,11 +172,11 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignBaseline="@id/tvWeight"
|
android:layout_alignBaseline="@id/etWeight"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_toEndOf="@id/tvWeight"
|
android:layout_toEndOf="@id/etWeight"
|
||||||
android:text="kg"
|
android:text="kg"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/text_red"
|
||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
<variable
|
<variable
|
||||||
name="bean"
|
name="bean"
|
||||||
type="com.lukouguoji.module_base.bean.GjcWeighingBean" />
|
type="com.lukouguoji.module_base.bean.GjcWeighingBean" />
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="position"
|
||||||
|
type="int" />
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<androidx.appcompat.widget.LinearLayoutCompat
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
@@ -21,9 +25,10 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:padding="10dp">
|
android:padding="10dp">
|
||||||
|
|
||||||
<!-- 飞机图标 -->
|
<!-- 飞机图标 (根据checked状态切换图片) -->
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/iv_icon"
|
android:id="@+id/iv_icon"
|
||||||
|
loadImage="@{bean.checked.get() ? @drawable/img_plane_s : @drawable/img_plane}"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
|||||||
Reference in New Issue
Block a user