From d0cd4ae5cae387c88a3ba1f0803eb7548a1bf6d2 Mon Sep 17 00:00:00 2001 From: user Date: Fri, 14 Mar 2025 17:45:53 +0800 Subject: [PATCH] =?UTF-8?q?feat(repository):=20=E5=9C=A8=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=B8=AD=E5=A2=9E=E5=8A=A0=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E6=A8=A1=E7=B3=8A=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD=20-=20?= =?UTF-8?q?=E5=9C=A8=20DictRepository=20=E4=B8=AD=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=E5=AF=B9=E5=B1=9E=E6=80=A7=E5=AD=97=E6=AE=B5=E7=9A=84?= =?UTF-8?q?=E6=A8=A1=E7=B3=8A=E6=90=9C=E7=B4=A2=E6=94=AF=E6=8C=81=20-=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=20vue-select=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E7=84=A6=E7=82=B9=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E9=AB=98=E7=94=A8=E6=88=B7=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vxnet/pms/repository/DictRepository.java | 1 + .../webapp/app/shared/components/vue-select.vue | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/vxnet/pms/repository/DictRepository.java b/src/main/java/com/vxnet/pms/repository/DictRepository.java index b232330..faf6ad1 100644 --- a/src/main/java/com/vxnet/pms/repository/DictRepository.java +++ b/src/main/java/com/vxnet/pms/repository/DictRepository.java @@ -20,6 +20,7 @@ public interface DictRepository extends R2dbcRepository { "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}" diff --git a/src/main/webapp/app/shared/components/vue-select.vue b/src/main/webapp/app/shared/components/vue-select.vue index 68b1dd7..9526a0c 100644 --- a/src/main/webapp/app/shared/components/vue-select.vue +++ b/src/main/webapp/app/shared/components/vue-select.vue @@ -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(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,