From 080565bea68b06ccaa89eb8f3526bc11bbb191ec Mon Sep 17 00:00:00 2001
From: zhaojisen <1301338853@qq.com>
Date: Wed, 22 May 2024 14:18:16 +0800
Subject: [PATCH] =?UTF-8?q?perf:=20=E6=96=B0=E5=A2=9E=E6=8C=89=E9=94=AE=20?=
=?UTF-8?q?t=20=E4=BD=BF=E5=BE=97=20Search=20=E7=BB=84=E4=BB=B6=E8=87=AA?=
=?UTF-8?q?=E5=8A=A8=20focus?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Table/TagSearch/index.vue | 58 ++++++++++++++++++++++--
1 file changed, 53 insertions(+), 5 deletions(-)
diff --git a/src/components/Table/TagSearch/index.vue b/src/components/Table/TagSearch/index.vue
index 9998e6b58..660914984 100644
--- a/src/components/Table/TagSearch/index.vue
+++ b/src/components/Table/TagSearch/index.vue
@@ -29,13 +29,14 @@
:placeholder="placeholder"
:validate-event="false"
class="search-input"
- suffix-icon="el-icon-search"
+ :suffix-icon="suffixIcon"
@blur="handleBlur"
@change="handleConfirm"
- @focus="focus = true"
+ @focus="handleFocus"
@keyup.enter.native="handleConfirm"
@keyup.delete.native="handleDelete"
/>
+ t
@@ -67,10 +68,12 @@ export default {
filterKey: '',
filterValue: '',
valueLabel: '',
+ suffixIcon: '',
emptyCount: 0,
filterTags: this.default || {},
focus: false,
- showCascade: true
+ showCascade: true,
+ isFocus: false
}
},
computed: {
@@ -134,9 +137,22 @@ export default {
}
}
},
+ mounted() {
+ document.addEventListener('keyup', this.handleKeyUp)
+ },
+ beforeDestroy() {
+ document.removeEventListener('keyup', this.handleKeyUp)
+ },
methods: {
+ handleFocus() {
+ this.focus = true
+ this.isFocus = true
+ this.suffixIcon = 'el-icon-search'
+ },
handleBlur() {
this.focus = false
+ this.isFocus = false
+ this.suffixIcon = ''
this.$emit('blur')
},
// 获取url中的查询条件,判断是不是包含在当前查询条件里
@@ -329,6 +345,14 @@ export default {
this.filterValue = v.value
this.$refs.SearchInput.focus()
},
+ handleKeyUp(event) {
+ // 检查按下的键是否是"T"键
+ if (event.key === 'T' || event.key === 't') {
+ this.$refs.SearchInput.focus()
+ this.suffixIcon = 'el-icon-search'
+ this.isFocus = true
+ }
+ },
// 删除查询条件时改变url
checkUrlFields(evt) {
let newQuery = _.omit(this.$route.query, evt)
@@ -347,11 +371,16 @@ export default {