feat: visa

This commit is contained in:
2026-03-22 22:28:40 +08:00
parent d2a0648238
commit c7bf51bd9a
7 changed files with 143 additions and 110 deletions

View File

@@ -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<InputFilter>()
}
}
// ========== 自动查询功能 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)
}
}

View File

@@ -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)
}

View File

@@ -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)
}

View File

@@ -10,9 +10,9 @@
<RelativeLayout
android:id="@+id/rl"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_margin="10dp"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:background="@color/white">
<ImageView

View File

@@ -10,6 +10,7 @@ import com.lukouguoji.module_base.base.BaseBindingActivity
import com.lukouguoji.module_base.common.Constant
import com.lukouguoji.module_base.common.DetailsPageType
import com.lukouguoji.module_base.ktx.addOnItemClickListener
import com.lukouguoji.module_base.ktx.setUpperCaseAlphanumericFilter
/**
* 国际进港-事故签证新增/编辑
@@ -23,6 +24,11 @@ class IntImpAccidentVisaEditActivity :
override fun initOnCreate(savedInstanceState: Bundle?) {
binding.viewModel = viewModel
// 航班号:大写字母+数字
binding.fnoInput.et.setUpperCaseAlphanumericFilter()
// 运单号:大写字母+数字
binding.wbNoInput.et.setUpperCaseAlphanumericFilter()
viewModel.rv = binding.rv
binding.rv.addOnItemClickListener(viewModel)
viewModel.initOnCreate(intent)

View File

@@ -17,6 +17,7 @@ import com.lukouguoji.module_base.impl.FlowBus
import com.lukouguoji.module_base.impl.ImageSelectViewHolder
import com.lukouguoji.module_base.interfaces.IOnItemClickListener
import com.lukouguoji.module_base.ktx.commonAdapter
import com.lukouguoji.module_base.ktx.formatDate
import com.lukouguoji.module_base.ktx.launchCollect
import com.lukouguoji.module_base.ktx.launchLoadingCollect
import com.lukouguoji.module_base.ktx.noNull
@@ -26,6 +27,7 @@ import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
import com.lukouguoji.module_base.util.MediaUtil
import com.lukouguoji.module_base.util.UploadUtil
import dev.utils.app.info.KeyValue
import dev.utils.common.DateUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.catch
@@ -71,6 +73,13 @@ class IntImpAccidentVisaEditViewModel : BaseViewModel(), IOnItemClickListener {
id = intent.getLongExtra(Constant.Key.ID, 0)
pageType.value = if (id == 0L) DetailsPageType.Add else DetailsPageType.Modify
// 新增模式下默认航班日期为今天
if (pageType.value == DetailsPageType.Add) {
val bean = dataBean.value ?: GjAccidentVisaEditBean()
bean.fdate = DateUtils.getCurrentTime().formatDate()
dataBean.value = bean
}
loadDropdownLists()
if (id != 0L) {

View File

@@ -59,6 +59,7 @@
value='@={viewModel.dataBean.fdate}' />
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
android:id="@+id/fnoInput"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
@@ -84,6 +85,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
enable="@{false}"
hint='@{"航班信息自动填充"}'
title='@{"始发站"}'
titleLength="@{6}"
type="@{DataLayoutType.INPUT}"
@@ -94,6 +96,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
enable="@{false}"
hint='@{"航班信息自动填充"}'
title='@{"目的站"}'
titleLength="@{6}"
type="@{DataLayoutType.INPUT}"
@@ -109,6 +112,7 @@
android:orientation="horizontal">
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
android:id="@+id/wbNoInput"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"