fix(仪表板): 下拉框模糊搜索逻辑错误

This commit is contained in:
fit2cloud-chenyw 2022-07-26 22:58:21 +08:00
parent b71c821b7e
commit d51cf1d55e
2 changed files with 22 additions and 3 deletions

View File

@ -40,6 +40,10 @@ export default {
value: {
type: [String, Number, Array],
default: ''
},
keyWord: {
type: String,
default: ''
}
},
data() {
@ -80,7 +84,16 @@ export default {
this.init()
})
})
}
},
keyWord(val, old) {
if(val === old) return
const results = val ? this.list.filter(item => item.text.includes(val)) : null
this.resetList(results)
this.reCacularHeight()
this.$nextTick(() => {
this.callback()
})
},
},
mounted() {
this.resetList()

View File

@ -12,6 +12,8 @@
:popper-append-to-body="inScreen"
:size="size"
:filterable="true"
:filter-method="filterMethod"
:key-word="keyWord"
popper-class="coustom-de-select"
:list="datas"
@change="changeValue"
@ -71,7 +73,8 @@ export default {
show: true,
value: null,
datas: [],
onFocus: false
onFocus: false,
keyWord: ''
}
},
computed: {
@ -203,6 +206,9 @@ export default {
bus.$off('reset-default-value', this.resetDefaultValue)
},
methods: {
filterMethod(key) {
this.keyWord = key
},
onScroll() {
if (this.onFocus) {
this.$refs.deSelect.blur()
@ -215,7 +221,7 @@ export default {
}
},
onBlur() {
this.onFocus = false
// this.onFocus = false
},
handleElTagStyle() {
setTimeout(() => {