提交 cf557782 authored 作者: wangjiahao's avatar wangjiahao

feat: 视图所有操作移到仪表板

上级 0a6e5524
package io.dataease.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class ChartViewCache implements Serializable {
private String id;
private String name;
private String title;
private String sceneId;
private String tableId;
private String type;
private String render;
private Integer resultCount;
private String resultMode;
private String createBy;
private Long createTime;
private Long updateTime;
private String stylePriority;
private String chartType;
private Boolean isPlugin;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
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 ChartViewCacheWithBLOBs extends ChartViewCache implements Serializable {
private String xAxis;
private String xAxisExt;
private String yAxis;
private String yAxisExt;
private String extStack;
private String extBubble;
private String customAttr;
private String customStyle;
private String customFilter;
private String drillFields;
private String snapshot;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package io.dataease.base.mapper;
import io.dataease.base.domain.ChartViewCache;
import io.dataease.base.domain.ChartViewCacheExample;
import io.dataease.base.domain.ChartViewCacheWithBLOBs;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface ChartViewCacheMapper {
long countByExample(ChartViewCacheExample example);
int deleteByExample(ChartViewCacheExample example);
int deleteByPrimaryKey(String id);
int insert(ChartViewCacheWithBLOBs record);
int insertSelective(ChartViewCacheWithBLOBs record);
List<ChartViewCacheWithBLOBs> selectByExampleWithBLOBs(ChartViewCacheExample example);
List<ChartViewCache> selectByExample(ChartViewCacheExample example);
ChartViewCacheWithBLOBs selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") ChartViewCacheWithBLOBs record, @Param("example") ChartViewCacheExample example);
int updateByExampleWithBLOBs(@Param("record") ChartViewCacheWithBLOBs record, @Param("example") ChartViewCacheExample example);
int updateByExample(@Param("record") ChartViewCache record, @Param("example") ChartViewCacheExample example);
int updateByPrimaryKeySelective(ChartViewCacheWithBLOBs record);
int updateByPrimaryKeyWithBLOBs(ChartViewCacheWithBLOBs record);
int updateByPrimaryKey(ChartViewCache record);
}
\ No newline at end of file
......@@ -12,7 +12,7 @@ import java.util.List;
public interface ExtChartViewMapper {
List<ChartViewDTO> search(ChartViewRequest request);
ChartViewDTO searchOne(ChartViewRequest request);
// ChartViewDTO searchOne(ChartViewRequest request);
void chartCopy(@Param("newChartId")String newChartId,@Param("oldChartId")String oldChartId,@Param("panelId")String panelId);
......@@ -25,9 +25,24 @@ public interface ExtChartViewMapper {
ChartViewDTO searchOneWithPrivileges(@Param("userId") String userId,@Param("id") String id );
ChartViewDTO searchOne(@Param("id") String id );
void chartCopyWithPanel(@Param("copyId") String copyId);
void deleteCircleView(@Param("pid") String pid);
void deleteCircleGroup(@Param("pid") String pid);
List<ChartViewDTO> searchViewsWithPanelId(@Param("panelId") String panelId);
ChartViewDTO searchOneFromCache(@Param("id") String id );
void copyToCache(@Param("id") String id );
void deleteCacheWithPanel(@Param("panelId") String panelId );
void deleteViewCache(@Param("viewId") String viewId );
void copyCacheToView(@Param("viewIds") List<String> viewIds );
}
......@@ -16,22 +16,38 @@
<select id="searchOne" resultMap="BaseResultMapDTO">
select
id, `name`, scene_id, table_id, `type`, title, create_by, create_time, update_time,
style_priority,x_axis, y_axis, custom_attr, custom_style, custom_filter, snapshot
from chart_view
<where>
<if test="sceneId != null">
and scene_id = #{sceneId,jdbcType=VARCHAR}
</if>
<if test="id != null">
and id = #{id,jdbcType=VARCHAR}
</if>
</where>
<if test="sort != null">
order by ${sort}
</if>
chart_view.*
from chart_view where id = #{id}
</select>
<select id="searchOneFromCache" resultMap="BaseResultMapDTO">
select
chart_view_cache.*
from chart_view_cache where id = #{id}
</select>
<insert id="copyToCache">
Insert into chart_view_cache select * from chart_view where chart_view.id = #{id}
</insert>
<!-- <select id="searchOne" resultMap="BaseResultMapDTO">-->
<!-- select-->
<!-- id, `name`, scene_id, table_id, `type`, title, create_by, create_time, update_time,-->
<!-- style_priority,x_axis, y_axis, custom_attr, custom_style, custom_filter, snapshot-->
<!-- from chart_view-->
<!-- <where>-->
<!-- <if test="sceneId != null">-->
<!-- and scene_id = #{sceneId,jdbcType=VARCHAR}-->
<!-- </if>-->
<!-- <if test="id != null">-->
<!-- and id = #{id,jdbcType=VARCHAR}-->
<!-- </if>-->
<!-- </where>-->
<!-- <if test="sort != null">-->
<!-- order by ${sort}-->
<!-- </if>-->
<!-- </select>-->
<select id="search" resultMap="BaseResultMapDTO">
select
id, `name`, scene_id, table_id, `type`, title, create_by, create_time, update_time,
......@@ -236,4 +252,64 @@
<delete id="deleteCircleGroup">
delete chart_group from (select GET_CHART_GROUP_WITH_CHILDREN(#{pid}) cids) t,chart_group where FIND_IN_SET(chart_group.id,cids)
</delete>
<select id="searchViewsWithPanelId" resultMap="BaseResultMapDTO">
SELECT * FROM chart_view
WHERE
id IN (
SELECT
chart_view_id
FROM
panel_view
WHERE
panel_id = #{panelId}
)
</select>
<delete id="deleteCacheWithPanel">
DELETE cvc,
pv
FROM
chart_view_cache cvc
INNER JOIN panel_view pv ON cvc.id = pv.chart_view_id
WHERE
pv.panel_id = #{panelId}
</delete>
<delete id="deleteViewCache">
delete from chart_view_cache where id = #{viewId}
</delete>
<update id="copyCacheToView">
UPDATE chart_view cv,
chart_view_cache cve
SET cv.`name` = cve.`name`,
cv.title = cve.title,
cv.scene_id = cve.scene_id,
cv.table_id = cve.table_id,
cv.`type` = cve.`type`,
cv.render = cve.render,
cv.result_count = cve.result_count,
cv.result_mode = cve.result_mode,
cv.create_by = cve.create_by,
cv.create_time = cve.create_time,
cv.update_time = cve.update_time,
cv.style_priority = cve.style_priority,
cv.chart_type = cve.chart_type,
cv.is_plugin = cve.is_plugin,
cv.x_axis = cve.x_axis,
cv.x_axis_ext = cve.x_axis_ext,
cv.y_axis = cve.y_axis,
cv.y_axis_ext = cve.y_axis_ext,
cv.ext_stack = cve.ext_stack,
cv.ext_bubble = cve.ext_bubble,
cv.custom_attr = cve.custom_attr,
cv.custom_style = cve.custom_style,
cv.custom_filter = cve.custom_filter,
cv.drill_fields = cve.drill_fields,
cv.SNAPSHOT = cve.SNAPSHOT where cve.id = cv.id and cv.id in
<foreach collection="viewIds" item="viewId" open='(' separator=',' close=')'>
#{viewId}
</foreach>
</update>
</mapper>
......@@ -2,6 +2,7 @@ package io.dataease.base.mapper.ext;
import io.dataease.controller.request.dataset.DataSetTableRequest;
import io.dataease.dto.dataset.DataSetTableDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -10,4 +11,6 @@ public interface ExtDataSetTableMapper {
DataSetTableDTO searchOne(DataSetTableRequest request);
List<DataSetTableDTO> searchDataSetTableWithPanelId(@Param("panelId") String panelId, @Param("userId") String userId);
}
......@@ -100,4 +100,27 @@
ORDER BY CONVERT(`name` using gbk)
</select>
<select id="searchDataSetTableWithPanelId" resultMap="BaseResultMapDTO">
select
id, `name`, scene_id, data_source_id, `type`, `mode`,`info`, create_by, create_time,
get_auths(id,'dataset',#{userId}) as `privileges`
from dataset_table
where id in (
SELECT
table_id
FROM
chart_view
WHERE
id IN (
SELECT
chart_view_id
FROM
panel_view
WHERE
panel_id = #{panelId}
)
)
</select>
</mapper>
......@@ -43,6 +43,10 @@ public class CommonConstants {
// 仪表板
public static final String PANEL = "panel";
// 仪表板编辑
public static final String PANEL_EDIT = "panel_edit";
}
//视图数据查询模式
......@@ -54,4 +58,15 @@ public class CommonConstants {
// 自定义
public static final String CUSTOM = "custom";
}
//视图数据查询来源
public static final class VIEW_EDIT_FROM {
// 仪表板
public static final String PANEL = "panel";
// 仪表板编辑
public static final String CACHE = "cache";
}
}
......@@ -3,6 +3,7 @@ package io.dataease.controller.chart;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.dataease.auth.annotation.DePermission;
import io.dataease.auth.annotation.DePermissionProxy;
import io.dataease.base.domain.ChartViewCacheWithBLOBs;
import io.dataease.base.domain.ChartViewWithBLOBs;
import io.dataease.commons.constants.DePermissionType;
import io.dataease.commons.constants.ResourceAuthLevel;
......@@ -35,10 +36,17 @@ public class ChartViewController {
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
@ApiOperation("保存")
@PostMapping("/save/{panelId}")
public ChartViewWithBLOBs save(@PathVariable String panelId, @RequestBody ChartViewWithBLOBs chartViewWithBLOBs) {
public ChartViewDTO save(@PathVariable String panelId, @RequestBody ChartViewCacheWithBLOBs chartViewWithBLOBs) {
return chartViewService.save(chartViewWithBLOBs);
}
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
@ApiOperation("保存到缓存表")
@PostMapping("/save2Cache/{panelId}")
public void save2Cache(@PathVariable String panelId, @RequestBody ChartViewCacheWithBLOBs chartViewWithBLOBs) {
chartViewService.save2Cache(chartViewWithBLOBs);
}
@ApiIgnore
@ApiOperation("查询")
@PostMapping("/list")
......@@ -56,8 +64,8 @@ public class ChartViewController {
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_VIEW, paramIndex = 1)
@ApiOperation("详细信息")
@PostMapping("/get/{id}/{panelId}")
public ChartViewWithBLOBs get(@PathVariable String id, @PathVariable String panelId) {
return chartViewService.get(id);
public ChartViewDTO get(@PathVariable String id, @PathVariable String panelId,@RequestBody ChartViewRequest viewRequest) {
return chartViewService.getOne(id,viewRequest.getQueryFrom());
}
@ApiIgnore
......@@ -117,4 +125,20 @@ public class ChartViewController {
throws Exception {
return chartViewService.checkSameDataSet(viewIdSource, viewIdTarget);
}
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_VIEW)
@ApiOperation("初始化仪表板视图缓存")
@PostMapping("/initViewCache/{panelId}")
public void initViewCache(@PathVariable String panelId) {
chartViewService.initViewCache(panelId);
}
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_VIEW, paramIndex = 1)
@ApiOperation("重置视图缓存")
@PostMapping("/resetViewCache/{id}/{panelId}")
public void resetViewCache(@PathVariable String id, @PathVariable String panelId) {
chartViewService.resetViewCache(id);
}
}
......@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* Author: wangjiahao
......@@ -92,4 +93,11 @@ public class PanelGroupController {
return panelGroupService.queryPanelViewTree();
}
@ApiOperation("仪表板组件信息")
@GetMapping("/queryPanelComponents/{id}")
@I18n
public Map queryPanelComponents(@PathVariable String id){
return panelGroupService.queryPanelComponents(id);
}
}
......@@ -42,4 +42,5 @@ public class ChartExtRequest {
@ApiModelProperty(hidden = true)
private PermissionProxy proxy;
}
......@@ -16,4 +16,8 @@ public class ChartViewRequest extends ChartViewWithBLOBs {
private String sort;
@ApiModelProperty("当前登陆用户ID")
private String userId;
@ApiModelProperty("编辑来源")
private String editFrom;
@ApiModelProperty("查询来源")
private String queryFrom;
}
......@@ -2,11 +2,13 @@ package io.dataease.dto.panel;
import io.dataease.base.domain.PanelGroupWithBLOBs;
import io.dataease.commons.model.ITreeBase;
import io.dataease.dto.chart.ChartViewDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Author: wangjiahao
......@@ -31,6 +33,7 @@ public class PanelGroupDTO extends PanelGroupWithBLOBs implements ITreeBase<Pane
private String sourcePanelName;
@ApiModelProperty("子节点")
private List<PanelGroupDTO> children;
@ApiModelProperty("视图信息")
private List<Map<String, ChartViewDTO>> viewsInfo;
}
......@@ -6,6 +6,7 @@ import io.dataease.auth.api.dto.CurrentUserDto;
import io.dataease.auth.entity.SysUserEntity;
import io.dataease.auth.service.AuthUserService;
import io.dataease.base.domain.*;
import io.dataease.base.mapper.ChartViewCacheMapper;
import io.dataease.base.mapper.ChartViewMapper;
import io.dataease.base.mapper.ext.ExtChartGroupMapper;
import io.dataease.base.mapper.ext.ExtChartViewMapper;
......@@ -71,29 +72,55 @@ public class ChartViewService {
private PermissionService permissionService;
@Resource
private AuthUserService authUserService;
@Resource
private ChartViewCacheMapper chartViewCacheMapper;
//默认使用非公平
private ReentrantLock lock = new ReentrantLock();
public ChartViewWithBLOBs save(ChartViewWithBLOBs chartView) {
checkName(chartView);
// 直接保存统一到缓存表
public ChartViewDTO save(ChartViewCacheWithBLOBs chartView) {
long timestamp = System.currentTimeMillis();
chartView.setUpdateTime(timestamp);
if (ObjectUtils.isEmpty(chartView.getId())) {
chartView.setId(UUID.randomUUID().toString());
chartView.setCreateBy(AuthUtils.getUser().getUsername());
chartView.setCreateTime(timestamp);
chartView.setUpdateTime(timestamp);
chartViewMapper.insertSelective(chartView);
} else {
chartViewMapper.updateByPrimaryKeySelective(chartView);
}
chartViewCacheMapper.updateByPrimaryKeySelective(chartView);
Optional.ofNullable(chartView.getId()).ifPresent(id -> {
CacheUtils.remove(JdbcConstants.VIEW_CACHE_KEY, id);
});
return getOne(chartView.getId(),"panel_edit");
}
// 直接保存统一到缓存表
public void save2Cache(ChartViewCacheWithBLOBs chartView) {
long timestamp = System.currentTimeMillis();
chartView.setUpdateTime(timestamp);
chartViewCacheMapper.updateByPrimaryKeySelective(chartView);
Optional.ofNullable(chartView.getId()).ifPresent(id -> {
CacheUtils.remove(JdbcConstants.VIEW_CACHE_KEY, id);
});
return getOneWithPermission(chartView.getId());
}
// // 直接保存统一到缓存表
// public ChartViewWithBLOBs save(ChartViewRequest chartView) {
// checkName(chartView);
// long timestamp = System.currentTimeMillis();
// chartView.setUpdateTime(timestamp);
// if (ObjectUtils.isEmpty(chartView.getId())) {
// chartView.setId(UUID.randomUUID().toString());
// chartView.setCreateBy(AuthUtils.getUser().getUsername());
// chartView.setCreateTime(timestamp);
// chartView.setUpdateTime(timestamp);
// chartViewMapper.insertSelective(chartView);
// } else {
// chartViewMapper.updateByPrimaryKeySelective(chartView);
// }
// Optional.ofNullable(chartView.getId()).ifPresent(id -> {
// CacheUtils.remove(JdbcConstants.VIEW_CACHE_KEY, id);
// });
// return getOneWithPermission(chartView.getId());
// }
public List<ChartViewDTO> list(ChartViewRequest chartViewRequest) {
chartViewRequest.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
return extChartViewMapper.search(chartViewRequest);
......@@ -178,6 +205,21 @@ public class ChartViewService {
return extChartViewMapper.searchOneWithPrivileges(userId, id);
}
public ChartViewDTO getOne(String id,String queryFrom){
ChartViewDTO result;
//仪表板编辑页面 从缓存表中取数据 缓存表中没有数据则进行插入
if(CommonConstants.VIEW_QUERY_FROM.PANEL_EDIT.equals(queryFrom)){
result= extChartViewMapper.searchOneFromCache(id);
if(result == null){
extChartViewMapper.copyToCache(id);
result = extChartViewMapper.searchOneFromCache(id);
}
}else{
result = extChartViewMapper.searchOne(id);
}
return result;
}
public void delete(String id) {
chartViewMapper.deleteByPrimaryKey(id);
}
......@@ -189,7 +231,7 @@ public class ChartViewService {
}
public ChartViewDTO getData(String id, ChartExtRequest request) throws Exception {
ChartViewDTO view = this.getOneWithPermission(id);
ChartViewDTO view = this.getOne(id,request.getQueryFrom());
// 如果是从仪表板获取视图数据,则仪表板的查询模式,查询结果的数量,覆盖视图对应的属性
if (CommonConstants.VIEW_QUERY_FROM.PANEL.equals(request.getQueryFrom()) && CommonConstants.VIEW_RESULT_MODE.CUSTOM.equals(request.getResultMode())) {
view.setResultMode(request.getResultMode());
......@@ -1712,4 +1754,13 @@ public class ChartViewService {
}
}
}
public void initViewCache(String panelId){
extChartViewMapper.deleteCacheWithPanel(panelId);
}
public void resetViewCache (String viewId){
extChartViewMapper.deleteViewCache(viewId);
extChartViewMapper.copyToCache(viewId);
}
}
......@@ -14,14 +14,17 @@ import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.LogUtil;
import io.dataease.commons.utils.TreeUtils;
import io.dataease.controller.request.authModel.VAuthModelRequest;
import io.dataease.controller.request.dataset.DataSetTableRequest;
import io.dataease.controller.request.panel.PanelGroupRequest;
import io.dataease.dto.authModel.VAuthModelDTO;
import io.dataease.dto.chart.ChartViewDTO;
import io.dataease.dto.dataset.DataSetTableDTO;
import io.dataease.dto.panel.PanelGroupDTO;
import io.dataease.dto.panel.linkJump.PanelLinkJumpBaseRequest;
import io.dataease.exception.DataEaseException;
import io.dataease.i18n.Translator;
import io.dataease.service.chart.ChartViewService;
import io.dataease.service.dataset.DataSetTableService;
import io.dataease.service.sys.SysAuthService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -33,10 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -81,6 +81,11 @@ public class PanelGroupService {
private ExtPanelViewLinkageMapper extPanelViewLinkageMapper;
@Resource
private ExtChartViewMapper extChartViewMapper;
@Resource
private ExtDataSetTableMapper extDataSetTableMapper;
@Resource
private DataSetTableService dataSetTableService;
public List<PanelGroupDTO> tree(PanelGroupRequest panelGroupRequest) {
String userId = String.valueOf(AuthUtils.getUser().getUserId());
......@@ -99,13 +104,8 @@ public class PanelGroupService {
@DeCleaner(DePermissionType.PANEL)
// @Transactional
public PanelGroup saveOrUpdate(PanelGroupRequest request) {
try {
Boolean mobileLayout = panelViewService.syncPanelViews(request);
request.setMobileLayout(mobileLayout);
} catch (Exception e) {
e.printStackTrace();
LOGGER.error("更新panelView出错panelId:{}", request.getId());
}
Boolean mobileLayout = panelViewService.syncPanelViews(request);
request.setMobileLayout(mobileLayout);
String panelId = request.getId();
if (StringUtils.isEmpty(panelId)) {
// 新建
......@@ -341,4 +341,42 @@ public class PanelGroupService {
LogUtil.info("=====v1.8版本 仪表板私有化【结束】=====");
}
// 获取仪表板的视图信息
public Map queryPanelComponents(String panelId) {
try {
Map result, tableWithFields, viewWithViewInfo, tableWithTableInfo;
//查找所有view
List<ChartViewDTO> views = extChartViewMapper.searchViewsWithPanelId(panelId);
viewWithViewInfo = views.stream().collect(Collectors.toMap(ChartViewDTO::getId, ChartViewDTO -> ChartViewDTO));
//查找所有dataset
List<DataSetTableDTO> tables = extDataSetTableMapper.searchDataSetTableWithPanelId(panelId, String.valueOf(AuthUtils.getUser().getUserId()));
tableWithTableInfo = tables.stream().collect(Collectors.toMap(DataSetTableDTO::getId, DataSetTableDTO -> DataSetTableDTO));
//查找所有datasetFields
tableWithFields = new HashMap();
if (CollectionUtils.isNotEmpty(tables)) {
for (DataSetTableDTO table : tables) {
DataSetTableRequest dataSetTableRequest = new DataSetTableRequest();
dataSetTableRequest.setId(table.getId());
Map<String, List<DatasetTableField>> tableDataSetFields = dataSetTableService.getFieldsFromDE(dataSetTableRequest);
tableWithFields.put(table.getId(), tableDataSetFields);
}
}
result = new HashMap();
result.put("tableWithFields", tableWithFields);
result.put("viewWithViewInfo", viewWithViewInfo);
result.put("tableWithTableInfo", tableWithTableInfo);
return result;
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(e);
}
return null;
}
public void findPanelAttachInfo(String panelId) {
}
}
......@@ -7,6 +7,7 @@ import io.dataease.base.domain.PanelGroupWithBLOBs;
import io.dataease.base.domain.PanelView;
import io.dataease.base.domain.PanelViewExample;
import io.dataease.base.mapper.PanelViewMapper;
import io.dataease.base.mapper.ext.ExtChartViewMapper;
import io.dataease.base.mapper.ext.ExtPanelViewMapper;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.BeanUtils;
......@@ -39,6 +40,9 @@ public class PanelViewService {
@Resource
private PanelViewMapper panelViewMapper;
@Resource
private ExtChartViewMapper extChartViewMapper;
private final static String SCENE_TYPE = "scene";
public List<PanelViewDto> groups() {
......@@ -115,6 +119,10 @@ public class PanelViewService {
extPanelViewMapper.deleteWithPanelId(panelId);
if (CollectionUtils.isNotEmpty(panelViewInsertDTOList)) {
extPanelViewMapper.savePanelView(panelViewInsertDTOList);
//将视图从cache表中更新到正式表中
List<String> viewIds = panelViewInsertDTOList.stream().map(panelView ->panelView.getChartViewId()).collect(Collectors.toList());
extChartViewMapper.copyCacheToView(viewIds);
extChartViewMapper.deleteCacheWithPanel(panelId);
}
}
return mobileLayout;
......
......@@ -60,7 +60,7 @@
</javaClientGenerator>
<!--要生成的数据库表 -->
<table tableName="dataease_code_version"/>
<table tableName="chart_view_cache"/>
<!-- <table tableName="chart_view"/>-->
<!-- <table tableName="panel_view"/>-->
<!-- <table tableName="panel_link_jump"/>-->
......
import request from '@/utils/request'
import store from '@/store'
import { queryPanelComponents } from '@/api/panel/panel'
export function post(url, data) {
return request({
url: url,
method: 'post',
loading: true,
loading: false,
data
})
}
......@@ -13,7 +15,7 @@ export function getChartTree(data) {
return request({
url: 'api',
method: 'post',
loading: true,
loading: false,
data
})
}
......@@ -38,7 +40,7 @@ export function searchAdviceSceneId(panelId) {
return request({
url: '/chart/view/searchAdviceSceneId/' + panelId,
method: 'get',
loading: true
loading: false
})
}
......@@ -54,7 +56,7 @@ export function ajaxGetDataOnly(id, panelId, data) {
return request({
url: '/chart/view/getData/' + id + '/' + panelId,
method: 'post',
loading: true,
loading: false,
hideMsg: true,
data
})
......@@ -75,3 +77,34 @@ export function deleteCircle(id) {
})
}
export function getChartDetails(id, panelId, data) {
return request({
url: '/chart/view/get/' + id + '/' + panelId,
method: 'post',
loading: false,
data
})
}
export function save2Cache(panelId, data) {
return request({
url: '/chart/view/save2Cache/' + panelId,
method: 'post',
loading: false,
data
})
}
export function resetViewCacheCallBack(viewId, panelId, callback) {
// 加载仪表板组件视图数据
resetViewCache(viewId, panelId).then(rep => {
callback(rep)
})
}
export function resetViewCache(viewId, panelId) {
return request({
url: '/chart/view/resetViewCache/' + viewId + '/' + panelId,
method: 'post',
loading: false
})
}
......@@ -164,3 +164,28 @@ export function queryPanelViewTree() {
})
}
export function initPanelComponentsData(panelId, callback) {
// 加载仪表板组件视图数据
queryPanelComponents(panelId).then(rep => {
store.commit('initPanelComponents', rep.data)
callback(rep)
})
}
export function queryPanelComponents(id) {
return request({
url: 'panel/group/queryPanelComponents/' + id,
method: 'get',
loading: false
})
}
export function initViewCache(panelId) {
// 初始化仪表板视图缓存
return request({
url: 'chart/view/initViewCache/' + panelId,
method: 'post',
loading: false
})
}
......@@ -531,7 +531,7 @@ export default {
width: this.computedMainSlotWidth,
height: this.computedMainSlotHeight
}
if (this.element.commonBackground && this.element.commonBackground.enable) {
if (this.element.commonBackground&&this.element.commonBackground.enable) {
if (this.element.commonBackground.backgroundType === 'innerImage') {
style['background'] = `url(${this.element.commonBackground.innerImage}) no-repeat`
} else if (this.element.commonBackground.backgroundType === 'outerImage') {
......
......@@ -184,22 +184,25 @@ export default {
// resize
this.$emit('resizeView')
},
// edit() {
// // 编辑时临时保存 当前修改的画布
// this.$store.dispatch('panel/setComponentDataTemp', JSON.stringify(this.componentData))
// this.$store.dispatch('panel/setCanvasStyleDataTemp', JSON.stringify(this.canvasStyleData))
// if (this.curComponent.type === 'view') {
// this.$store.dispatch('chart/setViewId', null)
// this.$store.dispatch('chart/setViewId', this.curComponent.propValue.viewId)
// bus.$emit('PanelSwitchComponent', { name: 'ChartEdit', param: { 'id': this.curComponent.propValue.viewId, 'optType': 'edit' }})
// }
// if (this.curComponent.type === 'custom') {
// bus.$emit('component-dialog-edit')
// }
// // 编辑样式组件
// if (this.curComponent.type === 'v-text' || this.curComponent.type === 'rect-shape') {
// bus.$emit('component-dialog-style')
// }
// },
edit() {
// 编辑时临时保存 当前修改的画布
this.$store.dispatch('panel/setComponentDataTemp', JSON.stringify(this.componentData))
this.$store.dispatch('panel/setCanvasStyleDataTemp', JSON.stringify(this.canvasStyleData))
if (this.curComponent.type === 'view') {
this.$store.dispatch('chart/setViewId', null)
this.$store.dispatch('chart/setViewId', this.curComponent.propValue.viewId)
bus.$emit('PanelSwitchComponent', { name: 'ChartEdit', param: { 'id': this.curComponent.propValue.viewId, 'optType': 'edit' }})
}
if (this.curComponent.type === 'custom') {
bus.$emit('component-dialog-edit')
}
// 编辑样式组件
if (this.curComponent.type === 'v-text' || this.curComponent.type === 'rect-shape') {
bus.$emit('component-dialog-style')
}
bus.$emit('change_panel_right_draw', true)
},
linkageEdit() {
......
......@@ -46,23 +46,24 @@ export default {
]),
methods: {
edit() {
// 编辑时临时保存 当前修改的画布
this.$store.dispatch('panel/setComponentDataTemp', JSON.stringify(this.componentData))
this.$store.dispatch('panel/setCanvasStyleDataTemp', JSON.stringify(this.canvasStyleData))
if (this.curComponent.type === 'view') {
this.$store.dispatch('chart/setViewId', null)
this.$store.dispatch('chart/setViewId', this.curComponent.propValue.viewId)
bus.$emit('PanelSwitchComponent', { name: 'ChartEdit', param: { 'id': this.curComponent.propValue.viewId, 'optType': 'edit' }})
}
if (this.curComponent.type === 'custom') {
bus.$emit('component-dialog-edit')
}
// 编辑样式组件
if (this.curComponent.type === 'v-text' || this.curComponent.type === 'rect-shape') {
bus.$emit('component-dialog-style')
}
bus.$emit('change_panel_right_draw', true)
// // 编辑时临时保存 当前修改的画布
// this.$store.dispatch('panel/setComponentDataTemp', JSON.stringify(this.componentData))
// this.$store.dispatch('panel/setCanvasStyleDataTemp', JSON.stringify(this.canvasStyleData))
// if (this.curComponent.type === 'view') {
// this.$store.dispatch('chart/setViewId', null)
// this.$store.dispatch('chart/setViewId', this.curComponent.propValue.viewId)
// bus.$emit('PanelSwitchComponent', { name: 'ChartEdit', param: { 'id': this.curComponent.propValue.viewId, 'optType': 'edit' }})
// }
// if (this.curComponent.type === 'custom') {
// bus.$emit('component-dialog-edit')
// }
//
// // 编辑样式组件
//
// if (this.curComponent.type === 'v-text' || this.curComponent.type === 'rect-shape') {
// bus.$emit('component-dialog-style')
// }
},
lock() {
this.$store.commit('lock')
......
......@@ -57,6 +57,7 @@
@linkJumpSet="linkJumpSet(item)"
@boardSet="boardSet(item)"
@canvasDragging="canvasDragging"
@editComponent="editComponent(index,item)"
>
<component
:is="item.component"
......@@ -1286,6 +1287,11 @@ export default {
this.$refs.wrapperChild[index].chartResize()
}
},
editComponent(index, item) {
if (item.type === 'view') {
this.$refs.wrapperChild[index].editChart()
}
},
handleDragOver(e) {
this.dragComponentInfo.shadowStyle.x = e.pageX - 220
this.dragComponentInfo.shadowStyle.y = e.pageY - 90 + this.scrollTop
......
......@@ -372,6 +372,9 @@ export default {
bus.$on('plugin-add-view-track-filter', param => {
param.viewId && param.viewId === this.element.propValue.viewId && this.addViewTrackFilter(param)
})
bus.$on('view-in-cache', param => {
param.viewId && param.viewId === this.element.propValue.viewId && this.getDataEdit(param)
})
},
addViewTrackFilter(linkageParam) {
......@@ -431,7 +434,8 @@ export default {
}
const requestInfo = {
...this.filter,
cache: cache
cache: cache,
queryFrom: this.isEdit ? 'panel_edit' : 'panel'
}
if (this.panelInfo.proxy) {
// method = viewInfo
......@@ -711,6 +715,18 @@ export default {
renderComponent() {
return this.chart.render
},
getDataEdit(param) {
this.$store.state.styleChangeTimes++
if (param.type === 'propChange') {
this.getData(param.viewId, false)
} else if (param.type === 'styleChange') {
this.chart.customAttr = param.viewInfo.customAttr
this.chart.customStyle = param.viewInfo.customStyle
this.sourceCustomAttrStr = this.chart.customAttr
this.sourceCustomStyleStr = this.chart.customStyle
this.mergeScale()
}
}
}
}
......
......@@ -1029,7 +1029,8 @@ export default {
table_item_align: 'Body Align',
table_align_left: 'Left',
table_align_center: 'Center',
table_align_right: 'Right'
table_align_right: 'Right',
draw_back: 'Draw Back'
},
dataset: {
sheet_warn: 'There are multiple sheet pages, and the first one is extracted by default',
......@@ -1578,7 +1579,8 @@ export default {
uninstall_confirm: 'Comfirm to uninstall the plugin?',
uninstall_cancel: 'Cancel uninstall plugin',
setting_background: 'BackGround',
setting_jump: 'Jump Setting'
setting_jump: 'Jump Setting',
select_view: 'Select View'
},
display: {
logo: 'Head system logo',
......
......@@ -1029,7 +1029,8 @@ export default {
table_item_align: '表格對齊方式',
table_align_left: '左對齊',
table_align_center: '居中',
table_align_right: '右對齊'
table_align_right: '右對齊',
draw_back: '收回'
},
dataset: {
sheet_warn: '有多個 Sheet 頁,默認抽取第一個',
......@@ -1564,7 +1565,8 @@ export default {
choose_background: '选择组件背景',
choose_background_tips: '组件自有的背景设置会覆盖当前设置',
setting_background: '设置背景',
setting_jump: '跳转设置'
setting_jump: '跳转设置',
select_view: '请选择视图...'
},
plugin: {
local_install: '本地安裝',
......
......@@ -1032,7 +1032,8 @@ export default {
table_item_align: '表格对齐方式',
table_align_left: '左对齐',
table_align_center: '居中',
table_align_right: '右对齐'
table_align_right: '右对齐',
draw_back: '收回'
},
dataset: {
sheet_warn: '有多个 Sheet 页,默认抽取第一个',
......@@ -1573,7 +1574,8 @@ export default {
choose_background: '选择组件背景',
choose_background_tips: '组件自有的背景设置会覆盖当前设置',
setting_background: '设置背景',
setting_jump: '跳转设置'
setting_jump: '跳转设置',
select_view: '请选择视图...'
},
plugin: {
local_install: '本地安装',
......
......@@ -99,7 +99,9 @@ const data = {
x: 300,
y: 600
},
scrollAutoMove: 0
scrollAutoMove: 0,
// 视图是否编辑记录
panelViewEditInfo: {}
},
mutations: {
...animation.mutations,
......@@ -392,6 +394,17 @@ const data = {
},
setScrollAutoMove(state, offset) {
state.scrollAutoMove = offset
},
initPanelComponents(state, panelComponents) {
if (panelComponents) {
state.canvasStyleData['panelComponents'] = panelComponents
}
},
recordViewEdit(state, viewInfo) {
state.panelViewEditInfo[viewInfo.viewId] = viewInfo.hasEdit
},
resetViewEditInfo(state) {
state.panelViewEditInfo = {}
}
},
modules: {
......
......@@ -145,12 +145,12 @@ export default {
init() {
if (this.data.id) {
if (this.type === 'dataset') {
post('/dataset/table/datasetDetail/' + this.data.id, null).then(res => {
post('/dataset/table/datasetDetail/' + this.data.id, null,false).then(res => {
this.detail = res.data
this.info = JSON.parse(res.data.table.info)
})
} else if (this.type === 'chart') {
post('/chart/view/chartDetail/' + this.data.id + '/' + this.panelInfo.id, null).then(res => {
post('/chart/view/chartDetail/' + this.data.id + '/' + this.panelInfo.id, null,false).then(res => {
this.detail = res.data
this.info = JSON.parse(res.data.table.info)
})
......
......@@ -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="23">
<el-col :span="17">
<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">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论