feat: 国际出港 出港组装
This commit is contained in:
@@ -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("删除") { _, _ ->
|
||||
deleteSelectedItems(selectedItems)
|
||||
}
|
||||
.setNegativeButton("取消", null)
|
||||
.show()
|
||||
getTopActivity().showConfirmDialog("确定要删除选中的 ${selectedItems.size} 条记录吗?") {
|
||||
deleteSelectedItems(selectedItems)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除选中项
|
||||
*/
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user