feat:仪表板联动时,在视图上增加取消联动按钮

This commit is contained in:
wangjiahao 2021-08-17 18:52:22 +08:00
parent 1dca2e0ff7
commit 2a8d39bbb8
6 changed files with 40 additions and 5 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<div v-show="existLinkage" class="bar-main"> <div v-show="existLinkage" class="bar-main">
<div> <div>
<el-button size="mini" type="info" @click="clearAllLinkage">清除所有联动</el-button> <el-button size="mini" type="warning" @click="clearAllLinkage"><i class="icon iconfont icon-quxiaoliandong" />{{ $t('panel.remove_all_linkage') }}</el-button>
</div> </div>
</div> </div>
</template> </template>

View File

@ -11,6 +11,7 @@
</setting-menu> </setting-menu>
<i v-if="activeModel==='edit'&&curComponent&&editFilter.includes(curComponent.type)" class="icon iconfont icon-edit" @click.stop="edit" /> <i v-if="activeModel==='edit'&&curComponent&&editFilter.includes(curComponent.type)" class="icon iconfont icon-edit" @click.stop="edit" />
<i v-if="curComponent.type==='view'" class="icon iconfont icon-fangda" @click.stop="showViewDetails" /> <i v-if="curComponent.type==='view'" class="icon iconfont icon-fangda" @click.stop="showViewDetails" />
<i v-if="curComponent.type==='view'&&existLinkage" class="icon iconfont icon-quxiaoliandong" @click.stop="clearLinkage" />
</div> </div>
</div> </div>
@ -53,6 +54,19 @@ export default {
} }
}, },
computed: { computed: {
existLinkage() {
let linkageFiltersCount = 0
this.componentData.forEach(item => {
if (item.linkageFilters && item.linkageFilters.length > 0) {
item.linkageFilters.forEach(linkage => {
if (this.element.propValue.viewId === linkage.sourceViewId) {
linkageFiltersCount++
}
})
}
})
return linkageFiltersCount
},
linkageInfo() { linkageInfo() {
return this.targetLinkageInfo[this.element.propValue.viewId] return this.targetLinkageInfo[this.element.propValue.viewId]
}, },
@ -93,6 +107,21 @@ export default {
}, },
linkageEdit() { linkageEdit() {
},
// sourceViewId
clearLinkage() {
this.componentData.forEach(item => {
if (item.linkageFilters && item.linkageFilters.length > 0) {
const newList = item.linkageFilters.filter(linkage => linkage.sourceViewId !== this.element.propValue.viewId)
item.linkageFilters.splice(0, item.linkageFilters.length)
// push watch
if (newList.length > 0) {
newList.forEach(newLinkage => {
item.linkageFilters.push(newLinkage)
})
}
}
})
} }
} }
} }

View File

@ -1210,7 +1210,9 @@ export default {
do_not_save: "Don't Save", do_not_save: "Don't Save",
save_and_close: 'Save', save_and_close: 'Save',
drill: 'drill', drill: 'drill',
linkage: 'linkage' linkage: 'linkage',
cancel_linkage: 'Cancel Linkage',
remove_all_linkage: 'Remove All Linkage'
}, },
plugin: { plugin: {
local_install: 'Local installation', local_install: 'Local installation',

View File

@ -1209,7 +1209,9 @@ export default {
do_not_save: '不保存', do_not_save: '不保存',
save: '保存', save: '保存',
drill: '下钻', drill: '下钻',
linkage: '联动' linkage: '联动',
cancel_linkage: '取消联动',
remove_all_linkage: '清除所有联动'
}, },
plugin: { plugin: {
local_install: '本地安裝', local_install: '本地安裝',

View File

@ -1211,7 +1211,9 @@ export default {
do_not_save: '不保存', do_not_save: '不保存',
save: '保存', save: '保存',
drill: '下钻', drill: '下钻',
linkage: '联动' linkage: '联动',
cancel_linkage: '取消联动',
remove_all_linkage: '清除所有联动'
}, },
plugin: { plugin: {
local_install: '本地安装', local_install: '本地安装',

View File

@ -178,7 +178,7 @@ const data = {
if (element.propValue.viewId === targetViewId) { // 如果目标视图 和 当前循环组件id相等 则进行条件增减 if (element.propValue.viewId === targetViewId) { // 如果目标视图 和 当前循环组件id相等 则进行条件增减
const targetFieldId = targetInfoArray[1] // 目标视图列ID const targetFieldId = targetInfoArray[1] // 目标视图列ID
const condition = new Condition('', targetFieldId, 'eq', [dimension.value], [targetViewId]) const condition = new Condition('', targetFieldId, 'eq', [dimension.value], [targetViewId])
condition.sourceViewId = viewId
let j = currentFilters.length let j = currentFilters.length
while (j--) { while (j--) {
const filter = currentFilters[j] const filter = currentFilters[j]