Merge pull request #8555 from dataease/pr@dev_select_filter

fix(仪表板): 过滤组件多选时,进行输入搜索选项,会把之前勾选的清空
This commit is contained in:
dataeaseShu 2024-03-18 11:24:11 +08:00 committed by GitHub
commit b919900c56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -54,6 +54,7 @@ import { getLinkToken, getToken } from '@/utils/auth'
import customInput from '@/components/widget/deWidget/customInput' import customInput from '@/components/widget/deWidget/customInput'
import { textSelectWidget } from '@/components/widget/deWidget/serviceNameFn.js' import { textSelectWidget } from '@/components/widget/deWidget/serviceNameFn.js'
import { uuid } from 'vue-uuid' import { uuid } from 'vue-uuid'
import _ from 'lodash'
export default { export default {
components: { ElVisualSelect }, components: { ElVisualSelect },
mixins: [customInput], mixins: [customInput],
@ -96,7 +97,6 @@ export default {
onFocus: false, onFocus: false,
keyWord: '', keyWord: '',
separator: ',', separator: ',',
timeMachine: null,
changeIndex: 0, changeIndex: 0,
flag: uuid.v1(), flag: uuid.v1(),
hasDestroy: false hasDestroy: false
@ -313,29 +313,14 @@ export default {
this.$refs.deSelect && this.$refs.deSelect.resetSelectAll && this.$refs.deSelect.resetSelectAll() this.$refs.deSelect && this.$refs.deSelect.resetSelectAll && this.$refs.deSelect.resetSelectAll()
}, },
searchWithKey(index) { searchWithKey: _.debounce(function () {
this.timeMachine = setTimeout(() => { this.refreshOptions()
if (index === this.changeIndex) { }, 1000),
this.refreshOptions()
}
this.destroyTimeMachine()
}, 1500)
},
destroyTimeMachine() {
this.timeMachine && clearTimeout(this.timeMachine)
this.timeMachine = null
},
filterMethod(key) { filterMethod(key) {
if (key === this.keyWord) {
return
}
this.keyWord = key this.keyWord = key
this.destroyTimeMachine() this.searchWithKey()
this.changeIndex++
this.searchWithKey(this.changeIndex)
}, },
refreshOptions() { refreshOptions() {
// this.data = []
let method = multFieldValues let method = multFieldValues
const token = this.$store.getters.token || getToken() const token = this.$store.getters.token || getToken()
const linkToken = this.$store.getters.linkToken || getLinkToken() const linkToken = this.$store.getters.linkToken || getLinkToken()
@ -564,7 +549,7 @@ export default {
}) })
}, },
filterInvalidValue(data) { filterInvalidValue(data) {
if (this.value === null) { if (this.value === null || !!this.keyWord) {
return return
} }
if (!data.length) { if (!data.length) {