feat(repository): 在字典查询中增加属性模糊搜索功能

- 在 DictRepository 中添加了对属性字段的模糊搜索支持
- 优化了 vue-select 组件的焦点处理逻辑,提高用户体验
This commit is contained in:
user 2025-03-14 17:45:53 +08:00
parent 17d4cc6813
commit d0cd4ae5ca
2 changed files with 16 additions and 2 deletions

View File

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

View File

@ -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,