shish 11 месяцев назад
Родитель
Сommit
0df70346ff
1 измененных файлов с 21 добавлено и 1 удалено
  1. 21 1
      hdPad/src/pages/home/components/customList.vue

+ 21 - 1
hdPad/src/pages/home/components/customList.vue

@@ -93,6 +93,7 @@ export default {
             selCustomId:0,
             sn:'',
             searchKeyword: '',
+            searchTimer: null,
         }
     },
     created(){
@@ -112,17 +113,36 @@ export default {
             this.getCustomData()
         },
         handleSearch() {
+            // 清除可能存在的定时器
+            if (this.searchTimer) {
+                clearTimeout(this.searchTimer)
+                this.searchTimer = null
+            }
+            
             this.resetList()
             this.getCustomData()
         },
         clearSearch() {
+            // 清除可能存在的定时器
+            if (this.searchTimer) {
+                clearTimeout(this.searchTimer)
+                this.searchTimer = null
+            }
+            
             this.searchKeyword = ''
             this.resetList()
             this.getCustomData()
         },
         appendNumber(num) {
             this.searchKeyword += num.toString()
-            this.handleSearch()
+            // 清除之前的定时器
+            if (this.searchTimer) {
+                clearTimeout(this.searchTimer)
+            }
+            // 设置新的定时器
+            this.searchTimer = setTimeout(() => {
+                this.handleSearch()
+            }, 900)
         },
         reachBottom() {
             if (!this.list.finished) {