Merge pull request #757 from dataease/pr@dev@refactor_panel-pdf

feat:仪表板新增复制功能
This commit is contained in:
王嘉豪 2021-09-03 11:20:52 +08:00 committed by GitHub
commit 6bd2c603aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 5 deletions

View File

@ -103,7 +103,19 @@ public class PanelGroupService {
newDefaultPanel.setCreateBy(AuthUtils.getUser().getUsername()); newDefaultPanel.setCreateBy(AuthUtils.getUser().getUsername());
checkPanelName(newDefaultPanel.getName(), newDefaultPanel.getPid(), PanelConstants.OPT_TYPE_INSERT, newDefaultPanel.getId()); checkPanelName(newDefaultPanel.getName(), newDefaultPanel.getPid(), PanelConstants.OPT_TYPE_INSERT, newDefaultPanel.getId());
panelGroupMapper.insertSelective(newDefaultPanel); panelGroupMapper.insertSelective(newDefaultPanel);
} else { } else if ("copy".equals(request.getOptType())) {
panelId = UUID.randomUUID().toString();
// 复制模板
PanelGroupWithBLOBs newPanel = panelGroupMapper.selectByPrimaryKey(request.getId());
// 插入校验
if (StringUtils.isNotEmpty(request.getName())) {
checkPanelName(request.getName(), newPanel.getPid(), PanelConstants.OPT_TYPE_INSERT, request.getId());
}
newPanel.setName(request.getName());
newPanel.setId(panelId);
newPanel.setCreateBy(AuthUtils.getUser().getUsername());
panelGroupMapper.insertSelective(newPanel);
}else {
// 更新 // 更新
if (StringUtils.isNotEmpty(request.getName())) { if (StringUtils.isNotEmpty(request.getName())) {
checkPanelName(request.getName(), request.getPid(), PanelConstants.OPT_TYPE_UPDATE, request.getId()); checkPanelName(request.getName(), request.getPid(), PanelConstants.OPT_TYPE_UPDATE, request.getId());

View File

@ -109,6 +109,9 @@
<el-dropdown-item v-if="data.nodeType==='panel'" icon="el-icon-share" :command="beforeClickMore('share',data,node)"> <el-dropdown-item v-if="data.nodeType==='panel'" icon="el-icon-share" :command="beforeClickMore('share',data,node)">
{{ $t('panel.share') }} {{ $t('panel.share') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item v-if="data.nodeType==='panel'" icon="el-icon-document-copy" :command="beforeClickMore('copy',data,node)">
{{ $t('panel.copy') }}
</el-dropdown-item>
<el-dropdown-item v-if="data.nodeType==='panel'" icon="el-icon-paperclip" :command="beforeClickMore('link',data,node)"> <el-dropdown-item v-if="data.nodeType==='panel'" icon="el-icon-paperclip" :command="beforeClickMore('link',data,node)">
{{ $t('panel.create_public_links') }} {{ $t('panel.create_public_links') }}
</el-dropdown-item> </el-dropdown-item>
@ -306,11 +309,16 @@ export default {
this.lastActiveNodeData.name = panelInfo.name this.lastActiveNodeData.name = panelInfo.name
return return
} }
if (!this.lastActiveNodeData.children) { //
this.$set(this.lastActiveNodeData, 'children', []) if (this.editPanel.optType === 'copy') {
this.lastActiveNode.parent.data.children.push(panelInfo)
} else {
if (!this.lastActiveNodeData.children) {
this.$set(this.lastActiveNodeData, 'children', [])
}
this.lastActiveNodeData.children.push(panelInfo)
this.lastActiveNode.expanded = true
} }
this.lastActiveNodeData.children.push(panelInfo)
this.lastActiveNode.expanded = true
this.activeNodeAndClick(panelInfo) this.activeNodeAndClick(panelInfo)
} else { } else {
this.tree(this.groupForm) this.tree(this.groupForm)
@ -367,6 +375,18 @@ export default {
} }
} }
break break
case 'copy':
this.editPanel = {
visible: true,
titlePre: this.$t('panel.copy'),
optType: 'copy',
panelInfo: {
id: param.data.id,
name: param.data.name,
optType: 'copy'
}
}
break
} }
switch (param.type) { switch (param.type) {
case 'folder': case 'folder':
@ -388,6 +408,7 @@ export default {
clickMore(param) { clickMore(param) {
switch (param.optType) { switch (param.optType) {
case 'copy':
case 'toDefaultPanel': case 'toDefaultPanel':
case 'rename': case 'rename':
this.showEditPanel(param) this.showEditPanel(param)