Merge pull request #9312 from dataease/pr@dev_st

fix(过滤组件): 修复过滤组件搜索完值丢失问题
This commit is contained in:
dataeaseShu 2024-04-24 18:02:48 +08:00 committed by GitHub
commit 36e9250431
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -23,7 +23,7 @@
:is-config="isConfig"
:custom-style="customStyle"
:radio-style="element.style"
@resetKeyWords="filterMethod"
@resetKeyWords="resetKeyWords"
@change="changeValue"
@focus="setOptionWidth"
@blur="onBlur"
@ -93,6 +93,7 @@ export default {
data() {
return {
showNumber: false,
resetKeyWordsVal: '',
selectOptionWidth: 0,
show: true,
value: null,
@ -322,6 +323,11 @@ export default {
searchWithKey: _.debounce(function() {
this.refreshOptions()
}, 1000),
resetKeyWords() {
this.resetKeyWordsVal = this.value
this.keyWord = ''
this.searchWithKey()
},
filterMethod(key) {
if (!key && !this.keyWord) {
this.keyWord = key
@ -550,6 +556,12 @@ export default {
if (this.isCustomSortWidget && this.element.options.attrs?.sort?.sort === 'custom') {
tempData = mergeCustomSortOption(this.element.options.attrs.sort.list, tempData)
}
if (Array.isArray(this.resetKeyWordsVal) && this.resetKeyWordsVal.length) {
tempData = [...new Set([...this.resetKeyWordsVal, ...tempData])]
} else if (!Array.isArray(this.resetKeyWordsVal) && this.resetKeyWordsVal) {
tempData = [...new Set([this.resetKeyWordsVal, ...tempData])]
}
this.filterInvalidValue(this.element.options.attrs.showEmpty ? [...tempData, '_empty_$'] : tempData)
return tempData.map(item => {
return {