feat(仪表板): 进入仪表板菜单默认打开第一个默认仪表板且默认仪表板增加置顶功能

This commit is contained in:
wangjiahao 2022-11-18 15:37:08 +08:00
parent 5199aaae8f
commit 9875240437
12 changed files with 212 additions and 116 deletions

View File

@ -5,11 +5,11 @@ import io.dataease.auth.annotation.DePermission;
import io.dataease.auth.annotation.DePermissionProxy; import io.dataease.auth.annotation.DePermissionProxy;
import io.dataease.auth.annotation.DePermissions; import io.dataease.auth.annotation.DePermissions;
import io.dataease.auth.service.impl.ExtAuthServiceImpl; 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.DePermissionType;
import io.dataease.commons.constants.PanelConstants;
import io.dataease.commons.constants.ResourceAuthLevel; import io.dataease.commons.constants.ResourceAuthLevel;
import io.dataease.controller.handler.annotation.I18n; import io.dataease.controller.handler.annotation.I18n;
import io.dataease.controller.request.panel.*;
import io.dataease.dto.PermissionProxy; import io.dataease.dto.PermissionProxy;
import io.dataease.dto.authModel.VAuthModelDTO; import io.dataease.dto.authModel.VAuthModelDTO;
import io.dataease.dto.panel.PanelExport2App; import io.dataease.dto.panel.PanelExport2App;
@ -17,10 +17,11 @@ import io.dataease.dto.panel.PanelGroupDTO;
import io.dataease.service.panel.PanelGroupService; import io.dataease.service.panel.PanelGroupService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; 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.apache.shiro.authz.annotation.Logical;
import org.pentaho.di.core.util.UUIDUtil;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
@ -62,12 +63,12 @@ public class PanelGroupController {
@DePermission(type = DePermissionType.PANEL, value = "pid", level = ResourceAuthLevel.PANEL_LEVEL_MANAGE) @DePermission(type = DePermissionType.PANEL, value = "pid", level = ResourceAuthLevel.PANEL_LEVEL_MANAGE)
}, logical = Logical.AND) }, logical = Logical.AND)
@I18n @I18n
public PanelGroupDTO save(@RequestBody PanelGroupRequest request) throws Exception{ public PanelGroupDTO save(@RequestBody PanelGroupRequest request) throws Exception {
String panelId = panelGroupService.save(request); String panelId = panelGroupService.save(request);
PanelGroupDTO result = findOne(panelId); PanelGroupDTO result = findOne(panelId);
// 如果新建来源来自模板市场在返回数据中加入父级ID便于跳转展开仪表板树 // 如果新建来源来自模板市场在返回数据中加入父级ID便于跳转展开仪表板树
if(PanelConstants.NEW_PANEL_FROM.NEW_MARKET_TEMPLATE.equals(request.getNewFrom())){ if (PanelConstants.NEW_PANEL_FROM.NEW_MARKET_TEMPLATE.equals(request.getNewFrom())) {
result.setParents(authService.parentResource(panelId,"panel")); result.setParents(authService.parentResource(panelId, "panel"));
result.setRequestId(UUIDUtil.getUUIDAsString()); result.setRequestId(UUIDUtil.getUUIDAsString());
} }
return result; return result;
@ -150,31 +151,33 @@ public class PanelGroupController {
public void updatePanelStatus(@PathVariable String panelId, @RequestBody PanelGroupBaseInfoRequest request) { public void updatePanelStatus(@PathVariable String panelId, @RequestBody PanelGroupBaseInfoRequest request) {
panelGroupService.updatePanelStatus(panelId, request); panelGroupService.updatePanelStatus(panelId, request);
} }
@ApiOperation("自动缓存") @ApiOperation("自动缓存")
@PostMapping("/autoCache") @PostMapping("/autoCache")
@DePermissions(value = { @DePermissions(value = {
@DePermission(type = DePermissionType.PANEL, value = "id"), @DePermission(type = DePermissionType.PANEL, value = "id"),
@DePermission(type = DePermissionType.PANEL, value = "pid", level = ResourceAuthLevel.PANEL_LEVEL_MANAGE) @DePermission(type = DePermissionType.PANEL, value = "pid", level = ResourceAuthLevel.PANEL_LEVEL_MANAGE)
}, logical = Logical.AND) }, logical = Logical.AND)
public void autoCache(@RequestBody PanelGroupRequest request){ public void autoCache(@RequestBody PanelGroupRequest request) {
panelGroupService.autoCache(request); panelGroupService.autoCache(request);
} }
@ApiOperation("查找缓存") @ApiOperation("查找缓存")
@GetMapping("/findUserCache/{panelId}") @GetMapping("/findUserCache/{panelId}")
public PanelGroupDTO findUserCache(@PathVariable String panelId){ public PanelGroupDTO findUserCache(@PathVariable String panelId) {
return panelGroupService.findUserPanelCache(panelId); return panelGroupService.findUserPanelCache(panelId);
} }
@ApiOperation("检查缓存") @ApiOperation("检查缓存")
@GetMapping("/checkUserCache/{panelId}") @GetMapping("/checkUserCache/{panelId}")
public Boolean checkUserCache(@PathVariable String panelId){ public Boolean checkUserCache(@PathVariable String panelId) {
return panelGroupService.checkUserCache(panelId); return panelGroupService.checkUserCache(panelId);
} }
@ApiOperation("删除缓存") @ApiOperation("删除缓存")
@DeleteMapping("/removePanelCache/{panelId}") @DeleteMapping("/removePanelCache/{panelId}")
public void removePanelCache(@PathVariable String panelId){ public void removePanelCache(@PathVariable String panelId) {
panelGroupService.removePanelCache(panelId); panelGroupService.removePanelCache(panelId);
} }
@ -183,39 +186,46 @@ public class PanelGroupController {
public void viewLog(@RequestBody PanelViewLogRequest request) { public void viewLog(@RequestBody PanelViewLogRequest request) {
panelGroupService.viewLog(request); panelGroupService.viewLog(request);
} }
@ApiOperation("获取仪表板中视图Element信息") @ApiOperation("获取仪表板中视图Element信息")
@GetMapping("/findPanelElementInfo/{viewId}") @GetMapping("/findPanelElementInfo/{viewId}")
@I18n @I18n
public Object findPanelElementInfo(@PathVariable String viewId){ public Object findPanelElementInfo(@PathVariable String viewId) {
return panelGroupService.findPanelElementInfo(viewId); return panelGroupService.findPanelElementInfo(viewId);
} }
@GetMapping("/export2AppCheck/{panelId}") @GetMapping("/export2AppCheck/{panelId}")
@I18n @I18n
public PanelExport2App export2AppCheck(@PathVariable String panelId){ public PanelExport2App export2AppCheck(@PathVariable String panelId) {
return panelGroupService.panelExport2AppCheck(panelId); return panelGroupService.panelExport2AppCheck(panelId);
} }
@PostMapping("/appApply") @PostMapping("/appApply")
public PanelGroupDTO appApply(@RequestBody PanelAppTemplateApplyRequest request) throws Exception{ public PanelGroupDTO appApply(@RequestBody PanelAppTemplateApplyRequest request) throws Exception {
String panelId = panelGroupService.appApply(request); String panelId = panelGroupService.appApply(request);
PanelGroupDTO result = findOne(panelId); PanelGroupDTO result = findOne(panelId);
result.setParents(authService.parentResource(panelId,"panel")); result.setParents(authService.parentResource(panelId, "panel"));
result.setRequestId(UUIDUtil.getUUIDAsString()); result.setRequestId(UUIDUtil.getUUIDAsString());
result.setResponseSource("appApply"); result.setResponseSource("appApply");
return result; return result;
} }
@PostMapping("/appEdit") @PostMapping("/appEdit")
public void appEdit(@RequestBody PanelAppTemplateApplyRequest request) throws Exception{ public void appEdit(@RequestBody PanelAppTemplateApplyRequest request) throws Exception {
panelGroupService.appEdit(request); panelGroupService.appEdit(request);
} }
@GetMapping("/findOneWithParent/{panelId}") @GetMapping("/findOneWithParent/{panelId}")
public PanelGroupDTO findOneWithParent(@PathVariable String panelId) throws Exception{ public PanelGroupDTO findOneWithParent(@PathVariable String panelId) throws Exception {
PanelGroupDTO result = findOne(panelId); PanelGroupDTO result = findOne(panelId);
result.setParents(authService.parentResource(panelId,"panel")); result.setParents(authService.parentResource(panelId, "panel"));
result.setRequestId(UUIDUtil.getUUIDAsString()); result.setRequestId(UUIDUtil.getUUIDAsString());
result.setResponseSource("appApply"); result.setResponseSource("appApply");
return result; return result;
} }
@PostMapping("/toTop/{panelId}")
public void toTop(@PathVariable String panelId) throws Exception {
panelGroupService.toTop(panelId);
}
} }

View File

@ -16,16 +16,19 @@
<select id="findOneWithPrivileges" resultMap="BaseResultMapDTO"> <select id="findOneWithPrivileges" resultMap="BaseResultMapDTO">
select panel_group.*, select panel_group.*,
panel_group.name as label, panel_group.name as label,
(select nick_name from sys_user where username = panel_group.create_by) as creator_name, (select nick_name from sys_user where username = panel_group.create_by) as creator_name,
(select nick_name from sys_user where username = panel_group.update_by) as update_name, (select nick_name from sys_user where username = panel_group.update_by) as update_name,
get_auths(panel_group.id, 'panel', #{userId}) as `privileges` get_auths(panel_group.id, 'panel', #{userId}) as `privileges`
from panel_group from panel_group
where id = #{panelId} where id = #{panelId}
</select> </select>
<select id="panelGroupInit" resultMap="BaseResultMapDTO"> <select id="panelGroupInit" resultMap="BaseResultMapDTO">
select id, name,panel_data from panel_group where node_type = 'panel' and panel_type ='self' select id, name, panel_data
from panel_group
where node_type = 'panel'
and panel_type = 'self'
</select> </select>
<select id="panelGroupListDefault" resultMap="BaseResultMapDTO"> <select id="panelGroupListDefault" resultMap="BaseResultMapDTO">
@ -49,34 +52,34 @@
LEFT JOIN panel_group sourcePanelGroup LEFT JOIN panel_group sourcePanelGroup
on sourcePanelGroup.id=panel_group.source on sourcePanelGroup.id=panel_group.source
left join ( left join (
SELECT SELECT
auth_source, auth_source,
group_concat( DISTINCT sys_auth_detail.privilege_extend ) as `privileges` group_concat( DISTINCT sys_auth_detail.privilege_extend ) as `privileges`
FROM FROM
( (
`sys_auth` `sys_auth`
LEFT JOIN `sys_auth_detail` ON (( LEFT JOIN `sys_auth_detail` ON ((
`sys_auth`.`id` = `sys_auth_detail`.`auth_id` `sys_auth`.`id` = `sys_auth_detail`.`auth_id`
))) )))
WHERE WHERE
sys_auth_detail.privilege_value = 1 sys_auth_detail.privilege_value = 1
AND sys_auth.auth_source_type = 'panel' AND sys_auth.auth_source_type = 'panel'
AND ( AND (
( (
sys_auth.auth_target_type = 'dept' sys_auth.auth_target_type = 'dept'
AND sys_auth.auth_target IN ( SELECT dept_id FROM sys_user WHERE user_id = #{userId} ) AND sys_auth.auth_target IN ( SELECT dept_id FROM sys_user WHERE user_id = #{userId} )
) )
OR ( OR (
sys_auth.auth_target_type = 'user' sys_auth.auth_target_type = 'user'
AND sys_auth.auth_target = #{userId} AND sys_auth.auth_target = #{userId}
) )
OR ( OR (
sys_auth.auth_target_type = 'role' sys_auth.auth_target_type = 'role'
AND sys_auth.auth_target IN ( SELECT role_id FROM sys_users_roles WHERE user_id = #{userId} ) AND sys_auth.auth_target IN ( SELECT role_id FROM sys_users_roles WHERE user_id = #{userId} )
) )
) )
GROUP BY GROUP BY
`sys_auth`.`auth_source` `sys_auth`.`auth_source`
) authInfo ) authInfo
on panel_group.id = authInfo.auth_source on panel_group.id = authInfo.auth_source
<where> <where>
@ -100,7 +103,7 @@
and panel_group.level = #{level} and panel_group.level = #{level}
</if> </if>
</where> </where>
ORDER BY CONVERT(panel_group.name using gbk) ORDER BY panel_group.panel_sort desc, CONVERT(panel_group.name using gbk)
</select> </select>
<select id="panelGroupList" resultMap="BaseResultMapDTO"> <select id="panelGroupList" resultMap="BaseResultMapDTO">
@ -125,34 +128,34 @@
LEFT JOIN panel_group defaultPanelGroup LEFT JOIN panel_group defaultPanelGroup
on defaultPanelGroup.source=panel_group.id and defaultPanelGroup.source is not null on defaultPanelGroup.source=panel_group.id and defaultPanelGroup.source is not null
left join ( left join (
SELECT SELECT
auth_source, auth_source,
group_concat( DISTINCT sys_auth_detail.privilege_extend ) as `privileges` group_concat( DISTINCT sys_auth_detail.privilege_extend ) as `privileges`
FROM FROM
( (
`sys_auth` `sys_auth`
LEFT JOIN `sys_auth_detail` ON (( LEFT JOIN `sys_auth_detail` ON ((
`sys_auth`.`id` = `sys_auth_detail`.`auth_id` `sys_auth`.`id` = `sys_auth_detail`.`auth_id`
))) )))
WHERE WHERE
sys_auth_detail.privilege_value = 1 sys_auth_detail.privilege_value = 1
AND sys_auth.auth_source_type = 'panel' AND sys_auth.auth_source_type = 'panel'
AND ( AND (
( (
sys_auth.auth_target_type = 'dept' sys_auth.auth_target_type = 'dept'
AND sys_auth.auth_target IN ( SELECT dept_id FROM sys_user WHERE user_id = #{userId} ) AND sys_auth.auth_target IN ( SELECT dept_id FROM sys_user WHERE user_id = #{userId} )
) )
OR ( OR (
sys_auth.auth_target_type = 'user' sys_auth.auth_target_type = 'user'
AND sys_auth.auth_target = #{userId} AND sys_auth.auth_target = #{userId}
) )
OR ( OR (
sys_auth.auth_target_type = 'role' sys_auth.auth_target_type = 'role'
AND sys_auth.auth_target IN ( SELECT role_id FROM sys_users_roles WHERE user_id = #{userId} ) AND sys_auth.auth_target IN ( SELECT role_id FROM sys_users_roles WHERE user_id = #{userId} )
) )
) )
GROUP BY GROUP BY
`sys_auth`.`auth_source` `sys_auth`.`auth_source`
) authInfo ) authInfo
on panel_group.id = authInfo.auth_source on panel_group.id = authInfo.auth_source
<where> <where>
@ -176,42 +179,47 @@
and panel_group.level = #{level} and panel_group.level = #{level}
</if> </if>
</where> </where>
ORDER BY panel_group.node_type desc, CONVERT(panel_group.name using gbk) ORDER BY panel_group.node_type desc, CONVERT(panel_group.name using gbk)
</select> </select>
<delete id="deleteCircle"> <delete id="deleteCircle">
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> </delete>
<delete id="deleteCircleView"> <delete id="deleteCircleView">
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> </delete>
<delete id="deleteCircleViewCache"> <delete id="deleteCircleViewCache">
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}))
</delete> </delete>
<insert id="copyPanelView"> <insert id="copyPanelView">
INSERT INTO panel_view ( id, panel_id, chart_view_id ) SELECT INSERT INTO panel_view (id, panel_id, chart_view_id)
uuid(), SELECT uuid(),
#{panelId}, #{panelId},
chart_view_id chart_view_id
FROM FROM panel_view
panel_view WHERE panel_id = #{panelId}
WHERE
panel_id = #{panelId}
</insert> </insert>
<delete id="removeUselessViews"> <delete id="removeUselessViews">
DELETE DELETE
FROM FROM
chart_view chart_view
WHERE WHERE
chart_view.chart_type = 'private' chart_view.chart_type = 'private'
AND chart_view.scene_id = #{panelId} AND chart_view.scene_id = #{panelId}
<if test="viewIds != null and viewIds.size>0"> <if test="viewIds != null and viewIds.size>0">
AND id NOT IN AND id NOT IN
<foreach collection="viewIds" item="viewId" open="(" separator="," close=")" > <foreach collection="viewIds" item="viewId" open="(" separator="," close=")">
#{viewId} #{viewId}
</foreach> </foreach>
</if> </if>

View File

@ -947,4 +947,15 @@ public class PanelGroupService {
//数据源变更 //数据源变更
panelAppTemplateService.editDatasource(request.getDatasourceList()); 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);
}
} }

View File

@ -36,3 +36,6 @@ WHERE (`component` = 'msg/all');
UPDATE `sys_menu` UPDATE `sys_menu`
SET `component` = 'msg/Setting' SET `component` = 'msg/Setting'
WHERE (`component` = 'msg/setting'); WHERE (`component` = 'msg/setting');
ALTER TABLE `panel_group`
ADD COLUMN `panel_sort` bigint(13) NULL COMMENT '排序' AFTER `watermark_open`;

View File

@ -358,3 +358,11 @@ export function findOneWithParent(panelId) {
loading: false loading: false
}) })
} }
export function panelToTop(panelId) {
return request({
url: 'panel/group/toTop/' + panelId,
method: 'post',
loading: false
})
}

