feat: 出港装载状态重置改为弹框选状态
参照出港运抵页面交互,「状态重置」按钮不再直接调接口, 而是先弹出居中弹框,让用户在下拉框选择「正常 / 未申报」后 点击「保存」再调接口;选「未申报」时请求体不带 restStatus。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package com.lukouguoji.gjc.dialog
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.DialogIntExpLoadResetBinding
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
/**
|
||||
* 国际出港装载 - 状态重置对话框
|
||||
*/
|
||||
class IntExpLoadResetDialogModel(
|
||||
private val callback: (IntExpLoadResetDialogModel) -> Unit
|
||||
) : BaseDialogModel<DialogIntExpLoadResetBinding>(DIALOG_TYPE_CENTER) {
|
||||
|
||||
val resetStatusList = MutableLiveData<List<KeyValue>>()
|
||||
val selectedResetStatus = MutableLiveData("")
|
||||
var resetStatusCode: String? = null
|
||||
|
||||
override fun layoutId(): Int = R.layout.dialog_int_exp_load_reset
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
initResetStatusList()
|
||||
selectedResetStatus.observeForever { value ->
|
||||
resetStatusCode = when (value) {
|
||||
"01" -> "01"
|
||||
"02" -> null
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initResetStatusList() {
|
||||
resetStatusList.value = listOf(
|
||||
KeyValue("正常", "01"),
|
||||
KeyValue("未申报", "02")
|
||||
)
|
||||
}
|
||||
|
||||
fun onSaveClick() {
|
||||
if (selectedResetStatus.value.verifyNullOrEmpty("请选择重置状态")) return
|
||||
dismiss()
|
||||
callback(this)
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.dialog.IntExpLoadDeleteDialogModel
|
||||
import com.lukouguoji.gjc.dialog.IntExpLoadResetDialogModel
|
||||
import com.lukouguoji.gjc.holder.IntExpLoadViewHolder
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GjcCheckInPage
|
||||
@@ -84,7 +85,7 @@ class IntExpLoadViewModel : BasePageViewModel() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态重置 (批量操作)
|
||||
* 状态重置 (批量操作) — 弹框选状态后调接口
|
||||
*/
|
||||
fun resetDeclare() {
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcExportLoad> ?: return
|
||||
@@ -95,18 +96,26 @@ class IntExpLoadViewModel : BasePageViewModel() {
|
||||
return
|
||||
}
|
||||
|
||||
val param = GjcDeclareParam(loadList = selectedItems)
|
||||
val requestData = param.toRequestBody()
|
||||
val dialog = IntExpLoadResetDialogModel { dialogModel ->
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"loadList" to selectedItems
|
||||
)
|
||||
if (dialogModel.resetStatusCode != null) {
|
||||
params["restStatus"] = dialogModel.resetStatusCode
|
||||
}
|
||||
val requestData = params.toRequestBody()
|
||||
|
||||
launchLoadingCollect({ NetApply.api.resetDeclare(requestData) }) {
|
||||
onSuccess = {
|
||||
showToast("状态重置成功")
|
||||
viewModelScope.launch {
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
|
||||
launchLoadingCollect({ NetApply.api.resetDeclare(requestData) }) {
|
||||
onSuccess = {
|
||||
showToast("状态重置成功")
|
||||
viewModelScope.launch {
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
87
module_gjc/src/main/res/layout/dialog_int_exp_load_reset.xml
Normal file
87
module_gjc/src/main/res/layout/dialog_int_exp_load_reset.xml
Normal file
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
<import type="com.lukouguoji.module_base.ui.weight.search.layout.SearchLayoutType"/>
|
||||
|
||||
<variable
|
||||
name="model"
|
||||
type="com.lukouguoji.gjc.dialog.IntExpLoadResetDialogModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="600dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_dialog_f2_radius_10"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/bg_primary_radius_top_10"
|
||||
android:gravity="center"
|
||||
android:text="状态重置"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<!-- 表单内容 -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="30dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- 重置状态 -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
completeSpace="@{5}"
|
||||
android:text="重置状态:"
|
||||
android:textColor="@color/text_normal"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<com.lukouguoji.module_base.ui.weight.search.layout.PadSearchLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
type="@{SearchLayoutType.SPINNER}"
|
||||
hint='@{"请选择重置状态"}'
|
||||
list="@{model.resetStatusList}"
|
||||
value="@={model.selectedResetStatus}" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40dp"
|
||||
android:layout_marginBottom="20dp">
|
||||
|
||||
<TextView
|
||||
style="@style/tv_bottom_btn"
|
||||
android:onClick="@{()->model.dismiss()}"
|
||||
android:text="取消" />
|
||||
|
||||
<TextView
|
||||
style="@style/tv_bottom_btn"
|
||||
android:onClick="@{()->model.onSaveClick()}"
|
||||
android:text="保存" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
Reference in New Issue
Block a user