From a663609eeb96022b38dfbae0624df40f6d00a4c0 Mon Sep 17 00:00:00 2001 From: YANG JIANKUAN Date: Fri, 20 Mar 2026 15:18:56 +0800 Subject: [PATCH] feat: input required check --- .../gjj/viewModel/IntArrSupplementInfoViewModel.kt | 12 ++++++++++++ .../res/layout/activity_int_arr_supplement_info.xml | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntArrSupplementInfoViewModel.kt b/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntArrSupplementInfoViewModel.kt index 82fd336..7664973 100644 --- a/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntArrSupplementInfoViewModel.kt +++ b/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntArrSupplementInfoViewModel.kt @@ -13,6 +13,7 @@ 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 com.lukouguoji.module_base.ktx.verifyNullOrEmpty import dev.utils.app.info.KeyValue import kotlinx.coroutines.launch @@ -96,6 +97,17 @@ class IntArrSupplementInfoViewModel : BaseViewModel() { fun save() { val formBean = dataBean.value ?: return + // 收货人必填校验 + if (formBean.consigneeName.verifyNullOrEmpty("收货人名称不能为空")) return + if (formBean.consigneeCountryCode.verifyNullOrEmpty("收货人国家代码不能为空")) return + if (formBean.consigneeComType.verifyNullOrEmpty("收货人通讯方式不能为空")) return + if (formBean.consigneePNum.verifyNullOrEmpty("收货人联系号码不能为空")) return + // 发货人必填校验 + if (formBean.consignorName.verifyNullOrEmpty("发货人名称不能为空")) return + if (formBean.consignorCountryCode.verifyNullOrEmpty("发货人国家代码不能为空")) return + if (formBean.consignorComType.verifyNullOrEmpty("发货人通讯方式不能为空")) return + if (formBean.consignorPNum.verifyNullOrEmpty("发货人联系号码不能为空")) return + if (manifestList.isEmpty()) { showToast("无可保存的数据") return diff --git a/module_gjj/src/main/res/layout/activity_int_arr_supplement_info.xml b/module_gjj/src/main/res/layout/activity_int_arr_supplement_info.xml index 30a8fc1..594d3da 100644 --- a/module_gjj/src/main/res/layout/activity_int_arr_supplement_info.xml +++ b/module_gjj/src/main/res/layout/activity_int_arr_supplement_info.xml @@ -59,6 +59,7 @@ android:layout_weight="1" enable="@{true}" hint='@{"请输入名称"}' + required="@{true}" title='@{"名称"}' titleLength="@{5}" type="@{DataLayoutType.INPUT}" @@ -71,6 +72,7 @@ enable="@{true}" hint='@{"请选择国家代码"}' list="@{viewModel.countryCodeList}" + required="@{true}" title='@{"国家代码"}' titleLength="@{5}" type="@{DataLayoutType.SPINNER}" @@ -83,6 +85,7 @@ enable="@{true}" hint='@{"请选择通讯方式"}' list="@{viewModel.comTypeList}" + required="@{true}" title='@{"通讯方式"}' titleLength="@{5}" type="@{DataLayoutType.SPINNER}" @@ -103,6 +106,7 @@ android:layout_weight="1" enable="@{true}" hint='@{"请输入联系号码"}' + required="@{true}" title='@{"联系号码"}' titleLength="@{5}" type="@{DataLayoutType.INPUT}" @@ -154,6 +158,7 @@ android:layout_weight="1" enable="@{true}" hint='@{"请输入名称"}' + required="@{true}" title='@{"名称"}' titleLength="@{5}" type="@{DataLayoutType.INPUT}" @@ -166,6 +171,7 @@ enable="@{true}" hint='@{"请选择国家代码"}' list="@{viewModel.countryCodeList}" + required="@{true}" title='@{"国家代码"}' titleLength="@{5}" type="@{DataLayoutType.SPINNER}" @@ -178,6 +184,7 @@ enable="@{true}" hint='@{"请选择通讯方式"}' list="@{viewModel.comTypeList}" + required="@{true}" title='@{"通讯方式"}' titleLength="@{5}" type="@{DataLayoutType.SPINNER}" @@ -198,6 +205,7 @@ android:layout_weight="1" enable="@{true}" hint='@{"请输入联系号码"}' + required="@{true}" title='@{"联系号码"}' titleLength="@{5}" type="@{DataLayoutType.INPUT}"