fix: 国际进港原始舱单补充信息改为批量保存模式

回滚列表项侧滑菜单,改为多选后点底部按钮进入补充信息页;
表单信息批量复制到所有选中单据后调用 complete 接口提交数组。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 13:35:23 +08:00
parent 9406047a57
commit d0c7207b5a
6 changed files with 119 additions and 19 deletions

View File

@@ -32,9 +32,9 @@ class IntArrSupplementInfoActivity :
companion object {
@JvmStatic
fun start(context: Context, manifest: GjjImportManifest) {
fun start(context: Context, manifestList: ArrayList<GjjImportManifest>) {
val starter = Intent(context, IntArrSupplementInfoActivity::class.java)
.putExtra(Constant.Key.DATA, manifest)
.putExtra(Constant.Key.DATA, manifestList)
context.startActivity(starter)
}
}

View File

@@ -1,7 +1,6 @@
package com.lukouguoji.gjj.holder
import android.view.View
import com.lukouguoji.gjj.R
import com.lukouguoji.gjj.databinding.ItemIntArrAirManifestBinding
import com.lukouguoji.module_base.base.BaseViewHolder
import com.lukouguoji.module_base.bean.GjjAirManifest

View File

@@ -140,13 +140,14 @@ class IntArrAirManifestViewModel : BasePageViewModel() {
return
}
// 获取第一个选中项的主单数据
val manifest = selectedItems.firstOrNull()?.maWb ?: return
// 收集所有选中项的主单数据
val manifestList = ArrayList(selectedItems.mapNotNull { it.maWb })
if (manifestList.isEmpty()) return
// 跳转到补充信息页面
// 跳转到补充信息页面(传递完整列表)
com.lukouguoji.gjj.activity.IntArrSupplementInfoActivity.start(
getTopActivity(),
manifest
manifestList
)
}

View File

@@ -2,43 +2,133 @@ package com.lukouguoji.gjj.viewModel
import android.content.Intent
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.lukouguoji.module_base.base.BaseViewModel
import com.lukouguoji.module_base.bean.GjjImportManifest
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.launchCollect
import com.lukouguoji.module_base.ktx.launchLoadingCollect
import com.lukouguoji.module_base.ktx.showToast
import com.lukouguoji.module_base.ktx.toRequestBody
import dev.utils.app.info.KeyValue
import kotlinx.coroutines.launch
/**
* 国际进港补充信息 ViewModel
*/
class IntArrSupplementInfoViewModel : BaseViewModel() {
// 数据对象
// 表单编辑用数据对象
val dataBean = MutableLiveData<GjjImportManifest>()
// 所有选中的 manifest 列表(用于批量保存)
private var manifestList: List<GjjImportManifest> = emptyList()
// 国家代码下拉列表
val countryCodeList = MutableLiveData<List<KeyValue>>(emptyList())
// 通讯方式下拉列表
val comTypeList = MutableLiveData<List<KeyValue>>(emptyList())
/**
* 初始化数据
*/
@Suppress("UNCHECKED_CAST")
fun initOnCreated(intent: Intent) {
val manifest = intent.getSerializableExtra(Constant.Key.DATA) as? GjjImportManifest
if (manifest != null) {
dataBean.value = manifest
val list = intent.getSerializableExtra(Constant.Key.DATA) as? ArrayList<GjjImportManifest>
if (!list.isNullOrEmpty()) {
manifestList = list
// 取首个填充表单,让用户看到已有数据
dataBean.value = list.first().copy()
} else {
dataBean.value = GjjImportManifest()
}
// 加载下拉列表
loadCountryCodeList()
loadComTypeList()
}
/**
* 加载国家代码下拉列表
*/
private fun loadCountryCodeList() {
launchCollect({ NetApply.api.getAreaTypeList() }) {
onSuccess = { result ->
val keyValueList = result.data?.mapNotNull { bean ->
if (bean.code != null && bean.name != null) {
KeyValue(bean.name, bean.code)
} else null
} ?: emptyList()
countryCodeList.value = keyValueList
}
}
}
/**
* 取消按钮点击 - 暂不实现
* 加载通讯方式下拉列表(本地固定值)
*/
private fun loadComTypeList() {
comTypeList.value = listOf(
KeyValue("电话TE", "TE"),
KeyValue("传真FX", "FX")
)
}
/**
* 取消按钮点击
*/
fun cancel() {
showToast("取消功能暂未实现")
getTopActivity().finish()
}
/**
* 保存按钮点击 - 暂不实现
* 保存按钮点击 - 将表单信息复制到所有选中项,批量提交
*/
fun save() {
showToast("保存功能暂未实现")
val formBean = dataBean.value ?: return
if (manifestList.isEmpty()) {
showToast("无可保存的数据")
return
}
// 将表单中的收发货人+危险品字段复制到每个 manifest
val updatedList = manifestList.map { manifest ->
manifest.copy(
// 收货人信息
consigneeName = formBean.consigneeName,
consigneeCountryCode = formBean.consigneeCountryCode,
consigneeComType = formBean.consigneeComType,
consigneePNum = formBean.consigneePNum,
consigneeAddress = formBean.consigneeAddress,
// 发货人信息
consignorName = formBean.consignorName,
consignorCountryCode = formBean.consignorCountryCode,
consignorComType = formBean.consignorComType,
consignorPNum = formBean.consignorPNum,
consignorAddress = formBean.consignorAddress,
// 危险品信息
dgrContactMame = formBean.dgrContactMame,
dgrContactNumber = formBean.dgrContactNumber,
unNumber = formBean.unNumber
)
}
// 拼装成数组提交
launchLoadingCollect({
NetApply.api.completeIntArrManifest(updatedList.toRequestBody())
}) {
onSuccess = {
showToast("保存成功")
viewModelScope.launch {
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
}
getTopActivity().finish()
}
}
}
}

View File

@@ -70,9 +70,10 @@
android:layout_weight="1"
enable="@{true}"
hint='@{"请选择国家代码"}'
list="@{viewModel.countryCodeList}"
title='@{"国家代码"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
type="@{DataLayoutType.SPINNER}"
value='@={viewModel.dataBean.consigneeCountryCode}' />
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
@@ -81,9 +82,10 @@
android:layout_weight="1"
enable="@{true}"
hint='@{"请选择通讯方式"}'
list="@{viewModel.comTypeList}"
title='@{"通讯方式"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
type="@{DataLayoutType.SPINNER}"
value='@={viewModel.dataBean.consigneeComType}' />
</LinearLayout>
@@ -163,9 +165,10 @@
android:layout_weight="1"
enable="@{true}"
hint='@{"请选择国家代码"}'
list="@{viewModel.countryCodeList}"
title='@{"国家代码"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
type="@{DataLayoutType.SPINNER}"
value='@={viewModel.dataBean.consignorCountryCode}' />
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
@@ -174,9 +177,10 @@
android:layout_weight="1"
enable="@{true}"
hint='@{"请选择通讯方式"}'
list="@{viewModel.comTypeList}"
title='@{"通讯方式"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
type="@{DataLayoutType.SPINNER}"
value='@={viewModel.dataBean.consignorComType}' />
</LinearLayout>