feat(仪表板、数据大屏): Tab组件支持整页复制 #10828

This commit is contained in:
wangjiahao 2024-09-05 15:36:59 +08:00
parent 4604864816
commit 3c14cc8db9
2 changed files with 22 additions and 0 deletions

View File

@ -47,6 +47,9 @@
>
删除
</el-dropdown-item>
<el-dropdown-item :command="beforeHandleCommand('copyCur', tabItem)">
复制
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
@ -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

View File

@ -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()