提交 769b7bc2 authored 作者: wangjiahao's avatar wangjiahao

feat: 视图归属于仪表板,去掉视图菜单

上级 ecf1be44
......@@ -14,7 +14,7 @@ public interface ExtChartViewMapper {
ChartViewDTO searchOne(ChartViewRequest request);
void chartCopy(@Param("newChartId")String newChartId,@Param("oldChartId")String oldChartId);
void chartCopy(@Param("newChartId")String newChartId,@Param("oldChartId")String oldChartId,@Param("panelId")String panelId);
@Select("select id from chart_view where table_id = #{tableId}")
List<String> allViewIds(@Param("tableId") String tableId);
......
......@@ -109,11 +109,12 @@
`y_axis_ext`,
`render`,
`result_count`,
`result_mode`
`result_mode`,
`chart_type`
) SELECT
#{newChartId},
GET_CHART_VIEW_COPY_NAME ( #{oldChartId} ),
`scene_id`,
#{panelId},
`table_id`,
`type`,
GET_CHART_VIEW_COPY_NAME ( #{oldChartId} ),
......@@ -133,7 +134,8 @@
`y_axis_ext`,
`render`,
`result_count`,
`result_mode`
`result_mode`,
'private'
FROM
chart_view
WHERE
......
......@@ -19,5 +19,7 @@ public interface ExtPanelGroupMapper {
void copyPanelView(@Param("pid") String panelId);
//移除未使用的视图
void removeUselessViews(@Param("panelId") String panelId);
}
......@@ -178,4 +178,21 @@
panel_id = #{panelId}
</insert>
<delete id="removeUselessViews">
DELETE
FROM
chart_view
WHERE
chart_view.chart_type = 'private'
AND chart_view.scene_id = #{panelId}
AND id NOT IN (
SELECT
panel_view.chart_view_id
FROM
panel_view
WHERE
panel_view.panel_id = #{panelId}
)
</delete>
</mapper>
......@@ -8,6 +8,9 @@ import java.util.List;
public interface ExtVAuthModelMapper {
List<VAuthModelDTO> queryAuthModel (@Param("record") VAuthModelRequest record);
List<VAuthModelDTO> queryAuthModel(@Param("record") VAuthModelRequest record);
List<VAuthModelDTO> queryAuthModelViews (@Param("record") VAuthModelRequest record);
List<VAuthModelDTO> queryAuthViewsOriginal (@Param("record") VAuthModelRequest record);
}
......@@ -4,106 +4,175 @@
<resultMap extends="io.dataease.base.mapper.VAuthModelMapper.ResultMapWithBLOBs" id="ExtResultMap"
type="io.dataease.dto.authModel.VAuthModelDTO">
<result column="privileges" jdbcType="VARCHAR" property="privileges"/>
<result column="inner_id" jdbcType="VARCHAR" property="innerId"/>
</resultMap>
<select id="queryAuthModel" resultMap="ExtResultMap">
SELECT
v_auth_model.id,
v_auth_model.name,
v_auth_model.label,
v_auth_model.pid,
v_auth_model.node_type,
v_auth_model.model_type,
v_auth_model.model_inner_type,
v_auth_model.auth_type,
v_auth_model.create_by,
v_auth_model.level,
v_auth_model.mode,
v_auth_model.data_source_id,
authInfo.PRIVILEGES AS `privileges`
FROM
( SELECT GET_V_AUTH_MODEL_ID_P_USE ( #{record.userId}, #{record.modelType} ) cids ) t,
v_auth_model
LEFT JOIN (
SELECT
auth_source,
group_concat( DISTINCT sys_auth_detail.privilege_extend ) AS `privileges`
FROM
(
`sys_auth`
LEFT JOIN `sys_auth_detail` ON ((
`sys_auth`.`id` = `sys_auth_detail`.`auth_id`
)))
WHERE
sys_auth_detail.privilege_value = 1
AND sys_auth.auth_source_type = #{record.modelType}
AND (
(
sys_auth.auth_target_type = 'dept'
AND sys_auth.auth_target IN ( SELECT dept_id FROM sys_user WHERE user_id = #{record.userId} )
)
OR (
sys_auth.auth_target_type = 'user'
AND sys_auth.auth_target = #{record.userId}
)
OR (
sys_auth.auth_target_type = 'role'
AND sys_auth.auth_target IN ( SELECT role_id FROM sys_users_roles WHERE user_id = #{record.userId} )
)
)
GROUP BY
`sys_auth`.`auth_source`
) authInfo ON v_auth_model.id = authInfo.auth_source
WHERE
FIND_IN_SET( v_auth_model.id, cids )
<if test="record.id != null">
and v_auth_model.id = #{record.id,jdbcType=VARCHAR}
</if>
<if test="record.pid != null">
and v_auth_model.pid = #{record.pid,jdbcType=VARCHAR}
</if>
<if test="record.nodeType != null">
and v_auth_model.node_type = #{record.nodeType,jdbcType=VARCHAR}
</if>
<if test="record.modelType != null">
and v_auth_model.model_type = #{record.modelType,jdbcType=VARCHAR}
</if>
<if test="record.modelInnerType != null">
and v_auth_model.model_inner_type = #{record.modelInnerType,jdbcType=VARCHAR}
</if>
<if test="record.authType != null">
and v_auth_model.auth_type = #{record.authType,jdbcType=VARCHAR}
</if>
<if test="record.createBy != null">
and v_auth_model.create_by = #{record.createBy,jdbcType=VARCHAR}
</if>
<if test="record.level != null">
and v_auth_model.`level` = #{record.level,jdbcType=BIGINT}
</if>
<if test="record.mode != null">
<if test="record.mode == 0">
and v_auth_model.`mode` = 0
</if>
<if test='record.mode == 1 and record.modelType != null and record.modelType == "dataset"'>
and (v_auth_model.`mode` = 1 or (v_auth_model.`model_inner_type` = 'group' and v_auth_model.model_type = 'dataset'))
</if>
</if>
<if test="record.dataSourceId != null">
and v_auth_model.data_source_id = #{record.dataSourceId,jdbcType=VARCHAR}
</if>
<if test="record.name != null">
and v_auth_model.`name` = #{record.name,jdbcType=LONGVARCHAR}
</if>
<if test="record.label != null">
and v_auth_model.`label` = #{record.label,jdbcType=LONGVARCHAR}
</if>
<if test="record.modelInnerTypeArray != null and record.modelInnerTypeArray.size() > 0">
and v_auth_model.model_inner_type in
<foreach collection="record.modelInnerTypeArray" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
ORDER BY v_auth_model.node_type desc, CONVERT(v_auth_model.label using gbk) asc
</select>
SELECT
v_auth_model.id,
v_auth_model.name,
v_auth_model.label,
v_auth_model.pid,
v_auth_model.node_type,
v_auth_model.model_type,
v_auth_model.model_inner_type,
v_auth_model.auth_type,
v_auth_model.create_by,
v_auth_model.level,
v_auth_model.mode,
v_auth_model.data_source_id,
authInfo.PRIVILEGES AS `privileges`
FROM
( SELECT GET_V_AUTH_MODEL_ID_P_USE ( #{record.userId}, #{record.modelType} ) cids ) t,
v_auth_model
LEFT JOIN (
SELECT
auth_source,
group_concat( DISTINCT sys_auth_detail.privilege_extend ) AS `privileges`
FROM
(
`sys_auth`
LEFT JOIN `sys_auth_detail` ON ((
`sys_auth`.`id` = `sys_auth_detail`.`auth_id`
)))
WHERE
sys_auth_detail.privilege_value = 1
AND sys_auth.auth_source_type = #{record.modelType}
AND (
(
sys_auth.auth_target_type = 'dept'
AND sys_auth.auth_target IN ( SELECT dept_id FROM sys_user WHERE user_id = #{record.userId} )
)
OR (
sys_auth.auth_target_type = 'user'
AND sys_auth.auth_target = #{record.userId}
)
OR (
sys_auth.auth_target_type = 'role'
AND sys_auth.auth_target IN ( SELECT role_id FROM sys_users_roles WHERE user_id = #{record.userId} )
)
)
GROUP BY
`sys_auth`.`auth_source`
) authInfo ON v_auth_model.id = authInfo.auth_source
WHERE
FIND_IN_SET( v_auth_model.id, cids )
<if test="record.id != null">
and v_auth_model.id = #{record.id,jdbcType=VARCHAR}
</if>
<if test="record.pid != null">
and v_auth_model.pid = #{record.pid,jdbcType=VARCHAR}
</if>
<if test="record.nodeType != null">
and v_auth_model.node_type = #{record.nodeType,jdbcType=VARCHAR}
</if>
<if test="record.modelType != null">
and v_auth_model.model_type = #{record.modelType,jdbcType=VARCHAR}
</if>
<if test="record.modelInnerType != null">
and v_auth_model.model_inner_type = #{record.modelInnerType,jdbcType=VARCHAR}
</if>
<if test="record.authType != null">
and v_auth_model.auth_type = #{record.authType,jdbcType=VARCHAR}
</if>
<if test="record.createBy != null">
and v_auth_model.create_by = #{record.createBy,jdbcType=VARCHAR}
</if>
<if test="record.level != null">
and v_auth_model.`level` = #{record.level,jdbcType=BIGINT}
</if>
<if test="record.mode != null">
<if test="record.mode == 0">
and v_auth_model.`mode` = 0
</if>
<if test='record.mode == 1 and record.modelType != null and record.modelType == "dataset"'>
and (v_auth_model.`mode` = 1 or (v_auth_model.`model_inner_type` = 'group' and v_auth_model.model_type =
'dataset'))
</if>
</if>
<if test="record.dataSourceId != null">
and v_auth_model.data_source_id = #{record.dataSourceId,jdbcType=VARCHAR}
</if>
<if test="record.name != null">
and v_auth_model.`name` = #{record.name,jdbcType=LONGVARCHAR}
</if>
<if test="record.label != null">
and v_auth_model.`label` = #{record.label,jdbcType=LONGVARCHAR}
</if>
<if test="record.modelInnerTypeArray != null and record.modelInnerTypeArray.size() > 0">
and v_auth_model.model_inner_type in
<foreach collection="record.modelInnerTypeArray" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
ORDER BY v_auth_model.node_type desc, CONVERT(v_auth_model.label using gbk) asc
</select>
<select id="queryAuthModelViews" resultMap="ExtResultMap">
SELECT
panel_view.id,
chart_view.id as 'inner_id',
chart_view.NAME,
chart_view.NAME AS 'label',
panel_view.panel_id AS pid,
chart_view.type as 'model_inner_type',
'leaf' AS node_type,
'view' AS model_type
FROM
panel_view
LEFT JOIN chart_view ON panel_view.chart_view_id = chart_view.id
<where>
<if test="record.pids != null and record.pids.size() > 0">
and panel_view.panel_id in
<foreach collection="record.pids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
ORDER BY CONVERT(chart_view.name using gbk) asc
</select>
<select id="queryAuthViewsOriginal" resultMap="ExtResultMap">
select * from (
SELECT
chart_group.id,
chart_group.id AS 'inner_id',
chart_group.NAME,
chart_group.NAME AS 'label',
chart_group.pid AS pid,
chart_group.type AS 'model_inner_type',
'spine' AS node_type,
'view' AS model_type
FROM
chart_group
UNION ALL
SELECT
panel_view.id,
chart_view.id AS 'inner_id',
chart_view.NAME,
chart_view.NAME AS 'label',
chart_view.scene_id AS pid,
chart_view.type AS 'model_inner_type',
'leaf' AS node_type,
'view' AS model_type
FROM
panel_view
LEFT JOIN chart_view ON panel_view.chart_view_id = chart_view.id
<where>
chart_view.chart_type ='public'
<if test="record.pids != null and record.pids.size() > 0">
and panel_view.panel_id in
<foreach collection="record.pids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
) viewsOriginal
ORDER BY viewsOriginal.node_type desc, CONVERT(viewsOriginal.label using gbk) asc
</select>
</mapper>
......@@ -2,6 +2,7 @@ package io.dataease.commons.utils;
import io.dataease.commons.model.ITreeBase;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
......@@ -18,6 +19,9 @@ public class TreeUtils{
*/
public static<T extends ITreeBase> List<T> mergeTree(List<T> tree,String ... rootPid) {
Assert.notNull(rootPid, "Root Pid cannot be null");
if(CollectionUtils.isEmpty(tree)){
return null;
}
List<T> result = new ArrayList<>();
// 构建id-节点map映射
Map<String, T> treePidMap = tree.stream().collect(Collectors.toMap(T::getId, t -> t));
......
......@@ -72,9 +72,9 @@ public class ChartViewController {
}
@ApiOperation("复制")
@PostMapping("chartCopy/{id}")
public String chartCopy(@PathVariable String id) {
return chartViewService.chartCopy(id);
@PostMapping("chartCopy/{id}/{panelId}")
public String chartCopy(@PathVariable String id, @PathVariable String panelId) {
return chartViewService.chartCopy(id,panelId);
}
@ApiIgnore
......
......@@ -9,6 +9,7 @@ import io.dataease.commons.constants.DePermissionType;
import io.dataease.commons.constants.ResourceAuthLevel;
import io.dataease.controller.handler.annotation.I18n;
import io.dataease.controller.request.panel.PanelGroupRequest;
import io.dataease.dto.authModel.VAuthModelDTO;
import io.dataease.dto.panel.PanelGroupDTO;
import io.dataease.service.panel.PanelGroupService;
import io.swagger.annotations.Api;
......@@ -70,5 +71,11 @@ public class PanelGroupController {
return panelGroupService.findOne(id);
}
@ApiOperation("仪表板视图信息")
@PostMapping("/queryPanelViewTree")
@I18n
public List<VAuthModelDTO> queryPanelViewTree(){
return panelGroupService.queryPanelViewTree();
}
}
......@@ -14,9 +14,15 @@ import java.util.List;
public class VAuthModelRequest extends VAuthModelDTO {
private String userId;
private String privileges;
private Integer datasetMode;
private boolean clearEmptyDir;
private List<String> modelInnerTypeArray;
private List<String> pids;
}
......@@ -17,5 +17,13 @@ public class VAuthModelDTO extends VAuthModelWithBLOBs implements ITreeBase<VAu
private String privileges;
private List<VAuthModelDTO> children;
private long allLeafs = 0l;
private String innerId;
public String toString(){
return this.getId();
}
}
......@@ -1684,9 +1684,9 @@ public class ChartViewService {
return chartViewMapper.selectByPrimaryKey(id);
}
public String chartCopy(String id) {
public String chartCopy(String id,String panelId) {
String newChartId = UUID.randomUUID().toString();
extChartViewMapper.chartCopy(newChartId, id);
extChartViewMapper.chartCopy(newChartId, id,panelId);
return newChartId;
}
......
......@@ -3,12 +3,16 @@ package io.dataease.service.panel;
import io.dataease.base.domain.*;
import io.dataease.base.mapper.ChartViewMapper;
import io.dataease.base.mapper.PanelGroupMapper;
import io.dataease.base.mapper.VAuthModelMapper;
import io.dataease.base.mapper.ext.ExtPanelGroupMapper;
import io.dataease.base.mapper.ext.ExtPanelLinkJumpMapper;
import io.dataease.base.mapper.ext.ExtVAuthModelMapper;
import io.dataease.commons.constants.PanelConstants;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.TreeUtils;
import io.dataease.controller.request.authModel.VAuthModelRequest;
import io.dataease.controller.request.panel.PanelGroupRequest;
import io.dataease.dto.authModel.VAuthModelDTO;
import io.dataease.dto.chart.ChartViewDTO;
import io.dataease.dto.panel.PanelGroupDTO;
import io.dataease.exception.DataEaseException;
......@@ -28,6 +32,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* Author: wangjiahao
......@@ -59,7 +64,10 @@ public class PanelGroupService {
private PanelViewService panelViewService;
@Resource
private ExtPanelLinkJumpMapper extPanelLinkJumpMapper;
@Resource
private ExtVAuthModelMapper extVAuthModelMapper;
@Resource
private VAuthModelMapper vAuthModelMapper;
public List<PanelGroupDTO> tree(PanelGroupRequest panelGroupRequest) {
String userId = String.valueOf(AuthUtils.getUser().getUserId());
......@@ -157,6 +165,9 @@ public class PanelGroupService {
if (!CollectionUtils.isNotEmpty(panelGroupDTOList)) {
DataEaseException.throwException("未查询到用户对应的资源权限,请尝试刷新重新保存");
}
//移除没有用到的仪表板私有视图
extPanelGroupMapper.removeUselessViews(panelId);
return panelGroupDTOList.get(0);
}
......@@ -214,4 +225,31 @@ public class PanelGroupService {
return chartViewDTOList;
}
public List<VAuthModelDTO> queryPanelViewTree(){
List<VAuthModelDTO> result = new ArrayList<>();
VAuthModelRequest panelRequest = new VAuthModelRequest();
panelRequest.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
panelRequest.setModelType("panel");
List<VAuthModelDTO> panelResult = extVAuthModelMapper.queryAuthModel(panelRequest);
// 获取仪表板下面的视图
if(CollectionUtils.isNotEmpty(panelResult)){
result.addAll(panelResult);
List<String> panelIds = panelResult.stream().map(VAuthModelDTO::getId).collect(Collectors.toList());
VAuthModelRequest viewRequest = new VAuthModelRequest();
viewRequest.setPids(panelIds);
List<VAuthModelDTO> viewResult = extVAuthModelMapper.queryAuthModelViews(viewRequest);
if(CollectionUtils.isNotEmpty(viewResult)){
result.addAll(viewResult);
}
result = TreeUtils.mergeTree(panelResult,"panel_list");
// 原有视图的目录结构
List<VAuthModelDTO> viewOriginal = extVAuthModelMapper.queryAuthViewsOriginal(viewRequest);
if(CollectionUtils.isNotEmpty(viewOriginal) && viewOriginal.size()>1){
result.addAll(TreeUtils.mergeTree(viewOriginal,"public_chart"));
}
}
return result;
}
}
ALTER TABLE `chart_view` ADD COLUMN `x_axis_ext` LONGTEXT COMMENT 'table-row' AFTER `x_axis`;
UPDATE `chart_view` SET `x_axis_ext` = '[]';
\ No newline at end of file
UPDATE `chart_view` SET `x_axis_ext` = '[]';
INSERT INTO `chart_group` (`id`, `name`, `pid`, `level`, `type`, `create_by`, `create_time`) VALUES ('0', 'i18n_public_chart', 'public_chart', -1, 'group', 'admin', NULL);
ALTER TABLE `chart_view`
MODIFY COLUMN `scene_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '场景ID chart_type为privat的时候 是仪表板id' AFTER `title`,
ADD COLUMN `chart_type` varchar(255) NULL DEFAULT 'public' COMMENT '视图类型 public 公共 历史可复用的视图,private 私有 专属某个仪表板' AFTER `style_priority`;
delete from sys_auth_detail where auth_id in(select id from sys_auth where auth_source_type = 'chart');
delete from sys_auth where auth_source_type = 'chart';
DROP TRIGGER `new_auth_chart_view`;
DROP TRIGGER `delete_auth_chart_view`;
delete from sys_menu where menu_id ='10';
DROP VIEW
IF
EXISTS `v_auth_model`;
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `v_auth_model` AS SELECT
`sys_user`.`user_id` AS `id`,
`sys_user`.`username` AS `name`,
`sys_user`.`username` AS `label`,
'0' AS `pid`,
'leaf' AS `node_type`,
'user' AS `model_type`,
'user' AS `model_inner_type`,
'target' AS `auth_type`,
`sys_user`.`create_by` AS `create_by`,
0 AS `level`,
0 AS `mode`,
'0' AS `data_source_id`
FROM
`sys_user`
WHERE
( `sys_user`.`is_admin` <> 1 ) UNION ALL
SELECT
`sys_role`.`role_id` AS `id`,
`sys_role`.`name` AS `name`,
`sys_role`.`name` AS `label`,
'0' AS `pid`,
'leaf' AS `node_type`,
'role' AS `model_type`,
'role' AS `model_inner_type`,
'target' AS `auth_type`,
`sys_role`.`create_by` AS `create_by`,
0 AS `level`,
0 AS `mode`,
'0' AS `data_source_id`
FROM
`sys_role` UNION ALL
SELECT
`sys_dept`.`dept_id` AS `id`,
`sys_dept`.`name` AS `name`,
`sys_dept`.`name` AS `lable`,(
cast( `sys_dept`.`pid` AS CHAR charset utf8mb4 ) COLLATE utf8mb4_general_ci
) AS `pid`,
IF
(( `sys_dept`.`sub_count` = 0 ), 'leaf', 'spine' ) AS `node_type`,
'dept' AS `model_type`,
'dept' AS `model_inner_type`,
'target' AS `auth_type`,
`sys_dept`.`create_by` AS `create_by`,
0 AS `level`,
0 AS `mode`,
'0' AS `data_source_id`
FROM
`sys_dept` UNION ALL
SELECT
`datasource`.`id` AS `id`,
`datasource`.`name` AS `NAME`,
`datasource`.`name` AS `label`,
'0' AS `pid`,
'leaf' AS `node_type`,
'link' AS `model_type`,
`datasource`.`type` AS `model_inner_type`,
'source' AS `auth_type`,
`datasource`.`create_by` AS `create_by`,
0 AS `level`,
0 AS `mode`,
'0' AS `data_source_id`
FROM
`datasource` UNION ALL
SELECT
`dataset_group`.`id` AS `id`,
`dataset_group`.`name` AS `NAME`,
`dataset_group`.`name` AS `lable`,
IF
( isnull( `dataset_group`.`pid` ), '0', `dataset_group`.`pid` ) AS `pid`,
'spine' AS `node_type`,
'dataset' AS `model_type`,
`dataset_group`.`type` AS `model_inner_type`,
'source' AS `auth_type`,
`dataset_group`.`create_by` AS `create_by`,
`dataset_group`.`level` AS `level`,
0 AS `mode`,
'0' AS `data_source_id`
FROM
`dataset_group` UNION ALL
SELECT
`dataset_table`.`id` AS `id`,
`dataset_table`.`name` AS `NAME`,
`dataset_table`.`name` AS `lable`,
`dataset_table`.`scene_id` AS `pid`,
'leaf' AS `node_type`,
'dataset' AS `model_type`,
`dataset_table`.`type` AS `model_inner_type`,
'source' AS `auth_type`,
`dataset_table`.`create_by` AS `create_by`,
0 AS `level`,
`dataset_table`.`mode` AS `mode`,
`dataset_table`.`data_source_id` AS `data_source_id`
FROM
`dataset_table` UNION ALL
SELECT
`panel_group`.`id` AS `id`,
`panel_group`.`name` AS `NAME`,
`panel_group`.`name` AS `label`,(
CASE
`panel_group`.`id`
WHEN 'panel_list' THEN
'0'
WHEN 'default_panel' THEN
'0' ELSE `panel_group`.`pid`
END
) AS `pid`,
IF
(( `panel_group`.`node_type` = 'folder' ), 'spine', 'leaf' ) AS `node_type`,
'panel' AS `model_type`,
`panel_group`.`panel_type` AS `model_inner_type`,
'source' AS `auth_type`,
`panel_group`.`create_by` AS `create_by`,
0 AS `level`,
0 AS `mode`,
'0' AS `data_source_id`
FROM
`panel_group` UNION ALL
SELECT
`sys_menu`.`menu_id` AS `menu_id`,
`sys_menu`.`title` AS `name`,
`sys_menu`.`title` AS `label`,
`sys_menu`.`pid` AS `pid`,
IF
(( `sys_menu`.`sub_count` > 0 ), 'spine', 'leaf' ) AS `node_type`,
'menu' AS `model_type`,(
CASE
`sys_menu`.`type`
WHEN 0 THEN
'folder'
WHEN 1 THEN
'menu'
WHEN 2 THEN
'button'
END
) AS `model_inner_type`,
'source' AS `auth_type`,
`sys_menu`.`create_by` AS `create_by`,
0 AS `level`,
0 AS `mode`,
'0' AS `data_source_id`
FROM
`sys_menu`
WHERE
((
`sys_menu`.`i_frame` <> 1
)
OR isnull( `sys_menu`.`i_frame` )) UNION ALL
SELECT
`plugin_sys_menu`.`menu_id` AS `menu_id`,
`plugin_sys_menu`.`title` AS `name`,
`plugin_sys_menu`.`title` AS `label`,
`plugin_sys_menu`.`pid` AS `pid`,
IF
(( `plugin_sys_menu`.`sub_count` > 0 ), 'spine', 'leaf' ) AS `node_type`,
'menu' AS `model_type`,(
CASE
`plugin_sys_menu`.`type`
WHEN 0 THEN
'folder'
WHEN 1 THEN
'menu'
WHEN 2 THEN
'button'
END
) AS `model_inner_type`,
'source' AS `auth_type`,
`plugin_sys_menu`.`create_by` AS `create_by`,
0 AS `level`,
0 AS `mode`,
'0' AS `data_source_id`
FROM
`plugin_sys_menu`
WHERE
((
`plugin_sys_menu`.`i_frame` <> 1
)
OR isnull( `plugin_sys_menu`.`i_frame` ));
......@@ -118,4 +118,5 @@ i18n_calc_field_error=Field expression error
i18n_cp_exist=Column permission of the same type already exists
connection_failed=Connection Failed
theme_name_repeat=name of theme has been existed
theme_name_empty=name can not be empty
\ No newline at end of file
theme_name_empty=name can not be empty
i18n_public_chart= Public Chart
......@@ -118,3 +118,4 @@ i18n_cp_exist=已有同类型的列权限存在
connection_failed=连接失败
theme_name_repeat=名称已存在
theme_name_empty=名称不能为空
i18n_public_chart= 存量视图
......@@ -119,3 +119,4 @@ i18n_cp_exist=已有同類型的列權限存在
connection_failed=連接失敗
theme_name_repeat=名稱已存在
theme_name_empty=名稱不能為空
i18n_public_chart= 存量视图
......@@ -28,11 +28,11 @@ export function getChartTree(data) {
})
}
export function chartCopy(id) {
export function chartCopy(id, panelId) {
return request({
url: '/chart/view/chartCopy/' + id,
url: '/chart/view/chartCopy/' + id + '/' + panelId,
method: 'post',
loading: true
loading: false
})
}
export function chartGroupTree(data) {
......
......@@ -154,3 +154,11 @@ export function initPanelData(panelId, callback) {
callback(response)
})
}
export function queryPanelViewTree() {
return request({
url: '/panel/group/queryPanelViewTree',
method: 'post'
})
}
......@@ -47,7 +47,7 @@ export default {
// 如果是用户视图 测先进行底层复制
if (data.type === 'view') {
chartCopy(data.propValue.viewId).then(res => {
chartCopy(data.propValue.viewId, state.panel.panelInfo.id).then(res => {
const newView = deepCopy(data)
newView.id = uuid.v1()
newView.propValue.viewId = res.data
......
......@@ -2,7 +2,7 @@
<el-col v-loading="loading">
<el-row style="margin-top: 5px">
<el-row style="margin-left: 5px;margin-right: 5px">
<el-col :span="selectModel ? 23 : 16">
<el-col :span="23">
<el-input
v-model="templateFilterText"
:placeholder="$t('panel.filter_keywords')"
......@@ -11,9 +11,9 @@
prefix-icon="el-icon-search"
/>
</el-col>
<el-col v-if="!selectModel" :span="7">
<el-button type="primary" size="mini" style="float: right" @click="newChart">新建 </el-button>
</el-col>
<!-- <el-col v-if="!selectModel" :span="7">-->
<!-- <el-button type="primary" size="mini" style="float: right" @click="newChart">新建 </el-button>-->
<!-- </el-col>-->
</el-row>
<el-row style="margin-top: 5px">
......@@ -31,46 +31,35 @@
:filter-node-method="filterNode"
:highlight-current="true"
@node-drag-start="handleDragStart"
@node-click="nodeClick"
@check="checkChanged"
@node-drag-end="dragEnd"
>
<span slot-scope="{ node, data }" class="custom-tree-node">
<span>
<span v-if="data.type==='scene'||data.type==='group'">
<span v-if="data.modelType==='panel'|| data.nodeType === 'spine'">
<el-button
icon="el-icon-folder"
type="text"
/>
</span>
<span v-else>
<svg-icon :icon-class="data.type" style="width: 14px;height: 14px" />
<svg-icon :icon-class="data.modelInnerType" style="width: 14px;height: 14px" />
</span>
<span style="margin-left: 6px;font-size: 14px">{{ data.name }}</span>
</span>
</span>
</el-tree>
</el-row>
<!-- <el-row v-if="detailItem&&detailItem.snapshot" class="detail-class">-->
<!-- <el-card class="filter-card-class">-->
<!-- <div slot="header" class="button-div-class">-->
<!-- <span>{{ detailItem.name }}</span>-->
<!-- </div>-->
<!-- <img draggable="false" class="view-list-thumbnails" :src="detailItem.snapshot" alt="">-->
<!-- </el-card>-->
<!-- </el-row>-->
</el-row>
</el-col>
</template>
<script>
import { tree, findOne } from '@/api/panel/view'
import componentList from '@/components/canvas/custom-component/component-list'
import { deepCopy } from '@/components/canvas/utils/utils'
import eventBus from '@/components/canvas/utils/eventBus'
import { mapState } from 'vuex'
import { queryPanelViewTree } from '@/api/panel/panel'
export default {
name: 'ViewSelect',
......@@ -113,15 +102,9 @@ export default {
if (!value) return true
return data.name.indexOf(value) !== -1
},
nodeClick(data, node) {
findOne(data.id).then(res => {
this.detailItem = res.data
})
},
loadData() {
const param = {}
this.loading = true
tree(param).then(res => {
queryPanelViewTree().then(res => {
const nodeDatas = res.data
if (this.selectModel) {
this.setParentDisable(nodeDatas)
......@@ -135,7 +118,7 @@ export default {
ev.dataTransfer.effectAllowed = 'copy'
const dataTrans = {
type: 'view',
id: node.data.id
id: node.data.innerId
}
ev.dataTransfer.setData('componentInfo', JSON.stringify(dataTrans))
eventBus.$emit('startMoveIn')
......@@ -146,7 +129,7 @@ export default {
},
// 判断节点能否被拖拽
allowDrag(draggingNode) {
if (draggingNode.data.type === 'scene' || draggingNode.data.type === 'group') {
if (draggingNode.data.modelType === 'panel' || draggingNode.data.nodeType === 'spine') {
return false
} else {
return true
......@@ -171,7 +154,7 @@ export default {
},
setParentDisable(nodes) {
nodes.forEach(node => {
if (node.type === 'group') {
if (node.modelType === 'panel' || node.nodeType === 'spine') {
node.disabled = true
}
if (node.children && node.children.length > 0) {
......
......@@ -25,7 +25,7 @@
<div style="width: 60px;height: 100%;overflow: hidden auto;position: relative;margin: 0px auto; font-size: 14px">
<!-- 视图图表 start -->
<div class="button-div-class" style=" width: 24px;height: 24px;text-align: center;line-height: 1;position: relative;margin: 16px auto 0px;">
<el-button :class="show&&showIndex===0? 'button-show':'button-closed'" circle class="el-icon-circle-plus-outline" size="mini" @click="showPanel(0)" />
<el-button circle class="el-icon-circle-plus-outline" size="mini" @click="newChart()" />
</div>
<div class="button-text" style="position: relative; margin: 18px auto 16px;">
<div style="max-width: 100%;text-align: center;white-space: nowrap;text-overflow: ellipsis;position: relative;flex-shrink: 0;">
......@@ -66,6 +66,21 @@
<div style="width: 60px;height: 1px;line-height: 1px;text-align: center;white-space: pre;text-overflow: ellipsis;position: relative;flex-shrink: 0;" />
</div>
<!-- 其他组件 end -->
<!-- 视图复用 start -->
<div class="button-div-class" style=" width: 24px;height: 24px;text-align: center;line-height: 1;position: relative;margin: 16px auto 0px;">
<el-button :class="show&&showIndex===0? 'button-show':'button-closed'" circle class="el-icon-copy-document" size="mini" @click="showPanel(0)" />
</div>
<div class="button-text" style="position: relative; margin: 18px auto 16px;">
<div style="max-width: 100%;text-align: center;white-space: nowrap;text-overflow: ellipsis;position: relative;flex-shrink: 0;">
<!-- {{ $t('panel.view') }}-->
复用
</div>
</div>
<div style="height: 1px; position: relative; margin: 0px auto;background-color:#E6E6E6;">
<div style="width: 60px;height: 1px;line-height: 1px;text-align: center;white-space: pre;text-overflow: ellipsis;position: relative;flex-shrink: 0;" />
</div>
<!-- 视图复用 end -->
</div>
</div>
</de-aside-container>
......@@ -228,7 +243,7 @@ import elementResizeDetectorMaker from 'element-resize-detector'
import AssistComponent from '@/views/panel/AssistComponent'
import PanelTextEditor from '@/components/canvas/custom-component/PanelTextEditor'
import ChartGroup from '@/views/chart/group/Group'
import { searchAdviceSceneId } from '@/api/chart/chart'
import { chartCopy, searchAdviceSceneId } from '@/api/chart/chart'
// 引入样式
import '@/components/canvas/assets/iconfont/iconfont.css'
import '@/components/canvas/styles/animate.css'
......@@ -628,8 +643,18 @@ export default {
component.id = newComponentId
// 新拖入的组件矩阵状态 和仪表板当前的矩阵状态 保持一致
component.auxiliaryMatrix = this.canvasStyleData.auxiliaryMatrix
this.$store.commit('addComponent', { component })
this.$store.commit('recordSnapshot', 'handleDrop')
// 视图统一调整为复制
if (componentInfo.type === 'view') {
chartCopy(component.propValue.viewId, this.panelInfo.id).then(res => {
component.propValue.viewId = res.data
this.$store.commit('addComponent', { component })
this.$store.commit('recordSnapshot', 'handleDrop')
})
} else {
this.$store.commit('addComponent', { component })
this.$store.commit('recordSnapshot', 'handleDrop')
}
this.clearCurrentInfo()
},
clearCurrentInfo() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论