diff --git a/core/frontend/src/components/widget/deWidget/DeDate.vue b/core/frontend/src/components/widget/deWidget/DeDate.vue index ff391cf5d9..86cc6fd680 100644 --- a/core/frontend/src/components/widget/deWidget/DeDate.vue +++ b/core/frontend/src/components/widget/deWidget/DeDate.vue @@ -459,6 +459,9 @@ export default { return param }, setCondition() { + if (this.showRequiredTips) { + return + } const param = this.getCondition() !this.isRelation && this.inDraw && this.$store.commit('addViewFilter', param) }, @@ -472,6 +475,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.values && Array.isArray(this.values)) ? this.values.join(',') : this.values + }) + } } this.setCondition() }, @@ -501,7 +510,16 @@ export default { } }, 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 || typeof lastFilters.val === 'undefined') ? '' : lastFilters.val.toString() + } + } + } if (this.element.options.attrs.type === 'daterange') { if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '' || defaultV === '[object Object]') { diff --git a/core/frontend/src/components/widget/deWidget/DeInputSearch.vue b/core/frontend/src/components/widget/deWidget/DeInputSearch.vue index 74b87f9b59..5447cc3212 100644 --- a/core/frontend/src/components/widget/deWidget/DeInputSearch.vue +++ b/core/frontend/src/components/widget/deWidget/DeInputSearch.vue @@ -114,6 +114,11 @@ export default { search() { if (!this.inDraw) { this.element.options.value = this.value + } else 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() }, @@ -127,6 +132,9 @@ export default { return param }, setCondition() { + if (this.showRequiredTips) { + return + } const param = this.getCondition() !this.isRelation && this.inDraw && this.$store.commit('addViewFilter', param) }, @@ -142,7 +150,16 @@ export default { } }, 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 (defaultV === null || typeof defaultV === 'undefined' || defaultV === '' || defaultV === '[object Object]') return null return defaultV.split(',')[0] } diff --git a/core/frontend/src/components/widget/deWidget/DeNumberRange.vue b/core/frontend/src/components/widget/deWidget/DeNumberRange.vue index 55414ff536..c66186c86e 100644 --- a/core/frontend/src/components/widget/deWidget/DeNumberRange.vue +++ b/core/frontend/src/components/widget/deWidget/DeNumberRange.vue @@ -127,7 +127,7 @@ export default { }, 'defaultvalues': function(value, old) { if (value === old) return - const values = this.element.options.value + const values = this.fillValueDerfault() this.form.min = values[0] if (values.length > 1) { this.form.max = values[1] @@ -145,7 +145,7 @@ export default { }, created() { if (this.element.options.value && this.element.options.value.length > 0) { - const values = this.element.options.value + const values = this.fillValueDerfault() this.form.min = values[0] if (values.length > 1) { this.form.max = values[1] @@ -174,13 +174,12 @@ export default { this.form.min = null this.form.max = null } else { - const values = this.element.options.value + const values = this.fillValueDerfault() this.form.min = values[0] if (values.length > 1) { this.form.max = values[1] } } - this.search() } }, @@ -251,7 +250,13 @@ export default { if (!valid) { return false } - + if (!this.showRequiredTips) { + const values = [this.form.min, this.form.max] + this.$store.commit('setLastValidFilters', { + componentId: this.element.id, + val: (values && Array.isArray(values)) ? values.join(',') : values + }) + } this.setCondition() }) }) @@ -283,6 +288,9 @@ export default { return param }, setCondition() { + if (this.showRequiredTips) { + return + } const param = this.getCondition() if (this.form.min && this.form.max) { @@ -316,6 +324,20 @@ export default { } else { this.element.options.manualModify = true } + }, + fillValueDerfault() { + 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 (defaultV === null || typeof defaultV === 'undefined' || defaultV === '' || defaultV === '[object Object]') return [] + return defaultV.split(',') } } } diff --git a/core/frontend/src/components/widget/deWidget/DeSelectGrid.vue b/core/frontend/src/components/widget/deWidget/DeSelectGrid.vue index 2d488304f5..df937aa02b 100644 --- a/core/frontend/src/components/widget/deWidget/DeSelectGrid.vue +++ b/core/frontend/src/components/widget/deWidget/DeSelectGrid.vue @@ -381,6 +381,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() }, @@ -394,6 +400,9 @@ export default { return param }, setCondition() { + if (this.showRequiredTips) { + return + } const param = this.getCondition() !this.isRelation && this.inDraw && this.$store.commit('addViewFilter', param) }, @@ -403,7 +412,16 @@ export default { return this.value.split(',') }, 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 [] diff --git a/core/frontend/src/components/widget/deWidget/DeSelectTree.vue b/core/frontend/src/components/widget/deWidget/DeSelectTree.vue index 3b02170d82..7bc39163b7 100644 --- a/core/frontend/src/components/widget/deWidget/DeSelectTree.vue +++ b/core/frontend/src/components/widget/deWidget/DeSelectTree.vue @@ -313,6 +313,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() }, @@ -331,6 +337,9 @@ export default { }, setCondition() { + if (this.showRequiredTips) { + return + } const param = this.getCondition() !this.isRelation && this.inDraw && this.$store.commit('addViewFilter', param) }, @@ -370,7 +379,16 @@ export default { }, 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(',') diff --git a/core/frontend/src/components/widget/serviceImpl/NumberRangeServiceImpl.js b/core/frontend/src/components/widget/serviceImpl/NumberRangeServiceImpl.js index 9b1c1dca25..341b4fb2ca 100644 --- a/core/frontend/src/components/widget/serviceImpl/NumberRangeServiceImpl.js +++ b/core/frontend/src/components/widget/serviceImpl/NumberRangeServiceImpl.js @@ -67,9 +67,14 @@ class NumberRangeServiceImpl extends WidgetService { }) } - getParam(element) { - if (element.options.value && element.options.value.length > 0) { - const values = element.options.value + getParam(element, val) { + let values = null + if (val === null || val === '' || typeof val === 'undefined') { + values = element.options.value + } else { + values = val.split(',') + } + if (values && values.length > 0) { const min = values[0] let max = null if (values.length > 1) { diff --git a/core/frontend/src/components/widget/serviceImpl/NumberSelectGridServiceImpl.js b/core/frontend/src/components/widget/serviceImpl/NumberSelectGridServiceImpl.js index b3d2af607e..c34ffc01aa 100644 --- a/core/frontend/src/components/widget/serviceImpl/NumberSelectGridServiceImpl.js +++ b/core/frontend/src/components/widget/serviceImpl/NumberSelectGridServiceImpl.js @@ -82,8 +82,13 @@ class NumberSelectGridServiceImpl extends WidgetService { } }) } - getParam(element) { - const value = this.fillValueDerfault(element) + getParam(element, val) { + let value = null + if (val === null || val === '' || typeof val === 'undefined') { + value = this.fillValueDerfault(element) + } else { + value = [val] + } const param = { component: element, value: !value ? [] : Array.isArray(value) ? value : value.toString().split(','), diff --git a/core/frontend/src/components/widget/serviceImpl/NumberSelectServiceImpl.js b/core/frontend/src/components/widget/serviceImpl/NumberSelectServiceImpl.js index d18f91f69f..92efb280cb 100644 --- a/core/frontend/src/components/widget/serviceImpl/NumberSelectServiceImpl.js +++ b/core/frontend/src/components/widget/serviceImpl/NumberSelectServiceImpl.js @@ -84,8 +84,13 @@ class NumberSelectServiceImpl extends WidgetService { } }) } - getParam(element) { - const value = this.fillValueDerfault(element) + getParam(element, val) { + let value = null + if (val === null || val === '' || typeof val === 'undefined') { + value = this.fillValueDerfault(element) + } else { + value = [val] + } const param = { component: element, value: !value ? [] : Array.isArray(value) ? value : value.toString().split(','), diff --git a/core/frontend/src/components/widget/serviceImpl/TextInputServiceImpl.js b/core/frontend/src/components/widget/serviceImpl/TextInputServiceImpl.js index 87090ebd17..207aea0188 100644 --- a/core/frontend/src/components/widget/serviceImpl/TextInputServiceImpl.js +++ b/core/frontend/src/components/widget/serviceImpl/TextInputServiceImpl.js @@ -68,8 +68,13 @@ class TextInputServiceImpl extends WidgetService { return field['deType'] === 0 }) } - getParam(element) { - const value = this.fillValueDerfault(element) + getParam(element, val) { + let value = null + if (!val) { + value = this.fillValueDerfault(element) + } else { + value = [val] + } const param = { component: element, value: !value ? [] : Array.isArray(value) ? value : [value], diff --git a/core/frontend/src/components/widget/serviceImpl/TextSelectGridServiceImpl.js b/core/frontend/src/components/widget/serviceImpl/TextSelectGridServiceImpl.js index d80dc1c4c0..75808bb1f0 100644 --- a/core/frontend/src/components/widget/serviceImpl/TextSelectGridServiceImpl.js +++ b/core/frontend/src/components/widget/serviceImpl/TextSelectGridServiceImpl.js @@ -83,8 +83,13 @@ class TextSelectGridServiceImpl extends WidgetService { } }) } - getParam(element) { - const value = this.fillValueDerfault(element) + getParam(element, val) { + let value = null + if (!val) { + value = this.fillValueDerfault(element) + } else { + value = [val] + } const param = { component: element, value: !value ? [] : Array.isArray(value) ? value : value.toString().split(','), diff --git a/core/frontend/src/components/widget/serviceImpl/TextSelectTreeServiceImpl.js b/core/frontend/src/components/widget/serviceImpl/TextSelectTreeServiceImpl.js index 4f6d02afac..01f7acfa13 100644 --- a/core/frontend/src/components/widget/serviceImpl/TextSelectTreeServiceImpl.js +++ b/core/frontend/src/components/widget/serviceImpl/TextSelectTreeServiceImpl.js @@ -86,8 +86,13 @@ class TextSelectTreeServiceImpl extends WidgetService { }) } - getParam(element) { - const value = this.fillValueDerfault(element) + getParam(element, val) { + let value = null + if (!val) { + value = this.fillValueDerfault(element) + } else { + value = [val] + } const param = { component: element, value: !value ? [] : Array.isArray(value) ? value : value.toString().split(','), diff --git a/core/frontend/src/components/widget/serviceImpl/TimeDateRangeServiceImpl.js b/core/frontend/src/components/widget/serviceImpl/TimeDateRangeServiceImpl.js index cd33146057..765b109a6c 100644 --- a/core/frontend/src/components/widget/serviceImpl/TimeDateRangeServiceImpl.js +++ b/core/frontend/src/components/widget/serviceImpl/TimeDateRangeServiceImpl.js @@ -310,9 +310,13 @@ class TimeDateRangeServiceImpl extends WidgetService { return false } } - getParam(element) { + getParam(element, val) { let timeArr = [] - if (element.options.attrs.default && element.options.attrs.default.isDynamic) { + if (val) { + let value = [val] + value = this.formatFilterValue(value) + timeArr = this.formatValues(value, element) + } else if (element.options.attrs.default && element.options.attrs.default.isDynamic) { let value = this.dynamicDateFormNow(element) value = this.formatFilterValue(value) timeArr = this.formatValues(value, element) diff --git a/core/frontend/src/components/widget/serviceImpl/TimeDateServiceImpl.js b/core/frontend/src/components/widget/serviceImpl/TimeDateServiceImpl.js index a1646a5383..2d6d619d41 100644 --- a/core/frontend/src/components/widget/serviceImpl/TimeDateServiceImpl.js +++ b/core/frontend/src/components/widget/serviceImpl/TimeDateServiceImpl.js @@ -167,9 +167,13 @@ class TimeDateServiceImpl extends WidgetService { } } } - getParam(element) { + getParam(element, val) { let timeArr = [] - if (element.options.attrs.default && element.options.attrs.default.isDynamic) { + if (val) { + let value = [val] + value = this.formatFilterValue(value) + timeArr = this.formatValues(value, element) + } else if (element.options.attrs.default && element.options.attrs.default.isDynamic) { let value = this.dynamicDateFormNow(element) value = this.formatFilterValue(value) timeArr = this.formatValues(value, element) diff --git a/core/frontend/src/components/widget/serviceImpl/TimeMonthServiceImpl.js b/core/frontend/src/components/widget/serviceImpl/TimeMonthServiceImpl.js index 1254999750..f8ba82b7f7 100644 --- a/core/frontend/src/components/widget/serviceImpl/TimeMonthServiceImpl.js +++ b/core/frontend/src/components/widget/serviceImpl/TimeMonthServiceImpl.js @@ -128,9 +128,13 @@ class TimeMonthServiceImpl extends WidgetService { } } } - getParam(element) { + getParam(element, val) { let timeArr = [] - if (element.options.attrs.default && element.options.attrs.default.isDynamic) { + if (val) { + let value = [val] + value = this.formatFilterValue(value) + timeArr = this.formatValues(value, element) + } else if (element.options.attrs.default && element.options.attrs.default.isDynamic) { let value = this.dynamicDateFormNow(element) value = this.formatFilterValue(value) timeArr = this.formatValues(value, element) diff --git a/core/frontend/src/components/widget/serviceImpl/TimeYearServiceImpl.js b/core/frontend/src/components/widget/serviceImpl/TimeYearServiceImpl.js index 90d440cdf2..12169259fe 100644 --- a/core/frontend/src/components/widget/serviceImpl/TimeYearServiceImpl.js +++ b/core/frontend/src/components/widget/serviceImpl/TimeYearServiceImpl.js @@ -115,9 +115,13 @@ class TimeYearServiceImpl extends WidgetService { return new Date(dynamicSuffix === 'before' ? (nowYear - dynamicPrefix) : (nowYear + dynamicPrefix), 0, 1).getTime() } } - getParam(element) { + getParam(element, val) { let timeArr = [] - if (element.options.attrs.default && element.options.attrs.default.isDynamic) { + if (val) { + let value = [val] + value = this.formatFilterValue(value) + timeArr = this.formatValues(value, element) + } else if (element.options.attrs.default && element.options.attrs.default.isDynamic) { let value = this.dynamicDateFormNow(element) value = this.formatFilterValue(value) timeArr = this.formatValues(value, element)