提交 eae0095d authored 作者: taojinlong's avatar taojinlong

refactor: resolve Conflicts

......@@ -5,7 +5,7 @@
<parent>
<artifactId>dataease-server</artifactId>
<groupId>io.dataease</groupId>
<version>1.8.0</version>
<version>1.9.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......@@ -106,6 +106,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
<scope>runtime</scope>
</dependency>
<dependency>
......@@ -214,12 +215,12 @@
<dependency>
<groupId>io.dataease</groupId>
<artifactId>dataease-plugin-interface</artifactId>
<version>1.8.0</version>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>io.dataease</groupId>
<artifactId>dataease-plugin-view</artifactId>
<version>1.8.0</version>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
......@@ -279,6 +280,16 @@
<artifactId>json-path</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
</dependencies>
<build>
......
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 senior;
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,95 @@
<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 (
id,
`name`,
title,
scene_id,
table_id,
`type`,
render,
result_count,
result_mode,
create_by,
create_time,
update_time,
style_priority,
chart_type,
is_plugin,
x_axis,
x_axis_ext,
y_axis,
y_axis_ext,
ext_stack,
ext_bubble,
custom_attr,
custom_style,
custom_filter,
drill_fields,
senior,
SNAPSHOT
) SELECT
id,
`name`,
title,
scene_id,
table_id,
`type`,
render,
result_count,
result_mode,
create_by,
create_time,
update_time,
style_priority,
chart_type,
is_plugin,
x_axis,
x_axis_ext,
y_axis,
y_axis_ext,
ext_stack,
ext_bubble,
custom_attr,
custom_style,
custom_filter,
drill_fields,
senior,
SNAPSHOT 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,
......@@ -110,11 +183,11 @@
`chart_type`,
`senior`)
SELECT #{newChartId},
GET_CHART_VIEW_COPY_NAME(#{oldChartId}),
`name`,
#{panelId},
`table_id`,
`type`,
GET_CHART_VIEW_COPY_NAME(#{oldChartId}),
`title`,
`x_axis`,
`x_axis_ext`,
`y_axis`,
......@@ -135,7 +208,7 @@
`result_mode`,
'private',
`senior`
FROM chart_view
FROM chart_view_cache
WHERE id = #{oldChartId}
</insert>
......@@ -261,4 +334,64 @@
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
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.senior = cve.senior,
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>
......@@ -15,12 +15,16 @@ public interface ExtPanelGroupMapper {
//会级联删除pid 下的所有数据
int deleteCircle(@Param("pid") String pid);
int deleteCircleView(@Param("pid") String pid);
int deleteCircleViewCache(@Param("pid") String pid);
PanelGroupDTO findOneWithPrivileges(@Param("panelId") String panelId,@Param("userId") String userId);
void copyPanelView(@Param("pid") String panelId);
//移除未使用的视图
void removeUselessViews(@Param("panelId") String panelId);
void removeUselessViews(@Param("panelId") String panelId,@Param("viewIds") List<String> viewIds);
List<PanelGroupDTO> panelGroupInit();
......
......@@ -171,6 +171,14 @@
delete from panel_group where FIND_IN_SET(panel_group.id,GET_PANEL_GROUP_WITH_CHILDREN(#{pid})) or FIND_IN_SET(panel_group.source,GET_PANEL_GROUP_WITH_CHILDREN(#{pid}))
</delete>
<delete id="deleteCircleView">
delete from chart_view where FIND_IN_SET(chart_view.scene_id,GET_PANEL_GROUP_WITH_CHILDREN(#{pid}))
</delete>
<delete id="deleteCircleViewCache">
delete from chart_view_cache where FIND_IN_SET(chart_view_cache.scene_id,GET_PANEL_GROUP_WITH_CHILDREN(#{pid}))
</delete>
<insert id="copyPanelView">
INSERT INTO panel_view ( id, panel_id, chart_view_id ) SELECT
uuid(),
......@@ -189,14 +197,13 @@
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}
)
<if test="viewIds != null and viewIds.size>0">
AND id NOT IN
<foreach collection="viewIds" item="viewId" open="(" separator="," close=")" >
#{viewId}
</foreach>
</if>
</delete>
</mapper>
package io.dataease.commons.condition;
import io.dataease.commons.utils.CommonBeanFactory;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;
public class RedisStatusCondition implements Condition {
private static final String DEFAULT_TYPE = "ehcache";
private static final String TARGET_TYPE = "redis";
private static final String TYPE_KEY = "spring.cache.type";
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
Environment environment = context.getEnvironment();
String ehcacheType = environment.getProperty(TYPE_KEY, String.class, DEFAULT_TYPE);
return StringUtils.equals(TARGET_TYPE, ehcacheType);
}
}
......@@ -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";
}
}
package io.dataease.config;
import io.dataease.commons.condition.RedisStatusCondition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
@Configuration
public class RedisConfig {
@Conditional({RedisStatusCondition.class})
@Bean
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(factory);
Jackson2JsonRedisSerializer<Object> serializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
redisTemplate.setDefaultSerializer(serializer);
return redisTemplate;
}
}
......@@ -3,11 +3,13 @@ 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;
import io.dataease.controller.request.chart.ChartCalRequest;
import io.dataease.controller.request.chart.ChartExtRequest;
import io.dataease.controller.request.chart.ChartViewCacheRequest;
import io.dataease.controller.request.chart.ChartViewRequest;
import io.dataease.controller.response.ChartDetail;
import io.dataease.dto.chart.ChartViewDTO;
......@@ -35,8 +37,22 @@ public class ChartViewController {
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
@ApiOperation("保存")
@PostMapping("/save/{panelId}")
public ChartViewDTO save(@PathVariable String panelId, @RequestBody ChartViewCacheRequest request) {
return chartViewService.save(request);
}
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
@ApiOperation("新建视图")
@PostMapping("/newOne/{panelId}")
public ChartViewWithBLOBs save(@PathVariable String panelId, @RequestBody ChartViewWithBLOBs chartViewWithBLOBs) {
return chartViewService.save(chartViewWithBLOBs);
return chartViewService.newOne(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
......@@ -56,8 +72,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 +133,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;
}
package io.dataease.controller.request.chart;
import io.dataease.base.domain.ChartViewCacheWithBLOBs;
import lombok.Data;
/**
* Author: wangjiahao
* Date: 2022/3/10
* Description:
*/
@Data
public class ChartViewCacheRequest extends ChartViewCacheWithBLOBs {
private String savePosition = "cache";
}
......@@ -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;
}
package io.dataease.listener.util;
import io.dataease.commons.utils.CommonBeanFactory;
import net.sf.ehcache.Cache;
import net.sf.ehcache.Element;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import java.util.Date;
import java.util.concurrent.TimeUnit;
@Configuration
public class CacheUtils {
private static CacheManager manager;
private static CacheManager cacheManager;
@Autowired
public void setManager(CacheManager manager) {
CacheUtils.manager = manager;
private static CacheManager getCacheManager() {
if (cacheManager == null)
cacheManager = CommonBeanFactory.getBean(CacheManager.class);
return cacheManager;
}
public static Object get(String cacheName, Object key) {
if (getCacheManager() instanceof RedisCacheManager) {
org.springframework.cache.Cache cache = getCacheManager().getCache(cacheName);
if (null == cache) return null;
return cache.get(key);
}
Element element = cache(cacheName).get(key);
if (null == element) return null;
return element.getObjectValue();
}
public static void put(String cacheName, Object key, Object value, Integer ttl, Integer tti) {
if (getCacheManager() instanceof RedisCacheManager) {
RedisTemplate redisTemplate = (RedisTemplate) CommonBeanFactory.getBean("redisTemplate");
ValueOperations valueOperations = redisTemplate.opsForValue();
valueOperations.setIfPresent(cacheName + "::" + key , value );
return;
}
Element e = new Element(key, value);
//不设置则使用xml配置
if (ttl != null) {
......@@ -33,19 +49,35 @@ public class CacheUtils {
}
if (tti != null)
e.setTimeToIdle(tti);
cache(cacheName).put(e);
Cache cache = cache(cacheName);
if (null != cache)
cache.put(e);
}
public static boolean remove(String cacheName, Object key) {
if (getCacheManager() instanceof RedisCacheManager) {
org.springframework.cache.Cache cache = getCacheManager().getCache(cacheName);
if (null == cache) return false;
return cache.evictIfPresent(key);
}
return cache(cacheName).remove(key);
}
public static void removeAll(String cacheName) {
if (getCacheManager() instanceof RedisCacheManager) {
org.springframework.cache.Cache cache = getCacheManager().getCache(cacheName);
if (null == cache) return;
cache.clear();
return;
}
cache(cacheName).removeAll();
}
private static Cache cache(String cacheName) {
net.sf.ehcache.CacheManager cacheManager = ((EhCacheCacheManager) manager).getCacheManager();
if (getCacheManager() instanceof RedisCacheManager) {
return null;
}
net.sf.ehcache.CacheManager cacheManager = ((EhCacheCacheManager) getCacheManager()).getCacheManager();
if (!cacheManager.cacheExists(cacheName))
cacheManager.addCache(cacheName);
Cache cacheManagerCache = cacheManager.getCache(cacheName);
......@@ -57,6 +89,12 @@ public class CacheUtils {
long exp = (time - System.currentTimeMillis()) / 1000;
int intExp = (int)exp;
removeAll("lic_info");
if (getCacheManager() instanceof RedisCacheManager) {
RedisTemplate redisTemplate = (RedisTemplate) CommonBeanFactory.getBean("redisTemplate");
ValueOperations valueOperations = redisTemplate.opsForValue();
valueOperations.set("lic_info::lic", "lic", exp, TimeUnit.SECONDS);
return;
}
put("lic_info", "lic", "lic", intExp, intExp);
}
}
......@@ -5,6 +5,7 @@ import com.google.gson.reflect.TypeToken;
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;
......@@ -37,6 +38,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
......@@ -72,29 +74,70 @@ public class ChartViewService {
private AuthUserService authUserService;
@Resource
private EngineService engineService;
@Resource
private ChartViewCacheMapper chartViewCacheMapper;
//默认使用非公平
private ReentrantLock lock = new ReentrantLock();
public ChartViewWithBLOBs save(ChartViewWithBLOBs chartView) {
checkName(chartView);
// 直接保存统一到缓存表
public ChartViewDTO save(ChartViewCacheRequest 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 ChartViewWithBLOBs newOne(ChartViewWithBLOBs chartView) {
long timestamp = System.currentTimeMillis();
chartView.setUpdateTime(timestamp);
chartView.setId(UUID.randomUUID().toString());
chartView.setCreateBy(AuthUtils.getUser().getUsername());
chartView.setCreateTime(timestamp);
chartView.setUpdateTime(timestamp);
chartViewMapper.insertSelective(chartView);
// 新建的视图也存入缓存表中
extChartViewMapper.copyToCache(chartView.getId());
return chartView;
}
// 直接保存统一到缓存表
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);
......@@ -179,6 +222,22 @@ public class ChartViewService {
return extChartViewMapper.searchOneWithPrivileges(userId, id);
}
@Transactional
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);
}
......@@ -190,7 +249,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());
......@@ -1685,6 +1744,7 @@ public class ChartViewService {
public String chartCopy(String id, String panelId) {
String newChartId = UUID.randomUUID().toString();
extChartViewMapper.chartCopy(newChartId, id, panelId);
extChartViewMapper.copyToCache(newChartId);
return newChartId;
}
......@@ -1713,4 +1773,14 @@ public class ChartViewService {
}
}
}
public void initViewCache(String panelId){
extChartViewMapper.deleteCacheWithPanel(panelId);
}
public void resetViewCache (String viewId){
extChartViewMapper.deleteViewCache(viewId);
extChartViewMapper.copyToCache(viewId);
}
}
......@@ -51,7 +51,9 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.MessageFormat;
import java.text.NumberFormat;
......@@ -1182,6 +1184,14 @@ public class DataSetTableService {
DEException.throwException(
Translator.get("i18n_custom_ds_delete") + String.format(":table id [%s]", tableId));
}
CurrentUserDto user = AuthUtils.getUser();
if (user != null && !user.getIsAdmin()) {
DataSetTableDTO withPermission = getWithPermission(datasetTable.getId(), user.getUserId());
if (ObjectUtils.isEmpty(withPermission.getPrivileges()) || !withPermission.getPrivileges().contains("use")) {
DEException.throwException(
Translator.get("i18n_dataset_no_permission") + String.format(":table name [%s]", withPermission.getName()));
}
}
List<DatasetTableField> fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField());
String[] array = fields.stream()
......@@ -1310,6 +1320,14 @@ public class DataSetTableService {
DEException.throwException(
Translator.get("i18n_custom_ds_delete") + String.format(":table id [%s]", tableId));
}
CurrentUserDto user = AuthUtils.getUser();
if (user != null && !user.getIsAdmin()) {
DataSetTableDTO withPermission = getWithPermission(datasetTable.getId(), user.getUserId());
if (ObjectUtils.isEmpty(withPermission.getPrivileges()) || !withPermission.getPrivileges().contains("use")) {
DEException.throwException(
Translator.get("i18n_dataset_no_permission") + String.format(":table name [%s]", withPermission.getName()));
}
}
List<DatasetTableField> fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField());
String[] array = fields.stream()
......
......@@ -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,14 +104,11 @@ 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());
}
String panelId = request.getId();
List<String> viewIds = null;
if(StringUtils.isNotEmpty(panelId)){
viewIds = panelViewService.syncPanelViews(request);
}
if (StringUtils.isEmpty(panelId)) {
// 新建
checkPanelName(request.getName(), request.getPid(), PanelConstants.OPT_TYPE_INSERT, null, request.getNodeType());
......@@ -164,7 +166,7 @@ public class PanelGroupService {
}
//移除没有用到的仪表板私有视图
extPanelGroupMapper.removeUselessViews(panelId);
extPanelGroupMapper.removeUselessViews(panelId,viewIds);
return panelGroupDTOList.get(0);
}
......@@ -187,12 +189,18 @@ public class PanelGroupService {
public void deleteCircle(String id) {
Assert.notNull(id, "id cannot be null");
sysAuthService.checkTreeNoManageCount("panel", id);
//清理view 和 view cache
extPanelGroupMapper.deleteCircleView(id);
extPanelGroupMapper.deleteCircleViewCache(id);
// 同时会删除对应默认仪表盘
extPanelGroupMapper.deleteCircle(id);
storeService.removeByPanelId(id);
shareService.delete(id, null);
panelLinkService.deleteByResourceId(id);
//清理跳转信息
extPanelLinkJumpMapper.deleteJumpTargetViewInfoWithPanel(id);
extPanelLinkJumpMapper.deleteJumpInfoWithPanel(id);
......@@ -341,4 +349,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() {
......@@ -80,7 +84,8 @@ public class PanelViewService {
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Boolean syncPanelViews(PanelGroupWithBLOBs panelGroup) {
public List<String> syncPanelViews(PanelGroupWithBLOBs panelGroup) {
List<String> viewIds = new ArrayList<>();
Boolean mobileLayout = null;
String panelId = panelGroup.getId();
Assert.notNull(panelId, "panelId cannot be null");
......@@ -115,9 +120,14 @@ public class PanelViewService {
extPanelViewMapper.deleteWithPanelId(panelId);
if (CollectionUtils.isNotEmpty(panelViewInsertDTOList)) {
extPanelViewMapper.savePanelView(panelViewInsertDTOList);
//将视图从cache表中更新到正式表中
viewIds = panelViewInsertDTOList.stream().map(panelView ->panelView.getChartViewId()).collect(Collectors.toList());
extChartViewMapper.copyCacheToView(viewIds);
extChartViewMapper.deleteCacheWithPanel(panelId);
}
}
return mobileLayout;
panelGroup.setMobileLayout(mobileLayout);
return viewIds;
}
public List<PanelViewTableDTO> detailList(String panelId) {
......
......@@ -61,13 +61,14 @@ quartz.scheduler-name=deServerJob
spring.servlet.multipart.max-file-size=500MB
spring.servlet.multipart.max-request-size=500MB
# actuator
management.server.port=8083
management.endpoints.web.exposure.include=*
management.health.redis.enabled=false
#management.server.port=8083
#management.endpoints.web.exposure.include=*
#spring.freemarker.checkTemplateLocation=false
#RSA非对称加密参数:私钥
rsa.private_key=MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==
rsa.public_key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ==
spring.cache.type=ehcache
#spring.cache.type=ehcache
spring.cache.ehcache.config=classpath:/ehcache/ehcache.xml
#打印URL路径
#logging.level.org.springframework.web=trace
......@@ -85,6 +86,32 @@ server.compression.enabled=true
server.compression.mime-types=application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain
server.compression.min-response-size=1024
#下面的配置新增到/opt/dataease/conf/dataease/properties
#缓存类型
##spring.cache.type=redis
#spring.cache.type=ehcache
#redis公共配置
#spring.redis.timeout=10000
#spring.redis.lettuce.pool.max-active=8
#spring.redis.lettuce.pool.max-wait=-1
#spring.redis.lettuce.pool.max-idle=8
#单机模式redis配置
#spring.redis.database=0
#spring.redis.host=192.168.0.110
#spring.redis.port=6379
#spring.redis.password=DataEase_ZNB@REDIS
#哨兵模式redis配置
#spring.redis.sentinel.master=mymaster
#spring.redis.sentinel.nodes=192.168.0.110:26379,192.168.0.110:26380,192.168.0.110:26381
#spring.redis.sentinel.password=
#cluster模式redis配置
#spring.redis.cluster.nodes=192.168.0.110:7001,192.168.0.110:7002,192.168.0.110:7003,192.168.0.110:7004,192.168.0.110:7005,192.168.0.110:7006
#spring.redis.cluster.max-redirects=3
#spring.redis.password=DataEase_ZNB@REDIS
......
ALTER TABLE `chart_view` ADD COLUMN `senior` LONGTEXT COMMENT '高级' AFTER `drill_fields`;
UPDATE `chart_view` SET `senior` = '{}';
CREATE TABLE `chart_view_cache` (
`id` varchar(50) NOT NULL COMMENT 'ID',
`name` varchar(1024) DEFAULT NULL COMMENT '名称',
`title` varchar(1024) DEFAULT NULL COMMENT 'EChart标题',
`scene_id` varchar(50) NOT NULL COMMENT '场景ID chart_type为private的时候 是仪表板id',
`table_id` varchar(50) NOT NULL COMMENT '数据集表ID',
`type` varchar(50) DEFAULT NULL COMMENT '图表类型',
`render` varchar(50) DEFAULT NULL COMMENT '视图渲染方式',
`result_count` int(10) DEFAULT NULL COMMENT '展示结果',
`result_mode` varchar(50) DEFAULT NULL COMMENT '展示模式',
`x_axis` longtext COMMENT '横轴field',
`x_axis_ext` longtext COMMENT 'table-row',
`y_axis` longtext COMMENT '纵轴field',
`y_axis_ext` longtext COMMENT '副轴',
`ext_stack` longtext COMMENT '堆叠项',
`ext_bubble` longtext COMMENT '气泡大小',
`custom_attr` longtext COMMENT '图形属性',
`custom_style` longtext COMMENT '组件样式',
`custom_filter` longtext COMMENT '结果过滤',
`drill_fields` longtext COMMENT '钻取字段',
`senior` longtext COMMENT '高级',
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人ID',
`create_time` bigint(13) DEFAULT NULL COMMENT '创建时间',
`update_time` bigint(13) DEFAULT NULL COMMENT '更新时间',
`snapshot` longtext COMMENT '缩略图 ',
`style_priority` varchar(255) DEFAULT 'panel' COMMENT '样式优先级 panel 仪表板 view 视图',
`chart_type` varchar(255) DEFAULT 'private' COMMENT '视图类型 public 公共 历史可复用的视图,private 私有 专属某个仪表板',
`is_plugin` bit(1) DEFAULT NULL COMMENT '是否插件',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
SET FOREIGN_KEY_CHECKS = 1;
......@@ -63,5 +63,6 @@
<table tableName="de_engine">
<columnOverride column="configuration" property="configuration" javaType="java.lang.String"/>
</table>
<table tableName="chart_view_cache"/>
</context>
</generatorConfiguration>
......@@ -6,7 +6,7 @@
<parent>
<artifactId>dataease-server</artifactId>
<groupId>io.dataease</groupId>
<version>1.8.0</version>
<version>1.9.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
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
......
......@@ -62,6 +62,7 @@
class="table-class"
/>
<label-normal v-else-if="labelShowFlag" :ref="element.propValue.id" :chart="chart" class="table-class" />
<label-normal-text v-else-if="labelTextShowFlag" :ref="element.propValue.id" :chart="chart" class="table-class" />
<div style="position: absolute;left: 8px;bottom:8px;">
<drill-path :drill-filters="drillFilters" @onDrillJump="drillJump" />
</div>
......@@ -90,9 +91,10 @@ import EditBarView from '@/components/canvas/components/Editor/EditBarView'
import { customAttrTrans, customStyleTrans, recursionTransObj } from '@/components/canvas/utils/style'
import ChartComponentS2 from '@/views/chart/components/ChartComponentS2'
import PluginCom from '@/views/system/plugin/PluginCom'
import LabelNormalText from '@/views/chart/components/normal/LabelNormalText'
export default {
name: 'UserView',
components: { PluginCom, ChartComponentS2, EditBarView, ChartComponent, TableNormal, LabelNormal, DrillPath, ChartComponentG2 },
components: { LabelNormalText, PluginCom, ChartComponentS2, EditBarView, ChartComponent, TableNormal, LabelNormal, DrillPath, ChartComponentG2 },
props: {
element: {
type: Object,
......@@ -184,13 +186,13 @@ export default {
return this.active && this.inTab && !this.mobileLayoutStatus
},
charViewShowFlag() {
return this.httpRequest.status && this.chart.type && !this.chart.type.includes('table') && !this.chart.type.includes('text') && this.renderComponent() === 'echarts'
return this.httpRequest.status && this.chart.type && !this.chart.type.includes('table') && !this.chart.type.includes('text') && this.chart.type !== 'label' && this.renderComponent() === 'echarts'
},
charViewG2ShowFlag() {
return this.httpRequest.status && this.chart.type && !this.chart.type.includes('table') && !this.chart.type.includes('text') && this.renderComponent() === 'antv'
return this.httpRequest.status && this.chart.type && !this.chart.type.includes('table') && !this.chart.type.includes('text') && this.chart.type !== 'label' && this.renderComponent() === 'antv'
},
charViewS2ShowFlag() {
return this.httpRequest.status && this.chart.type && this.chart.type.includes('table') && !this.chart.type.includes('text') && this.renderComponent() === 'antv'
return this.httpRequest.status && this.chart.type && this.chart.type.includes('table') && !this.chart.type.includes('text') && this.chart.type !== 'label' && this.renderComponent() === 'antv'
},
tableShowFlag() {
return this.httpRequest.status && this.chart.type && this.chart.type.includes('table') && this.renderComponent() === 'echarts'
......@@ -198,6 +200,9 @@ export default {
labelShowFlag() {
return this.httpRequest.status && this.chart.type && this.chart.type.includes('text')
},
labelTextShowFlag() {
return this.httpRequest.status && this.chart.type && this.chart.type === 'label'
},
loadingFlag() {
return (this.canvasStyleData.refreshViewLoading || this.searchCount === 0) && this.requestStatus === 'waiting'
},
......@@ -372,6 +377,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 +439,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 +720,19 @@ 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.chart.senior = param.viewInfo.senior
this.sourceCustomAttrStr = this.chart.customAttr
this.sourceCustomStyleStr = this.chart.customStyle
this.mergeScale()
}
}
}
}
......
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1621224495563" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7328" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M376.795429 691.2c15.616 0 27.008-10.733714 27.008-27.337143v-46.848h1.316571c20.809143 45.878857 63.451429 74.514286 117.449143 74.514286 88.832 0 147.072-70.619429 147.072-179.620572s-58.569143-179.620571-146.413714-179.620571c-53.028571 0-96 28.964571-116.169143 74.203429h-1.627429v-166.290286c0-17.554286-11.062857-28.946286-27.337143-28.946286-16.274286 0-27.318857 11.373714-27.318857 28.946286v423.68c0 16.914286 10.422857 27.318857 26.020572 27.318857z m490.697142 0.329143c64.091429 0 118.765714-35.145143 137.325715-84.937143 1.938286-5.522286 2.925714-10.733714 2.925714-15.286857 0-13.988571-9.764571-23.753143-23.442286-23.753143-12.361143 0-18.870857 4.882286-26.020571 19.2-17.261714 37.101714-46.537143 57.270857-90.459429 57.270857-63.451429 0-105.106286-50.432-105.106285-131.785143 0-80.694857 41.654857-132.443429 105.106285-132.443428 41.965714 0 72.228571 19.858286 89.782857 57.929143 6.857143 13.659429 13.348571 18.541714 25.398858 18.541714 13.988571 0 23.753143-9.106286 23.753142-23.424 0-3.913143-0.969143-8.777143-2.267428-13.019429-16.274286-49.792-71.917714-87.533714-137.984-87.533714-96.950857 0-160.091429 71.259429-160.091429 180.278857 0 109.659429 63.780571 178.962286 161.078857 178.962286zM116.169143 691.2c49.444571 0 96.310857-27.008 115.84-68.662857h0.969143v42.313143c0.658286 15.926857 11.392 26.678857 26.697143 26.678857 15.597714 0 26.331429-10.733714 26.331428-27.977143v-215.405714c0-70.290286-51.401143-115.529143-133.394286-115.529143-60.854857 0-111.286857 26.697143-130.157714 68.022857-3.584 8.118857-5.851429 15.926857-5.851428 22.765714 0 14.317714 10.404571 23.424 24.722285 23.424 10.093714 0 17.554286-3.584 22.784-12.690285 17.554286-37.412571 45.220571-54.674286 87.204572-54.674286 50.102857 0 79.725714 27.977143 79.725714 73.216v27.337143l-103.808 5.851428C45.531429 491.428571 0 528.201143 0 588.068571 0 650.203429 47.506286 691.2 116.169143 691.2z m394.057143-47.177143c-61.184 0-104.777143-52.388571-104.777143-131.785143 0-79.725714 43.593143-132.114286 104.777143-132.114285 63.104 0 102.802286 51.090286 102.802285 131.785142 0 81.353143-39.68 132.114286-102.820571 132.114286z m-381.037715 1.956572c-43.611429 0-72.905143-23.771429-72.905142-58.898286 0-34.176 27.337143-56.630857 77.769142-60.196572l96.969143-6.180571v33.828571c0 51.419429-45.220571 91.428571-101.851428 91.428572z m700.891429 249.892571a39.168 39.168 0 0 0 39.04-39.058286 39.168 39.168 0 0 0-39.058286-39.04c-21.467429 0-39.04 17.572571-39.04 39.058286 0 21.467429 17.554286 39.04 39.058286 39.04z m154.88 0A39.168 39.168 0 0 0 1024 856.813714c0-21.467429-17.554286-39.04-39.04-39.04-21.485714 0-39.058286 17.572571-39.058286 39.058286 0 21.467429 17.572571 39.04 39.058286 39.04z m-309.76 0a38.948571 38.948571 0 0 0 39.04-39.058286 38.948571 38.948571 0 0 0-39.058286-39.04c-21.467429 0-39.04 17.572571-39.04 39.058286 0 21.467429 17.554286 39.04 39.04 39.04z m-154.898286 0a38.948571 38.948571 0 0 0 39.04-39.058286 38.948571 38.948571 0 0 0-39.04-39.04c-21.485714 0-39.058286 17.572571-39.058285 39.058286 0 21.467429 17.572571 39.04 39.058285 39.04z m-154.88 0a38.948571 38.948571 0 0 0 39.04-39.058286 38.948571 38.948571 0 0 0-39.058285-39.04c-21.467429 0-39.04 17.572571-39.04 39.058286 0 21.467429 17.572571 39.04 39.058285 39.04z m-154.88 0a39.241143 39.241143 0 0 0 39.350857-39.058286 39.222857 39.222857 0 0 0-78.409142 0c0 21.485714 17.554286 39.058286 39.04 39.058286z m-155.227428 0a38.948571 38.948571 0 0 0 39.04-39.058286 38.948571 38.948571 0 0 0-39.04-39.04c-21.467429 0-39.04 17.572571-39.04 39.058286 0 21.467429 17.554286 39.04 39.04 39.04z" p-id="7329"></path></svg>
......@@ -1031,6 +1031,7 @@ export default {
table_align_left: 'Left',
table_align_center: 'Center',
table_align_right: 'Right',
draw_back: 'Draw Back',
senior: 'Senior',
senior_cfg: 'Senior Config',
function_cfg: 'Function Config',
......@@ -1042,7 +1043,23 @@ export default {
field_fixed: 'Fixed',
line_type_dotted: 'Dotted',
value_can_not_empty: 'Value can not be empty',
value_error: 'Value illegal'
value_error: 'Value illegal',
threshold: 'Threshold',
threshold_range: 'Range',
gauge_threshold_format_error: 'Format Error',
total_cfg: 'Total Config',
col_cfg: 'Column',
row_cfg: 'Row',
total_show: 'Total',
total_position: 'Position',
total_label: 'Alias',
sub_total_show: 'Sub Total',
total_pos_top: 'Top',
total_pos_bottom: 'Bottom',
total_pos_left: 'Left',
total_pos_right: 'Right',
chart_label: 'Label',
drag_block_label: 'Label'
},
dataset: {
sheet_warn: 'There are multiple sheet pages, and the first one is extracted by default',
......@@ -1591,7 +1608,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',
......
......@@ -1031,6 +1031,7 @@ export default {
table_align_left: '左對齊',
table_align_center: '居中',
table_align_right: '右對齊',
draw_back: '收回',
senior: '高級',
senior_cfg: '高級設置',
function_cfg: '功能設置',
......@@ -1042,7 +1043,23 @@ export default {
field_fixed: '固定值',
line_type_dotted: '點',
value_can_not_empty: '值不能為空',
value_error: '值必須為數值'
value_error: '值必須為數值',
threshold: '閾值',
threshold_range: '閾值區間',
gauge_threshold_format_error: '格式錯誤',
total_cfg: '總計配置',
col_cfg: '列匯總',
row_cfg: '行匯總',
total_show: '總計',
total_position: '位置',
total_label: '別名',
sub_total_show: '小計',
total_pos_top: '頂部',
total_pos_bottom: '底部',
total_pos_left: '左側',
total_pos_right: '右側',
chart_label: '文本卡',
drag_block_label: '標簽'
},
dataset: {
sheet_warn: '有多個 Sheet 頁,默認抽取第一個',
......@@ -1577,7 +1594,8 @@ export default {
choose_background: '选择组件背景',
choose_background_tips: '组件自有的背景设置会覆盖当前设置',
setting_background: '设置背景',
setting_jump: '跳转设置'
setting_jump: '跳转设置',
select_view: '请选择视图...'
},
plugin: {
local_install: '本地安裝',
......
......@@ -1034,6 +1034,7 @@ export default {
table_align_left: '左对齐',
table_align_center: '居中',
table_align_right: '右对齐',
draw_back: '收回',
senior: '高级',
senior_cfg: '高级设置',
function_cfg: '功能设置',
......@@ -1045,7 +1046,23 @@ export default {
field_fixed: '固定值',
line_type_dotted: '点',
value_can_not_empty: '值不能为空',
value_error: '值必须为数值'
value_error: '值必须为数值',
threshold: '阈值',
threshold_range: '阈值区间',
gauge_threshold_format_error: '格式错误',
total_cfg: '总计配置',
col_cfg: '列汇总',
row_cfg: '行汇总',
total_show: '总计',
total_position: '位置',
total_label: '别名',
sub_total_show: '小计',
total_pos_top: '顶部',
total_pos_bottom: '底部',
total_pos_left: '左侧',
total_pos_right: '右侧',
chart_label: '文本卡',
drag_block_label: '标签'
},
dataset: {
sheet_warn: '有多个 Sheet 页,默认抽取第一个',
......@@ -1586,7 +1603,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: {
......
......@@ -25,7 +25,7 @@ export function baseBarOption(chart_option, chart) {
const y = chart.data.series[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// size
if (customAttr.size) {
......@@ -88,7 +88,7 @@ export function horizontalBarOption(chart_option, chart) {
const y = chart.data.series[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// size
if (customAttr.size) {
......
......@@ -78,6 +78,38 @@ export const DEFAULT_TOOLTIP = {
},
formatter: ''
}
export const DEFAULT_TOTAL = {
row: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: false,
reverseSubLayout: false,
label: '总计',
subLabel: '小计',
subTotalsDimensions: [],
calcTotals: {
aggregation: 'SUM'
},
calcSubTotals: {
aggregation: 'SUM'
}
},
col: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: false,
reverseSubLayout: false,
label: '总计',
subLabel: '小计',
subTotalsDimensions: [],
calcTotals: {
aggregation: 'SUM'
},
calcSubTotals: {
aggregation: 'SUM'
}
}
}
export const DEFAULT_TITLE_STYLE = {
show: true,
fontSize: '18',
......@@ -244,6 +276,9 @@ export const DEFAULT_FUNCTION_CFG = {
sliderShow: false,
sliderRange: [0, 10]
}
export const DEFAULT_THRESHOLD = {
gaugeThreshold: ''
}
// chart config
export const BASE_BAR = {
title: {
......
......@@ -77,6 +77,11 @@ export function getCustomTheme(chart) {
fill: DEFAULT_COLOR_CASE.tableFontColor,
fontSize: DEFAULT_SIZE.tableItemFontSize,
textAlign: itemAlign
},
bolderText: {
fill: DEFAULT_COLOR_CASE.tableFontColor,
fontSize: DEFAULT_SIZE.tableItemFontSize,
textAlign: itemAlign
}
}
}
......@@ -114,6 +119,7 @@ export function getCustomTheme(chart) {
theme.dataCell.cell.backgroundColor = i_c
theme.dataCell.cell.horizontalBorderColor = b_c
theme.dataCell.cell.verticalBorderColor = b_c
theme.dataCell.bolderText.fill = c.tableFontColor
theme.dataCell.text.fill = c.tableFontColor
}
// size
......@@ -137,6 +143,8 @@ export function getCustomTheme(chart) {
theme.colCell.text.fontSize = parseInt(s.tableTitleFontSize)
theme.colCell.text.textAlign = h_a
theme.dataCell.bolderText.fontSize = parseInt(s.tableItemFontSize)
theme.dataCell.bolderText.textAlign = i_a
theme.dataCell.text.fontSize = parseInt(s.tableItemFontSize)
theme.dataCell.text.textAlign = i_a
}
......
......@@ -40,7 +40,7 @@ export function baseFunnelOption(chart_option, chart) {
y.name = chart.data.x[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// y.type = 'funnel'
chart_option.series[0].data.push(y)
......
import { componentStyle } from '../common/common'
import { hexColorToRGBA } from '@/views/chart/chart/util'
import { DEFAULT_THRESHOLD } from '@/views/chart/chart/chart'
export function baseGaugeOption(chart_option, chart) {
// 处理shape attr
......@@ -49,6 +50,57 @@ export function baseGaugeOption(chart_option, chart) {
value: chart.data.series[0].data[0]
}
chart_option.series[0].data.push(y)
// threshold
if (chart.senior) {
const range = []
let index = 0
let flag = false
const senior = JSON.parse(chart.senior)
const threshold = JSON.parse(JSON.stringify(senior.threshold ? senior.threshold : DEFAULT_THRESHOLD))
if (threshold.gaugeThreshold && threshold.gaugeThreshold !== '') {
const arr = threshold.gaugeThreshold.split(',')
const per = parseFloat(chart.data.series[0].data[0]) / parseFloat(chart_option.series[0].max)
for (let i = 0; i < arr.length; i++) {
const ele = arr[i]
const p = parseInt(ele) / 100
range.push([p, hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)])
if (!flag && per <= p) {
flag = true
index = i
}
}
if (!flag) {
index = arr.length
}
range.push([1, hexColorToRGBA(customAttr.color.colors[arr.length % customAttr.color.colors.length], customAttr.color.alpha)])
chart_option.series[0].axisLine = {
lineStyle: {
color: range
}
}
chart_option.series[0].itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[index], customAttr.color.alpha)
}
chart_option.series[0].progress = {
show: false
}
chart_option.series[0].axisTick = {
lineStyle: {
color: 'auto'
}
}
chart_option.series[0].splitLine = {
lineStyle: {
color: 'auto'
}
}
chart_option.series[0].axisLabel = {
color: 'auto'
}
}
}
}
}
// console.log(chart_option);
......
import { getPadding, getTheme } from '@/views/chart/chart/common/common_antv'
import { Gauge } from '@antv/g2plot'
import { DEFAULT_SIZE } from '@/views/chart/chart/chart'
import { DEFAULT_SIZE, DEFAULT_THRESHOLD } from '@/views/chart/chart/chart'
export function baseGaugeOptionAntV(plot, container, chart, action) {
let max, labelContent, startAngel, endAngel
......@@ -33,11 +33,39 @@ export function baseGaugeOptionAntV(plot, container, chart, action) {
labelContent = false
}
}
const per = (parseFloat(data) / parseFloat(max))
const range = [0]
let index = 0
let flag = false
let hasThreshold = false
if (chart.senior) {
const senior = JSON.parse(chart.senior)
const threshold = JSON.parse(JSON.stringify(senior.threshold ? senior.threshold : DEFAULT_THRESHOLD))
if (threshold.gaugeThreshold && threshold.gaugeThreshold !== '') {
hasThreshold = true
const arr = threshold.gaugeThreshold.split(',')
for (let i = 0; i < arr.length; i++) {
const ele = arr[i]
const p = parseInt(ele) / 100
range.push(p)
if (!flag && per <= p) {
flag = true
index = i
}
}
if (!flag) {
index = arr.length
}
}
}
range.push(1)
// options
const options = {
theme: theme,
percent: (parseFloat(data) / parseFloat(max)),
percent: per,
startAngle: startAngel,
endAngle: endAngel,
appendPadding: getPadding(chart),
......@@ -52,6 +80,24 @@ export function baseGaugeOptionAntV(plot, container, chart, action) {
// lineCap: 'round'
// }
}
if (hasThreshold) {
options.range = {
color: theme.styleSheet.paletteQualitative10,
ticks: range
}
options.indicator = {
pointer: {
style: {
stroke: theme.styleSheet.paletteQualitative10[index % theme.styleSheet.paletteQualitative10.length]
}
},
pin: {
style: {
stroke: theme.styleSheet.paletteQualitative10[index % theme.styleSheet.paletteQualitative10.length]
}
}
}
}
// 开始渲染
if (plot) {
......
......@@ -25,7 +25,7 @@ export function baseLineOption(chart_option, chart) {
const y = chart.data.series[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// size
if (customAttr.size) {
......
......@@ -73,7 +73,7 @@ export function baseMapOption(chart_option, chart) {
y.name = chart.data.x[i]
// color
// y.itemStyle = {
// color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha),
// color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha),
// borderRadius: 0
// }
chart_option.series[0].data.push(y)
......
......@@ -27,7 +27,7 @@ export function baseMixOption(chart_option, chart) {
y.type = y.type ? y.type : 'bar'
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// size
if (customAttr.size) {
......
......@@ -43,7 +43,7 @@ export function baseMixOptionAntV(plot, container, chart, action) {
const o = {
type: '',
options: {
color: colors[i % 9],
color: colors[i % colors.length],
data: d.data,
xField: 'field',
yField: 'value',
......
......@@ -41,7 +41,7 @@ export function basePieOption(chart_option, chart) {
y.name = chart.data.x[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha),
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha),
borderRadius: 0
}
y.type = 'pie'
......@@ -94,7 +94,7 @@ export function rosePieOption(chart_option, chart) {
y.name = chart.data.x[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha),
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha),
borderRadius: customAttr.size.pieRoseRadius
}
y.type = 'pie'
......
......@@ -33,7 +33,7 @@ export function baseRadarOption(chart_option, chart) {
}
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// label
if (customAttr.label) {
......
......@@ -30,7 +30,7 @@ export function baseScatterOption(chart_option, chart, terminal = 'pc') {
const y = chart.data.series[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// size
if (customAttr.size) {
......
import { TableSheet, S2Event, PivotSheet } from '@antv/s2'
import { getCustomTheme, getSize } from '@/views/chart/chart/common/common_table'
import { DEFAULT_TOTAL } from '@/views/chart/chart/chart'
export function baseTableInfo(s2, container, chart, action, tableData) {
const containerDom = document.getElementById(container)
......@@ -281,11 +282,31 @@ export function baseTablePivot(s2, container, chart, action, tableData) {
data: tableData
}
// total config
let totalCfg = {}
const chartObj = JSON.parse(JSON.stringify(chart))
if (chartObj.customAttr) {
let customAttr = null
if (Object.prototype.toString.call(chartObj.customAttr) === '[object Object]') {
customAttr = JSON.parse(JSON.stringify(chartObj.customAttr))
} else {
customAttr = JSON.parse(chartObj.customAttr)
}
if (customAttr.totalCfg) {
totalCfg = customAttr.totalCfg
} else {
totalCfg = JSON.parse(JSON.stringify(DEFAULT_TOTAL))
}
}
totalCfg.row.subTotalsDimensions = r
totalCfg.col.subTotalsDimensions = c
// options
const s2Options = {
width: containerDom.offsetWidth,
height: containerDom.offsetHeight,
style: getSize(chart)
style: getSize(chart),
totals: totalCfg
}
// 开始渲染
......
......@@ -49,7 +49,7 @@ export function baseTreemapOption(chart_option, chart) {
y.name = chart.data.x[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// y.type = 'treemap'
chart_option.series[0].data.push(y)
......
......@@ -50,6 +50,13 @@ export const TYPE_CONFIGS = [
icon: 'table-pivot'
},
{
render: 'antv',
category: 'chart.chart_type_quota',
value: 'label',
title: 'chart.chart_label',
icon: 'label'
},
{
render: 'antv',
category: 'chart.chart_type_quota',
......@@ -189,6 +196,13 @@ export const TYPE_CONFIGS = [
icon: 'table-info'
},
{
render: 'echarts',
category: 'chart.chart_type_quota',
value: 'label',
title: 'chart.chart_label',
icon: 'label'
},
{
render: 'echarts',
category: 'chart.chart_type_quota',
......
<template>
<div ref="tableContainer" :style="bg_class" style="padding: 8px;width: 100%;height: 100%;overflow: hidden;">
<p v-show="title_show" ref="title" :style="title_class">{{ chart.title }}</p>
<div
v-if="chart.data && chart.data.datas && chart.data.datas.length > 0"
id="label-content"
:style="content_class"
>
<span :style="label_class">
<p :style="label_content_class">
{{ chart.data.datas[0].name }}
</p>
</span>
<!-- 字段名暂时隐藏-->
<!-- <span v-if="dimensionShow" :style="label_space">-->
<!-- <p :style="label_class">-->
<!-- {{ chart.data.datas[0].category }}-->
<!-- </p>-->
<!-- </span>-->
</div>
</div>
</template>
<script>
import { hexColorToRGBA } from '../../chart/util'
import eventBus from '@/components/canvas/utils/eventBus'
export default {
name: 'LabelNormalText',
props: {
chart: {
type: Object,
required: true
},
filter: {
type: Object,
required: false,
default: function() {
return {}
}
}
},
data() {
return {
height: 'auto',
splitHeight: '10px',
dimensionShow: true,
quotaShow: true,
title_class: {
margin: '0 0',
width: '100%',
fontSize: '18px',
color: '#303133',
textAlign: 'left',
fontStyle: 'normal',
fontWeight: 'normal'
},
content_class: {
display: 'flex',
flex: 1,
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
height: 'auto'
},
label_class: {
margin: 0
},
label_content_class: {
margin: 0
},
label_space: {
marginTop: '10px',
textAlign: 'center'
},
bg_class: {
background: hexColorToRGBA('#ffffff', 0)
},
title_show: true,
borderRadius: '0px'
}
},
computed: {
// bg_class() {
// return {
// background: hexColorToRGBA('#ffffff', 0),
// borderRadius: this.borderRadius
// }
// }
},
watch: {
chart() {
this.init()
this.calcHeight()
}
},
mounted() {
this.init()
this.calcHeight()
// 监听元素变动事件
eventBus.$on('resizing', (componentId) => {
this.chartResize()
})
},
methods: {
init() {
const that = this
this.initStyle()
window.onresize = function() {
that.calcHeight()
}
this.setBackGroundBorder()
},
setBackGroundBorder() {
if (this.chart.customStyle) {
const customStyle = JSON.parse(this.chart.customStyle)
if (customStyle.background) {
this.borderRadius = (customStyle.background.borderRadius || 0) + 'px'
this.bg_class.borderRadius = this.borderRadius
}
}
},
calcHeight() {
const that = this
this.$nextTick(function() {
if (that.$refs.tableContainer) {
const currentHeight = that.$refs.tableContainer.offsetHeight
const contentHeight = currentHeight - that.$refs.title.offsetHeight - 16
that.height = contentHeight + 'px'
that.content_class.height = that.height
}
})
},
initStyle() {
if (this.chart.customAttr) {
const customAttr = JSON.parse(this.chart.customAttr)
if (customAttr.color) {
this.label_class.color = customAttr.color.dimensionColor
this.label_content_class.color = customAttr.color.quotaColor
}
if (customAttr.size) {
this.dimensionShow = customAttr.size.dimensionShow
this.quotaShow = customAttr.size.quotaShow
this.label_class.fontSize = customAttr.size.dimensionFontSize + 'px'
this.label_content_class.fontSize = customAttr.size.quotaFontSize + 'px'
if (!this.dimensionShow) {
this.label_space.marginTop = '0px'
} else {
this.label_space.marginTop = customAttr.size.spaceSplit + 'px'
}
}
}
if (this.chart.customStyle) {
const customStyle = JSON.parse(this.chart.customStyle)
if (customStyle.text) {
this.title_show = customStyle.text.show
this.title_class.fontSize = customStyle.text.fontSize + 'px'
this.title_class.color = customStyle.text.color
this.title_class.textAlign = customStyle.text.hPosition
this.title_class.fontStyle = customStyle.text.isItalic ? 'italic' : 'normal'
this.title_class.fontWeight = customStyle.text.isBolder ? 'bold' : 'normal'
}
if (customStyle.background) {
this.bg_class.background = hexColorToRGBA(customStyle.background.color, customStyle.background.alpha)
}
}
},
chartResize() {
// 指定图表的配置项和数据
this.calcHeight()
}
}
}
</script>
<style scoped>
.table-class>>>.body--wrapper{
background: rgba(1,1,1,0);
}
</style>
......@@ -6,7 +6,7 @@
<el-checkbox v-model="functionForm.sliderShow" @change="changeFunctionCfg">{{ $t('chart.show') }}</el-checkbox>
</el-form-item>
<el-form-item v-show="functionForm.sliderShow" :label="$t('chart.slider_range')+'(%)'" class="form-item form-item-slider">
<el-slider v-model="functionForm.sliderRange" :min="0" :max="100" input-size="mini" range @change="changeFunctionCfg" />
<el-slider v-model="functionForm.sliderRange" style="width: 90%" :min="0" :max="100" input-size="mini" range @change="changeFunctionCfg" />
</el-form-item>
</el-form>
</el-col>
......
<template>
<div style="width: 100%">
<el-col v-if="chart.type && chart.type === 'gauge'">
<el-form ref="thresholdForm" :model="thresholdForm" label-width="80px" size="mini">
<el-form-item :label="$t('chart.threshold_range')+'(%)'" class="form-item">
<span>0,</span>
<el-input v-model="thresholdForm.gaugeThreshold" style="width: 100px;margin: 0 10px;" :placeholder="$t('chart.threshold_range')" size="mini" clearable @change="changeThreshold" />
<span>,100</span>
<el-tooltip class="item" effect="dark" placement="bottom">
<div slot="content">
阈值设置,决定仪表盘区间颜色,为空则不开启阈值,范围(0-100),仅限整数,且逐级递增
<br>
例如:输入 30,70;表示:分为3段,分别为[0,30],(30,70],(70,100]
</div>
<i class="el-icon-info" style="cursor: pointer;margin-left: 10px;font-size: 12px;" />
</el-tooltip>
</el-form-item>
</el-form>
</el-col>
</div>
</template>
<script>
import { DEFAULT_THRESHOLD } from '@/views/chart/chart/chart'
export default {
name: 'Threshold',
props: {
chart: {
type: Object,
required: true
}
},
data() {
return {
thresholdForm: JSON.parse(JSON.stringify(DEFAULT_THRESHOLD))
}
},
watch: {
'chart': {
handler: function() {
this.initData()
}
}
},
mounted() {
this.initData()
},
methods: {
initData() {
const chart = JSON.parse(JSON.stringify(this.chart))
if (chart.senior) {
let senior = null
if (Object.prototype.toString.call(chart.senior) === '[object Object]') {
senior = JSON.parse(JSON.stringify(chart.senior))
} else {
senior = JSON.parse(chart.senior)
}
if (senior.threshold) {
this.thresholdForm = senior.threshold
} else {
this.thresholdForm = JSON.parse(JSON.stringify(DEFAULT_THRESHOLD))
}
}
},
changeThreshold() {
// check input
if (this.thresholdForm.gaugeThreshold) {
const arr = this.thresholdForm.gaugeThreshold.split(',')
for (let i = 0; i < arr.length; i++) {
const ele = arr[i]
if (ele.indexOf('.') > -1 || parseInt(ele).toString() === 'NaN' || parseInt(ele) < 1 || parseInt(ele) > 99) {
this.$message({
message: this.$t('chart.gauge_threshold_format_error'),
type: 'error',
showClose: true
})
return
}
}
}
this.$emit('onThresholdChange', this.thresholdForm)
}
}
}
</script>
<style scoped>
.shape-item{
padding: 6px;
border: none;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
.form-item-slider>>>.el-form-item__label{
font-size: 12px;
line-height: 38px;
}
.form-item>>>.el-form-item__label{
font-size: 12px;
}
.el-select-dropdown__item{
padding: 0 20px;
}
span{
font-size: 12px
}
.el-form-item{
margin-bottom: 6px;
}
.switch-style{
position: absolute;
right: 10px;
margin-top: -4px;
}
.color-picker-style{
cursor: pointer;
z-index: 1003;
}
</style>
......@@ -58,7 +58,7 @@ export default {
name: '辅助线',
field: '0', // 固定值
axis: 'y', // 主轴
value: 0,
value: '0',
lineType: 'solid',
color: '#ff0000'
},
......@@ -81,7 +81,7 @@ export default {
this.lineArr = JSON.parse(JSON.stringify(this.line))
},
addLine() {
this.lineArr.push(this.lineObj)
this.lineArr.push(JSON.parse(JSON.stringify(this.lineObj)))
this.changeAssistLine()
},
removeLine(index) {
......
......@@ -3,7 +3,7 @@
<el-col>
<el-form ref="colorForm" :model="colorForm" label-width="80px" size="mini">
<div v-if="sourceType==='view' || sourceType==='panelEchart'">
<el-form-item v-show="chart.type && !chart.type.includes('table') && !chart.type.includes('text')" :label="$t('chart.color_case')" class="form-item">
<el-form-item v-show="chart.type && !chart.type.includes('table') && !chart.type.includes('text') && chart.type !== 'label'" :label="$t('chart.color_case')" class="form-item">
<el-popover
placement="bottom"
width="400"
......@@ -45,7 +45,7 @@
</el-popover>
</el-form-item>
<el-form-item v-show="(chart.type && chart.type.includes('text')) || sourceType==='panelTable'" :label="$t('chart.quota_color')" class="form-item">
<el-form-item v-show="(chart.type && (chart.type.includes('text') || chart.type === 'label')) || sourceType==='panelTable'" :label="$t('chart.quota_color')" class="form-item">
<el-color-picker v-model="colorForm.quotaColor" class="color-picker-style" :predefine="predefineColors" @change="changeColorCase" />
</el-form-item>
<el-form-item v-show="(chart.type && chart.type.includes('text')) || sourceType==='panelTable'" :label="$t('chart.dimension_color')" class="form-item">
......@@ -71,7 +71,7 @@
<!-- </el-form-item>-->
</div>
<el-form-item v-show="chart.type && !chart.type.includes('text')" :label="$t('chart.not_alpha')" class="form-item form-item-slider">
<el-form-item v-show="chart.type && !chart.type.includes('text') && chart.type !== 'label'" :label="$t('chart.not_alpha')" class="form-item form-item-slider">
<el-slider v-model="colorForm.alpha" show-input :show-input-controls="false" input-size="mini" @change="changeColorCase" />
</el-form-item>
</el-form>
......
......@@ -127,21 +127,21 @@
</el-form-item>
</el-form>
<el-form v-show="chart.type && chart.type.includes('text')" ref="sizeFormPie" :model="sizeForm" label-width="100px" size="mini">
<el-form v-show="chart.type && (chart.type.includes('text') || chart.type === 'label')" ref="sizeFormPie" :model="sizeForm" label-width="100px" size="mini">
<el-form-item :label="$t('chart.quota_font_size')" class="form-item">
<el-select v-model="sizeForm.quotaFontSize" :placeholder="$t('chart.quota_font_size')" @change="changeBarSizeCase">
<el-option v-for="option in fontSize" :key="option.value" :label="option.name" :value="option.value" />
</el-select>
</el-form-item>
<el-form-item :label="$t('chart.dimension_show')" class="form-item">
<el-form-item v-show="chart.type && (chart.type.includes('text'))" :label="$t('chart.dimension_show')" class="form-item">
<el-checkbox v-model="sizeForm.dimensionShow" @change="changeBarSizeCase">{{ $t('chart.show') }}</el-checkbox>
</el-form-item>
<el-form-item :label="$t('chart.dimension_font_size')" class="form-item">
<el-form-item v-show="chart.type && (chart.type.includes('text'))" :label="$t('chart.dimension_font_size')" class="form-item">
<el-select v-model="sizeForm.dimensionFontSize" :placeholder="$t('chart.dimension_font_size')" @change="changeBarSizeCase">
<el-option v-for="option in fontSize" :key="option.value" :label="option.name" :value="option.value" />
</el-select>
</el-form-item>
<el-form-item :label="$t('chart.space_split')" class="form-item">
<el-form-item v-show="chart.type && (chart.type.includes('text'))" :label="$t('chart.space_split')" class="form-item">
<el-input-number v-model="sizeForm.spaceSplit" size="mini" @change="changeBarSizeCase" />
</el-form-item>
</el-form>
......
......@@ -153,21 +153,21 @@
</el-form-item>
</el-form>
<el-form v-show="chart.type && chart.type.includes('text')" ref="sizeFormPie" :model="sizeForm" label-width="100px" size="mini">
<el-form v-show="chart.type && (chart.type.includes('text') || chart.type === 'label')" ref="sizeFormPie" :model="sizeForm" label-width="100px" size="mini">
<el-form-item :label="$t('chart.quota_font_size')" class="form-item">
<el-select v-model="sizeForm.quotaFontSize" :placeholder="$t('chart.quota_font_size')" @change="changeBarSizeCase">
<el-option v-for="option in fontSize" :key="option.value" :label="option.name" :value="option.value" />
</el-select>
</el-form-item>
<el-form-item :label="$t('chart.dimension_show')" class="form-item">
<el-form-item v-show="chart.type && (chart.type.includes('text'))" :label="$t('chart.dimension_show')" class="form-item">
<el-checkbox v-model="sizeForm.dimensionShow" @change="changeBarSizeCase">{{ $t('chart.show') }}</el-checkbox>
</el-form-item>
<el-form-item :label="$t('chart.dimension_font_size')" class="form-item">
<el-form-item v-show="chart.type && (chart.type.includes('text'))" :label="$t('chart.dimension_font_size')" class="form-item">
<el-select v-model="sizeForm.dimensionFontSize" :placeholder="$t('chart.dimension_font_size')" @change="changeBarSizeCase">
<el-option v-for="option in fontSize" :key="option.value" :label="option.name" :value="option.value" />
</el-select>
</el-form-item>
<el-form-item :label="$t('chart.space_split')" class="form-item">
<el-form-item v-show="chart.type && (chart.type.includes('text'))" :label="$t('chart.space_split')" class="form-item">
<el-input-number v-model="sizeForm.spaceSplit" size="mini" @change="changeBarSizeCase" />
</el-form-item>
</el-form>
......
<template>
<div style="width: 100%">
<el-col>
<el-form ref="totalForm" :model="totalForm" label-width="80px" size="mini">
<el-divider content-position="center" class="divider-style">{{ $t('chart.row_cfg') }}</el-divider>
<el-form-item :label="$t('chart.total_show')" class="form-item">
<el-checkbox v-model="totalForm.row.showGrandTotals" @change="changeTotalCfg">{{ $t('chart.show') }}</el-checkbox>
</el-form-item>
<div v-show="totalForm.row.showGrandTotals">
<el-form-item :label="$t('chart.total_position')" class="form-item">
<el-radio-group v-model="totalForm.row.reverseLayout" @change="changeTotalCfg">
<el-radio :label="true">{{ $t('chart.total_pos_top') }}</el-radio>
<el-radio :label="false">{{ $t('chart.total_pos_bottom') }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item :label="$t('chart.total_label')" class="form-item">
<el-input v-model="totalForm.row.label" style="width: 160px;" :placeholder="$t('chart.total_label')" size="mini" clearable @change="changeTotalCfg" />
</el-form-item>
</div>
<el-form-item :label="$t('chart.sub_total_show')" class="form-item">
<el-checkbox v-model="totalForm.row.showSubTotals" :disabled="rowNum < 2" @change="changeTotalCfg">{{ $t('chart.show') }}</el-checkbox>
</el-form-item>
<div v-show="totalForm.row.showSubTotals">
<el-form-item :label="$t('chart.total_position')" class="form-item">
<el-radio-group v-model="totalForm.row.reverseSubLayout" :disabled="rowNum < 2" @change="changeTotalCfg">
<el-radio :label="true">{{ $t('chart.total_pos_top') }}</el-radio>
<el-radio :label="false">{{ $t('chart.total_pos_bottom') }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item :label="$t('chart.total_label')" class="form-item">
<el-input v-model="totalForm.row.subLabel" :disabled="rowNum < 2" style="width: 160px;" :placeholder="$t('chart.total_label')" size="mini" clearable @change="changeTotalCfg" />
</el-form-item>
</div>
<el-divider content-position="center" class="divider-style">{{ $t('chart.col_cfg') }}</el-divider>
<el-form-item :label="$t('chart.total_show')" class="form-item">
<el-checkbox v-model="totalForm.col.showGrandTotals" @change="changeTotalCfg">{{ $t('chart.show') }}</el-checkbox>
</el-form-item>
<div v-show="totalForm.col.showGrandTotals">
<el-form-item :label="$t('chart.total_position')" class="form-item">
<el-radio-group v-model="totalForm.col.reverseLayout" @change="changeTotalCfg">
<el-radio :label="true">{{ $t('chart.total_pos_left') }}</el-radio>
<el-radio :label="false">{{ $t('chart.total_pos_right') }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item :label="$t('chart.total_label')" class="form-item">
<el-input v-model="totalForm.col.label" style="width: 160px;" :placeholder="$t('chart.total_label')" size="mini" clearable @change="changeTotalCfg" />
</el-form-item>
</div>
<el-form-item :label="$t('chart.sub_total_show')" class="form-item">
<el-checkbox v-model="totalForm.col.showSubTotals" :disabled="colNum < 2" @change="changeTotalCfg">{{ $t('chart.show') }}</el-checkbox>
</el-form-item>
<div v-show="totalForm.col.showSubTotals">
<el-form-item :label="$t('chart.total_position')" class="form-item">
<el-radio-group v-model="totalForm.col.reverseSubLayout" :disabled="colNum < 2" @change="changeTotalCfg">
<el-radio :label="true">{{ $t('chart.total_pos_left') }}</el-radio>
<el-radio :label="false">{{ $t('chart.total_pos_right') }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item :label="$t('chart.total_label')" class="form-item">
<el-input v-model="totalForm.col.subLabel" :disabled="colNum < 2" style="width: 160px;" :placeholder="$t('chart.total_label')" size="mini" clearable @change="changeTotalCfg" />
</el-form-item>
</div>
</el-form>
</el-col>
</div>
</template>
<script>
import { DEFAULT_TOTAL } from '@/views/chart/chart/chart'
export default {
name: 'TotalCfg',
props: {
chart: {
type: Object,
required: true
}
},
data() {
return {
totalForm: JSON.parse(JSON.stringify(DEFAULT_TOTAL))
}
},
computed: {
rowNum() {
const chart = JSON.parse(JSON.stringify(this.chart))
if (chart.xaxisExt) {
let arr = null
if (Object.prototype.toString.call(chart.xaxisExt) === '[object Object]') {
arr = JSON.parse(JSON.stringify(chart.xaxisExt))
} else {
arr = JSON.parse(chart.xaxisExt)
}
return arr.length
}
return 0
},
colNum() {
const chart = JSON.parse(JSON.stringify(this.chart))
if (chart.xaxis) {
let arr = null
if (Object.prototype.toString.call(chart.xaxis) === '[object Object]') {
arr = JSON.parse(JSON.stringify(chart.xaxis))
} else {
arr = JSON.parse(chart.xaxis)
}
return arr.length
}
return 0
}
},
watch: {
'chart': {
handler: function() {
this.initData()
}
}
},
mounted() {
this.initData()
},
methods: {
initData() {
const chart = JSON.parse(JSON.stringify(this.chart))
if (chart.customAttr) {
let customAttr = null
if (Object.prototype.toString.call(chart.customAttr) === '[object Object]') {
customAttr = JSON.parse(JSON.stringify(chart.customAttr))
} else {
customAttr = JSON.parse(chart.customAttr)
}
if (customAttr.totalCfg) {
this.totalForm = customAttr.totalCfg
} else {
this.totalForm = JSON.parse(JSON.stringify(DEFAULT_TOTAL))
}
}
},
changeTotalCfg() {
this.$emit('onTotalCfgChange', this.totalForm)
}
}
}
</script>
<style scoped>
.shape-item{
padding: 6px;
border: none;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
.form-item-slider>>>.el-form-item__label{
font-size: 12px;
line-height: 38px;
}
.form-item>>>.el-form-item__label{
font-size: 12px;
}
.el-select-dropdown__item{
padding: 0 20px;
}
span{font-size: 12px}
.el-form-item{
margin-bottom: 6px;
}
.el-divider--horizontal {
margin: 10px 0
}
.divider-style>>>.el-divider__text{
color: #606266;
font-size: 12px;
font-weight: 400;
padding: 0 10px;
}
</style>
......@@ -309,7 +309,9 @@ import {
DEFAULT_YAXIS_EXT_STYLE,
DEFAULT_BACKGROUND_COLOR,
DEFAULT_SPLIT,
DEFAULT_FUNCTION_CFG
DEFAULT_FUNCTION_CFG,
DEFAULT_THRESHOLD,
DEFAULT_TOTAL
} from '../chart/chart'
export default {
......@@ -754,7 +756,8 @@ export default {
tableColor: DEFAULT_COLOR_CASE,
size: DEFAULT_SIZE,
label: DEFAULT_LABEL,
tooltip: DEFAULT_TOOLTIP
tooltip: DEFAULT_TOOLTIP,
totalCfg: DEFAULT_TOTAL
})
view.customStyle = JSON.stringify({
text: DEFAULT_TITLE_STYLE,
......@@ -767,7 +770,8 @@ export default {
})
view.senior = JSON.stringify({
functionCfg: DEFAULT_FUNCTION_CFG,
assistLine: []
assistLine: [],
threshold: DEFAULT_THRESHOLD
})
view.stylePriority = 'view' // 默认样式优先级视图
view.xaxis = JSON.stringify([])
......@@ -780,7 +784,7 @@ export default {
view.extBubble = JSON.stringify([])
this.setChartDefaultOptions(view)
const _this = this
post('/chart/view/save/' + this.panelInfo.id, view).then(response => {
post('/chart/view/newOne/' + this.panelInfo.id, view).then(response => {
this.closeCreateChart()
this.$store.dispatch('chart/setTableId', null)
this.$store.dispatch('chart/setTableId', this.table.id)
......
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论