Merge pull request #2943 from dataease/pr@dev@fix_filter_button

fix(仪表板-过滤器按钮): 清空按钮可以拖入多个
This commit is contained in:
fit2cloud-chenyw 2022-08-25 15:00:52 +08:00 committed by GitHub
commit 8cd0eb8932
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 33 deletions

View File

@ -135,6 +135,16 @@ export default {
},
deleteComponent() {
if (this.curComponent.type === 'custom-button' && this.curComponent.serviceName === 'buttonSureWidget') {
let len = this.componentData.length
while (len--) {
const item = this.componentData[len]
if (item.type === 'custom-button' && item.serviceName === 'buttonResetWidget') {
this.componentData.splice(len, 1)
}
}
}
this.$emit('amRemoveItem')
this.deleteCurCondition()
this.$store.commit('deleteComponent')

View File

@ -368,7 +368,7 @@ export default {
},
'cfilters': {
handler: function(val1, val2) {
if (isChange(val1, val2) && !this.isFirstLoad) {
if ((isChange(val1, val2) || isChange(val1, this.filters)) && !this.isFirstLoad) {
this.getData(this.element.propValue.viewId)
}
},

View File

@ -100,7 +100,6 @@ export const buildFilterMap = panelItems => {
let result = buildViewKeyMap(panelItems)
result = buildViewKeyFilters(panelItems, result)
fillElementsFilter(panelItems, result)
return result
}

View File

@ -9,9 +9,9 @@
v-for="(widget, index) in item"
:key="widget.widgetName+index"
:data-id="widget.widgetName"
:draggable="(widget.widgetName !== 'buttonSureWidget' && widget.widgetName !== 'buttonResetWidget') || (widget.widgetName === 'buttonSureWidget' && !searchButtonExist) || (widget.widgetName === 'buttonResetWidget' && searchButtonExist)"
:draggable="(widget.widgetName !== 'buttonSureWidget' && widget.widgetName !== 'buttonResetWidget') || (widget.widgetName === 'buttonSureWidget' && !searchButtonExist) || (widget.widgetName === 'buttonResetWidget' && searchButtonExist && !resetButtonExist)"
:data-index="index"
:class="'filter-widget '+ (widget.defaultClass || '')"
:class="('filter-widget '+ (widget.widgetName === 'buttonSureWidget' ? sureButtonClass : widget.widgetName === 'buttonResetWidget' ? resetButtonClass : widget.defaultClass))"
>
<div class="filter-widget-icon">
<i :class="(widget.icon || 'el-icon-setting') + ' widget-icon-i'" />
@ -74,38 +74,15 @@ export default {
resetButtonExist() {
return this.componentData && this.componentData.some(component => component.type === 'custom-button' && component.serviceName === 'buttonResetWidget')
},
resetButtonDisable() {
return !this.resetButtonExist && this.searchButtonExist
}
sureButtonClass() {
return this.searchButtonExist ? 'button-disable-filter' : 'time-filter'
},
watch: {
searchButtonExist(val, old) {
if (val === old) return
if (val) {
this.widgetSubjects['按钮'][0].defaultClass = 'button-disable-filter'
if (this.resetButtonExist) {
this.widgetSubjects['按钮'][1].defaultClass = 'button-disable-filter'
} else {
this.widgetSubjects['按钮'][1].defaultClass = 'time-filter'
}
} else {
this.widgetSubjects['按钮'][0].defaultClass = 'time-filter'
this.widgetSubjects['按钮'][1].defaultClass = 'button-disable-filter'
}
},
resetButtonExist(val, old) {
if (val === old) return
if (val) {
this.widgetSubjects['按钮'][1].defaultClass = 'button-disable-filter'
} else {
if (this.searchButtonExist) {
this.widgetSubjects['按钮'][1].defaultClass = 'time-filter'
} else {
this.widgetSubjects['按钮'][1].defaultClass = 'button-disable-filter'
}
}
resetButtonClass() {
return (this.searchButtonExist && !this.resetButtonExist) ? 'time-filter' : 'button-disable-filter'
}
},
created() {
this.init()
},