Merge pull request #3430 from dataease/pr@dev@feat_tab-filter

feat(仪表板): Tab组件内的过滤组件作用域仅限于当前Tab页范围
This commit is contained in:
fit2cloud-chenyw 2022-10-24 17:39:35 +08:00 committed by GitHub
commit dc05931e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 71 additions and 16 deletions

View File

@ -41,12 +41,14 @@
:in-screen="inScreen" :in-screen="inScreen"
:edit-mode="'preview'" :edit-mode="'preview'"
:h="config.style.height" :h="config.style.height"
:canvas-id="canvasId"
/> />
<component <component
:is="config.component" :is="config.component"
v-else v-else
ref="wrapperChild" ref="wrapperChild"
class="component" class="component"
:canvas-id="canvasId"
:out-style="config.style" :out-style="config.style"
:style="getComponentStyleDefault(config.style)" :style="getComponentStyleDefault(config.style)"
:prop-value="config.propValue" :prop-value="config.propValue"
@ -83,6 +85,10 @@ export default {
components: { CloseBar, MobileCheckBar, DeOutWidget, EditBar }, components: { CloseBar, MobileCheckBar, DeOutWidget, EditBar },
mixins: [mixins], mixins: [mixins],
props: { props: {
canvasId: {
type: String,
required: true
},
sourceConfig: { sourceConfig: {
type: Object, type: Object,
require: true, require: true,

View File

@ -58,6 +58,7 @@
<de-out-widget <de-out-widget
v-if="renderOk && item.type==='custom'" v-if="renderOk && item.type==='custom'"
:id="'component' + item.id" :id="'component' + item.id"
:canvas-id="canvasId"
ref="wrapperChild" ref="wrapperChild"
class="component" class="component"
:style="getComponentStyleDefault(item.style)" :style="getComponentStyleDefault(item.style)"
@ -72,6 +73,7 @@
:is="item.component" :is="item.component"
v-else-if="renderOk && item.type==='other'" v-else-if="renderOk && item.type==='other'"
:id="'component' + item.id" :id="'component' + item.id"
:canvas-id="canvasId"
ref="wrapperChild" ref="wrapperChild"
class="component" class="component"
:style="getComponentStyle(item.style)" :style="getComponentStyle(item.style)"
@ -84,6 +86,7 @@
:is="item.component" :is="item.component"
v-else-if="renderOk" v-else-if="renderOk"
:id="'component' + item.id" :id="'component' + item.id"
:canvas-id="canvasId"
ref="wrapperChild" ref="wrapperChild"
class="component" class="component"
:filters="filterMap[item.propValue && item.propValue.viewId]" :filters="filterMap[item.propValue && item.propValue.viewId]"
@ -1416,10 +1419,12 @@ export default {
matrixStyleOriginWidth: this.matrixStyle.originWidth, matrixStyleOriginWidth: this.matrixStyle.originWidth,
matrixStyleOriginHeight: this.matrixStyle.originHeight matrixStyleOriginHeight: this.matrixStyle.originHeight
}) })
this.$store.commit('setPreviewCanvasScale', { if(this.canvasId === 'canvas-main'){
scaleWidth: this.scalePointWidth, this.$store.commit('setPreviewCanvasScale', {
scaleHeight: this.scalePointHeight scaleWidth: this.scalePointWidth,
}) scaleHeight: this.scalePointHeight
})
}
} }
}, },
getShapeStyleIntDeDrag(style, prop, item) { getShapeStyleIntDeDrag(style, prop, item) {
@ -1627,7 +1632,6 @@ export default {
let newY = Math.round((item.style.top * this.scalePointHeight) / this.matrixStyle.height) + 1 let newY = Math.round((item.style.top * this.scalePointHeight) / this.matrixStyle.height) + 1
newX = newX > 0 ? newX : 1 newX = newX > 0 ? newX : 1
newY = newY > 0 ? newY : 1 newY = newY > 0 ? newY : 1
console.log("moveTabCollisionActive="+this.moveTabCollisionActive)
if (this.moveTabCollisionActive) { if (this.moveTabCollisionActive) {
return return
} }

View File

@ -43,6 +43,7 @@
:key="index" :key="index"
ref="viewWrapperChild" ref="viewWrapperChild"
:config="item" :config="item"
:canvas-id="canvasId"
:source-config="componentData[index]" :source-config="componentData[index]"
:search-count="searchCount" :search-count="searchCount"
:in-screen="inScreen" :in-screen="inScreen"
@ -440,7 +441,9 @@ export default {
} else { } else {
this.scaleHeight = canvasHeight * 100 / this.canvasStyleData.height// this.scaleHeight = canvasHeight * 100 / this.canvasStyleData.height//
} }
this.$store.commit('setPreviewCanvasScale', { scaleWidth: (this.scaleWidth / 100), scaleHeight: (this.scaleHeight / 100) }) if(this.canvasId === 'canvas-main'){
this.$store.commit('setPreviewCanvasScale', { scaleWidth: (this.scaleWidth / 100), scaleHeight: (this.scaleHeight / 100) })
}
this.handleScaleChange() this.handleScaleChange()
}, },
resetID(data) { resetID(data) {

View File

@ -216,6 +216,10 @@ export default {
name: 'UserView', name: 'UserView',
components: { UserViewDialog, DeRichTextView, LabelNormalText, PluginCom, ChartComponentS2, EditBarView, ChartComponent, TableNormal, LabelNormal, DrillPath, ChartComponentG2 }, components: { UserViewDialog, DeRichTextView, LabelNormalText, PluginCom, ChartComponentS2, EditBarView, ChartComponent, TableNormal, LabelNormal, DrillPath, ChartComponentG2 },
props: { props: {
canvasId: {
type: String,
required: true
},
element: { element: {
type: Object, type: Object,
default: null default: null

View File

@ -39,6 +39,7 @@
:is="element.component" :is="element.component"
v-if="element.type==='custom'" v-if="element.type==='custom'"
:id="'component' + element.id" :id="'component' + element.id"
:canvas-id="canvasId"
ref="deOutWidget" ref="deOutWidget"
class="component-custom" class="component-custom"
:out-style="element.style" :out-style="element.style"
@ -64,6 +65,10 @@ export default {
name: 'DeOutWidget', name: 'DeOutWidget',
mixins: [inputStyleMixin], mixins: [inputStyleMixin],
props: { props: {
canvasId: {
type: String,
required: true
},
element: { element: {
type: Object, type: Object,
default: () => {} default: () => {}

View File

@ -35,6 +35,10 @@ import customInput from '@/components/widget/DeWidget/customInput'
export default { export default {
mixins: [customInput], mixins: [customInput],
props: { props: {
canvasId: {
type: String,
required: true
},
element: { element: {
type: Object, type: Object,
default: null default: null
@ -221,6 +225,7 @@ export default {
}, },
getCondition() { getCondition() {
const param = { const param = {
canvasId: this.canvasId,
component: this.element, component: this.element,
value: this.formatFilterValue(), value: this.formatFilterValue(),
operator: this.operator operator: this.operator

View File

@ -27,6 +27,10 @@ import bus from '@/utils/bus'
export default { export default {
props: { props: {
canvasId: {
type: String,
required: true
},
element: { element: {
type: Object, type: Object,
default: null default: null
@ -104,6 +108,7 @@ export default {
}, },
getCondition() { getCondition() {
const param = { const param = {
canvasId: this.canvasId,
component: this.element, component: this.element,
value: !this.value ? [] : Array.isArray(this.value) ? this.value : [this.value], value: !this.value ? [] : Array.isArray(this.value) ? this.value : [this.value],
operator: this.operator operator: this.operator

View File

@ -47,6 +47,10 @@ import bus from '@/utils/bus'
export default { export default {
props: { props: {
canvasId: {
type: String,
required: true
},
element: { element: {
type: Object, type: Object,
default: null default: null
@ -230,6 +234,7 @@ export default {
}, },
getCondition() { getCondition() {
const param = { const param = {
canvasId: this.canvasId,
component: this.element, component: this.element,
value: [this.form.min, this.form.max], value: [this.form.min, this.form.max],
operator: this.operator operator: this.operator

View File

@ -52,6 +52,10 @@ export default {
components: { ElVisualSelect }, components: { ElVisualSelect },
mixins: [customInput], mixins: [customInput],
props: { props: {
canvasId: {
type: String,
required: true
},
element: { element: {
type: Object, type: Object,
default: () => {} default: () => {}
@ -311,6 +315,7 @@ export default {
}, },
getCondition() { getCondition() {
const param = { const param = {
canvasId: this.canvasId,
component: this.element, component: this.element,
value: this.formatFilterValue(), value: this.formatFilterValue(),
operator: this.operator operator: this.operator

View File

@ -73,6 +73,10 @@ import { attrsMap, styleAttrs, textSelectGridWidget } from '@/components/widget/
export default { export default {
props: { props: {
canvasId: {
type: String,
required: true
},
element: { element: {
type: Object, type: Object,
default: null default: null
@ -312,6 +316,7 @@ export default {
}, },
getCondition() { getCondition() {
const param = { const param = {
canvasId: this.canvasId,
component: this.element, component: this.element,
value: this.formatFilterValue(), value: this.formatFilterValue(),
operator: this.operator operator: this.operator

View File

@ -36,6 +36,10 @@ export default {
components: { ElTreeSelect }, components: { ElTreeSelect },
mixins: [customInput], mixins: [customInput],
props: { props: {
canvasId: {
type: String,
required: true
},
element: { element: {
type: Object, type: Object,
default: () => {} default: () => {}
@ -298,6 +302,7 @@ export default {
const val = this.formatFilterValue() const val = this.formatFilterValue()
const param = { const param = {
canvasId: this.canvasId,
component: this.element, component: this.element,
value: val, value: val,
operator: this.operator, operator: this.operator,

View File

@ -164,7 +164,7 @@ const data = {
...snapshot.mutations, ...snapshot.mutations,
...lock.mutations, ...lock.mutations,
setTabActiveTabNameMap(state, tabActiveInfo){ setTabActiveTabNameMap(state, tabActiveInfo) {
state.tabActiveTabNameMap[tabActiveInfo.tabId] = tabActiveInfo.activeTabName state.tabActiveTabNameMap[tabActiveInfo.tabId] = tabActiveInfo.activeTabName
}, },
@ -288,6 +288,13 @@ const data = {
const vValid = valueValid(condition) const vValid = valueValid(condition)
// 1.根据componentId过滤 // 1.根据componentId过滤
const filterComponentId = condition.componentId const filterComponentId = condition.componentId
const canvasId = data.canvasId
//过滤时 主画布的过滤组件可以过滤所有的视图
const canvasViewIds = state.componentData.filter(item => item.type === 'view' && (canvasId === 'canvas-main' || item.canvasId === canvasId)).map((itemView) => {
return itemView.propValue.viewId
})
const canvasViewIdMatch = (viewId) => canvasViewIds && canvasViewIds.length > 0 && canvasViewIds.includes(viewId)
// 2.循环每个Component 得到 三种情况 a增加b删除c无操作 // 2.循环每个Component 得到 三种情况 a增加b删除c无操作
const viewIdMatch = (viewIds, viewId) => !viewIds || viewIds.length === 0 || viewIds.includes(viewId) const viewIdMatch = (viewIds, viewId) => !viewIds || viewIds.length === 0 || viewIds.includes(viewId)
@ -317,7 +324,7 @@ const data = {
} }
if (!element.type || element.type !== 'view') continue if (!element.type || element.type !== 'view') continue
const currentFilters = element.filters || [] const currentFilters = element.filters || []
const vidMatch = viewIdMatch(condition.viewIds, element.propValue.viewId) const vidMatch = viewIdMatch(condition.viewIds, element.propValue.viewId) && canvasViewIdMatch(element.propValue.viewId)
let j = currentFilters.length let j = currentFilters.length
while (j--) { while (j--) {
const filter = currentFilters[j] const filter = currentFilters[j]
@ -484,12 +491,8 @@ const data = {
} }
} }
}, },
deleteComponent(state) {
deleteComponent(state, index) { this.commit('deleteComponentWithId',state.curComponent.id)
if (index === undefined) {
index = state.curComponentIndex
}
state.componentData.splice(index, 1)
}, },
setLinkageInfo(state, targetLinkageInfo) { setLinkageInfo(state, targetLinkageInfo) {
state.linkageSettingStatus = true state.linkageSettingStatus = true
@ -752,13 +755,13 @@ const data = {
setTabMoveOutComponentId(state, componentId) { setTabMoveOutComponentId(state, componentId) {
state.tabMoveOutComponentId = componentId state.tabMoveOutComponentId = componentId
}, },
clearTabMoveInfo(state){ clearTabMoveInfo(state) {
state.tabMoveInActiveId = null state.tabMoveInActiveId = null
state.tabCollisionActiveId = null state.tabCollisionActiveId = null
state.tabMoveOutActiveId = null state.tabMoveOutActiveId = null
state.tabMoveOutComponentId = null state.tabMoveOutComponentId = null
}, },
setMousePointShadowMap(state,mousePoint){ setMousePointShadowMap(state, mousePoint) {
state.mousePointShadowMap.mouseX = mousePoint.mouseX state.mousePointShadowMap.mouseX = mousePoint.mouseX
state.mousePointShadowMap.mouseY = mousePoint.mouseY state.mousePointShadowMap.mouseY = mousePoint.mouseY
state.mousePointShadowMap.width = mousePoint.width state.mousePointShadowMap.width = mousePoint.width