Browse Source

解决搜索内容完全删除还会出现下拉框(2471)

zhangxc 5 years ago
parent
commit
deaa5cf59e

+ 11 - 4
src/components/diagBase/AddDiagBase.vue

@@ -174,7 +174,8 @@
             searchIndex: -1,
             searchFiled: '',
             searchResultList: [],
-            loading: undefined
+            loading: undefined,
+            showSearchList: true //是否展示搜索列表(解决引接口回来比较迟输入内容为空搜索内容还存在)
         }
     },
     created(){
@@ -316,7 +317,7 @@
                 type
             }
             api.diagBaseSearch(param).then((res)=>{
-                if(res.data.code == '0') {
+                if(res.data.code == '0'&&this.showSearchList) {
                     this.searchResultList = res.data.data
                 } else {
                      this.searchResultList = []
@@ -894,13 +895,16 @@
                     if(resultVal) {
                         const searchVal = this.getSearchVal(resultVal)
                         if(searchVal) {
+                             this.showSearchList = true
                              this.searchIndex = index
                             this.searchFiled = 'FeatureStand'
                             this.diagBaseSearch(2,searchVal,itemType)
                         } else {
+                            this.showSearchList = false
                             this.searchResultList = []
                         }
                     } else {
+                         this.showSearchList = false
                         this.searchResultList = []
                     }
                     
@@ -935,14 +939,17 @@
                if(resultVal) {
                     const searchVal = this.getSearchVal(resultVal)
                     if(searchVal) {
+                         this.showSearchList = true
                         this.searchIndex = index
                         this.searchFiled = 'FeatureRelate'
                         this.diagBaseSearch(3,searchVal,itemType)
-                    } else [
+                    } else {
+                        this.showSearchList = false
                         this.searchResultList = []
-                    ]
+                    }
 
                 } else {
+                    this.showSearchList = false
                     this.searchResultList = []
                 }
 

+ 7 - 2
src/components/diagBase/DisFeatureItem.vue

@@ -125,7 +125,7 @@ export default {
             'searchFiled', 'searchResultList'],
     data() {
         return {
-
+            timer: undefined
         }
     },
     mounted(){
@@ -143,7 +143,12 @@ export default {
    },
     methods: {
         handleInp(index,e,type,itemType) {
-            this.$emit('handleInp',{index,e,type,itemType})
+            clearTimeout(this.timer)
+            let timer = setTimeout(()=>{
+                clearTimeout(this.timer);
+                this.$emit('handleInp',{index,e,type,itemType})
+            }, 100)
+            this.timer = timer
         },
         clickItem(index, type) {
              this.$emit('clickItem',{index, type})

+ 7 - 2
src/components/diagBase/DisFormulaItem.vue

@@ -32,7 +32,7 @@ export default {
     props:['item', 'index','formulaTypeList'],
     data() {
         return {
-
+            timer: undefined
         }
     },
     mounted(){
@@ -50,7 +50,12 @@ export default {
    },
     methods: {
         handleInp(index,e,type,itemType) {
-            this.$emit('handleInp',{index,e,type,itemType})
+             clearTimeout(this.timer)
+            let timer = setTimeout(()=>{
+                clearTimeout(this.timer);
+                this.$emit('handleInp',{index,e,type,itemType})
+            }, 100)
+            this.timer = timer
         },
         clickItem(index, type) {
              this.$emit('clickItem',{index, type})