feat: 国际进港舱单主分单独立选择及分离删除接口

主分单选择解除联动,删除操作使用独立接口,先删分单再删主单

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-01 18:23:20 +08:00
parent 43acf0a2de
commit 936af73ec0
5 changed files with 64 additions and 42 deletions

View File

@@ -116,7 +116,10 @@
"Bash(echo \"exit:$?\")", "Bash(echo \"exit:$?\")",
"mcp__apifox__read_project_oas_j7j64k", "mcp__apifox__read_project_oas_j7j64k",
"mcp__apifox__read_project_oas_ref_resources_j7j64k", "mcp__apifox__read_project_oas_ref_resources_j7j64k",
"mcp__apifox__read_project_oas_ruugy8" "mcp__apifox__read_project_oas_ruugy8",
"mcp__apifox__read_project_oas_ref_resources_ldmedm",
"mcp__apifox__read_project_oas_ldmedm",
"mcp__apifox__refresh_project_oas_ldmedm"
], ],
"deny": [], "deny": [],
"ask": [] "ask": []

View File

@@ -1280,6 +1280,18 @@ interface Api {
@POST("IntImpManiFest/deleteFestList") @POST("IntImpManiFest/deleteFestList")
suspend fun gjjManifestDeleteBatch(@Body data: RequestBody): BaseResultBean<Any> suspend fun gjjManifestDeleteBatch(@Body data: RequestBody): BaseResultBean<Any>
/**
* 删除舱单(主单)- 请求体为 GjjManifest 对象数组
*/
@POST("IntImpManifest/deleteManifest")
suspend fun intImpManifestDeleteManifest(@Body data: RequestBody): BaseResultBean<Any>
/**
* 删除分单 - 请求体为 GjjHaWb 对象数组
*/
@POST("IntImpManifest/deleteHawb")
suspend fun intImpManifestDeleteHawb(@Body data: RequestBody): BaseResultBean<Any>
/** /**
* 新增-国际进港舱单 * 新增-国际进港舱单
*/ */

View File

@@ -1,11 +1,9 @@
package com.lukouguoji.gjj.holder package com.lukouguoji.gjj.holder
import android.view.View import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.lukouguoji.gjj.databinding.ItemIntImpManifestSubBinding import com.lukouguoji.gjj.databinding.ItemIntImpManifestSubBinding
import com.lukouguoji.module_base.base.BaseViewHolder import com.lukouguoji.module_base.base.BaseViewHolder
import com.lukouguoji.module_base.bean.GjjHaWb import com.lukouguoji.module_base.bean.GjjHaWb
import com.lukouguoji.module_base.bean.GjjManifest
/** /**
* 国际进港舱单 - 分单子列表 ViewHolder * 国际进港舱单 - 分单子列表 ViewHolder
@@ -24,13 +22,6 @@ class IntImpManifestSubViewHolder(view: View) :
val newCheckedState = !bean.checked.get() val newCheckedState = !bean.checked.get()
bean.checked.set(newCheckedState) bean.checked.set(newCheckedState)
binding.executePendingBindings() binding.executePendingBindings()
// 反向联动主列表项(勾选子项时自动勾选父项)
if (newCheckedState) {
val recyclerView = itemView.parent as? RecyclerView ?: return@setOnClickListener
val parentBean = recyclerView.tag as? GjjManifest ?: return@setOnClickListener
parentBean.checked.set(true)
}
} }
} }
} }

View File

@@ -25,10 +25,7 @@ class IntImpManifestViewHolder(view: View) :
binding.ivIcon.setOnClickListener { binding.ivIcon.setOnClickListener {
val newCheckedState = !bean.checked.get() val newCheckedState = !bean.checked.get()
bean.checked.set(newCheckedState) bean.checked.set(newCheckedState)
// 联动子列表选中状态
bean.haWbList?.forEach { sub -> sub.checked.set(newCheckedState) }
binding.executePendingBindings() binding.executePendingBindings()
binding.rvSub.adapter?.notifyDataSetChanged()
} }
// 整卡点击 - 跳转详情页 // 整卡点击 - 跳转详情页

View File

@@ -9,6 +9,7 @@ import com.lukouguoji.gjj.activity.GjjManifestAddActivity
import com.lukouguoji.gjj.activity.IntImpManifestSubEditActivity import com.lukouguoji.gjj.activity.IntImpManifestSubEditActivity
import com.lukouguoji.gjj.holder.IntImpManifestViewHolder import com.lukouguoji.gjj.holder.IntImpManifestViewHolder
import com.lukouguoji.module_base.base.BasePageViewModel import com.lukouguoji.module_base.base.BasePageViewModel
import com.lukouguoji.module_base.bean.GjjHaWb
import com.lukouguoji.module_base.bean.GjjManifest import com.lukouguoji.module_base.bean.GjjManifest
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.common.ConstantEvent
@@ -121,18 +122,6 @@ class IntImpManifestViewModel : BasePageViewModel() {
// ========== 分单管理模式 ========== // ========== 分单管理模式 ==========
val isSubManagementMode = MutableLiveData(false) val isSubManagementMode = MutableLiveData(false)
init {
// 监听全选状态,自动更新所有列表项(联动子列表)
isAllChecked.observeForever { checked ->
val list = pageModel.rv?.commonAdapter()?.items as? List<GjjManifest> ?: return@observeForever
list.forEach {
it.checked.set(checked)
it.haWbList?.forEach { sub -> sub.checked.set(checked) }
}
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
}
}
// ========== 适配器配置 ========== // ========== 适配器配置 ==========
val itemViewHolder = IntImpManifestViewHolder::class.java val itemViewHolder = IntImpManifestViewHolder::class.java
val itemLayoutId = R.layout.item_int_imp_manifest val itemLayoutId = R.layout.item_int_imp_manifest
@@ -312,7 +301,7 @@ class IntImpManifestViewModel : BasePageViewModel() {
message = "确定要删除运单号 ${bean.getWaybillNo()} 的舱单吗?", message = "确定要删除运单号 ${bean.getWaybillNo()} 的舱单吗?",
title = "提示" title = "提示"
) { ) {
doDeleteByIds(listOf(bean.mfId)) doDelete(listOf(bean), emptyList())
}.show() }.show()
} }
@@ -321,37 +310,67 @@ class IntImpManifestViewModel : BasePageViewModel() {
*/ */
fun onDeleteClick() { fun onDeleteClick() {
val list = pageModel.rv?.commonAdapter()?.items as? List<GjjManifest> ?: return val list = pageModel.rv?.commonAdapter()?.items as? List<GjjManifest> ?: return
val selectedItems = list.filter { it.isSelected }
if (selectedItems.isEmpty()) { val selectedManifests = list.filter { it.isSelected }
val selectedHawbs = list.flatMap { it.haWbList?.filter { hawb -> hawb.isSelected } ?: emptyList() }
if (selectedManifests.isEmpty() && selectedHawbs.isEmpty()) {
showToast("请选择要删除的记录") showToast("请选择要删除的记录")
return return
} }
// 构建确认提示信息
val msgParts = mutableListOf<String>()
if (selectedManifests.isNotEmpty()) {
msgParts.add("${selectedManifests.size} 条主单")
}
if (selectedHawbs.isNotEmpty()) {
msgParts.add("${selectedHawbs.size} 条分单")
}
ConfirmDialogModel( ConfirmDialogModel(
message = "确定要删除选中的 ${selectedItems.size} 条舱单吗?", message = "确定要删除选中的 ${msgParts.joinToString("和")} 吗?",
title = "批量删除确认" title = "批量删除确认"
) { ) {
doDeleteByIds(selectedItems.map { it.mfId }) doDelete(selectedManifests, selectedHawbs)
}.show() }.show()
} }
/** /**
* 执行批量删除(统一接口,请求体为 mfId 数组 * 执行删除:先删分单,再删主单(串行执行
*/ */
private fun doDeleteByIds(mfIds: List<Long>) { private fun doDelete(manifests: List<GjjManifest>, hawbs: List<GjjHaWb>) {
launchLoadingCollect({ NetApply.api.gjjManifestDeleteBatch(mfIds.toRequestBody()) }) { viewModelScope.launch {
onSuccess = { try {
if (it.verifySuccess()) { showLoading()
// 第一步:删除分单(如果有选中的分单)
if (hawbs.isNotEmpty()) {
val hawbResult = NetApply.api.intImpManifestDeleteHawb(hawbs.toRequestBody())
if (!hawbResult.verifySuccess()) {
showToast(hawbResult.msg.noNull("分单删除失败"))
refresh()
return@launch
}
}
// 第二步:删除主单(分单删除成功后才执行)
if (manifests.isNotEmpty()) {
val manifestResult = NetApply.api.intImpManifestDeleteManifest(manifests.toRequestBody())
if (!manifestResult.verifySuccess()) {
showToast(manifestResult.msg.noNull("分单已删除,但主单删除失败"))
refresh()
return@launch
}
}
showToast("删除成功") showToast("删除成功")
isAllChecked.value = false isAllChecked.value = false
viewModelScope.launch {
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh") FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
} } catch (e: Exception) {
refresh() showToast("删除失败:${e.message}")
} else { } finally {
showToast(it.msg.noNull("删除失败")) dismissLoading()
}
} }
} }
} }