From 3c14cc8db915099bd2e8f4d37155fa1480dc7656 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Thu, 5 Sep 2024 15:36:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E4=BB=AA=E8=A1=A8=E6=9D=BF=E3=80=81?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=A7=E5=B1=8F):=20Tab=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=95=B4=E9=A1=B5=E5=A4=8D=E5=88=B6=20#10828?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/custom-component/de-tabs/Component.vue | 9 +++++++++ .../src/store/modules/data-visualization/copy.ts | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/core/core-frontend/src/custom-component/de-tabs/Component.vue b/core/core-frontend/src/custom-component/de-tabs/Component.vue index 56e17c599e..78e3b8b8d9 100644 --- a/core/core-frontend/src/custom-component/de-tabs/Component.vue +++ b/core/core-frontend/src/custom-component/de-tabs/Component.vue @@ -47,6 +47,9 @@ > 删除 + + 复制 + @@ -126,10 +129,12 @@ import DePreview from '@/components/data-visualization/canvas/DePreview.vue' import { useEmitt } from '@/hooks/web/useEmitt' import { getPanelAllLinkageInfo } from '@/api/visualization/linkage' import { dataVTabComponentAdd, groupSizeStyleAdaptor } from '@/utils/style' +import { copyStoreWithOut, deepCopyTabItemHelper } from '@/store/modules/data-visualization/copy' const dvMainStore = dvMainStoreWithOut() const { tabMoveInActiveId, bashMatrixInfo, editMode, mobileInPc } = storeToRefs(dvMainStore) const tabComponentRef = ref(null) let carouselTimer = null +const copyStore = copyStoreWithOut() const props = defineProps({ canvasStyleData: { @@ -259,6 +264,10 @@ function deleteCur(param) { } } } +function copyCur(param) { + state.curItem = param + element.value.propValue.push(deepCopyTabItemHelper(element.value.id, param)) +} function editCurTitle(param) { state.activeTabName = param.name diff --git a/core/core-frontend/src/store/modules/data-visualization/copy.ts b/core/core-frontend/src/store/modules/data-visualization/copy.ts index 7427d5b287..4cb9cdaf73 100644 --- a/core/core-frontend/src/store/modules/data-visualization/copy.ts +++ b/core/core-frontend/src/store/modules/data-visualization/copy.ts @@ -184,6 +184,19 @@ export const copyStore = defineStore('copy', { } }) +export function deepCopyTabItemHelper(tabId, tabItem, idMap) { + const result = deepCopy(tabItem) + const newComponentId = generateID() + result.id = newComponentId + result.componentData = [] + tabItem.componentData.forEach(item => { + const newItem = deepCopyHelper(item, idMap) + newItem.canvasId = tabId + '--' + newComponentId + result.componentData.push(deepCopyHelper(item, idMap)) + }) + return result +} + function deepCopyHelper(data, idMap) { const result = deepCopy(data) const newComponentId = generateID()