View File

@ -137,7 +137,7 @@
:target="curComponent.hyperlinks.openMode " :target="curComponent.hyperlinks.openMode "
:href="curComponent.hyperlinks.content " :href="curComponent.hyperlinks.content "
> >
<i class="icon iconfont icon-com-jump"/> <i class="icon iconfont icon-com-jump" />
</a> </a>
</span> </span>

View File

@ -9,7 +9,7 @@
:style="customStyle" :style="customStyle"
@scroll="canvasScroll" @scroll="canvasScroll"
> >
<canvas-opt-bar @link-export-pdf="downloadAsPDF" /> <canvas-opt-bar @link-export-pdf="downloadAsPDF"/>
<div <div
:id="previewDomId" :id="previewDomId"
:ref="previewRefId" :ref="previewRefId"
@ -112,11 +112,12 @@ import bus from '@/utils/bus'
import { buildFilterMap, buildViewKeyMap, formatCondition, valueValid, viewIdMatch } from '@/utils/conditionUtil' import { buildFilterMap, buildViewKeyMap, formatCondition, valueValid, viewIdMatch } from '@/utils/conditionUtil'
import { hasDataPermission } from '@/utils/permission' import { hasDataPermission } from '@/utils/permission'
import { activeWatermark } from '@/components/canvas/tools/watermark' import { activeWatermark } from '@/components/canvas/tools/watermark'
import { proxyUserLoginInfo, userLoginInfo } from '@/api/systemInfo/userLogin' import { userLoginInfo } from '@/api/systemInfo/userLogin'
import html2canvas from 'html2canvasde' import html2canvas from 'html2canvasde'
import { queryAll } from '@/api/panel/pdfTemplate' import { queryAll } from '@/api/panel/pdfTemplate'
const erd = elementResizeDetectorMaker()
import PDFPreExport from '@/views/panel/export/PDFPreExport' import PDFPreExport from '@/views/panel/export/PDFPreExport'
const erd = elementResizeDetectorMaker()
export default { export default {
components: { ComponentWrapper, CanvasOptBar, PDFPreExport }, components: { ComponentWrapper, CanvasOptBar, PDFPreExport },
model: { model: {

View File

@ -1865,12 +1865,10 @@ export default {
sure_bt: 'Confirm' sure_bt: 'Confirm'
}, },
panel: { panel: {
to_top: 'To Top',
down: 'Down', down: 'Down',
mobile_style_setting: 'Style setting', mobile_style_setting: 'Style setting',
mobile_style_setting_tips: 'Customize the mobile background', mobile_style_setting_tips: 'Customize the mobile background',
board: 'Border', board: 'Border',
text: 'Text', text: 'Text',
board_background: 'Background', board_background: 'Background',

View File

@ -1865,12 +1865,10 @@ export default {
sure_bt: '確定' sure_bt: '確定'
}, },
panel: { panel: {
to_top: '置頂',
down: '下載', down: '下載',
mobile_style_setting: '樣式設置', mobile_style_setting: '樣式設置',
mobile_style_setting_tips: '自定義移動端背景', mobile_style_setting_tips: '自定義移動端背景',
board: '邊框', board: '邊框',
text: '文字', text: '文字',
board_background: '背景', board_background: '背景',

View File

@ -1865,12 +1865,10 @@ export default {
sure_bt: '确定' sure_bt: '确定'
}, },
panel: { panel: {
to_top: '置顶',
down: '下载', down: '下载',
mobile_style_setting: '样式设置', mobile_style_setting: '样式设置',
mobile_style_setting_tips: '自定义移动端背景', mobile_style_setting_tips: '自定义移动端背景',
board: '边框', board: '边框',
text: '文字', text: '文字',
board_background: '背景', board_background: '背景',

View File

@ -112,7 +112,7 @@
:http-request="upload" :http-request="upload"
:file-list="fileList" :file-list="fileList"
> >
<i class="el-icon-plus"/> <i class="el-icon-plus" />
</el-upload> </el-upload>
<el-dialog <el-dialog
top="25vh" top="25vh"

View File

@ -67,6 +67,19 @@
:title="data.name" :title="data.name"
>{{ data.name }}</span> >{{ data.name }}</span>
</span> </span>
<span
v-if="hasDataPermission('manage', data.privileges)"
:title="'置顶'"
class="child"
@click.stop
>
<el-button
icon="el-icon-upload2"
type="text"
size="small"
@click="toTop(data, node)"
/>
</span>
<span <span
style="margin-left: 12px" style="margin-left: 12px"
class="child" class="child"
@ -431,7 +444,16 @@ import LinkGenerate from '@/views/link/generate'
import { uuid } from 'vue-uuid' import { uuid } from 'vue-uuid'
import bus from '@/utils/bus' import bus from '@/utils/bus'
import EditPanel from './editPanel' import EditPanel from './editPanel'
import { addGroup, defaultTree, delGroup, groupTree, initPanelData, panelUpdate, viewPanelLog } from '@/api/panel/panel' import {
addGroup,
defaultTree,
delGroup,
groupTree,
initPanelData,
panelToTop,
panelUpdate,
viewPanelLog
} from '@/api/panel/panel'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import { DEFAULT_COMMON_CANVAS_STYLE_STRING } from '@/views/panel/panel' import { DEFAULT_COMMON_CANVAS_STYLE_STRING } from '@/views/panel/panel'
import TreeSelector from '@/components/treeSelector' import TreeSelector from '@/components/treeSelector'
@ -442,6 +464,7 @@ export default {
components: { GrantAuth, LinkGenerate, EditPanel, TreeSelector }, components: { GrantAuth, LinkGenerate, EditPanel, TreeSelector },
data() { data() {
return { return {
lastActiveDefaultPanelId: null, //
responseSource: 'panelQuery', responseSource: 'panelQuery',
defaultExpansion: false, defaultExpansion: false,
clearLocalStorage: ['chart-tree', 'dataset-tree'], clearLocalStorage: ['chart-tree', 'dataset-tree'],
@ -591,13 +614,13 @@ export default {
}, },
mounted() { mounted() {
this.clearCanvas() this.clearCanvas()
this.defaultTree(true)
this.initCache() this.initCache()
const routerParam = this.$router.currentRoute.params const routerParam = this.$router.currentRoute.params
if (routerParam && routerParam.responseSource === 'appApply') { if (routerParam && routerParam.responseSource === 'appApply') {
this.responseSource = routerParam.responseSource this.responseSource = routerParam.responseSource
this.lastActiveNode = routerParam this.lastActiveNode = routerParam
this.tree() this.tree()
this.defaultTree(true, false)
} else if ( } else if (
routerParam && routerParam &&
routerParam.nodeType === 'panel' && routerParam.nodeType === 'panel' &&
@ -605,12 +628,19 @@ export default {
) { ) {
this.historyRequestId = routerParam.requestId this.historyRequestId = routerParam.requestId
this.tree() this.tree()
this.defaultTree(true, false)
this.edit(routerParam, null) this.edit(routerParam, null)
} else { } else {
this.defaultTree(true, true)
this.tree(true) this.tree(true)
} }
}, },
methods: { methods: {
toTop(data, node) {
panelToTop(data.id).then(() => {
this.defaultTree()
})
},
fromAppActive() { fromAppActive() {
this.activeNodeAndClickOnly(this.lastActiveNode) this.activeNodeAndClickOnly(this.lastActiveNode)
this.clearLocalStorage.forEach((item) => { this.clearLocalStorage.forEach((item) => {
@ -637,7 +667,7 @@ export default {
closeEditPanelDialog(panelInfo) { closeEditPanelDialog(panelInfo) {
this.editPanel.visible = false this.editPanel.visible = false
if (panelInfo) { if (panelInfo) {
this.defaultTree() this.defaultTree(false)
this.tree() this.tree()
if (this.editPanel.optType === 'rename' && panelInfo.id === this.$store.state.panel.panelInfo.id) { if (this.editPanel.optType === 'rename' && panelInfo.id === this.$store.state.panel.panelInfo.id) {
this.$store.state.panel.panelInfo.name = panelInfo.name this.$store.state.panel.panelInfo.name = panelInfo.name
@ -809,7 +839,7 @@ export default {
showClose: true showClose: true
}) })
this.tree() this.tree()
this.defaultTree() this.defaultTree(false)
}) })
} else { } else {
this.$message({ this.$message({
@ -837,7 +867,7 @@ export default {
}) })
this.clearCanvas() this.clearCanvas()
this.tree() this.tree()
this.defaultTree() this.defaultTree(false)
}) })
}) })
.catch(() => { .catch(() => {
@ -887,7 +917,7 @@ export default {
} }
}) })
}, },
defaultTree(cache = false) { defaultTree(cache = false, showFirst = false) {
const requestInfo = { const requestInfo = {
panelType: 'system' panelType: 'system'
} }
@ -896,21 +926,38 @@ export default {
if (userCache) { if (userCache) {
this.defaultData = JSON.parse(modelInfo) 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) => { defaultTree(requestInfo, false).then((res) => {
localStorage.setItem('panel-default-tree', JSON.stringify(res.data)) localStorage.setItem('panel-default-tree', JSON.stringify(res.data))
if (!userCache) { if (!userCache) {
this.defaultData = res.data this.defaultData = res.data
if (showFirst && this.defaultData.length > 0) {
this.activeDefaultNodeAndClickOnly(this.defaultData[0].id)
}
} }
if (this.filterText) { if (this.filterText) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.default_panel_tree.filter(this.filterText) this.$refs.default_panel_tree.filter(this.filterText)
}) })
} }
if (currentKey) {
this.$nextTick(() => {
this.$refs.default_panel_tree.setCurrentKey(currentKey)
})
}
}) })
}, },
nodeClick(data, node) { 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.lastActiveNode = node
this.lastActiveNodeData = data this.lastActiveNodeData = data
this.activeTree = data.panelType 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) { moveTo(data) {
const _this = this const _this = this
this.moveInfo = data this.moveInfo = data