feat: 国际出港 出港运抵 状态重置
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package com.lukouguoji.gjc.dialog
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.DialogIntExpArriveResetBinding
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
/**
|
||||
* 国际出港运抵 - 状态重置对话框
|
||||
*/
|
||||
class IntExpArriveResetDialogModel(
|
||||
private val callback: (IntExpArriveResetDialogModel) -> Unit
|
||||
) : BaseDialogModel<DialogIntExpArriveResetBinding>(DIALOG_TYPE_CENTER) {
|
||||
|
||||
// 重置状态列表
|
||||
val resetStatusList = MutableLiveData<List<KeyValue>>()
|
||||
|
||||
// 选中的重置状态(存储的是value)
|
||||
val selectedResetStatus = MutableLiveData("")
|
||||
|
||||
// 重置状态code (传给后端的restStatus参数)
|
||||
var resetStatusCode: String? = null
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_int_exp_arrive_reset
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
initResetStatusList()
|
||||
|
||||
// 监听选择变化,更新resetStatusCode
|
||||
selectedResetStatus.observeForever { value ->
|
||||
resetStatusCode = when (value) {
|
||||
"01" -> "01" // 正常
|
||||
"02" -> null // 未申报
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化重置状态列表
|
||||
*/
|
||||
private fun initResetStatusList() {
|
||||
val list = listOf(
|
||||
KeyValue("正常", "01"),
|
||||
KeyValue("未申报", "02")
|
||||
)
|
||||
resetStatusList.value = list
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存按钮点击
|
||||
*/
|
||||
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.IntExpArriveDeleteDialogModel
|
||||
import com.lukouguoji.gjc.dialog.IntExpArriveResetDialogModel
|
||||
import com.lukouguoji.gjc.holder.IntExpArriveViewHolder
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GjcDeclareParam
|
||||
@@ -131,17 +132,32 @@ class IntExpArriveViewModel : BasePageViewModel() {
|
||||
return
|
||||
}
|
||||
|
||||
val requestData = mapOf("maWbList" to selectedItems).toRequestBody()
|
||||
// 创建并显示弹框
|
||||
val dialog = IntExpArriveResetDialogModel { dialogModel ->
|
||||
// 弹框确认后的回调
|
||||
val params = mutableMapOf<String, Any?>("maWbList" to selectedItems)
|
||||
|
||||
launchLoadingCollect({ NetApply.api.resetArriveDeclare(requestData) }) {
|
||||
onSuccess = {
|
||||
showToast("状态重置成功")
|
||||
viewModelScope.launch {
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
|
||||
// 根据选择添加restStatus参数
|
||||
// 选择"正常"时传递 "01",选择"未申报"时不传递此参数
|
||||
if (dialogModel.resetStatusCode != null) {
|
||||
params["restStatus"] = dialogModel.resetStatusCode
|
||||
}
|
||||
|
||||
val requestData = params.toRequestBody()
|
||||
|
||||
// 调用重置接口
|
||||
launchLoadingCollect({ NetApply.api.resetArriveDeclare(requestData) }) {
|
||||
onSuccess = {
|
||||
showToast("状态重置成功")
|
||||
viewModelScope.launch {
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.IntExpArriveResetDialogModel" />
|
||||
|
||||
</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