diff --git a/core/frontend/src/api/panel/panel.js b/core/frontend/src/api/panel/panel.js index 86b9057988..a1829cc0d2 100644 --- a/core/frontend/src/api/panel/panel.js +++ b/core/frontend/src/api/panel/panel.js @@ -166,6 +166,7 @@ export function delGroup(groupId) { } export function initPanelData(panelId, useCache = false, callback) { + store.commit('resetLastValidFilters') const queryMethod = useCache ? findUserCacheRequest : findOne // 加载视图数据 queryMethod(panelId).then(response => { diff --git a/core/frontend/src/api/panel/shareProxy.js b/core/frontend/src/api/panel/shareProxy.js index 10c5853dd7..ddf5646703 100644 --- a/core/frontend/src/api/panel/shareProxy.js +++ b/core/frontend/src/api/panel/shareProxy.js @@ -5,6 +5,7 @@ import { $error } from '@/utils/message' import i18n from '@/lang' export function proxyInitPanelData(panelId, proxy, callback) { + store.commit('resetLastValidFilters') // 加载视图数据 findOne(panelId, proxy).then(response => { if (response.data) { diff --git a/core/frontend/src/components/widget/deWidget/DeSelect.vue b/core/frontend/src/components/widget/deWidget/DeSelect.vue index 7bb1b44c11..156ac552f4 100644 --- a/core/frontend/src/components/widget/deWidget/DeSelect.vue +++ b/core/frontend/src/components/widget/deWidget/DeSelect.vue @@ -378,7 +378,6 @@ export default { }, 500) }, initLoad() { - // this.value = this.fillValueDerfault() this.initOptions(this.fillFirstSelected) if (this.element.options.value && !this.selectFirst) { this.value = this.fillValueDerfault() @@ -442,6 +441,12 @@ export default { this.element.options.manualModify = false } else { this.element.options.manualModify = true + if (!this.showRequiredTips) { + this.$store.commit('setLastValidFilters', { + componentId: this.element.id, + val: (this.value && Array.isArray(this.value)) ? this.value.join(',') : this.value + }) + } } this.setCondition() this.handleShowNumber() @@ -478,6 +483,9 @@ export default { return param }, setCondition() { + if (this.showRequiredTips) { + return + } const param = this.getCondition() !this.isRelation && this.inDraw && this.$store.commit('addViewFilter', param) }, @@ -504,7 +512,17 @@ export default { this.firstChange(this.value) }, fillValueDerfault() { - const defaultV = this.element.options.value === null ? '' : this.element.options.value.toString() + let defaultV = this.element.options.value === null ? '' : this.element.options.value.toString() + if (this.inDraw) { + let lastFilters = null + if (this.$store.state.lastValidFilters) { + lastFilters = this.$store.state.lastValidFilters[this.element.id] + if (lastFilters) { + defaultV = lastFilters.val === null ? '' : lastFilters.val.toString() + } + } + } + if (this.element.options.attrs.multiple) { if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '' || defaultV === '[object Object]') return [] return defaultV.split(this.separator) diff --git a/core/frontend/src/store/index.js b/core/frontend/src/store/index.js index 7c657ffda5..8445509308 100644 --- a/core/frontend/src/store/index.js +++ b/core/frontend/src/store/index.js @@ -156,7 +156,8 @@ const data = { previewComponentData: [], currentCanvasNewId: [], lastViewRequestInfo: {}, - multiplexingStyleAdapt: true // 复用样式跟随主题 + multiplexingStyleAdapt: true, // 复用样式跟随主题 + lastValidFilters: {} }, mutations: { ...animation.mutations, @@ -562,6 +563,9 @@ const data = { state.componentData.push(component) }, deleteComponentWithId(state, id) { + if (state.lastValidFilters && state.lastValidFilters[id]) { + delete state.lastValidFilters[id] + } for (let index = 0; index < state.componentData.length; index++) { const element = state.componentData[index] if (element.id && element.id === id) { @@ -819,6 +823,7 @@ const data = { state.changeProperties[propertyInfo.custom][propertyInfo.property] = propertyInfo.value }, initCanvasBase(state) { + this.commit('resetLastValidFilters') this.commit('setCurComponent', { component: null, index: null }) this.commit('clearLinkageSettingInfo', false) this.commit('resetViewEditInfo') @@ -889,6 +894,10 @@ const data = { for (let index = 0; index < state.componentData.length; index++) { const element = state.componentData[index] if (element.canvasId && element.canvasId.includes(canvasId)) { + const cid = state.componentData[index] + if (state.lastValidFilters && state.lastValidFilters[cid]) { + delete state.lastValidFilters[cid] + } state.componentData.splice(index, 1) } } @@ -913,6 +922,12 @@ const data = { }, setMultiplexingStyleAdapt(state, value) { state.multiplexingStyleAdapt = value + }, + setLastValidFilters(state, data) { + state.lastValidFilters[data.componentId] = data + }, + resetLastValidFilters(state) { + state.lastValidFilters = {} } }, modules: { diff --git a/core/frontend/src/utils/conditionUtil.js b/core/frontend/src/utils/conditionUtil.js index ac93c68890..2e36428102 100644 --- a/core/frontend/src/utils/conditionUtil.js +++ b/core/frontend/src/utils/conditionUtil.js @@ -96,6 +96,7 @@ export const buildViewKeyFilters = (panelItems, result, isEdit = false) => { return result } const buildItems = panelItems[0].canvasId === 'canvas-main' ? panelItems : store.state.componentData + const lastValidFilters = store.state.lastValidFilters const canvasIdMap = buildCanvasIdMap(buildItems) buildItems.forEach((element, index) => { if (element.type !== 'custom') { @@ -105,9 +106,16 @@ export const buildViewKeyFilters = (panelItems, result, isEdit = false) => { let param = null const widget = ApplicationContext.getService(element.serviceName) - param = widget.getParam(element) + let lastFilter = null + if (lastValidFilters) { + lastFilter = lastValidFilters[element.id] + } + param = widget.getParam(element, lastFilter?.val) const condition = formatCondition(param) - const vValid = valueValid(condition) + let vValid = valueValid(condition) + if (lastFilter && !lastFilter.val) { + vValid = false + } const filterComponentId = condition.componentId Object.keys(result).forEach(viewId => { // 进行过滤时 如果过滤组件在主画布 则条件适用于所有画布视图 否则需要过滤组件和视图在相同画布