From c7bf51bd9aa994ba3675655e91f1ee250ea529e1 Mon Sep 17 00:00:00 2001 From: YANG JIANKUAN Date: Sun, 22 Mar 2026 22:28:40 +0800 Subject: [PATCH] feat: visa --- .../ui/weight/data/layout/DataLayoutKtx.kt | 218 +++++++++--------- .../ui/weight/data/layout/PadDataLayout.kt | 5 + .../ui/weight/data/layout/PadDataLayoutNew.kt | 5 + .../src/main/res/layout/item_image_select.xml | 6 +- .../IntImpAccidentVisaEditActivity.kt | 6 + .../IntImpAccidentVisaEditViewModel.kt | 9 + .../activity_int_imp_accident_visa_edit.xml | 4 + 7 files changed, 143 insertions(+), 110 deletions(-) diff --git a/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/DataLayoutKtx.kt b/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/DataLayoutKtx.kt index 647a989..2ebc5e5 100644 --- a/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/DataLayoutKtx.kt +++ b/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/DataLayoutKtx.kt @@ -47,7 +47,9 @@ fun setDataLayoutData( hint?.let { dataLayout.hint = hint } - dataLayout.icon = icon + icon?.let { + dataLayout.icon = it + } } @@ -189,7 +191,9 @@ fun setDataLayoutDataNew( hint?.let { dataLayout.hint = hint } - dataLayout.icon = icon + icon?.let { + dataLayout.icon = it + } } @@ -293,108 +297,108 @@ fun setTextAllCapsNew(layout: PadDataLayoutNew, textAllCaps: Boolean) { } else { layout.et.filters = emptyArray() } -} -// ========== 自动查询功能 BindingAdapter(新增) ========== - -/** - * 启用自动查询功能 - * @param enabled 是否启用 - */ -@BindingAdapter("autoQueryEnabled") -fun setAutoQueryEnabled(layout: PadDataLayoutNew, enabled: Boolean) { - layout.autoQueryConfig.enabled = enabled -} - -/** - * 设置查询接口地址 - * @param url 接口地址(如:/IntExpCheckIn/checked/queryWbNoList) - */ -@BindingAdapter("autoQueryUrl") -fun setAutoQueryUrl(layout: PadDataLayoutNew, url: String?) { - layout.autoQueryConfig.url = url ?: "" -} - -/** - * 设置查询参数的 key 名称 - * @param paramKey 参数名(默认 "value") - */ -@BindingAdapter("autoQueryParamKey") -fun setAutoQueryParamKey(layout: PadDataLayoutNew, paramKey: String?) { - layout.autoQueryConfig.paramKey = paramKey ?: "value" -} - -/** - * 设置触发查询的最小长度 - * @param minLength 最小长度(默认 4) - */ -@BindingAdapter("autoQueryMinLength") -fun setAutoQueryMinLength(layout: PadDataLayoutNew, minLength: Int?) { - layout.autoQueryConfig.minLength = minLength ?: 4 -} - -/** - * 设置触发查询的最大长度 - * @param maxLength 最大长度(默认 8) - */ -@BindingAdapter("autoQueryMaxLength") -fun setAutoQueryMaxLength(layout: PadDataLayoutNew, maxLength: Int?) { - layout.autoQueryConfig.maxLength = maxLength ?: 8 -} - -/** - * 设置弹框标题 - * @param title 标题(默认 "请选择") - */ -@BindingAdapter("autoQueryTitle") -fun setAutoQueryTitle(layout: PadDataLayoutNew, title: String?) { - layout.autoQueryConfig.title = title ?: "请选择" -} - -/** - * 设置防抖延迟 - * @param debounceMillis 延迟毫秒数(默认 300ms) - */ -@BindingAdapter("autoQueryDebounce") -fun setAutoQueryDebounce(layout: PadDataLayoutNew, debounceMillis: Long?) { - layout.autoQueryConfig.debounceMillis = debounceMillis ?: 300L -} - -/** - * 统一配置自动查询(所有属性设置完成后调用) - * - * ⚠️ 重要:必须在所有 autoQuery* 属性之后绑定,使用 requireAll = false - */ -@BindingAdapter( - "autoQueryEnabled", - "autoQueryUrl", - "autoQueryParamKey", - "autoQueryMinLength", - "autoQueryMaxLength", - "autoQueryTitle", - "autoQueryDebounce", - requireAll = false -) -fun configureAutoQuery( - layout: PadDataLayoutNew, - enabled: Boolean?, - url: String?, - paramKey: String?, - minLength: Int?, - maxLength: Int?, - title: String?, - debounceMillis: Long? -) { - // 应用所有配置 - enabled?.let { layout.autoQueryConfig.enabled = it } - url?.let { layout.autoQueryConfig.url = it } - paramKey?.let { layout.autoQueryConfig.paramKey = it } - minLength?.let { layout.autoQueryConfig.minLength = it } - maxLength?.let { layout.autoQueryConfig.maxLength = it } - title?.let { layout.autoQueryConfig.title = it } - debounceMillis?.let { layout.autoQueryConfig.debounceMillis = it } - - // 验证并启用自动查询 - if (layout.autoQueryConfig.isValid()) { - layout.enableAutoQuery(layout.autoQueryConfig) - } -} +} +// ========== 自动查询功能 BindingAdapter(新增) ========== + +/** + * 启用自动查询功能 + * @param enabled 是否启用 + */ +@BindingAdapter("autoQueryEnabled") +fun setAutoQueryEnabled(layout: PadDataLayoutNew, enabled: Boolean) { + layout.autoQueryConfig.enabled = enabled +} + +/** + * 设置查询接口地址 + * @param url 接口地址(如:/IntExpCheckIn/checked/queryWbNoList) + */ +@BindingAdapter("autoQueryUrl") +fun setAutoQueryUrl(layout: PadDataLayoutNew, url: String?) { + layout.autoQueryConfig.url = url ?: "" +} + +/** + * 设置查询参数的 key 名称 + * @param paramKey 参数名(默认 "value") + */ +@BindingAdapter("autoQueryParamKey") +fun setAutoQueryParamKey(layout: PadDataLayoutNew, paramKey: String?) { + layout.autoQueryConfig.paramKey = paramKey ?: "value" +} + +/** + * 设置触发查询的最小长度 + * @param minLength 最小长度(默认 4) + */ +@BindingAdapter("autoQueryMinLength") +fun setAutoQueryMinLength(layout: PadDataLayoutNew, minLength: Int?) { + layout.autoQueryConfig.minLength = minLength ?: 4 +} + +/** + * 设置触发查询的最大长度 + * @param maxLength 最大长度(默认 8) + */ +@BindingAdapter("autoQueryMaxLength") +fun setAutoQueryMaxLength(layout: PadDataLayoutNew, maxLength: Int?) { + layout.autoQueryConfig.maxLength = maxLength ?: 8 +} + +/** + * 设置弹框标题 + * @param title 标题(默认 "请选择") + */ +@BindingAdapter("autoQueryTitle") +fun setAutoQueryTitle(layout: PadDataLayoutNew, title: String?) { + layout.autoQueryConfig.title = title ?: "请选择" +} + +/** + * 设置防抖延迟 + * @param debounceMillis 延迟毫秒数(默认 300ms) + */ +@BindingAdapter("autoQueryDebounce") +fun setAutoQueryDebounce(layout: PadDataLayoutNew, debounceMillis: Long?) { + layout.autoQueryConfig.debounceMillis = debounceMillis ?: 300L +} + +/** + * 统一配置自动查询(所有属性设置完成后调用) + * + * ⚠️ 重要:必须在所有 autoQuery* 属性之后绑定,使用 requireAll = false + */ +@BindingAdapter( + "autoQueryEnabled", + "autoQueryUrl", + "autoQueryParamKey", + "autoQueryMinLength", + "autoQueryMaxLength", + "autoQueryTitle", + "autoQueryDebounce", + requireAll = false +) +fun configureAutoQuery( + layout: PadDataLayoutNew, + enabled: Boolean?, + url: String?, + paramKey: String?, + minLength: Int?, + maxLength: Int?, + title: String?, + debounceMillis: Long? +) { + // 应用所有配置 + enabled?.let { layout.autoQueryConfig.enabled = it } + url?.let { layout.autoQueryConfig.url = it } + paramKey?.let { layout.autoQueryConfig.paramKey = it } + minLength?.let { layout.autoQueryConfig.minLength = it } + maxLength?.let { layout.autoQueryConfig.maxLength = it } + title?.let { layout.autoQueryConfig.title = it } + debounceMillis?.let { layout.autoQueryConfig.debounceMillis = it } + + // 验证并启用自动查询 + if (layout.autoQueryConfig.isValid()) { + layout.enableAutoQuery(layout.autoQueryConfig) + } +} diff --git a/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/PadDataLayout.kt b/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/PadDataLayout.kt index d859333..69badb4 100644 --- a/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/PadDataLayout.kt +++ b/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/PadDataLayout.kt @@ -212,6 +212,11 @@ class PadDataLayout : FrameLayout { et.visibility = GONE spinner.visibility = GONE tvSpinner.visibility = GONE + iv.visibility = VISIBLE + iv.setImageResource(R.mipmap.img_date) + val dp20 = dev.utils.app.SizeUtils.dp2px(20f) + iv.layoutParams.width = dp20 + iv.layoutParams.height = dp20 setOnClickListener(dateClick) } diff --git a/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/PadDataLayoutNew.kt b/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/PadDataLayoutNew.kt index f69a1c0..93dbe7d 100644 --- a/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/PadDataLayoutNew.kt +++ b/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/PadDataLayoutNew.kt @@ -240,6 +240,11 @@ class PadDataLayoutNew : FrameLayout { et.visibility = GONE spinner.visibility = GONE tvSpinner.visibility = GONE + iv.visibility = VISIBLE + iv.setImageResource(R.mipmap.img_date) + val dp20 = dev.utils.app.SizeUtils.dp2px(20f) + iv.layoutParams.width = dp20 + iv.layoutParams.height = dp20 setOnClickListener(dateClick) } diff --git a/module_base/src/main/res/layout/item_image_select.xml b/module_base/src/main/res/layout/item_image_select.xml index 1aeb854..796c1f2 100644 --- a/module_base/src/main/res/layout/item_image_select.xml +++ b/module_base/src/main/res/layout/item_image_select.xml @@ -10,9 +10,9 @@