feat: 国际进港理货报告四个操作按钮功能实现

实现人工放行、状态重置、删除理货、理货申报四个按钮的完整业务逻辑,
新增删除申报和状态重置弹框组件,对接后端API接口。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 12:44:19 +08:00
parent 43b1b6f44f
commit d31e78ff49
6 changed files with 479 additions and 20 deletions

View File

@@ -1902,6 +1902,30 @@ interface Api {
@POST("IntImpTally/listHaWb")
suspend fun getIntImpTallySubList(@Body data: RequestBody): BaseResultBean<List<GjjImportTally>>
/**
* 国际进港理货-人工放行
*/
@POST("IntImpTally/customCommand")
suspend fun intImpTallyCustomCommand(@Body data: RequestBody): BaseResultBean<Boolean>
/**
* 国际进港理货-状态重置
*/
@POST("IntImpTally/resetDeclare")
suspend fun intImpTallyResetDeclare(@Body data: RequestBody): BaseResultBean<Boolean>
/**
* 国际进港理货-删除申报
*/
@POST("IntImpTally/deleteDeclare")
suspend fun intImpTallyDeleteDeclare(@Body data: RequestBody): BaseResultBean<Boolean>
/**
* 国际进港理货-理货申报
*/
@POST("IntImpTally/declare")
suspend fun intImpTallyDeclare(@Body data: RequestBody): BaseResultBean<Boolean>
/**
* 国际进港舱单-货物发放
*/

View File

@@ -0,0 +1,58 @@
package com.lukouguoji.gjj.dialog
import android.content.Context
import androidx.lifecycle.MutableLiveData
import com.lukouguoji.gjj.R
import com.lukouguoji.gjj.databinding.DialogIntImpTallyDeleteBinding
import com.lukouguoji.module_base.base.BaseDialogModel
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
import dev.utils.app.info.KeyValue
/**
* 国际进港理货 - 删除申报对话框
*/
class IntImpTallyDeleteDialogModel(
val changeReasonList: List<KeyValue>, // 变更原因列表
private val callback: (IntImpTallyDeleteDialogModel) -> Unit
) : BaseDialogModel<DialogIntImpTallyDeleteBinding>(DIALOG_TYPE_CENTER) {
// 变更原因代码(存储的是 code
val changeReason = MutableLiveData("")
// 联系人姓名
val contactName = MutableLiveData("")
// 联系人电话
val contactPhone = MutableLiveData("")
override fun layoutId(): Int {
return R.layout.dialog_int_imp_tally_delete
}
override fun onDialogCreated(context: Context) {
binding.model = this
}
/**
* 确认按钮点击
*/
fun onConfirmClick() {
// 验证变更原因
if (changeReason.value.verifyNullOrEmpty("请选择变更原因")) {
return
}
// 验证联系人姓名
if (contactName.value.verifyNullOrEmpty("请输入联系人姓名")) {
return
}
// 验证联系人电话
if (contactPhone.value.verifyNullOrEmpty("请输入联系人电话")) {
return
}
dismiss()
callback(this)
}
}

View File

@@ -0,0 +1,66 @@
package com.lukouguoji.gjj.dialog
import android.content.Context
import androidx.lifecycle.MutableLiveData
import com.lukouguoji.gjj.R
import com.lukouguoji.gjj.databinding.DialogIntImpTallyResetBinding
import com.lukouguoji.module_base.base.BaseDialogModel
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
import dev.utils.app.info.KeyValue
/**
* 国际进港理货 - 状态重置对话框
*/
class IntImpTallyResetDialogModel(
private val callback: (IntImpTallyResetDialogModel) -> Unit
) : BaseDialogModel<DialogIntImpTallyResetBinding>(DIALOG_TYPE_CENTER) {
// 重置状态列表
val resetStatusList = MutableLiveData<List<KeyValue>>()
// 选中的重置状态存储的是value
val selectedResetStatus = MutableLiveData("")
// 重置状态code (传给后端的restStatus参数)
var resetStatusCode: String? = null
override fun layoutId(): Int {
return R.layout.dialog_int_imp_tally_reset
}
override fun onDialogCreated(context: Context) {
binding.model = this
initResetStatusList()
// 监听选择变化更新resetStatusCode
selectedResetStatus.observeForever { value ->
resetStatusCode = when (value) {
"01" -> "01" // 正常
"02" -> null // 未申报
else -> null
}
}
}
/**
* 初始化重置状态列表
*/
private fun initResetStatusList() {
val list = listOf(
KeyValue("正常", "01"),
KeyValue("未申报", "02")
)
resetStatusList.value = list
}
/**
* 保存按钮点击
*/
fun onSaveClick() {
if (selectedResetStatus.value.verifyNullOrEmpty("请选择重置状态")) {
return
}
dismiss()
callback(this)
}
}

View File

@@ -3,10 +3,13 @@ package com.lukouguoji.gjj.viewModel
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.lukouguoji.gjj.R
import com.lukouguoji.gjj.dialog.IntImpTallyDeleteDialogModel
import com.lukouguoji.gjj.dialog.IntImpTallyResetDialogModel
import dev.utils.common.DateUtils
import com.lukouguoji.module_base.ktx.formatDate
import com.lukouguoji.gjj.holder.IntImpTallyViewHolder
import com.lukouguoji.module_base.base.BasePageViewModel
import com.lukouguoji.module_base.bean.GjjDeclareParam
import com.lukouguoji.module_base.bean.GjjImportTally
import com.lukouguoji.module_base.common.Constant
import com.lukouguoji.module_base.common.ConstantEvent
@@ -94,63 +97,146 @@ class IntImpTallyViewModel : BasePageViewModel() {
}
/**
* 人工放行(暂不实现)
* 收集选中的主单和分单
*/
private fun getSelectedData(): Pair<List<GjjImportTally>, List<GjjImportTally>> {
val list = pageModel.rv?.commonAdapter()?.items as? List<GjjImportTally>
?: return Pair(emptyList(), emptyList())
val selectedMaWb = list.filter { it.isSelected }
val selectedHaWb = mutableListOf<GjjImportTally>()
list.forEach { maWb ->
maWb.haWbList?.forEach { haWb ->
if (haWb.isSelected) selectedHaWb.add(haWb)
}
}
return Pair(selectedMaWb, selectedHaWb)
}
/**
* 人工放行
*/
fun manualReleaseClick() {
val list = pageModel.rv?.commonAdapter()?.items as? List<GjjImportTally> ?: return
val selectedItems = list.filter { it.isSelected }
val (selectedMaWb, selectedHaWb) = getSelectedData()
if (selectedItems.isEmpty()) {
if (selectedMaWb.isEmpty() && selectedHaWb.isEmpty()) {
showToast("请选择要放行的记录")
return
}
showToast("人工放行功能开发中")
val param = GjjDeclareParam(
mtallyList = if (selectedMaWb.isNotEmpty()) selectedMaWb else null,
htallyList = if (selectedHaWb.isNotEmpty()) selectedHaWb else null
)
launchLoadingCollect({ NetApply.api.intImpTallyCustomCommand(param.toRequestBody()) }) {
onSuccess = {
showToast("人工放行成功")
viewModelScope.launch {
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
}
refresh()
}
}
}
/**
* 状态重置(暂不实现)
* 状态重置
*/
fun statusResetClick() {
val list = pageModel.rv?.commonAdapter()?.items as? List<GjjImportTally> ?: return
val selectedItems = list.filter { it.isSelected }
val (selectedMaWb, selectedHaWb) = getSelectedData()
if (selectedItems.isEmpty()) {
if (selectedMaWb.isEmpty() && selectedHaWb.isEmpty()) {
showToast("请选择要重置的记录")
return
}
showToast("状态重置功能开发中")
val dialog = IntImpTallyResetDialogModel { dialogModel ->
val param = GjjDeclareParam(
mtallyList = if (selectedMaWb.isNotEmpty()) selectedMaWb else null,
htallyList = if (selectedHaWb.isNotEmpty()) selectedHaWb else null,
restStatus = dialogModel.resetStatusCode
)
launchLoadingCollect({ NetApply.api.intImpTallyResetDeclare(param.toRequestBody()) }) {
onSuccess = {
showToast("状态重置成功")
viewModelScope.launch {
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
}
refresh()
}
}
}
dialog.show()
}
/**
* 删除理货(暂不实现)
* 删除理货
*/
fun deleteTallyClick() {
val list = pageModel.rv?.commonAdapter()?.items as? List<GjjImportTally> ?: return
val selectedItems = list.filter { it.isSelected }
val (selectedMaWb, selectedHaWb) = getSelectedData()
if (selectedItems.isEmpty()) {
if (selectedMaWb.isEmpty() && selectedHaWb.isEmpty()) {
showToast("请选择要删除的记录")
return
}
showToast("删除理货功能开发中")
// 从接口获取删除原因列表
launchLoadingCollect({ NetApply.api.getDelReasonList() }) {
onSuccess = { result ->
val changeReasonList = result.data?.map { it.toKeyValue() } ?: emptyList()
val dialog = IntImpTallyDeleteDialogModel(changeReasonList) { dialogModel ->
val param = GjjDeclareParam(
dcode = dialogModel.changeReason.value ?: "",
dcontactsName = dialogModel.contactName.value ?: "",
dcontactsTel = dialogModel.contactPhone.value ?: "",
mtallyList = if (selectedMaWb.isNotEmpty()) selectedMaWb else null,
htallyList = if (selectedHaWb.isNotEmpty()) selectedHaWb else null
)
launchLoadingCollect({ NetApply.api.intImpTallyDeleteDeclare(param.toRequestBody()) }) {
onSuccess = {
showToast("删除申报成功")
viewModelScope.launch {
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
}
refresh()
}
}
}
dialog.show()
}
}
}
/**
* 理货申报(暂不实现)
* 理货申报
*/
fun tallyDeclareClick() {
val list = pageModel.rv?.commonAdapter()?.items as? List<GjjImportTally> ?: return
val selectedItems = list.filter { it.isSelected }
val (selectedMaWb, selectedHaWb) = getSelectedData()
if (selectedItems.isEmpty()) {
if (selectedMaWb.isEmpty() && selectedHaWb.isEmpty()) {
showToast("请选择要申报的记录")
return
}
showToast("理货申报功能开发中")
val param = GjjDeclareParam(
mtallyList = if (selectedMaWb.isNotEmpty()) selectedMaWb else null,
htallyList = if (selectedHaWb.isNotEmpty()) selectedHaWb else null
)
launchLoadingCollect({ NetApply.api.intImpTallyDeclare(param.toRequestBody()) }) {
onSuccess = {
showToast("理货申报成功")
viewModelScope.launch {
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
}
refresh()
}
}
}
/**

View File

@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<import type="com.lukouguoji.module_base.ui.weight.search.layout.SearchLayoutType"/>
<variable
name="model"
type="com.lukouguoji.gjj.dialog.IntImpTallyDeleteDialogModel" />
</data>
<LinearLayout
android:layout_width="600dp"
android:layout_height="wrap_content"
android:background="@drawable/bg_dialog_f2_radius_10"
android:gravity="center_horizontal"
android:orientation="vertical">
<!-- 标题栏 -->
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/bg_primary_radius_top_10"
android:gravity="center"
android:text="删除原因"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<!-- 表单内容 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="30dp"
android:layout_marginTop="30dp"
android:orientation="vertical">
<!-- 变更原因 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="变更原因:"
completeSpace="@{6}"
android:textColor="@color/text_normal"
android:textSize="16sp" />
<com.lukouguoji.module_base.ui.weight.search.layout.PadSearchLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
type="@{SearchLayoutType.SPINNER}"
list="@{model.changeReasonList}"
value="@={model.changeReason}" />
</LinearLayout>
<!-- 联系人姓名 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="联系人姓名:"
completeSpace="@{6}"
android:textColor="@color/text_normal"
android:textSize="16sp" />
<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="@={model.contactName}" />
</LinearLayout>
<!-- 联系人电话 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="联系人电话:"
completeSpace="@{6}"
android:textColor="@color/text_normal"
android:textSize="16sp" />
<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="@={model.contactPhone}" />
</LinearLayout>
</LinearLayout>
<!-- 底部按钮 -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:layout_marginBottom="20dp">
<TextView
style="@style/tv_bottom_btn"
android:onClick="@{()->model.dismiss()}"
android:text="取消" />
<TextView
style="@style/tv_bottom_btn"
android:onClick="@{()->model.onConfirmClick()}"
android:text="保存" />
</LinearLayout>
</LinearLayout>
</layout>

View File

@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<import type="com.lukouguoji.module_base.ui.weight.search.layout.SearchLayoutType"/>
<variable
name="model"
type="com.lukouguoji.gjj.dialog.IntImpTallyResetDialogModel" />
</data>
<LinearLayout
android:layout_width="600dp"
android:layout_height="wrap_content"
android:background="@drawable/bg_dialog_f2_radius_10"
android:gravity="center_horizontal"
android:orientation="vertical">
<!-- 标题栏 -->
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/bg_primary_radius_top_10"
android:gravity="center"
android:text="状态重置"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<!-- 表单内容 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="30dp"
android:layout_marginTop="30dp"
android:orientation="vertical">
<!-- 重置状态 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
completeSpace="@{5}"
android:text="重置状态:"
android:textColor="@color/text_normal"
android:textSize="16sp" />
<com.lukouguoji.module_base.ui.weight.search.layout.PadSearchLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
type="@{SearchLayoutType.SPINNER}"
hint='@{"请选择重置状态"}'
list="@{model.resetStatusList}"
value="@={model.selectedResetStatus}" />
</LinearLayout>
</LinearLayout>
<!-- 底部按钮 -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:layout_marginBottom="20dp">
<TextView
style="@style/tv_bottom_btn"
android:onClick="@{()->model.dismiss()}"
android:text="取消" />
<TextView
style="@style/tv_bottom_btn"
android:onClick="@{()->model.onSaveClick()}"
android:text="保存" />
</LinearLayout>
</LinearLayout>
</layout>