feat:增加仪表盘预览等功能

This commit is contained in:
wangjiahao 2021-03-29 14:57:04 +08:00
parent ced8c21e28
commit 873a03065c
17 changed files with 351 additions and 232 deletions

View File

@ -21,7 +21,5 @@ public class PanelGroup implements Serializable {
private String panelType; private String panelType;
private String panelStyle;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -643,76 +643,6 @@ public class PanelGroupExample {
addCriterion("panel_type not between", value1, value2, "panelType"); addCriterion("panel_type not between", value1, value2, "panelType");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andPanelStyleIsNull() {
addCriterion("panel_style is null");
return (Criteria) this;
}
public Criteria andPanelStyleIsNotNull() {
addCriterion("panel_style is not null");
return (Criteria) this;
}
public Criteria andPanelStyleEqualTo(String value) {
addCriterion("panel_style =", value, "panelStyle");
return (Criteria) this;
}
public Criteria andPanelStyleNotEqualTo(String value) {
addCriterion("panel_style <>", value, "panelStyle");
return (Criteria) this;
}
public Criteria andPanelStyleGreaterThan(String value) {
addCriterion("panel_style >", value, "panelStyle");
return (Criteria) this;
}
public Criteria andPanelStyleGreaterThanOrEqualTo(String value) {
addCriterion("panel_style >=", value, "panelStyle");
return (Criteria) this;
}
public Criteria andPanelStyleLessThan(String value) {
addCriterion("panel_style <", value, "panelStyle");
return (Criteria) this;
}
public Criteria andPanelStyleLessThanOrEqualTo(String value) {
addCriterion("panel_style <=", value, "panelStyle");
return (Criteria) this;
}
public Criteria andPanelStyleLike(String value) {
addCriterion("panel_style like", value, "panelStyle");
return (Criteria) this;
}
public Criteria andPanelStyleNotLike(String value) {
addCriterion("panel_style not like", value, "panelStyle");
return (Criteria) this;
}
public Criteria andPanelStyleIn(List<String> values) {
addCriterion("panel_style in", values, "panelStyle");
return (Criteria) this;
}
public Criteria andPanelStyleNotIn(List<String> values) {
addCriterion("panel_style not in", values, "panelStyle");
return (Criteria) this;
}
public Criteria andPanelStyleBetween(String value1, String value2) {
addCriterion("panel_style between", value1, value2, "panelStyle");
return (Criteria) this;
}
public Criteria andPanelStyleNotBetween(String value1, String value2) {
addCriterion("panel_style not between", value1, value2, "panelStyle");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -0,0 +1,17 @@
package io.dataease.base.domain;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PanelGroupWithBLOBs extends PanelGroup implements Serializable {
private String panelStyle;
private String panelData;
private static final long serialVersionUID = 1L;
}

View File

@ -2,6 +2,7 @@ package io.dataease.base.mapper;
import io.dataease.base.domain.PanelGroup; import io.dataease.base.domain.PanelGroup;
import io.dataease.base.domain.PanelGroupExample; import io.dataease.base.domain.PanelGroupExample;
import io.dataease.base.domain.PanelGroupWithBLOBs;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -12,19 +13,25 @@ public interface PanelGroupMapper {
int deleteByPrimaryKey(String id); int deleteByPrimaryKey(String id);
int insert(PanelGroup record); int insert(PanelGroupWithBLOBs record);
int insertSelective(PanelGroup record); int insertSelective(PanelGroupWithBLOBs record);
List<PanelGroupWithBLOBs> selectByExampleWithBLOBs(PanelGroupExample example);
List<PanelGroup> selectByExample(PanelGroupExample example); List<PanelGroup> selectByExample(PanelGroupExample example);
PanelGroup selectByPrimaryKey(String id); PanelGroupWithBLOBs selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") PanelGroup record, @Param("example") PanelGroupExample example); int updateByExampleSelective(@Param("record") PanelGroupWithBLOBs record, @Param("example") PanelGroupExample example);
int updateByExampleWithBLOBs(@Param("record") PanelGroupWithBLOBs record, @Param("example") PanelGroupExample example);
int updateByExample(@Param("record") PanelGroup record, @Param("example") PanelGroupExample example); int updateByExample(@Param("record") PanelGroup record, @Param("example") PanelGroupExample example);
int updateByPrimaryKeySelective(PanelGroup record); int updateByPrimaryKeySelective(PanelGroupWithBLOBs record);
int updateByPrimaryKeyWithBLOBs(PanelGroupWithBLOBs record);
int updateByPrimaryKey(PanelGroup record); int updateByPrimaryKey(PanelGroup record);
} }

View File

@ -10,7 +10,10 @@
<result column="create_by" jdbcType="VARCHAR" property="createBy" /> <result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="BIGINT" property="createTime" /> <result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="panel_type" jdbcType="VARCHAR" property="panelType" /> <result column="panel_type" jdbcType="VARCHAR" property="panelType" />
<result column="panel_style" jdbcType="VARCHAR" property="panelStyle" /> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.dataease.base.domain.PanelGroupWithBLOBs">
<result column="panel_style" jdbcType="LONGVARCHAR" property="panelStyle" />
<result column="panel_data" jdbcType="LONGVARCHAR" property="panelData" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -71,8 +74,27 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, `name`, pid, `level`, node_type, create_by, create_time, panel_type, panel_style id, `name`, pid, `level`, node_type, create_by, create_time, panel_type
</sql> </sql>
<sql id="Blob_Column_List">
panel_style, panel_data
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.dataease.base.domain.PanelGroupExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from panel_group
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="io.dataease.base.domain.PanelGroupExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="io.dataease.base.domain.PanelGroupExample" resultMap="BaseResultMap">
select select
<if test="distinct"> <if test="distinct">
@ -87,9 +109,11 @@
order by ${orderByClause} order by ${orderByClause}
</if> </if>
</select> </select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from panel_group from panel_group
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</select> </select>
@ -103,17 +127,17 @@
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause" />
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="io.dataease.base.domain.PanelGroup"> <insert id="insert" parameterType="io.dataease.base.domain.PanelGroupWithBLOBs">
insert into panel_group (id, `name`, pid, insert into panel_group (id, `name`, pid,
`level`, node_type, create_by, `level`, node_type, create_by,
create_time, panel_type, panel_style create_time, panel_type, panel_style,
) panel_data)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{pid,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{pid,jdbcType=VARCHAR},
#{level,jdbcType=INTEGER}, #{nodeType,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{level,jdbcType=INTEGER}, #{nodeType,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{panelType,jdbcType=VARCHAR}, #{panelStyle,jdbcType=VARCHAR} #{createTime,jdbcType=BIGINT}, #{panelType,jdbcType=VARCHAR}, #{panelStyle,jdbcType=LONGVARCHAR},
) #{panelData,jdbcType=LONGVARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.PanelGroup"> <insert id="insertSelective" parameterType="io.dataease.base.domain.PanelGroupWithBLOBs">
insert into panel_group insert into panel_group
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@ -143,6 +167,9 @@
<if test="panelStyle != null"> <if test="panelStyle != null">
panel_style, panel_style,
</if> </if>
<if test="panelData != null">
panel_data,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@ -170,7 +197,10 @@
#{panelType,jdbcType=VARCHAR}, #{panelType,jdbcType=VARCHAR},
</if> </if>
<if test="panelStyle != null"> <if test="panelStyle != null">
#{panelStyle,jdbcType=VARCHAR}, #{panelStyle,jdbcType=LONGVARCHAR},
</if>
<if test="panelData != null">
#{panelData,jdbcType=LONGVARCHAR},
</if> </if>
</trim> </trim>
</insert> </insert>
@ -208,13 +238,32 @@
panel_type = #{record.panelType,jdbcType=VARCHAR}, panel_type = #{record.panelType,jdbcType=VARCHAR},
</if> </if>
<if test="record.panelStyle != null"> <if test="record.panelStyle != null">
panel_style = #{record.panelStyle,jdbcType=VARCHAR}, panel_style = #{record.panelStyle,jdbcType=LONGVARCHAR},
</if>
<if test="record.panelData != null">
panel_data = #{record.panelData,jdbcType=LONGVARCHAR},
</if> </if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
</update> </update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update panel_group
set id = #{record.id,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
pid = #{record.pid,jdbcType=VARCHAR},
`level` = #{record.level,jdbcType=INTEGER},
node_type = #{record.nodeType,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
panel_type = #{record.panelType,jdbcType=VARCHAR},
panel_style = #{record.panelStyle,jdbcType=LONGVARCHAR},
panel_data = #{record.panelData,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map"> <update id="updateByExample" parameterType="map">
update panel_group update panel_group
set id = #{record.id,jdbcType=VARCHAR}, set id = #{record.id,jdbcType=VARCHAR},
@ -224,13 +273,12 @@
node_type = #{record.nodeType,jdbcType=VARCHAR}, node_type = #{record.nodeType,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR}, create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
panel_type = #{record.panelType,jdbcType=VARCHAR}, panel_type = #{record.panelType,jdbcType=VARCHAR}
panel_style = #{record.panelStyle,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
</update> </update>
<update id="updateByPrimaryKeySelective" parameterType="io.dataease.base.domain.PanelGroup"> <update id="updateByPrimaryKeySelective" parameterType="io.dataease.base.domain.PanelGroupWithBLOBs">
update panel_group update panel_group
<set> <set>
<if test="name != null"> <if test="name != null">
@ -255,11 +303,27 @@
panel_type = #{panelType,jdbcType=VARCHAR}, panel_type = #{panelType,jdbcType=VARCHAR},
</if> </if>
<if test="panelStyle != null"> <if test="panelStyle != null">
panel_style = #{panelStyle,jdbcType=VARCHAR}, panel_style = #{panelStyle,jdbcType=LONGVARCHAR},
</if>
<if test="panelData != null">
panel_data = #{panelData,jdbcType=LONGVARCHAR},
</if> </if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.dataease.base.domain.PanelGroupWithBLOBs">
update panel_group
set `name` = #{name,jdbcType=VARCHAR},
pid = #{pid,jdbcType=VARCHAR},
`level` = #{level,jdbcType=INTEGER},
node_type = #{nodeType,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
panel_type = #{panelType,jdbcType=VARCHAR},
panel_style = #{panelStyle,jdbcType=LONGVARCHAR},
panel_data = #{panelData,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.PanelGroup"> <update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.PanelGroup">
update panel_group update panel_group
set `name` = #{name,jdbcType=VARCHAR}, set `name` = #{name,jdbcType=VARCHAR},
@ -268,8 +332,7 @@
node_type = #{nodeType,jdbcType=VARCHAR}, node_type = #{nodeType,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR}, create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
panel_type = #{panelType,jdbcType=VARCHAR}, panel_type = #{panelType,jdbcType=VARCHAR}
panel_style = #{panelStyle,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -1,6 +1,7 @@
package io.dataease.controller.panel; package io.dataease.controller.panel;
import io.dataease.base.domain.DatasetGroup; import io.dataease.base.domain.DatasetGroup;
import io.dataease.base.domain.PanelGroupWithBLOBs;
import io.dataease.controller.request.dataset.DataSetGroupRequest; import io.dataease.controller.request.dataset.DataSetGroupRequest;
import io.dataease.controller.request.panel.PanelGroupRequest; import io.dataease.controller.request.panel.PanelGroupRequest;
import io.dataease.dto.dataset.DataSetGroupDTO; import io.dataease.dto.dataset.DataSetGroupDTO;
@ -47,7 +48,7 @@ public class PanelGroupController {
} }
@GetMapping("/findOne/{id}") @GetMapping("/findOne/{id}")
public PanelGroupDTO findOne(@PathVariable String id) throws Exception { public PanelGroupWithBLOBs findOne(@PathVariable String id) throws Exception {
return panelGroupService.findOne(id); return panelGroupService.findOne(id);
} }

View File

@ -1,6 +1,7 @@
package io.dataease.dto.panel; package io.dataease.dto.panel;
import io.dataease.base.domain.PanelGroup; import io.dataease.base.domain.PanelGroup;
import io.dataease.base.domain.PanelGroupWithBLOBs;
import io.dataease.dto.chart.ChartViewDTO; import io.dataease.dto.chart.ChartViewDTO;
import lombok.Data; import lombok.Data;
@ -13,7 +14,7 @@ import java.util.List;
* Description: * Description:
*/ */
@Data @Data
public class PanelGroupDTO extends PanelGroup { public class PanelGroupDTO extends PanelGroupWithBLOBs {
private String label; private String label;

View File

@ -77,7 +77,7 @@ public class PanelGroupService {
request.setCreateTime(System.currentTimeMillis()); request.setCreateTime(System.currentTimeMillis());
panelGroupMapper.insert(request); panelGroupMapper.insert(request);
} else { } else {
panelGroupMapper.updateByPrimaryKey(request); panelGroupMapper.updateByPrimaryKeySelective(request);
} }
PanelGroupDTO panelGroupDTO = new PanelGroupDTO(); PanelGroupDTO panelGroupDTO = new PanelGroupDTO();
BeanUtils.copyBean(panelGroupDTO, request); BeanUtils.copyBean(panelGroupDTO, request);
@ -92,7 +92,11 @@ public class PanelGroupService {
} }
public PanelGroupDTO findOne(String panelId) throws Exception{ public PanelGroupWithBLOBs findOne(String panelId){
return panelGroupMapper.selectByPrimaryKey(panelId);
}
public PanelGroupDTO findOneBack(String panelId) throws Exception{
PanelGroupDTO panelGroupDTO = extPanelGroupMapper.panelGroup(panelId); PanelGroupDTO panelGroupDTO = extPanelGroupMapper.panelGroup(panelId);
Assert.notNull(panelGroupDTO, "未查询到仪表盘信息"); Assert.notNull(panelGroupDTO, "未查询到仪表盘信息");
PanelDesignExample panelDesignExample = new PanelDesignExample(); PanelDesignExample panelDesignExample = new PanelDesignExample();

View File

@ -21,6 +21,7 @@ CREATE TABLE `panel_design` (
-- ---------------------------- -- ----------------------------
-- Table structure for panel_group -- Table structure for panel_group
-- ---------------------------- -- ----------------------------
-- ----------------------------
DROP TABLE IF EXISTS `panel_group`; DROP TABLE IF EXISTS `panel_group`;
CREATE TABLE `panel_group` ( CREATE TABLE `panel_group` (
`id` varchar(50) NOT NULL, `id` varchar(50) NOT NULL,
@ -31,10 +32,10 @@ CREATE TABLE `panel_group` (
`create_by` varchar(255) DEFAULT NULL COMMENT '创建人', `create_by` varchar(255) DEFAULT NULL COMMENT '创建人',
`create_time` bigint(13) DEFAULT NULL COMMENT '创建时间', `create_time` bigint(13) DEFAULT NULL COMMENT '创建时间',
`panel_type` varchar(255) DEFAULT NULL COMMENT '仪表盘类型 system 系统内置 self 用户自建 ', `panel_type` varchar(255) DEFAULT NULL COMMENT '仪表盘类型 system 系统内置 self 用户自建 ',
`panel_style` varchar(2000) DEFAULT NULL COMMENT 'panel 样式', `panel_style` longtext COMMENT 'panel 样式',
`panel_data` longtext COMMENT 'panel 数据',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------- -- ----------------------------
-- Records of panel_group -- Records of panel_group
-- ---------------------------- -- ----------------------------

View File

@ -65,8 +65,8 @@
<!--要生成的数据库表 --> <!--要生成的数据库表 -->
<!-- <table tableName="datasource"/>--> <!-- <table tableName="datasource"/>-->
<table tableName="panel_design"/> <table tableName="panel_group"/>
<table tableName="panel_design"/> <!-- <table tableName="panel_design"/>-->
</context> </context>

View File

@ -0,0 +1,88 @@
<template>
<div class="bg" v-if="show">
<el-button @click="close" class="close">关闭</el-button>
<div class="canvas-container">
<div class="canvas"
:style="{
width: changeStyleWithScale(canvasStyleData.width) + 'px',
height: changeStyleWithScale(canvasStyleData.height) + 'px',
}"
>
<ComponentWrapper
v-for="(item, index) in componentData"
:key="index"
:config="item"
/>
</div>
</div>
</div>
</template>
<script>
import { getStyle } from '@/utils/style'
import { mapState } from 'vuex'
import ComponentWrapper from './ComponentWrapper'
import { changeStyleWithScale } from '@/utils/translate'
export default {
model: {
prop: 'show',
event: 'change',
},
props: {
show: {
type: Boolean,
default: false,
},
},
components: { ComponentWrapper },
computed: mapState([
'componentData',
'canvasStyleData',
]),
methods: {
changeStyleWithScale,
getStyle,
close() {
this.$emit('change', false)
},
},
}
</script>
<style lang="scss" scoped>
.bg {
width: 100%;
height: 100%;
top: 0;
left: 0;
position: fixed;
background: rgb(0, 0, 0, .5);
z-index: 10;
display: flex;
align-items: center;
justify-content: center;
overflow: auto;
padding: 20px;
.canvas-container {
width: calc(100% - 40px);
height: calc(100% - 120px);
overflow: auto;
.canvas {
background: #fff;
position: relative;
margin: auto;
}
}
.close {
position: absolute;
right: 20px;
top: 100px;
}
}
</style>

View File

@ -1,21 +1,19 @@
<template> <template>
<div class="bg" v-if="show"> <div class="canvas-container">
<el-button @click="close" class="close">关闭</el-button> <div
<div class="canvas-container"> class="canvas"
<div class="canvas" :style="{
:style="{ width: changeStyleWithScale(canvasStyleData.width) + 'px',
width: changeStyleWithScale(canvasStyleData.width) + 'px', height: changeStyleWithScale(canvasStyleData.height) + 'px',
height: changeStyleWithScale(canvasStyleData.height) + 'px', }"
}" >
> <ComponentWrapper
<ComponentWrapper v-for="(item, index) in componentData"
v-for="(item, index) in componentData" :key="index"
:key="index" :config="item"
:config="item" />
/>
</div>
</div>
</div> </div>
</div>
</template> </template>
<script> <script>
@ -25,30 +23,30 @@ import ComponentWrapper from './ComponentWrapper'
import { changeStyleWithScale } from '@/utils/translate' import { changeStyleWithScale } from '@/utils/translate'
export default { export default {
model: { components: { ComponentWrapper },
prop: 'show', model: {
event: 'change', prop: 'show',
}, event: 'change'
props: { },
show: { props: {
type: Boolean, show: {
default: false, type: Boolean,
}, default: false
}, }
components: { ComponentWrapper }, },
computed: mapState([ computed: mapState([
'componentData', 'componentData',
'canvasStyleData', 'canvasStyleData'
]), ]),
methods: { methods: {
changeStyleWithScale, changeStyleWithScale,
getStyle, getStyle,
close() { close() {
this.$emit('change', false) this.$emit('change', false)
}, }
}, }
} }
</script> </script>

View File

@ -1,23 +1,36 @@
<template> <template>
<div> <div>
<div class="toolbar"> <div class="toolbar">
<el-button @click="undo">撤消</el-button>
<el-button @click="redo">重做</el-button>
<label for="input" class="insert">插入图片</label>
<input id="input" type="file" hidden @change="handleFileChange">
<el-button style="margin-left: 10px;" @click="preview">预览</el-button>
<el-button @click="save">保存</el-button>
<el-button @click="clearCanvas">清空画布</el-button>
<div class="canvas-config"> <div class="canvas-config">
<span>画布大小</span> <span>画布大小</span>
<input v-model="canvasStyleData.width"> <input v-model="canvasStyleData.width">
<span>*</span> <span>*</span>
<input v-model="canvasStyleData.height"> <input v-model="canvasStyleData.height">
</div> </div>
<div class="canvas-config"> <div class="canvas-config" style="margin-right: 10px">
<span>画布比例</span> <span>画布比例</span>
<input v-model="scale" @input="handleScaleChange"> % <input v-model="scale" @input="handleScaleChange"> %
</div> </div>
<el-tooltip content="撤消">
<el-button class="el-icon-refresh-right" size="mini" circle @click="undo" />
</el-tooltip>
<el-tooltip content="重做">
<el-button class="el-icon-refresh-left" size="mini" circle @click="redo" />
</el-tooltip>
<el-tooltip content="插入图片">
<el-button class="el-icon-upload" size="mini" circle @click="goFile" />
</el-tooltip>
<el-tooltip content="清空画布" style="margin-right: 10px">
<el-button class="el-icon-document-delete" size="mini" circle @click="clearCanvas" />
</el-tooltip>
<input id="input" ref="files" type="file" hidden @change="handleFileChange">
<el-tooltip content="保存">
<el-button class="el-icon-circle-check" size="mini" circle @click="save" />
</el-tooltip>
<el-tooltip content="预览">
<el-button class="el-icon-view" size="mini" circle @click="preview" />
</el-tooltip>
</div> </div>
<!-- 预览 --> <!-- 预览 -->
@ -33,6 +46,7 @@ import Preview from '@/components/Editor/Preview'
import { commonStyle, commonAttr } from '@/custom-component/component-list' import { commonStyle, commonAttr } from '@/custom-component/component-list'
import eventBus from '@/utils/eventBus' import eventBus from '@/utils/eventBus'
import { deepCopy } from '@/utils/utils' import { deepCopy } from '@/utils/utils'
import { post } from '@/api/panel/panel'
export default { export default {
components: { Preview }, components: { Preview },
@ -65,6 +79,9 @@ export default {
this.scale = this.canvasStyleData.scale this.scale = this.canvasStyleData.scale
}, },
methods: { methods: {
goFile() {
this.$refs.files.click()
},
format(value) { format(value) {
const scale = this.scale const scale = this.scale
return value * parseInt(scale) / 100 return value * parseInt(scale) / 100
@ -171,9 +188,15 @@ export default {
save() { save() {
localStorage.setItem('canvasData', JSON.stringify(this.componentData)) localStorage.setItem('canvasData', JSON.stringify(this.componentData))
localStorage.setItem('canvasStyle', JSON.stringify(this.canvasStyleData)) localStorage.setItem('canvasStyle', JSON.stringify(this.canvasStyleData))
//
const requestInfo = {
id: this.$store.state.panel.panelInfo.id,
panelStyle: JSON.stringify(this.canvasStyleData),
panelData: JSON.stringify(this.componentData)
}
post('panel/group/save', requestInfo, () => {})
this.$message.success('保存成功') this.$message.success('保存成功')
}, },
clearCanvas() { clearCanvas() {
this.$store.commit('setComponentData', []) this.$store.commit('setComponentData', [])
this.$store.commit('recordSnapshot') this.$store.commit('recordSnapshot')
@ -188,8 +211,9 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.toolbar { .toolbar {
height: 50px; float: right;
line-height: 50px; height: 35px;
line-height: 35px;
background: #fff; background: #fff;
border-bottom: 1px solid #ddd; border-bottom: 1px solid #ddd;

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="rect-shape"> <div class="rect-shape">
<chart-component v-if="showCard" :ref="element.propValue.id" class="chart-class" :chart-id="element.propValue.id" :chart="chart" /> <chart-component :ref="element.propValue.id" class="chart-class" :chart-id="element.propValue.id" :chart="chart" />
</div> </div>
</template> </template>
@ -18,9 +18,7 @@ export default {
}, },
data() { data() {
return { return {
chart: {}, chart: {}
showCard: false
} }
}, },
created() { created() {
@ -40,7 +38,6 @@ export default {
post('/chart/view/getData/' + id, null).then(response => { post('/chart/view/getData/' + id, null).then(response => {
// echart // echart
this.chart = response.data this.chart = response.data
this.showCard = true
}) })
} }
} }

View File

@ -1,37 +1,17 @@
<template> <template>
<el-container> <el-container>
<!-- <de-header>Header</de-header> -->
<el-header class="de-header"> <el-header class="de-header">
<el-row class="panel-design-head"> <el-row class="panel-design-head">
<span style="float: left;line-height: 50px; color: gray"> <span style="float: left;line-height: 35px; color: gray">
<span>名称测试仪表板</span> 名称{{ panelInfo.name || '测试仪表板' }}
</span> </span>
<!--横向工具栏-->
<Toolbar /> <Toolbar />
<!-- <span style="float: right;line-height: 35px;">-->
<!-- <el-tooltip content="返回目录">-->
<!-- <el-button class="el-icon-refresh-left" size="mini" circle @click="toDir" />-->
<!-- </el-tooltip>-->
<!-- <el-tooltip content="背景图">-->
<!-- <el-button class="el-icon-full-screen" size="mini" circle />-->
<!-- </el-tooltip>-->
<!-- <el-tooltip content="保存">-->
<!-- <el-button class="el-icon-circle-check" size="mini" circle @click="saveDrawing" />-->
<!-- </el-tooltip>-->
<!-- <el-tooltip content="预览">-->
<!-- <el-button class="el-icon-view" size="mini" circle @click="preViewShow" />-->
<!-- </el-tooltip>-->
<!-- </span>-->
</el-row> </el-row>
</el-header> </el-header>
<de-container> <de-container>
<de-aside-container class="ms-aside-container"> <de-aside-container class="ms-aside-container">
<div style="width: 60px; left: 0px; top: 0px; bottom: 0px; position: absolute"> <div style="width: 60px; left: 0px; top: 0px; bottom: 0px; position: absolute">
<div style="width: 60px;height: 100%;overflow: hidden auto;position: relative;margin: 0px auto;"> <div style="width: 60px;height: 100%;overflow: hidden auto;position: relative;margin: 0px auto;">
<!-- 视图图表 --> <!-- 视图图表 -->
<div class="button-div-class" style=" width: 24px;height: 24px;text-align: center;line-height: 1;position: relative;margin: 32px auto 0px;font-size:150%;"> <div class="button-div-class" style=" width: 24px;height: 24px;text-align: center;line-height: 1;position: relative;margin: 32px auto 0px;font-size:150%;">
@ -49,28 +29,19 @@
</div> </div>
<!-- 过滤组件 --> <!-- 过滤组件 -->
<div tabindex="-1" style="position: relative; margin: 20px auto"> <div tabindex="-1" style="position: relative; margin: 20px auto">
<div style="height: 60px; position: relative"> <div style="height: 60px; position: relative">
<div class="button-div-class" style=" text-align: center;line-height: 1;position: absolute;inset: 0px 0px 45px; "> <div class="button-div-class" style=" text-align: center;line-height: 1;position: absolute;inset: 0px 0px 45px; ">
<!-- <i class="el-icon-s-tools" style="width: 24px; height: 24px;position: relative;flex-shrink: 0;font-size:150%;" /> -->
<el-button circle class="el-icon-s-tools" size="mini" @click="showPanel(1)" /> <el-button circle class="el-icon-s-tools" size="mini" @click="showPanel(1)" />
</div> </div>
<div style=" position: absolute;left: 0px;right: 0px;bottom: 10px; height: 16px;"> <div style=" position: absolute;left: 0px;right: 0px;bottom: 10px; height: 16px;">
<div style=" max-width: 100%;text-align: center;white-space: nowrap;text-overflow: ellipsis;position: relative;flex-shrink: 0;"> <div style=" max-width: 100%;text-align: center;white-space: nowrap;text-overflow: ellipsis;position: relative;flex-shrink: 0;">
组件 组件
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div ref="leftPanel" :class="{show:show}" class="leftPanel-container"> <div ref="leftPanel" :class="{show:show}" class="leftPanel-container">
<div /> <div />
<div v-show="show" class="leftPanel"> <div v-show="show" class="leftPanel">
@ -81,8 +52,9 @@
</div> </div>
</div> </div>
</div> </div>
</de-aside-container> </de-aside-container>
<!--画布区域-->
<de-main-container class="ms-main-container"> <de-main-container class="ms-main-container">
<div <div
class="content" class="content"
@ -113,6 +85,7 @@ import { listenGlobalKeyDown } from '@/utils/shortcutKey'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import { uuid } from 'vue-uuid' import { uuid } from 'vue-uuid'
import Toolbar from '@/components/Toolbar' import Toolbar from '@/components/Toolbar'
import { get } from '@/api/panel/panel'
// //
import '@/assets/iconfont/iconfont.css' import '@/assets/iconfont/iconfont.css'
@ -140,12 +113,19 @@ export default {
reSelectAnimateIndex: undefined reSelectAnimateIndex: undefined
} }
}, },
computed: mapState([
'componentData', computed: {
'curComponent', panelInfo() {
'isClickComponent', return this.$store.state.panel.panelInfo
'canvasStyleData' },
]), ...mapState([
'componentData',
'curComponent',
'isClickComponent',
'canvasStyleData'
])
},
watch: { watch: {
show(value) { show(value) {
if (value && !this.clickNotClose) { if (value && !this.clickNotClose) {
@ -156,10 +136,14 @@ export default {
} else { } else {
removeClass(document.body, 'showRightPanel') removeClass(document.body, 'showRightPanel')
} }
},
panelInfo(newVal, oldVal) {
this.init(newVal.id)
} }
}, },
created() { created() {
this.restore() this.init(this.$store.state.panel.panelInfo.id)
// this.restore()
// //
listenGlobalKeyDown() listenGlobalKeyDown()
}, },
@ -174,6 +158,18 @@ export default {
elx && elx.remove() elx && elx.remove()
}, },
methods: { methods: {
init(panelId) {
//
localStorage.setItem('canvasData', null)
localStorage.setItem('canvasStyle', null)
if (panelId) {
get('panel/group/findOne/' + panelId).then(response => {
localStorage.setItem('canvasData', response.data.panelData)
localStorage.setItem('canvasStyle', response.data.panelStyle)
this.restore()
})
}
},
save() { save() {
}, },

View File

@ -147,7 +147,8 @@
<script> <script>
import GrantAuth from '../GrantAuth' import GrantAuth from '../GrantAuth'
import LinkGenerate from '@/views/link/generate' import LinkGenerate from '@/views/link/generate'
import { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree, defaultTree } from '@/api/panel/panel' import generateID from '@/utils/generateID'
import { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree, defaultTree, get } from '@/api/panel/panel'
export default { export default {
name: 'PanelList', name: 'PanelList',
@ -422,6 +423,22 @@ export default {
if (data.nodeType === 'panel') { if (data.nodeType === 'panel') {
this.currGroup = data this.currGroup = data
this.$store.dispatch('panel/setPanelInfo', data) this.$store.dispatch('panel/setPanelInfo', data)
//
this.$nextTick(() => {
localStorage.setItem('canvasData', null)
localStorage.setItem('canvasStyle', null)
get('panel/group/findOne/' + data.id).then(response => {
localStorage.setItem('canvasData', response.data.panelData)
localStorage.setItem('canvasStyle', response.data.panelStyle)
//
if (localStorage.getItem('canvasData')) {
this.$store.commit('setComponentData', this.resetID(JSON.parse(localStorage.getItem('canvasData'))))
}
if (localStorage.getItem('canvasStyle')) {
this.$store.commit('setCanvasStyle', JSON.parse(localStorage.getItem('canvasStyle')))
}
})
})
} }
if (node.expanded) { if (node.expanded) {
this.expandedArray.push(data.id) this.expandedArray.push(data.id)
@ -431,14 +448,18 @@ export default {
this.expandedArray.splice(index, 1) this.expandedArray.splice(index, 1)
} }
} }
// console.log(this.expandedArray); },
resetID(data) {
data.forEach(item => {
item.id = generateID()
})
return data
}, },
back() { back() {
this.sceneMode = false this.sceneMode = false
// const route = this.$store.state.permission.currentRoutes
// console.log(route)
// this.$router.push('/dataset/index')
this.$store.dispatch('dataset/setSceneData', null) this.$store.dispatch('dataset/setSceneData', null)
this.$emit('switchComponent', { name: '' }) this.$emit('switchComponent', { name: '' })
}, },

View File

@ -6,54 +6,27 @@
<!--TODO 仪表盘设计公共设置区域--> <!--TODO 仪表盘设计公共设置区域-->
<el-row class="panel-design-head"> <el-row class="panel-design-head">
<span style="float: left;line-height: 40px; color: gray"> <span style="float: left;line-height: 40px; color: gray">
<span>名称{{ panelInfo.name || '测试仪表板' }}</span> <span>名称{{ panelInfo.name || '测试仪表板' }}</span>
</span> </span>
<span style="float: right;line-height: 40px;"> <span style="float: right;line-height: 40px;">
<el-tooltip content="背景图">
<el-button class="el-icon-full-screen" size="mini" circle />
</el-tooltip>
<!-- <el-tooltip content="保存">
<el-button class="el-icon-success" size="mini" circle @click="savePanel" />
</el-tooltip> -->
<el-tooltip content="预览"> <el-tooltip content="预览">
<el-button class="el-icon-view" size="mini" circle @click="preViewShow" /> <el-button class="el-icon-view" size="mini" circle @click="preViewShow" />
</el-tooltip> </el-tooltip>
</span> </span>
</el-row> </el-row>
<drawing-board /> <!--TODO 仪表盘预览区域-->
<!-- <el-row class="panel-design-show"> <!-- <Preview />-->
<div class="container" :style="panelDetails.gridStyle">
<vue-drag-resize-rotate
v-for="panelDesign in panelDetails.panelDesigns"
v-show="panelDesign.keepFlag"
:key="panelDesign.id"
:panel-design="panelDesign"
:parent="true"
@newStyle="newStyle"
>
<chart-component v-if="panelDesign.componentType==='view'" :ref="panelDesign.id" :chart-id="panelDesign.id" :chart="panelDesign.chartView" />
</vue-drag-resize-rotate>
</div>
</el-row> -->
</el-col> </el-col>
</el-row> </el-row>
</el-row> </el-row>
</template> </template>
<script> <script>
import DrawingBoard from '../DrawingBoard'
import bus from '@/utils/bus' import bus from '@/utils/bus'
import Preview from '@/components/Editor/Preview'
export default { export default {
name: 'PanelViewShow', name: 'PanelViewShow',
components: { DrawingBoard }, components: { Preview },
data() { data() {
return { return {