Merge pull request #12057 from dataease/pr@dev-v2@refactor_tab-copy

feat(仪表板、数据大屏): Tab批量复制优化
This commit is contained in:
王嘉豪 2024-09-06 10:30:00 +08:00 committed by GitHub
commit 1dc11a3db1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 37 additions and 15 deletions

View File

@ -131,6 +131,21 @@
<artifactId>flexmark-all</artifactId>
<version>${flexmark.version}</version>
</dependency>
<dependency>
<groupId>io.dataease</groupId>
<artifactId>xpack-permissions</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.dataease</groupId>
<artifactId>xpack-sync</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.dataease</groupId>
<artifactId>xpack-base</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>

View File

@ -40,16 +40,15 @@
<el-dropdown-item :command="beforeHandleCommand('editTitle', tabItem)">
编辑标题
</el-dropdown-item>
<el-dropdown-item :command="beforeHandleCommand('copyCur', tabItem)">
复制
</el-dropdown-item>
<el-dropdown-item
v-if="element.propValue.length > 1"
:command="beforeHandleCommand('deleteCur', tabItem)"
>
删除
</el-dropdown-item>
<el-dropdown-item :command="beforeHandleCommand('copyCur', tabItem)">
复制
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
@ -265,8 +264,12 @@ function deleteCur(param) {
}
}
function copyCur(param) {
state.curItem = param
element.value.propValue.push(deepCopyTabItemHelper(element.value.id, param))
addTab()
const newTabItem = element.value.propValue[element.value.propValue.length - 1]
const idMap = {}
const newCanvasId = element.value.id + '--' + newTabItem.name
newTabItem.componentData = deepCopyTabItemHelper(newCanvasId, param.componentData, idMap)
dvMainStore.updateCopyCanvasView(idMap)
}
function editCurTitle(param) {
@ -284,6 +287,9 @@ function handleCommand(command) {
case 'deleteCur':
deleteCur(command.param)
break
case 'copyCur':
copyCur(command.param)
break
}
}

View File

@ -184,17 +184,14 @@ 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 => {
export function deepCopyTabItemHelper(newCanvasId, tabComponentData, idMap) {
const resultComponentData = []
tabComponentData.forEach(item => {
const newItem = deepCopyHelper(item, idMap)
newItem.canvasId = tabId + '--' + newComponentId
result.componentData.push(deepCopyHelper(item, idMap))
newItem.canvasId = newCanvasId
resultComponentData.push(newItem)
})
return result
return resultComponentData
}
function deepCopyHelper(data, idMap) {

View File

@ -380,6 +380,10 @@ export const dvMainStore = defineStore('dataVisualization', {
}
})
}
//组件组内部可能还有多个图表
this.updateCopyCanvasView(idMap, canvasViewInfoPre)
},
updateCopyCanvasView(idMap, canvasViewInfoPre = this.canvasViewInfo) {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const _this = this
//组件组内部可能还有多个图表