feat(repository): 在字典查询中增加属性模糊搜索功能
- 在 DictRepository 中添加了对属性字段的模糊搜索支持 - 优化了 vue-select 组件的焦点处理逻辑,提高用户体验
This commit is contained in:
parent
17d4cc6813
commit
d0cd4ae5ca
@ -20,6 +20,7 @@ public interface DictRepository extends R2dbcRepository<Dict, Long> {
|
||||
"AND (:#{#params['name']} IS NULL OR name LIKE CONCAT('%', :#{#params['name']}, '%')) " +
|
||||
"AND (:#{#params['likeNumberName']} IS NULL OR CONCAT(number,name) LIKE CONCAT('%', :#{#params['likeNumberName']}, '%')) " +
|
||||
"AND (:#{#params['parentNumber']} IS NULL OR IFNULL(parent_number, '') = :#{#params['parentNumber']}) " +
|
||||
"AND (:#{#params['property']} IS NULL OR property LIKE CONCAT('%', :#{#params['property']}, '%')) " +
|
||||
"AND (:#{#params['status']} IS NULL OR status = :#{#params['status']}) " +
|
||||
"ORDER BY :#{#pageable.sort.toString().replace(':', ' ')} " +
|
||||
"LIMIT :#{#pageable.pageSize} OFFSET :#{#pageable.offset}"
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
:placeholder="placeholder"
|
||||
v-model="searchQuery"
|
||||
@input="onSearch"
|
||||
@focus="isOpen = true"
|
||||
@focus="onFocus"
|
||||
@blur="onBlur"
|
||||
@keydown.down.prevent="highlightNext"
|
||||
@keydown.up.prevent="highlightPrev"
|
||||
@ -95,6 +95,7 @@ export default defineComponent({
|
||||
const searchQuery = ref('');
|
||||
const highlightedIndex = ref(-1);
|
||||
const closeTimeout = ref<number | null>(null);
|
||||
const focusTriggered = ref(false);
|
||||
|
||||
// 计算当前选中的选项标签
|
||||
const selectedLabel = computed(() => {
|
||||
@ -148,9 +149,20 @@ export default defineComponent({
|
||||
}
|
||||
});
|
||||
|
||||
// 处理获取焦点事件
|
||||
const onFocus = () => {
|
||||
focusTriggered.value = true;
|
||||
isOpen.value = true;
|
||||
};
|
||||
|
||||
// 切换下拉框显示状态
|
||||
const toggleDropdown = () => {
|
||||
isOpen.value = !isOpen.value;
|
||||
// 如果是由focus事件触发的,则不要切换状态,只重置标志
|
||||
if (focusTriggered.value) {
|
||||
focusTriggered.value = false;
|
||||
} else {
|
||||
isOpen.value = !isOpen.value;
|
||||
}
|
||||
};
|
||||
|
||||
// 处理搜索输入
|
||||
@ -221,6 +233,7 @@ export default defineComponent({
|
||||
highlightedIndex,
|
||||
filteredOptions,
|
||||
toggleDropdown,
|
||||
onFocus,
|
||||
onSearch,
|
||||
onBlur,
|
||||
selectOption,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user