feat: 国际出港 出港组装

This commit is contained in:
2026-01-21 13:51:58 +08:00
parent 0f1dbe4e05
commit 6b655348e1
4 changed files with 100 additions and 21 deletions

View File

@@ -588,10 +588,10 @@ interface Api {
/**
* 国际出港组装-删除记录
* 接口路径: /IntExpAssemble/delete
* @param ids ULD使用记录ID多个用逗号分隔
* @param data GjcUldUseBean数组
*/
@POST("IntExpAssemble/delete")
suspend fun deleteIntExpAssemble(@Query("ids") ids: String): BaseResultBean<SimpleResultBean>
suspend fun deleteIntExpAssemble(@Body data: RequestBody): BaseResultBean<Boolean>
/**
* 国际出港组装-回填重量

View File

@@ -36,6 +36,19 @@ class IntExpAssembleItemViewHolder(view: View) :
clickListener?.onItemClick(position, 1000) // type=1000表示展开操作
}
// ========== 侧滑菜单按钮点击事件 ==========
// 修改按钮
binding.btnEdit.setOnClickListener {
binding.swipeMenu.quickClose()
clickListener?.onItemClick(position, 2000) // type=2000表示修改操作
}
// 删除按钮
binding.btnDelete.setOnClickListener {
binding.swipeMenu.quickClose()
clickListener?.onItemClick(position, 2001) // type=2001表示删除操作
}
// ========== 初始化子列表 RecyclerView ==========
setCommonAdapter(
binding.rvSub,

View File

@@ -14,6 +14,7 @@ import com.lukouguoji.module_base.http.net.NetApply
import com.lukouguoji.module_base.ktx.commonAdapter
import com.lukouguoji.module_base.ktx.launchCollect
import com.lukouguoji.module_base.ktx.launchLoadingCollect
import com.lukouguoji.module_base.ktx.showConfirmDialog
import com.lukouguoji.module_base.ktx.showToast
import com.lukouguoji.module_base.ktx.toRequestBody
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
@@ -171,8 +172,49 @@ class IntExpAssembleViewModel : BasePageViewModel() {
* Item点击事件处理
*/
override fun onItemClick(position: Int, type: Int) {
if (type == 1000) { // 展开/收起操作
toggleExpand(position)
when (type) {
1000 -> toggleExpand(position) // 展开/收起操作
2000 -> onEditItem(position) // 修改操作
2001 -> onDeleteSingleItem(position) // 删除操作
}
}
/**
* 修改单个列表项 - 跳转到开始组装页面
*/
private fun onEditItem(position: Int) {
val bean = pageModel.rv?.commonAdapter()?.getItem(position) as? GjcUldUseBean ?: return
ARouter.getInstance()
.build(ARouterConstants.ACTIVITY_URL_INT_EXP_ASSEMBLE_START)
.withLong("useId", bean.useId)
.withString("uld", bean.uld)
.withString("fdate", bean.fdate)
.withString("fno", bean.fno)
.navigation()
}
/**
* 删除单个列表项(侧滑操作)
*/
private fun onDeleteSingleItem(position: Int) {
val bean = pageModel.rv?.commonAdapter()?.getItem(position) as? GjcUldUseBean ?: return
getTopActivity().showConfirmDialog("确定要删除该条记录吗?") {
deleteSingleItem(bean)
}
}
/**
* 执行单项删除
*/
private fun deleteSingleItem(bean: GjcUldUseBean) {
val requestData = listOf(bean).toRequestBody()
launchLoadingCollect({ NetApply.api.deleteIntExpAssemble(requestData) }) {
onSuccess = {
showToast("删除成功")
refresh()
}
}
}
@@ -202,24 +244,18 @@ class IntExpAssembleViewModel : BasePageViewModel() {
}
// 显示确认对话框
val activity = getTopActivity()
AlertDialog.Builder(activity)
.setTitle("删除确认")
.setMessage("确定要删除选中的 ${selectedItems.size} 条记录吗?")
.setPositiveButton("删除") { _, _ ->
getTopActivity().showConfirmDialog("确定要删除选中的 ${selectedItems.size} 条记录吗?") {
deleteSelectedItems(selectedItems)
}
.setNegativeButton("取消", null)
.show()
}
/**
* 删除选中项
*/
private fun deleteSelectedItems(items: List<GjcUldUseBean>) {
val ids = items.mapNotNull { it.useId }.joinToString(",")
val requestData = items.toRequestBody()
launchLoadingCollect({ NetApply.api.deleteIntExpAssemble(ids) }) {
launchLoadingCollect({ NetApply.api.deleteIntExpAssemble(requestData) }) {
onSuccess = {
showToast("删除成功")
refresh()

View File

@@ -22,6 +22,12 @@
android:layout_marginTop="10dp"
android:orientation="vertical">
<!-- 侧滑布局 -->
<com.mcxtzhang.swipemenulib.SwipeMenuLayout
android:id="@+id/swipe_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- 白色卡片 -->
<LinearLayout
android:layout_width="match_parent"
@@ -340,6 +346,30 @@
</LinearLayout>
<!-- 侧滑菜单区域 -->
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<!-- 修改按钮 -->
<TextView
android:id="@+id/btn_edit"
style="@style/tv_item_action"
android:background="@color/colorPrimary"
android:text="修改" />
<!-- 删除按钮 -->
<TextView
android:id="@+id/btn_delete"
style="@style/tv_item_action"
android:background="@color/red"
android:text="删除" />
</androidx.appcompat.widget.LinearLayoutCompat>
</com.mcxtzhang.swipemenulib.SwipeMenuLayout>
<!-- 子列表容器 -->
<LinearLayout
visible="@{bean.showMore}"