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