Merge pull request #8725 from dataease/pr@dev@fix_filter_first

fix(过滤组件): 多个下拉过滤器设置首项导致视图无法加载 close#8579
This commit is contained in:
fit2cloud-chenyw 2024-03-27 13:21:11 +08:00 committed by GitHub
commit 6e49746000
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 7 deletions

View File

@ -354,6 +354,7 @@ export default {
},
data() {
return {
unReadyList: [],
dialogLoading: false,
imageDownloading: false,
innerRefreshTimer: null,
@ -653,6 +654,7 @@ export default {
},
mounted() {
bus.$on('tab-canvas-change', this.tabSwitch)
bus.$on('resolve-wait-condition', this.resolveWaitCondition)
this.bindPluginEvent()
},
@ -674,15 +676,16 @@ export default {
bus.$off('onThemeAttrChange', this.optFromBatchSingleProp)
bus.$off('clear_panel_linkage', this.clearPanelLinkage)
bus.$off('tab-canvas-change', this.tabSwitch)
bus.$off('resolve-wait-condition', this.resolveWaitCondition)
},
created() {
this.refId = uuid.v1
if (this.element && this.element.propValue && this.element.propValue.viewId) {
const group = this.groupFilter(this.filters)
const unReadyList = group.unReady
this.unReadyList = group.unReady
const readyList = group.ready
if (unReadyList.length) {
Promise.all(this.filters.filter(f => f instanceof Promise)).then(fList => {
if (this.unReadyList.length) {
Promise.all(this.unReadyList.filter(f => f instanceof Promise)).then(fList => {
this.filter.filter = readyList.concat(fList)
this.getData(this.element.propValue.viewId, false)
})
@ -692,6 +695,11 @@ export default {
}
},
methods: {
resolveWaitCondition(p) {
this.unReadyList.filter(f => f instanceof Promise && f.componentId === p.componentId).map(f => {
f.cacheObj.cb(p)
})
},
groupFilter(filters) {
const result = {
ready: [],

View File

@ -2,9 +2,9 @@
<component
:is="mode"
v-if="element.options!== null && element.options.attrs!==null && show "
:id="element.id"
ref="deSelect"
v-model="value"
:id="element.id"
:class-id="'visual-' + element.id + '-' + inDraw + '-' + inScreen"
:collapse-tags="showNumber"
:clearable="(inDraw || !selectFirst)"
@ -22,7 +22,7 @@
:flag="flag"
:is-config="isConfig"
:custom-style="customStyle"
:radioStyle="element.style"
:radio-style="element.style"
@resetKeyWords="filterMethod"
@change="changeValue"
@focus="setOptionWidth"
@ -319,7 +319,7 @@ export default {
this.$refs.deSelect && this.$refs.deSelect.resetSelectAll && this.$refs.deSelect.resetSelectAll()
},
searchWithKey: _.debounce(function () {
searchWithKey: _.debounce(function() {
this.refreshOptions()
}, 1000),
filterMethod(key) {

View File

@ -1,7 +1,7 @@
import { Condition } from '@/components/widget/bean/Condition'
import { ApplicationContext } from '@/utils/ApplicationContext'
import store from '@/store'
import bus from '@/utils/bus'
/**
* 判断两个conditions数组是否相同
* @param {*} conditions1
@ -167,6 +167,7 @@ export const buildAfterFilterLoaded = (originMap, p) => {
if (conditions?.length) {
conditions.forEach(condition => {
if (condition instanceof Promise && condition.componentId === componentId && condition.cacheObj?.cb) {
bus.$emit('resolve-wait-condition', p)
condition.cacheObj.cb(p)
}
})