From 9875240437a00163d8379d58ee2e49815b91cecf Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Fri, 18 Nov 2022 15:37:08 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E4=BB=AA=E8=A1=A8=E6=9D=BF=E8=8F=9C=E5=8D=95=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=89=93=E5=BC=80=E7=AC=AC=E4=B8=80=E4=B8=AA=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E4=BB=AA=E8=A1=A8=E6=9D=BF=E4=B8=94=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E4=BB=AA=E8=A1=A8=E6=9D=BF=E5=A2=9E=E5=8A=A0=E7=BD=AE=E9=A1=B6?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../panel/PanelGroupController.java | 50 +++--- .../io/dataease/ext/ExtPanelGroupMapper.xml | 160 +++++++++--------- .../service/panel/PanelGroupService.java | 11 ++ .../main/resources/db/migration/V44__1.17.sql | 3 + frontend/src/api/panel/panel.js | 8 + .../canvas/components/editor/EditBar.vue | 2 +- .../canvas/components/editor/Preview.vue | 7 +- frontend/src/lang/en.js | 4 +- frontend/src/lang/tw.js | 4 +- frontend/src/lang/zh.js | 4 +- frontend/src/views/background/index.vue | 2 +- frontend/src/views/panel/list/PanelList.vue | 73 +++++++- 12 files changed, 212 insertions(+), 116 deletions(-) diff --git a/backend/src/main/java/io/dataease/controller/panel/PanelGroupController.java b/backend/src/main/java/io/dataease/controller/panel/PanelGroupController.java index 217ab70c06..28bb812286 100644 --- a/backend/src/main/java/io/dataease/controller/panel/PanelGroupController.java +++ b/backend/src/main/java/io/dataease/controller/panel/PanelGroupController.java @@ -5,11 +5,11 @@ import io.dataease.auth.annotation.DePermission; import io.dataease.auth.annotation.DePermissionProxy; import io.dataease.auth.annotation.DePermissions; import io.dataease.auth.service.impl.ExtAuthServiceImpl; -import io.dataease.commons.constants.PanelConstants; -import io.dataease.controller.request.panel.*; import io.dataease.commons.constants.DePermissionType; +import io.dataease.commons.constants.PanelConstants; import io.dataease.commons.constants.ResourceAuthLevel; import io.dataease.controller.handler.annotation.I18n; +import io.dataease.controller.request.panel.*; import io.dataease.dto.PermissionProxy; import io.dataease.dto.authModel.VAuthModelDTO; import io.dataease.dto.panel.PanelExport2App; @@ -17,10 +17,11 @@ import io.dataease.dto.panel.PanelGroupDTO; import io.dataease.service.panel.PanelGroupService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.pentaho.di.core.util.UUIDUtil; -import springfox.documentation.annotations.ApiIgnore; import org.apache.shiro.authz.annotation.Logical; +import org.pentaho.di.core.util.UUIDUtil; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -62,12 +63,12 @@ public class PanelGroupController { @DePermission(type = DePermissionType.PANEL, value = "pid", level = ResourceAuthLevel.PANEL_LEVEL_MANAGE) }, logical = Logical.AND) @I18n - public PanelGroupDTO save(@RequestBody PanelGroupRequest request) throws Exception{ + public PanelGroupDTO save(@RequestBody PanelGroupRequest request) throws Exception { String panelId = panelGroupService.save(request); PanelGroupDTO result = findOne(panelId); // 如果新建来源来自模板市场,在返回数据中加入父级ID便于跳转展开仪表板树 - if(PanelConstants.NEW_PANEL_FROM.NEW_MARKET_TEMPLATE.equals(request.getNewFrom())){ - result.setParents(authService.parentResource(panelId,"panel")); + if (PanelConstants.NEW_PANEL_FROM.NEW_MARKET_TEMPLATE.equals(request.getNewFrom())) { + result.setParents(authService.parentResource(panelId, "panel")); result.setRequestId(UUIDUtil.getUUIDAsString()); } return result; @@ -150,31 +151,33 @@ public class PanelGroupController { public void updatePanelStatus(@PathVariable String panelId, @RequestBody PanelGroupBaseInfoRequest request) { panelGroupService.updatePanelStatus(panelId, request); } + @ApiOperation("自动缓存") @PostMapping("/autoCache") @DePermissions(value = { @DePermission(type = DePermissionType.PANEL, value = "id"), @DePermission(type = DePermissionType.PANEL, value = "pid", level = ResourceAuthLevel.PANEL_LEVEL_MANAGE) }, logical = Logical.AND) - public void autoCache(@RequestBody PanelGroupRequest request){ + public void autoCache(@RequestBody PanelGroupRequest request) { panelGroupService.autoCache(request); } @ApiOperation("查找缓存") @GetMapping("/findUserCache/{panelId}") - public PanelGroupDTO findUserCache(@PathVariable String panelId){ + public PanelGroupDTO findUserCache(@PathVariable String panelId) { return panelGroupService.findUserPanelCache(panelId); } + @ApiOperation("检查缓存") @GetMapping("/checkUserCache/{panelId}") - public Boolean checkUserCache(@PathVariable String panelId){ + public Boolean checkUserCache(@PathVariable String panelId) { return panelGroupService.checkUserCache(panelId); } @ApiOperation("删除缓存") @DeleteMapping("/removePanelCache/{panelId}") - public void removePanelCache(@PathVariable String panelId){ + public void removePanelCache(@PathVariable String panelId) { panelGroupService.removePanelCache(panelId); } @@ -183,39 +186,46 @@ public class PanelGroupController { public void viewLog(@RequestBody PanelViewLogRequest request) { panelGroupService.viewLog(request); } + @ApiOperation("获取仪表板中视图Element信息") @GetMapping("/findPanelElementInfo/{viewId}") @I18n - public Object findPanelElementInfo(@PathVariable String viewId){ - return panelGroupService.findPanelElementInfo(viewId); + public Object findPanelElementInfo(@PathVariable String viewId) { + return panelGroupService.findPanelElementInfo(viewId); } + @GetMapping("/export2AppCheck/{panelId}") @I18n - public PanelExport2App export2AppCheck(@PathVariable String panelId){ - return panelGroupService.panelExport2AppCheck(panelId); + public PanelExport2App export2AppCheck(@PathVariable String panelId) { + return panelGroupService.panelExport2AppCheck(panelId); } @PostMapping("/appApply") - public PanelGroupDTO appApply(@RequestBody PanelAppTemplateApplyRequest request) throws Exception{ + public PanelGroupDTO appApply(@RequestBody PanelAppTemplateApplyRequest request) throws Exception { String panelId = panelGroupService.appApply(request); PanelGroupDTO result = findOne(panelId); - result.setParents(authService.parentResource(panelId,"panel")); + result.setParents(authService.parentResource(panelId, "panel")); result.setRequestId(UUIDUtil.getUUIDAsString()); result.setResponseSource("appApply"); return result; } @PostMapping("/appEdit") - public void appEdit(@RequestBody PanelAppTemplateApplyRequest request) throws Exception{ + public void appEdit(@RequestBody PanelAppTemplateApplyRequest request) throws Exception { panelGroupService.appEdit(request); } @GetMapping("/findOneWithParent/{panelId}") - public PanelGroupDTO findOneWithParent(@PathVariable String panelId) throws Exception{ + public PanelGroupDTO findOneWithParent(@PathVariable String panelId) throws Exception { PanelGroupDTO result = findOne(panelId); - result.setParents(authService.parentResource(panelId,"panel")); + result.setParents(authService.parentResource(panelId, "panel")); result.setRequestId(UUIDUtil.getUUIDAsString()); result.setResponseSource("appApply"); return result; } + + @PostMapping("/toTop/{panelId}") + public void toTop(@PathVariable String panelId) throws Exception { + panelGroupService.toTop(panelId); + } } diff --git a/backend/src/main/java/io/dataease/ext/ExtPanelGroupMapper.xml b/backend/src/main/java/io/dataease/ext/ExtPanelGroupMapper.xml index d9249ab5d9..1354bc5b56 100644 --- a/backend/src/main/java/io/dataease/ext/ExtPanelGroupMapper.xml +++ b/backend/src/main/java/io/dataease/ext/ExtPanelGroupMapper.xml @@ -16,16 +16,19 @@ - delete from panel_group where FIND_IN_SET(panel_group.id,GET_PANEL_GROUP_WITH_CHILDREN(#{pid})) or FIND_IN_SET(panel_group.source,GET_PANEL_GROUP_WITH_CHILDREN(#{pid})) + delete + from panel_group + where FIND_IN_SET(panel_group.id, GET_PANEL_GROUP_WITH_CHILDREN(#{pid})) + or FIND_IN_SET(panel_group.source, GET_PANEL_GROUP_WITH_CHILDREN(#{pid})) - delete from chart_view where FIND_IN_SET(chart_view.scene_id,GET_PANEL_GROUP_WITH_CHILDREN(#{pid})) + delete + from chart_view + where FIND_IN_SET(chart_view.scene_id, GET_PANEL_GROUP_WITH_CHILDREN(#{pid})) - delete from chart_view_cache where FIND_IN_SET(chart_view_cache.scene_id,GET_PANEL_GROUP_WITH_CHILDREN(#{pid})) + delete + from chart_view_cache + where FIND_IN_SET(chart_view_cache.scene_id, GET_PANEL_GROUP_WITH_CHILDREN(#{pid})) - INSERT INTO panel_view ( id, panel_id, chart_view_id ) SELECT - uuid(), - #{panelId}, - chart_view_id - FROM - panel_view - WHERE - panel_id = #{panelId} + INSERT INTO panel_view (id, panel_id, chart_view_id) + SELECT uuid(), + #{panelId}, + chart_view_id + FROM panel_view + WHERE panel_id = #{panelId} DELETE FROM - chart_view + chart_view WHERE - chart_view.chart_type = 'private' - AND chart_view.scene_id = #{panelId} + chart_view.chart_type = 'private' + AND chart_view.scene_id = #{panelId} AND id NOT IN - + #{viewId} diff --git a/backend/src/main/java/io/dataease/service/panel/PanelGroupService.java b/backend/src/main/java/io/dataease/service/panel/PanelGroupService.java index ed05bbbf6d..5ad6ab684e 100644 --- a/backend/src/main/java/io/dataease/service/panel/PanelGroupService.java +++ b/backend/src/main/java/io/dataease/service/panel/PanelGroupService.java @@ -947,4 +947,15 @@ public class PanelGroupService { //数据源变更 panelAppTemplateService.editDatasource(request.getDatasourceList()); } + + public void toTop(String panelId) { + Long time = System.currentTimeMillis(); + PanelGroupWithBLOBs request = new PanelGroupWithBLOBs(); + request.setId(panelId); + request.setPanelSort(time); + request.setUpdateTime(time); + request.setUpdateBy(AuthUtils.getUser().getUsername()); + panelGroupMapper.updateByPrimaryKeySelective(request); + + } } diff --git a/backend/src/main/resources/db/migration/V44__1.17.sql b/backend/src/main/resources/db/migration/V44__1.17.sql index 0726c5ed68..30b3206948 100644 --- a/backend/src/main/resources/db/migration/V44__1.17.sql +++ b/backend/src/main/resources/db/migration/V44__1.17.sql @@ -36,3 +36,6 @@ WHERE (`component` = 'msg/all'); UPDATE `sys_menu` SET `component` = 'msg/Setting' WHERE (`component` = 'msg/setting'); + +ALTER TABLE `panel_group` + ADD COLUMN `panel_sort` bigint(13) NULL COMMENT '排序' AFTER `watermark_open`; diff --git a/frontend/src/api/panel/panel.js b/frontend/src/api/panel/panel.js index dc41cd5079..6bd6714b92 100644 --- a/frontend/src/api/panel/panel.js +++ b/frontend/src/api/panel/panel.js @@ -358,3 +358,11 @@ export function findOneWithParent(panelId) { loading: false }) } + +export function panelToTop(panelId) { + return request({ + url: 'panel/group/toTop/' + panelId, + method: 'post', + loading: false + }) +} diff --git a/frontend/src/components/canvas/components/editor/EditBar.vue b/frontend/src/components/canvas/components/editor/EditBar.vue index 5802d847ca..6a4d7bd3c2 100644 --- a/frontend/src/components/canvas/components/editor/EditBar.vue +++ b/frontend/src/components/canvas/components/editor/EditBar.vue @@ -137,7 +137,7 @@ :target="curComponent.hyperlinks.openMode " :href="curComponent.hyperlinks.content " > - + diff --git a/frontend/src/components/canvas/components/editor/Preview.vue b/frontend/src/components/canvas/components/editor/Preview.vue index a304a149cd..ed527059d7 100644 --- a/frontend/src/components/canvas/components/editor/Preview.vue +++ b/frontend/src/components/canvas/components/editor/Preview.vue @@ -9,7 +9,7 @@ :style="customStyle" @scroll="canvasScroll" > - +
- + {{ data.name }} + + + { + this.defaultTree() + }) + }, fromAppActive() { this.activeNodeAndClickOnly(this.lastActiveNode) this.clearLocalStorage.forEach((item) => { @@ -637,7 +667,7 @@ export default { closeEditPanelDialog(panelInfo) { this.editPanel.visible = false if (panelInfo) { - this.defaultTree() + this.defaultTree(false) this.tree() if (this.editPanel.optType === 'rename' && panelInfo.id === this.$store.state.panel.panelInfo.id) { this.$store.state.panel.panelInfo.name = panelInfo.name @@ -809,7 +839,7 @@ export default { showClose: true }) this.tree() - this.defaultTree() + this.defaultTree(false) }) } else { this.$message({ @@ -837,7 +867,7 @@ export default { }) this.clearCanvas() this.tree() - this.defaultTree() + this.defaultTree(false) }) }) .catch(() => { @@ -887,7 +917,7 @@ export default { } }) }, - defaultTree(cache = false) { + defaultTree(cache = false, showFirst = false) { const requestInfo = { panelType: 'system' } @@ -896,21 +926,38 @@ export default { if (userCache) { this.defaultData = JSON.parse(modelInfo) + if (showFirst && this.defaultData.length > 0) { + this.activeDefaultNodeAndClickOnly(this.defaultData[0].id) + } } + const currentKey = this.$refs.default_panel_tree.getCurrentKey() defaultTree(requestInfo, false).then((res) => { localStorage.setItem('panel-default-tree', JSON.stringify(res.data)) if (!userCache) { this.defaultData = res.data + if (showFirst && this.defaultData.length > 0) { + this.activeDefaultNodeAndClickOnly(this.defaultData[0].id) + } } if (this.filterText) { this.$nextTick(() => { this.$refs.default_panel_tree.filter(this.filterText) }) } + if (currentKey) { + this.$nextTick(() => { + this.$refs.default_panel_tree.setCurrentKey(currentKey) + }) + } }) }, nodeClick(data, node) { + if (data.panelType === 'self') { + this.$refs.default_panel_tree.setCurrentKey(null) + } else { + this.$refs.panel_list_tree.setCurrentKey(null) + } this.lastActiveNode = node this.lastActiveNodeData = data this.activeTree = data.panelType @@ -1029,6 +1076,20 @@ export default { }) } }, + // 激活当前默认仪表板节点节点 + activeDefaultNodeAndClickOnly(panelId) { + if (panelId) { + const _this = this + _this.$nextTick(() => { + _this.$refs.panel_list_tree.setCurrentKey(null) + // 延迟设置CurrentKey + _this.$refs.default_panel_tree.setCurrentKey(panelId) + _this.$nextTick(() => { + document.querySelector('.is-current').firstChild.click() + }) + }) + } + }, moveTo(data) { const _this = this this.moveInfo = data