From 0dbe7738d153697c48331e84802ef2e0cc40cdff Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Thu, 26 Dec 2024 17:26:11 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=95=B0=E6=8D=AE=E5=A4=A7=E5=B1=8F):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E5=88=86=E7=BB=84Tab=E5=B5=8C=E5=A5=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data-visualization/RealTimeGroup.vue | 19 +- .../data-visualization/RealTimeGroupInner.vue | 598 ++++++++++++++++++ .../data-visualization/RealTimeListTree.vue | 26 +- core/core-frontend/src/utils/ShapeUtils.ts | 88 +++ 4 files changed, 712 insertions(+), 19 deletions(-) create mode 100644 core/core-frontend/src/components/data-visualization/RealTimeGroupInner.vue create mode 100644 core/core-frontend/src/utils/ShapeUtils.ts diff --git a/core/core-frontend/src/components/data-visualization/RealTimeGroup.vue b/core/core-frontend/src/components/data-visualization/RealTimeGroup.vue index d20476762b..7f7c73c514 100644 --- a/core/core-frontend/src/components/data-visualization/RealTimeGroup.vue +++ b/core/core-frontend/src/components/data-visualization/RealTimeGroup.vue @@ -77,6 +77,7 @@ import ComposeShow from '@/components/data-visualization/canvas/ComposeShow.vue' import { composeStoreWithOut } from '@/store/modules/data-visualization/compose' import circlePackingOrigin from '@/assets/svg/circle-packing-origin.svg' import RealTimeTab from '@/components/data-visualization/RealTimeTab.vue' +import RealTimeGroupInner from '@/components/data-visualization/RealTimeGroupInner.vue' const dropdownMore = ref(null) const lockStore = lockStoreWithOut() @@ -319,8 +320,8 @@ const expandClick = component => { @click="onClick(transformIndex(index))" >
{ :component-data="getComponent(index).propValue" >
+
+ +
@@ -470,7 +477,7 @@ const expandClick = component => { align-items: center; justify-content: flex-start; font-size: 12px; - padding: 0 2px 0 20px; + padding: 0 2px 0 28px; user-select: none; .component-icon { @@ -513,7 +520,7 @@ const expandClick = component => { .component-base { opacity: 1; } - width: 70px !important; + width: 55px !important; } } @@ -521,7 +528,7 @@ const expandClick = component => { .component-base { opacity: 0; } - width: 0px; + width: 0; display: flex; justify-content: flex-end; align-items: center; @@ -575,7 +582,7 @@ const expandClick = component => { } .icon-container-show { - width: 70px !important; + width: 55px !important; } .icon-container-lock { diff --git a/core/core-frontend/src/components/data-visualization/RealTimeGroupInner.vue b/core/core-frontend/src/components/data-visualization/RealTimeGroupInner.vue new file mode 100644 index 0000000000..a81fac3fb4 --- /dev/null +++ b/core/core-frontend/src/components/data-visualization/RealTimeGroupInner.vue @@ -0,0 +1,598 @@ + + + + + + + diff --git a/core/core-frontend/src/components/data-visualization/RealTimeListTree.vue b/core/core-frontend/src/components/data-visualization/RealTimeListTree.vue index f44d480017..eda406b46d 100644 --- a/core/core-frontend/src/components/data-visualization/RealTimeListTree.vue +++ b/core/core-frontend/src/components/data-visualization/RealTimeListTree.vue @@ -81,6 +81,7 @@ import { contextmenuStoreWithOut } from '@/store/modules/data-visualization/cont import RealTimeTab from '@/components/data-visualization/RealTimeTab.vue' import { useI18n } from '@/hooks/web/useI18n' import circlePackingOrigin from '@/assets/svg/circle-packing-origin.svg' +import { checkJoinGroup } from '@/utils/canvasUtils' const dropdownMore = ref(null) const lockStore = lockStoreWithOut() @@ -136,16 +137,15 @@ const shiftDataPush = curClickIndex => { indexBegin = curClickIndex indexEnd = laterIndexTrans } - const shiftAreaComponents = componentData.value - .slice(indexBegin, indexEnd + 1) - .filter( - component => - !areaDataIdArray.includes(component.id) && - !component.isLock && - component.isShow && - component.category !== 'hidden' && - !['GroupArea', 'DeTabs'].includes(component.component) - ) + const shiftAreaComponents = componentData.value.slice(indexBegin, indexEnd + 1).filter( + component => + !areaDataIdArray.includes(component.id) && + !component.isLock && + component.isShow && + component.category !== 'hidden' && + !['GroupArea'].includes(component.component) && + checkJoinGroup(component) // 当前如果是Tab 则tab中不能包含Group + ) areaData.value.components.push(...shiftAreaComponents) dvMainStore.setCurComponent({ component: null, index: null }) } @@ -509,7 +509,7 @@ const canvasChange = () => { >
{ align-items: center; justify-content: flex-start; font-size: 12px; - padding: 0 2px 0 0px; + padding: 0 2px 0 8px; user-select: none; .component-icon { @@ -705,7 +705,7 @@ const canvasChange = () => { .component-base { opacity: 1; } - width: 66px !important; + max-width: 66px !important; } } diff --git a/core/core-frontend/src/utils/ShapeUtils.ts b/core/core-frontend/src/utils/ShapeUtils.ts new file mode 100644 index 0000000000..d722e1aba6 --- /dev/null +++ b/core/core-frontend/src/utils/ShapeUtils.ts @@ -0,0 +1,88 @@ +import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain' +import { storeToRefs } from 'pinia' + +const dvMainStore = dvMainStoreWithOut() +const { componentData } = storeToRefs(dvMainStore) + +// 检查是否可以加入到分组 +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) { + if (checkType === 'canvas-main') { + return isMainCanvas(item.canvasId) + } + const pathMap = {} + componentData.value.forEach(componentItem => { + canvasIdMapCheck(componentItem, null, pathMap) + }) + + // 父组件是Tab且在group中 + if (checkType === 'pTabGroup') { + return Boolean( + pathMap[item.id] && + pathMap[item.id].component === 'DeTabs' && + pathMap[pathMap[item.id].id] && + pathMap[pathMap[item.id].id].component === 'Group' + ) + } + // 当前组件是group且在Tab中 + if (checkType === 'groupInTab') { + return Boolean( + 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 +} + +export function canvasIdMapCheck(item, pItem, pathMap) { + pathMap[item.id] = pItem + if (item.component === 'DeTabs') { + item.propValue.forEach(tabItem => { + tabItem.componentData.forEach(tabComponent => { + canvasIdMapCheck(tabComponent, item, pathMap) + }) + }) + } else if (item.component === 'Group') { + item.propValue.forEach(groupItem => { + canvasIdMapCheck(groupItem, item, pathMap) + }) + } +}