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> <artifactId>flexmark-all</artifactId>
<version>${flexmark.version}</version> <version>${flexmark.version}</version>
</dependency> </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> </dependencies>
<build> <build>

View File

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

View File

@ -184,17 +184,14 @@ export const copyStore = defineStore('copy', {
} }
}) })
export function deepCopyTabItemHelper(tabId, tabItem, idMap) { export function deepCopyTabItemHelper(newCanvasId, tabComponentData, idMap) {
const result = deepCopy(tabItem) const resultComponentData = []
const newComponentId = generateID() tabComponentData.forEach(item => {
result.id = newComponentId
result.componentData = []
tabItem.componentData.forEach(item => {
const newItem = deepCopyHelper(item, idMap) const newItem = deepCopyHelper(item, idMap)
newItem.canvasId = tabId + '--' + newComponentId newItem.canvasId = newCanvasId
result.componentData.push(deepCopyHelper(item, idMap)) resultComponentData.push(newItem)
}) })
return result return resultComponentData
} }
function deepCopyHelper(data, idMap) { 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 // eslint-disable-next-line @typescript-eslint/no-this-alias
const _this = this const _this = this
//组件组内部可能还有多个图表 //组件组内部可能还有多个图表