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

View File

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

View File

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