feat: 国际进港舱单增删改查接口对齐及交互优化

- 新增/编辑接口切换至新路径,删除统一使用批量删除接口
- 新增模式下航班日期、航班号等字段可编辑,支持航班级联查询自动填充
- 编辑模式下从列表页传入航班日期和航班号进行回显
- 修复编辑模式标题显示错误、航班号大写限制、DATE类型hint不显示等问题

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 16:51:18 +08:00
parent 06d0244e24
commit 93939ed411
7 changed files with 129 additions and 44 deletions

View File

@@ -1254,21 +1254,21 @@ interface Api {
suspend fun getGjjManifestDetail(@Query("id") id: String): BaseResultBean<GjjManifestBean>
/**
* 删除-国际进-舱单-列表
* 批量删除-国际进舱单(请求体为 mfId 数组,如 [1,2,3]
*/
@POST("IntImpManiFest/deleteFestList")
suspend fun gjjManifestDelete(@Body data: RequestBody): BaseResultBean<Any>
suspend fun gjjManifestDeleteBatch(@Body data: RequestBody): BaseResultBean<Any>
/**
* 新增-国际进-舱单
* 新增-国际进舱单
*/
@POST("IntImpManiFest/saveFest")
@POST("IntImpManifest/addManifest")
suspend fun gjjManifestInsert(@Body data: RequestBody): BaseResultBean<Any>
/**
* 更新-国际进-舱单
* 修改-国际进舱单
*/
@POST("IntImpManiFest/updateFest")
@POST("IntImpManifest/modifyManifest")
suspend fun gjjManifestUpdate(@Body data: RequestBody): BaseResultBean<Any>
/**

View File

@@ -96,6 +96,7 @@ class PadDataLayoutNew : FrameLayout {
field = value
et.hint = value
tv.hint = value
bindAdapter(spinner, list, hint)
}

View File

@@ -11,6 +11,7 @@ import com.lukouguoji.module_base.base.BaseBindingActivity
import com.lukouguoji.module_base.common.Constant
import com.lukouguoji.module_base.common.DetailsPageType
import com.lukouguoji.module_base.ktx.noNull
import com.lukouguoji.module_base.ktx.setUpperCaseAlphanumericFilter
class GjjManifestAddActivity :
BaseBindingActivity<ActivityGjjManifestAddBinding, GjjManifestAddViewModel>() {
@@ -20,15 +21,16 @@ class GjjManifestAddActivity :
override fun viewModelClass() = GjjManifestAddViewModel::class.java
override fun initOnCreate(savedInstanceState: Bundle?) {
// 动态设置标题
val title = when {
viewModel.pageType.value == DetailsPageType.Modify -> "国际进港舱单编辑"
binding.viewModel = viewModel
binding.flightNoInput.et.setUpperCaseAlphanumericFilter()
viewModel.initOnCreated(intent)
// 动态设置标题(必须在 initOnCreated 之后pageType 已从 Intent 解析)
val title = when (viewModel.pageType.value) {
DetailsPageType.Modify -> "国际进港舱单编辑"
else -> "国际进港舱单新增"
}
setBackArrow(title)
binding.viewModel = viewModel
viewModel.initOnCreated(intent)
}
companion object {
@@ -49,10 +51,17 @@ class GjjManifestAddActivity :
* 编辑舱单通过Bean对象
*/
@JvmStatic
fun startForEdit(context: Context, bean: com.lukouguoji.module_base.bean.GjjManifest) {
fun startForEdit(
context: Context,
bean: com.lukouguoji.module_base.bean.GjjManifest,
flightDate: String = "",
flightNo: String = ""
) {
val starter = Intent(context, GjjManifestAddActivity::class.java)
.putExtra(Constant.Key.PAGE_TYPE, DetailsPageType.Modify.name)
.putExtra(Constant.Key.BEAN, bean)
.putExtra("flightDate", flightDate)
.putExtra("flightNo", flightNo)
context.startActivity(starter)
}

View File

@@ -44,6 +44,60 @@ class GjjManifestAddViewModel : BaseViewModel() {
// 运单号
val waybillNo = MutableLiveData("")
// ========== 航班级联查询 ==========
private var lastQueriedFlight = ""
fun onFlightDateInputComplete() {
lastQueriedFlight = ""
queryFlightIfReady()
}
fun onFlightNoInputComplete() {
queryFlightIfReady()
}
private fun queryFlightIfReady() {
val fdate = flightDate.value
val fno = flightNo.value
if (fdate.isNullOrEmpty() || fno.isNullOrEmpty()) return
val key = "$fdate-$fno"
if (key == lastQueriedFlight) return
lastQueriedFlight = key
launchCollect({
NetApply.api.getGjFlightBean(
mapOf(
"fdate" to fdate,
"fno" to fno,
"ieFlag" to "I",
).toRequestBody()
)
}) {
onSuccess = {
if (it.verifySuccess() && it.data != null) {
val flight = it.data!!
fid = flight.fid.noNull()
departure.value = flight.fdep.noNull()
destination.value = flight.fdest.noNull()
range.value = flight.range.noNull()
} else {
fid = ""
departure.value = ""
destination.value = ""
range.value = ""
showToast(it.msg.noNull("获取航班信息失败"))
}
}
onFailed = { _, _ ->
fid = ""
departure.value = ""
destination.value = ""
range.value = ""
}
}
}
// UN编号
val unNumber = MutableLiveData("")
@@ -146,6 +200,10 @@ class GjjManifestAddViewModel : BaseViewModel() {
// 编辑模式从Bean对象加载数据
if (pageType.value == DetailsPageType.Modify) {
// 回填航班日期和航班号Bean中不包含从列表页传入
flightDate.value = intent.getStringExtra("flightDate").noNull()
flightNo.value = intent.getStringExtra("flightNo").noNull()
val bean = intent.getSerializableExtra(Constant.Key.BEAN)
if (bean is com.lukouguoji.module_base.bean.GjjManifest) {
loadManifestFromBean(bean)
@@ -229,15 +287,14 @@ class GjjManifestAddViewModel : BaseViewModel() {
"mfId" to if (pageType.value == DetailsPageType.Modify) mfId else null,
"fid" to fid,
"wbNo" to waybillNo.value,
"agent" to agent.value,
"agentCode" to agent.value,
"spCode" to specialCode.value,
"businessType" to businessType.value,
"awbpc" to waybillNum.value,
"totalPc" to waybillNum.value,
"pc" to actualNum.value,
"weight" to actualWeight.value,
"planweight" to billingWeight.value,
"packagecode" to packageType.value,
"dep" to departure.value,
"cashWeight" to billingWeight.value,
"packageType" to packageType.value,
"origin" to departure.value,
"dest" to destination.value,
"goods" to goodsNameEn.value,

View File

@@ -266,7 +266,7 @@ class GjjManifestListViewModel : BasePageViewModel(), IOnItemClickListener {
private fun onDelete(list: List<GjjManifestBean>) {
showLoading()
launchCollect({
NetApply.api.gjjManifestDelete(
NetApply.api.gjjManifestDeleteBatch(
list.map { it.mfId }.toRequestBody()
)
}) {

View File

@@ -264,8 +264,12 @@ class IntImpManifestViewModel : BasePageViewModel() {
when (type) {
101 -> {
// 编辑传递整个Bean对象
GjjManifestAddActivity.startForEdit(getTopActivity(), bean)
// 编辑传递整个Bean对象 + 当前筛选的航班日期和航班号
GjjManifestAddActivity.startForEdit(
getTopActivity(), bean,
flightDate = flightDate.value ?: "",
flightNo = flightNo.value ?: ""
)
}
102 -> {
// 删除
@@ -279,28 +283,14 @@ class IntImpManifestViewModel : BasePageViewModel() {
}
/**
* 删除单个舱单
* 删除单个舱单(通过批量删除接口,传单元素数组)
*/
private fun deleteManifest(bean: GjjManifest) {
ConfirmDialogModel(
message = "确定要删除运单号 ${bean.getWaybillNo()} 的舱单吗?",
title = "提示"
) {
val params = mapOf("mfId" to bean.mfId).toRequestBody()
launchLoadingCollect({ NetApply.api.gjjManifestDelete(params) }) {
onSuccess = {
if (it.verifySuccess()) {
showToast("删除成功")
viewModelScope.launch {
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
}
refresh()
} else {
showToast(it.msg.noNull("删除失败"))
}
}
}
doDeleteByIds(listOf(bean.mfId))
}.show()
}
@@ -316,7 +306,32 @@ class IntImpManifestViewModel : BasePageViewModel() {
return
}
showToast("删除功能开发中")
ConfirmDialogModel(
message = "确定要删除选中的 ${selectedItems.size} 条舱单吗?",
title = "批量删除确认"
) {
doDeleteByIds(selectedItems.map { it.mfId })
}.show()
}
/**
* 执行批量删除(统一接口,请求体为 mfId 数组)
*/
private fun doDeleteByIds(mfIds: List<Long>) {
launchLoadingCollect({ NetApply.api.gjjManifestDeleteBatch(mfIds.toRequestBody()) }) {
onSuccess = {
if (it.verifySuccess()) {
showToast("删除成功")
isAllChecked.value = false
viewModelScope.launch {
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
}
refresh()
} else {
showToast(it.msg.noNull("删除失败"))
}
}
}
}
/**

View File

@@ -44,16 +44,17 @@
android:orientation="vertical"
android:padding="8dp">
<!-- 第1行航班日期、航班号、航程全部禁止编辑 -->
<!-- 第1行航班日期、航班号、航程新增可编辑,编辑禁止 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
enable="@{false}"
enable="@{viewModel.pageType == DetailsPageType.Add}"
hint='@{"请选择航班日期"}'
required="@{false}"
setRefreshCallBack="@{viewModel::onFlightDateInputComplete}"
title='@{"航班日期"}'
titleLength="@{5}"
type="@{DataLayoutType.DATE}"
@@ -63,9 +64,11 @@
android:layout_weight="1" />
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
enable="@{false}"
android:id="@+id/flightNoInput"
enable="@{viewModel.pageType == DetailsPageType.Add}"
hint='@{"请输入航班号"}'
required="@{false}"
setRefreshCallBack="@{viewModel::onFlightNoInputComplete}"
title='@{"航 班 号"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
@@ -76,7 +79,7 @@
android:layout_weight="1" />
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
enable="@{false}"
enable="@{viewModel.pageType == DetailsPageType.Add}"
hint='@{"请输入航程"}'
required="@{false}"
title='@{"航 程"}'
@@ -90,7 +93,7 @@
</LinearLayout>
<!-- 第2行运单号禁止编辑)、代理、特码 -->
<!-- 第2行运单号新增可编辑,编辑禁止)、代理、特码 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -98,7 +101,7 @@
android:orientation="horizontal">
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
enable="@{false}"
enable="@{viewModel.pageType == DetailsPageType.Add}"
hint='@{"请输入运单号"}'
required="@{false}"
title='@{"运 单 号"}'