feat(数据大屏): 支持分组移入Tab

This commit is contained in:
wangjiahao 2024-12-18 18:18:36 +08:00 committed by 王嘉豪
parent b09995677b
commit e8cbbfbca2
3 changed files with 50 additions and 10 deletions

View File

@ -133,6 +133,7 @@ import { useEmitt } from '@/hooks/web/useEmitt'
import ComposeShow from '@/components/data-visualization/canvas/ComposeShow.vue'
import { groupSizeStyleAdaptor, groupStyleRevert, tabInnerStyleRevert } from '@/utils/style'
import {
checkJoinTab,
isDashboard,
isGroupCanvas,
isMainCanvas,
@ -184,7 +185,7 @@ const state = reactive({
id: ''
},
// Tab
ignoreTabMoveComponent: ['de-button', 'de-reset-button', 'DeTabs', 'Group', 'GroupArea'],
ignoreTabMoveComponent: ['de-button', 'de-reset-button', 'DeTabs', 'GroupArea'],
// tab
parentWidthTabOffset: 40,
canvasChangeTips: 'none',
@ -283,7 +284,8 @@ const {
canvasActive
} = toRefs(props)
let pTabGroupFlag = itemCanvasPathCheck(element.value, 'pTabGroup')
const pTabGroupFlag = itemCanvasPathCheck(element.value, 'pTabGroup')
const pJoinTab = checkJoinTab(element.value)
const domId = ref('shape-id-' + element.value.id)
const pointList = ['lt', 't', 'rt', 'r', 'rb', 'b', 'lb', 'l']
const pointCorner = ['lt', 'rt', 'rb', 'lb']
@ -552,9 +554,11 @@ const handleMouseDownOnShape = e => {
// Tab(30px 30px 30px)
//
// 使curX 使 tab + +
// tabtabGroup pTabGroupFlag = true
// tabtabGroup pTabGroupFlag = true
// Tab pJoinTab = false
if (
!pTabGroupFlag &&
pJoinTab &&
!isMainCanvas(canvasId.value) &&
!isGroupCanvas(canvasId.value) &&
!isGroupArea.value &&

View File

@ -11,6 +11,7 @@ import {
} from '@/custom-component/component-list'
import { createGroupStyle, getComponentRotatedStyle } from '@/utils/style'
import eventBus from '@/utils/eventBus'
import { checkJoinGroup } from '@/utils/canvasUtils'
const dvMainStore = dvMainStoreWithOut()
const { curComponent, componentData, curOriginThemes } = storeToRefs(dvMainStore)
@ -159,7 +160,7 @@ export const composeStore = defineStore('compose', {
components.push(...component.propValue)
} else if (['GroupArea'].includes(component.component)) {
// do nothing GroupAreas组合视阔区 DeTabs 均不加入分组中
} else {
} else if (checkJoinGroup(component)) {
components.push(component)
}
})

View File

@ -632,10 +632,39 @@ export function setIdValueTrans(from, to, content, colList) {
export function isMainCanvas(canvasId) {
return canvasId === 'canvas-main'
}
// 检查是否可以加入到分组
export function checkJoinGroup(item) {
if (item.component === 'DeTabs') {
let result = true
item.propValue.forEach(tabItem => {
tabItem.componentData.forEach(tabComponent => {
if (tabComponent.component === 'Group') {
result = false
}
})
})
return result
} else {
return true
}
}
// 检查是否可以移入tab
export function checkJoinTab(item) {
if (item.component === 'Group') {
let result = true
item.propValue.forEach(groupItem => {
if (groupItem.component === 'DeTabs') {
result = false
}
})
return result
} else {
return true
}
}
// 目前仅允许group中还有一层Tab 或者 Tab中含有一层group
export function itemCanvasPathCheck(item, checkType) {
console.log('===test==' + item.component + '==' + checkType)
if (checkType === 'canvas-main') {
return isMainCanvas(item.canvasId)
}
@ -644,7 +673,7 @@ export function itemCanvasPathCheck(item, checkType) {
canvasIdMapCheck(componentItem, null, pathMap)
})
// 父组件是Tab且在group中
// 父组件是Tab且在group中
if (checkType === 'pTabGroup') {
return Boolean(
pathMap[item.id] &&
@ -653,15 +682,21 @@ export function itemCanvasPathCheck(item, checkType) {
pathMap[pathMap[item.id].id].component === 'Group'
)
}
// 父组件是group且否在Tab中
if (checkType === 'pGroupTab') {
// 当前组件是group且在Tab中
if (checkType === 'groupInTab') {
return Boolean(
pathMap[item.id] &&
pathMap[item.id].component === 'Group' &&
item.component === 'Group' &&
pathMap[pathMap[item.id].id] &&
pathMap[pathMap[item.id].id].component === 'DeTabs'
)
}
// 当前组件是Tab且在Group中
if (checkType === 'tabInGroup') {
return Boolean(
item.component === 'DeTabs' && pathMap[item.id] && pathMap[item.id].component === 'Group'
)
}
return false
}