Merge branch 'dev' of github.com:dataease/dataease into dev

This commit is contained in:
taojinlong 2022-05-26 15:17:52 +08:00
commit 68fb4980a1
40 changed files with 2353 additions and 543 deletions

View File

@ -54,7 +54,6 @@ public class ShiroServiceImpl implements ShiroService {
// 验证链接
filterChainDefinitionMap.put("/api/link/validate**", ANON);
filterChainDefinitionMap.put("/api/map/areaEntitys/**", ANON);
filterChainDefinitionMap.put("/dataset/field/fieldValues/**", ANON);
filterChainDefinitionMap.put("/linkJump/queryPanelJumpInfo/**", ANON);
filterChainDefinitionMap.put("/linkJump/queryTargetPanelJumpInfo", ANON);
@ -98,6 +97,7 @@ public class ShiroServiceImpl implements ShiroService {
filterChainDefinitionMap.put("/api/link/viewDetail/**", "link");
filterChainDefinitionMap.put("/panel/group/exportDetails", ANON);
filterChainDefinitionMap.put("/dataset/field/linkMultFieldValues", "link");
filterChainDefinitionMap.put("/dataset/field/linkMappingFieldValues", "link");
filterChainDefinitionMap.put("/**", "authc");

View File

@ -0,0 +1,28 @@
package io.dataease.commons.model;
import io.dataease.plugins.common.model.ITreeBase;
import lombok.Data;
import java.util.List;
@Data
public class BaseTreeNode implements ITreeBase<BaseTreeNode> {
private String id;
private String pid;
private String text;
private String nodeType;
private List<BaseTreeNode> children;
public BaseTreeNode(String id, String pid, String text, String nodeType) {
this.id = id;
this.pid = pid;
this.text = text;
this.nodeType = nodeType;
}
}

View File

@ -1,6 +1,7 @@
package io.dataease.commons.utils;
import io.dataease.plugins.common.model.ITreeBase;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@ -14,6 +15,9 @@ import java.util.stream.Collectors;
*/
public class TreeUtils{
public final static String DEFAULT_ROOT = "root";
public final static String SEPARATOR = "-de-";
/**
* Description: rootPid 是根节点PID
*/
@ -53,4 +57,41 @@ public class TreeUtils{
return mergeTree(tree,"0");
}
public static<T extends ITreeBase> List<T> mergeDuplicateTree(List<T> tree, String ... rootPid) {
Assert.notNull(rootPid, "Root Pid cannot be null");
if(CollectionUtils.isEmpty(tree)){
return null;
}
List<T> result = new ArrayList<>();
// 构建id-节点map映射
Map<String, T> treePidMap = tree.stream().collect(Collectors.toMap(node -> node.getNodeType(), t -> t));
tree.stream().filter(item -> StringUtils.isNotBlank(item.getId())).forEach(node -> {
String nodeType = node.getNodeType();
String[] links = nodeType.split(SEPARATOR);
int length = links.length;
int level = Integer.parseInt(links[length - 1]);
// 判断根节点
if (Arrays.asList(rootPid).contains(node.getPid()) && 0 == level) {
result.add(node);
} else {
//找到父元素
String[] pLinks = new String[level];
System.arraycopy(links, 0, pLinks, 0, level);
String parentType = Arrays.stream(pLinks).collect(Collectors.joining(SEPARATOR)) + TreeUtils.SEPARATOR + (level-1);
T parentNode = treePidMap.get(parentType);
if(parentNode==null){
// 可能出现 rootPid 更高的节点 这个操作相当于截断
return;
}
if (parentNode.getChildren() == null) {
parentNode.setChildren(new ArrayList());
}
parentNode.getChildren().add(node);
}
});
return result;
}
}

View File

@ -177,6 +177,23 @@ public class DataSetTableFieldController {
return list;
}
@ApiIgnore
@PostMapping("linkMappingFieldValues")
public List<Object> linkMappingFieldValues(@RequestBody MultFieldValuesRequest multFieldValuesRequest) throws Exception {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String linkToken = request.getHeader(F2CLinkFilter.LINK_TOKEN_KEY);
DecodedJWT jwt = JWT.decode(linkToken);
Long userId = jwt.getClaim("userId").asLong();
multFieldValuesRequest.setUserId(userId);
return dataSetFieldService.fieldValues(multFieldValuesRequest.getFieldIds(), multFieldValuesRequest.getUserId(), true, true);
}
@ApiIgnore
@PostMapping("mappingFieldValues")
public List<Object> mappingFieldValues(@RequestBody MultFieldValuesRequest multFieldValuesRequest) throws Exception {
return dataSetFieldService.fieldValues(multFieldValuesRequest.getFieldIds(), multFieldValuesRequest.getUserId(), true, true);
}
@ApiIgnore
@PostMapping("multFieldValuesForPermissions")
public List<Object> multFieldValuesForPermissions(@RequestBody MultFieldValuesRequest multFieldValuesRequest) throws Exception {

View File

@ -844,48 +844,65 @@ public class DorisQueryProvider extends QueryProvider {
List<SQLObj> list = new ArrayList<>();
for (ChartExtFilterRequest request : requestList) {
List<String> value = request.getValue();
DatasetTableField field = request.getDatasetTableField();
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
String whereName = "";
String whereTerm = transMysqlFilterTerm(request.getOperator());
String whereValue = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getDataeaseName());
List<String> whereNameList = new ArrayList<>();
List<DatasetTableField> fieldList = new ArrayList<>();
if (request.getIsTree()) {
fieldList.addAll(request.getDatasetTableFieldList());
} else {
originName = String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getDataeaseName());
fieldList.add(request.getDatasetTableField());
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5 || field.getDeExtractType() == 1) {
whereName = String.format(DorisConstants.STR_TO_DATE, originName, DorisConstants.DEFAULT_DATE_FORMAT);
for (DatasetTableField field : fieldList) {
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(DorisConstants.CAST, originName, DorisConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(DorisConstants.FROM_UNIXTIME, cast, DorisConstants.DEFAULT_DATE_FORMAT);
String whereName = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getDataeaseName());
} else {
originName = String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getDataeaseName());
}
} else if (field.getDeType() == 0) {
whereName = String.format(DorisConstants.CAST, originName, DorisConstants.VARCHAR);
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(DorisConstants.CAST, originName, DorisConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(DorisConstants.UNIX_TIMESTAMP, originName) + "*1000";
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5 || field.getDeExtractType() == 1) {
whereName = String.format(DorisConstants.STR_TO_DATE, originName, DorisConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(DorisConstants.CAST, originName, DorisConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(DorisConstants.FROM_UNIXTIME, cast, DorisConstants.DEFAULT_DATE_FORMAT);
}
} else if (field.getDeType() == 0) {
whereName = String.format(DorisConstants.CAST, originName, DorisConstants.VARCHAR);
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(DorisConstants.CAST, originName, DorisConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(DorisConstants.UNIX_TIMESTAMP, originName) + "*1000";
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
} else {
whereName = originName;
whereNameList.add(whereName);
}
String whereName = "";
if (request.getIsTree()) {
whereName = "CONCAT(" + StringUtils.join(whereNameList, ",',',") + ")";
} else {
whereName = whereNameList.get(0);
}
String whereTerm = transMysqlFilterTerm(request.getOperator());
String whereValue = "";
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereValue = "('" + StringUtils.join(value, "','") + "')";

View File

@ -848,48 +848,66 @@ public class MysqlQueryProvider extends QueryProvider {
List<SQLObj> list = new ArrayList<>();
for (ChartExtFilterRequest request : requestList) {
List<String> value = request.getValue();
DatasetTableField field = request.getDatasetTableField();
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
String whereName = "";
String whereTerm = transMysqlFilterTerm(request.getOperator());
String whereValue = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getDataeaseName());
List<String> whereNameList = new ArrayList<>();
List<DatasetTableField> fieldList = new ArrayList<>();
if (request.getIsTree()) {
fieldList.addAll(request.getDatasetTableFieldList());
} else {
originName = String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getDataeaseName());
fieldList.add(request.getDatasetTableField());
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5 || field.getDeExtractType() == 1) {
whereName = String.format(MysqlConstants.STR_TO_DATE, originName, MysqlConstants.DEFAULT_DATE_FORMAT);
for (DatasetTableField field : fieldList) {
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(MysqlConstants.CAST, originName, MysqlConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(MysqlConstants.FROM_UNIXTIME, cast, MysqlConstants.DEFAULT_DATE_FORMAT);
String whereName = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getDataeaseName());
} else {
originName = String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getDataeaseName());
}
} else if (field.getDeType() == 0 && field.getDeExtractType() == 0) {
whereName = String.format(MysqlConstants.CAST, originName, MysqlConstants.CHAR);
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(MysqlConstants.CAST, originName, MysqlConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(MysqlConstants.UNIX_TIMESTAMP, originName) + "*1000";
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5 || field.getDeExtractType() == 1) {
whereName = String.format(MysqlConstants.STR_TO_DATE, originName, MysqlConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(MysqlConstants.CAST, originName, MysqlConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(MysqlConstants.FROM_UNIXTIME, cast, MysqlConstants.DEFAULT_DATE_FORMAT);
}
} else if (field.getDeType() == 0 && field.getDeExtractType() == 0) {
whereName = String.format(MysqlConstants.CAST, originName, MysqlConstants.CHAR);
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(MysqlConstants.CAST, originName, MysqlConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(MysqlConstants.UNIX_TIMESTAMP, originName) + "*1000";
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
} else {
whereName = originName;
whereNameList.add(whereName);
}
String whereName = "";
if (request.getIsTree()) {
whereName = "CONCAT(" + StringUtils.join(whereNameList, ",',',") + ")";
} else {
whereName = whereNameList.get(0);
}
String whereTerm = transMysqlFilterTerm(request.getOperator());
String whereValue = "";
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereValue = "('" + StringUtils.join(value, "','") + "')";

View File

@ -879,50 +879,67 @@ public class CKQueryProvider extends QueryProvider {
List<SQLObj> list = new ArrayList<>();
for (ChartExtFilterRequest request : requestList) {
List<String> value = request.getValue();
DatasetTableField field = request.getDatasetTableField();
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
List<String> whereNameList = new ArrayList<>();
List<DatasetTableField> fieldList = new ArrayList<>();
if (request.getIsTree()) {
fieldList.addAll(request.getDatasetTableFieldList());
} else {
fieldList.add(request.getDatasetTableField());
}
for (DatasetTableField field : fieldList) {
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
String whereName = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == DeTypeConstants.DE_TIME) {
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
whereName = String.format(CKConstants.toDateTime, originName);
}
if (field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == 4) {
String cast = String.format(CKConstants.toFloat64, originName);
whereName = String.format(CKConstants.toDateTime, cast);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(CKConstants.toFloat64, originName);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(CKConstants.toInt32, String.format(CKConstants.toDateTime, originName)) + "*1000";
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
whereNameList.add(whereName);
}
String whereName = "";
if (request.getIsTree()) {
whereName = "CONCAT(" + StringUtils.join(whereNameList, ",',',") + ")";
} else {
whereName = whereNameList.get(0);
}
String whereTerm = transMysqlFilterTerm(request.getOperator());
String whereValue = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == DeTypeConstants.DE_TIME) {
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
whereName = String.format(CKConstants.toDateTime, originName);
}
if (field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == 4) {
String cast = String.format(CKConstants.toFloat64, originName);
whereName = String.format(CKConstants.toDateTime, cast);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(CKConstants.toFloat64, originName);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(CKConstants.toInt32, String.format(CKConstants.toDateTime, originName)) + "*1000";
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereValue = "('" + StringUtils.join(value, "','") + "')";
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
@ -940,12 +957,12 @@ public class CKQueryProvider extends QueryProvider {
whereValue = String.format(CKConstants.WHERE_VALUE_VALUE, value.get(0));
}
if (field.getDeType() == DeTypeConstants.DE_TIME && StringUtils.equalsIgnoreCase(request.getOperator(), "null")) {
if (!request.getIsTree() && fieldList.get(0).getDeType() == DeTypeConstants.DE_TIME && StringUtils.equalsIgnoreCase(request.getOperator(), "null")) {
list.add(SQLObj.builder()
.whereField(whereName)
.whereTermAndValue("is null")
.build());
} else if (field.getDeType() == DeTypeConstants.DE_TIME && StringUtils.equalsIgnoreCase(request.getOperator(), "not_null")) {
} else if (!request.getIsTree() && fieldList.get(0).getDeType() == DeTypeConstants.DE_TIME && StringUtils.equalsIgnoreCase(request.getOperator(), "not_null")) {
list.add(SQLObj.builder()
.whereField(whereName)
.whereTermAndValue("is not null")

View File

@ -848,51 +848,68 @@ public class Db2QueryProvider extends QueryProvider {
List<SQLObj> list = new ArrayList<>();
for (ChartExtFilterRequest request : requestList) {
List<String> value = request.getValue();
DatasetTableField field = request.getDatasetTableField();
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
List<String> whereNameList = new ArrayList<>();
List<DatasetTableField> fieldList = new ArrayList<>();
if (request.getIsTree()) {
fieldList.addAll(request.getDatasetTableFieldList());
} else {
fieldList.add(request.getDatasetTableField());
}
for (DatasetTableField field : fieldList) {
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
String whereName = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(Db2Constants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(Db2Constants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == DeTypeConstants.DE_TIME) {
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
originName = String.format(Db2Constants.STR_TO_DATE, originName);
whereName = String.format(Db2Constants.DATE_FORMAT, originName, Db2Constants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(Db2Constants.CAST, originName, Db2Constants.DEFAULT_INT_FORMAT);
whereName = String.format(Db2Constants.FROM_UNIXTIME, cast, Db2Constants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == DeTypeConstants.DE_TIME) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(Db2Constants.CAST, originName, Db2Constants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(Db2Constants.UNIX_TIMESTAMP, originName);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
whereNameList.add(whereName);
}
String whereName = "";
if (request.getIsTree()) {
whereName = "CONCAT(" + StringUtils.join(whereNameList, ",',',") + ")";
} else {
whereName = whereNameList.get(0);
}
String whereTerm = transMysqlFilterTerm(request.getOperator());
String whereValue = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(Db2Constants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(Db2Constants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == DeTypeConstants.DE_TIME) {
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
originName = String.format(Db2Constants.STR_TO_DATE, originName);
whereName = String.format(Db2Constants.DATE_FORMAT, originName, Db2Constants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(Db2Constants.CAST, originName, Db2Constants.DEFAULT_INT_FORMAT);
whereName = String.format(Db2Constants.FROM_UNIXTIME, cast, Db2Constants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == DeTypeConstants.DE_TIME) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(Db2Constants.CAST, originName, Db2Constants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(Db2Constants.UNIX_TIMESTAMP, originName);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereValue = "('" + StringUtils.join(value, "','") + "')";
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {

View File

@ -888,50 +888,67 @@ public class EsQueryProvider extends QueryProvider {
List<SQLObj> list = new ArrayList<>();
for (ChartExtFilterRequest request : requestList) {
List<String> value = request.getValue();
DatasetTableField field = request.getDatasetTableField();
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
List<String> whereNameList = new ArrayList<>();
List<DatasetTableField> fieldList = new ArrayList<>();
if (request.getIsTree()) {
fieldList.addAll(request.getDatasetTableFieldList());
} else {
fieldList.add(request.getDatasetTableField());
}
for (DatasetTableField field : fieldList) {
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
String whereName = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(EsSqlLConstants.CAST, originName, "timestamp");
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(EsSqlLConstants.CAST, originName, "timestamp");
whereName = String.format(EsSqlLConstants.DATETIME_FORMAT, cast, EsSqlLConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(EsSqlLConstants.CAST, originName, "double");
}
if (field.getDeExtractType() == 1) {
whereName = String.format(EsSqlLConstants.CAST, originName, "bigint");
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
whereNameList.add(whereName);
}
String whereName = "";
if (request.getIsTree()) {
whereName = "CONCAT(" + StringUtils.join(whereNameList, ",',',") + ")";
} else {
whereName = whereNameList.get(0);
}
String whereTerm = transMysqlFilterTerm(request.getOperator());
String whereValue = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(EsSqlLConstants.CAST, originName, "timestamp");
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(EsSqlLConstants.CAST, originName, "timestamp");
whereName = String.format(EsSqlLConstants.DATETIME_FORMAT, cast, EsSqlLConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(EsSqlLConstants.CAST, originName, "double");
}
if (field.getDeExtractType() == 1) {
whereName = String.format(EsSqlLConstants.CAST, originName, "bigint");
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereValue = "('" + StringUtils.join(value, "','") + "')";
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {

View File

@ -825,50 +825,67 @@ public class HiveQueryProvider extends QueryProvider {
List<SQLObj> list = new ArrayList<>();
for (ChartExtFilterRequest request : requestList) {
List<String> value = request.getValue();
DatasetTableField field = request.getDatasetTableField();
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
List<String> whereNameList = new ArrayList<>();
List<DatasetTableField> fieldList = new ArrayList<>();
if (request.getIsTree()) {
fieldList.addAll(request.getDatasetTableFieldList());
} else {
fieldList.add(request.getDatasetTableField());
}
for (DatasetTableField field : fieldList) {
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
String whereName = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(HiveConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(HiveConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == DeTypeConstants.DE_TIME) {
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
whereName = String.format(HiveConstants.STR_TO_DATE, originName, HiveConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(HiveConstants.CAST, originName, HiveConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(HiveConstants.FROM_UNIXTIME, cast, HiveConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == DeTypeConstants.DE_TIME) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(HiveConstants.CAST, originName, HiveConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(HiveConstants.UNIX_TIMESTAMP, originName) + "*1000";
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
whereNameList.add(whereName);
}
String whereName = "";
if (request.getIsTree()) {
whereName = "CONCAT(" + StringUtils.join(whereNameList, ",',',") + ")";
} else {
whereName = whereNameList.get(0);
}
String whereTerm = transMysqlFilterTerm(request.getOperator());
String whereValue = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(HiveConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(HiveConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == DeTypeConstants.DE_TIME) {
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
whereName = String.format(HiveConstants.STR_TO_DATE, originName, HiveConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(HiveConstants.CAST, originName, HiveConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(HiveConstants.FROM_UNIXTIME, cast, HiveConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == DeTypeConstants.DE_TIME) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(HiveConstants.CAST, originName, HiveConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(HiveConstants.UNIX_TIMESTAMP, originName) + "*1000";
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereValue = "('" + StringUtils.join(value, "','") + "')";
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {

View File

@ -5,7 +5,6 @@ import io.dataease.plugins.common.base.domain.DatasetTableField;
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
import io.dataease.plugins.common.base.domain.Datasource;
import io.dataease.plugins.common.base.mapper.DatasetTableFieldMapper;
import io.dataease.plugins.common.constants.DeTypeConstants;
import io.dataease.plugins.common.constants.ImpalaConstants;
import io.dataease.plugins.common.constants.SQLConstants;
@ -827,50 +826,67 @@ public class ImpalaQueryProvider extends QueryProvider {
List<SQLObj> list = new ArrayList<>();
for (ChartExtFilterRequest request : requestList) {
List<String> value = request.getValue();
DatasetTableField field = request.getDatasetTableField();
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
List<String> whereNameList = new ArrayList<>();
List<DatasetTableField> fieldList = new ArrayList<>();
if (request.getIsTree()) {
fieldList.addAll(request.getDatasetTableFieldList());
} else {
fieldList.add(request.getDatasetTableField());
}
for (DatasetTableField field : fieldList) {
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
String whereName = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(ImpalaConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(ImpalaConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == DeTypeConstants.DE_TIME) {
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
whereName = String.format(ImpalaConstants.DATE_FORMAT, originName, ImpalaConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(ImpalaConstants.CAST, originName, ImpalaConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(ImpalaConstants.FROM_UNIXTIME, cast, ImpalaConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == DeTypeConstants.DE_TIME) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(ImpalaConstants.CAST, originName, ImpalaConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(ImpalaConstants.UNIX_TIMESTAMP, originName) + "*1000";
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
whereNameList.add(whereName);
}
String whereName = "";
if (request.getIsTree()) {
whereName = "CONCAT(" + StringUtils.join(whereNameList, ",',',") + ")";
} else {
whereName = whereNameList.get(0);
}
String whereTerm = transMysqlFilterTerm(request.getOperator());
String whereValue = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(ImpalaConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(ImpalaConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == DeTypeConstants.DE_TIME) {
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
whereName = String.format(ImpalaConstants.DATE_FORMAT, originName, ImpalaConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(ImpalaConstants.CAST, originName, ImpalaConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(ImpalaConstants.FROM_UNIXTIME, cast, ImpalaConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == DeTypeConstants.DE_TIME) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(ImpalaConstants.CAST, originName, ImpalaConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(ImpalaConstants.UNIX_TIMESTAMP, originName) + "*1000";
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereValue = "('" + StringUtils.join(value, "','") + "')";
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
@ -885,7 +901,8 @@ public class ImpalaQueryProvider extends QueryProvider {
whereValue = String.format(ImpalaConstants.WHERE_BETWEEN, value.get(0), value.get(1));
}
} else {
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == DeTypeConstants.DE_BOOL) {
DatasetTableField field = fieldList.get(0);
if (!request.getIsTree() && (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == DeTypeConstants.DE_BOOL)) {
whereValue = String.format(ImpalaConstants.WHERE_NUMBER_VALUE_VALUE, value.get(0));
} else {
whereValue = String.format(ImpalaConstants.WHERE_VALUE_VALUE, value.get(0));

View File

@ -810,26 +810,43 @@ public class MongoQueryProvider extends QueryProvider {
List<SQLObj> list = new ArrayList<>();
for (ChartExtFilterRequest request : requestList) {
List<String> value = request.getValue();
DatasetTableField field = request.getDatasetTableField();
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
List<String> whereNameList = new ArrayList<>();
List<DatasetTableField> fieldList = new ArrayList<>();
if (request.getIsTree()) {
fieldList.addAll(request.getDatasetTableFieldList());
} else {
fieldList.add(request.getDatasetTableField());
}
for (DatasetTableField field : fieldList) {
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
String whereName = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == DeTypeConstants.DE_INT) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == DeTypeConstants.DE_TIME) {
originName = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
whereName = originName;
whereNameList.add(whereName);
}
String whereName = "";
if (request.getIsTree()) {
whereName = "CONCAT(" + StringUtils.join(whereNameList, ",',',") + ")";
} else {
whereName = whereNameList.get(0);
}
String whereTerm = transMysqlFilterTerm(request.getOperator());
String whereValue = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == DeTypeConstants.DE_INT) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == DeTypeConstants.DE_TIME) {
originName = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
whereName = originName;
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereValue = "('" + StringUtils.join(value, "','") + "')";
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
@ -844,7 +861,7 @@ public class MongoQueryProvider extends QueryProvider {
whereValue = String.format(MongoConstants.WHERE_BETWEEN, value.get(0), value.get(1));
}
} else {
if (field.getDeType() == DeTypeConstants.DE_STRING) {
if (!request.getIsTree() && fieldList.get(0).getDeType() == DeTypeConstants.DE_STRING) {
whereValue = String.format(MongoConstants.WHERE_VALUE_VALUE, value.get(0));
} else {
whereValue = value.get(0);

View File

@ -829,50 +829,67 @@ public class MysqlQueryProvider extends QueryProvider {
List<SQLObj> list = new ArrayList<>();
for (ChartExtFilterRequest request : requestList) {
List<String> value = request.getValue();
DatasetTableField field = request.getDatasetTableField();
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
List<String> whereNameList = new ArrayList<>();
List<DatasetTableField> fieldList = new ArrayList<>();
if (request.getIsTree()) {
fieldList.addAll(request.getDatasetTableFieldList());
} else {
fieldList.add(request.getDatasetTableField());
}
for (DatasetTableField field : fieldList) {
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
String whereName = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(MySQLConstants.STR_TO_DATE, originName, MySQLConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(MySQLConstants.CAST, originName, MySQLConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(MySQLConstants.FROM_UNIXTIME, cast, MySQLConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(MySQLConstants.CAST, originName, MySQLConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(MySQLConstants.UNIX_TIMESTAMP, originName);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
whereNameList.add(whereName);
}
String whereName = "";
if (request.getIsTree()) {
whereName = "CONCAT(" + StringUtils.join(whereNameList, ",',',") + ")";
} else {
whereName = whereNameList.get(0);
}
String whereTerm = transMysqlFilterTerm(request.getOperator());
String whereValue = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(MySQLConstants.STR_TO_DATE, originName, MySQLConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(MySQLConstants.CAST, originName, MySQLConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(MySQLConstants.FROM_UNIXTIME, cast, MySQLConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(MySQLConstants.CAST, originName, MySQLConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(MySQLConstants.UNIX_TIMESTAMP, originName);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereValue = "('" + StringUtils.join(value, "','") + "')";
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {

View File

@ -886,49 +886,67 @@ public class OracleQueryProvider extends QueryProvider {
List<SQLObj> list = new ArrayList<>();
for (ChartExtFilterRequest request : requestList) {
List<String> value = request.getValue();
DatasetTableField field = request.getDatasetTableField();
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
List<String> whereNameList = new ArrayList<>();
List<DatasetTableField> fieldList = new ArrayList<>();
if (request.getIsTree()) {
fieldList.addAll(request.getDatasetTableFieldList());
} else {
fieldList.add(request.getDatasetTableField());
}
for (DatasetTableField field : fieldList) {
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
String whereName = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(OracleConstants.TO_DATE, originName, OracleConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(OracleConstants.CAST, originName, OracleConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(OracleConstants.FROM_UNIXTIME, cast, OracleConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(OracleConstants.CAST, originName, OracleConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(OracleConstants.UNIX_TIMESTAMP, originName) + "*1000";
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
whereNameList.add(whereName);
}
String whereName = "";
if (request.getIsTree()) {
whereName = "CONCAT(" + StringUtils.join(whereNameList, ",',',") + ")";
} else {
whereName = whereNameList.get(0);
}
String whereTerm = transMysqlFilterTerm(request.getOperator());
String whereValue = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(OracleConstants.TO_DATE, originName, OracleConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(OracleConstants.CAST, originName, OracleConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(OracleConstants.FROM_UNIXTIME, cast, OracleConstants.DEFAULT_DATE_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(OracleConstants.CAST, originName, OracleConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(OracleConstants.UNIX_TIMESTAMP, originName) + "*1000";
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereValue = "('" + StringUtils.join(value, "','") + "')";
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {

View File

@ -10,7 +10,6 @@ import io.dataease.plugins.common.constants.DeTypeConstants;
import io.dataease.plugins.common.constants.PgConstants;
import io.dataease.plugins.common.constants.SQLConstants;
import io.dataease.plugins.common.constants.SqlServerSQLConstants;
import io.dataease.plugins.common.constants.SQLConstants;
import io.dataease.plugins.common.dto.chart.ChartCustomFilterItemDTO;
import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
@ -858,49 +857,67 @@ public class PgQueryProvider extends QueryProvider {
List<SQLObj> list = new ArrayList<>();
for (ChartExtFilterRequest request : requestList) {
List<String> value = request.getValue();
DatasetTableField field = request.getDatasetTableField();
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
List<String> whereNameList = new ArrayList<>();
List<DatasetTableField> fieldList = new ArrayList<>();
if (request.getIsTree()) {
fieldList.addAll(request.getDatasetTableFieldList());
} else {
fieldList.add(request.getDatasetTableField());
}
for (DatasetTableField field : fieldList) {
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
String whereName = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(PgConstants.CAST, originName, "timestamp");
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(PgConstants.CAST, originName, "bigint");
whereName = String.format(PgConstants.FROM_UNIXTIME, cast);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(PgConstants.CAST, originName, PgConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(PgConstants.UNIX_TIMESTAMP, originName);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
whereNameList.add(whereName);
}
String whereName = "";
if (request.getIsTree()) {
whereName = "CONCAT(" + StringUtils.join(whereNameList, ",',',") + ")";
} else {
whereName = whereNameList.get(0);
}
String whereTerm = transMysqlFilterTerm(request.getOperator());
String whereValue = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(PgConstants.CAST, originName, "timestamp");
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(PgConstants.CAST, originName, "bigint");
whereName = String.format(PgConstants.FROM_UNIXTIME, cast);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(PgConstants.CAST, originName, PgConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(PgConstants.UNIX_TIMESTAMP, originName);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereValue = "('" + StringUtils.join(value, "','") + "')";
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {

View File

@ -786,49 +786,67 @@ public class RedshiftQueryProvider extends QueryProvider {
List<SQLObj> list = new ArrayList<>();
for (ChartExtFilterRequest request : requestList) {
List<String> value = request.getValue();
DatasetTableField field = request.getDatasetTableField();
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
List<String> whereNameList = new ArrayList<>();
List<DatasetTableField> fieldList = new ArrayList<>();
if (request.getIsTree()) {
fieldList.addAll(request.getDatasetTableFieldList());
} else {
fieldList.add(request.getDatasetTableField());
}
for (DatasetTableField field : fieldList) {
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
String whereName = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(PgConstants.CAST, originName, "timestamp");
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(PgConstants.CAST, originName, "bigint");
whereName = String.format(PgConstants.FROM_UNIXTIME, cast);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(PgConstants.CAST, originName, PgConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(PgConstants.UNIX_TIMESTAMP, originName);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
whereNameList.add(whereName);
}
String whereName = "";
if (request.getIsTree()) {
whereName = "CONCAT(" + StringUtils.join(whereNameList, ",',',") + ")";
} else {
whereName = whereNameList.get(0);
}
String whereTerm = transMysqlFilterTerm(request.getOperator());
String whereValue = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(PgConstants.CAST, originName, "timestamp");
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(PgConstants.CAST, originName, "bigint");
whereName = String.format(PgConstants.FROM_UNIXTIME, cast);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(PgConstants.CAST, originName, PgConstants.DEFAULT_FLOAT_FORMAT);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(PgConstants.UNIX_TIMESTAMP, originName);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereValue = "('" + StringUtils.join(value, "','") + "')";
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {

View File

@ -7,8 +7,8 @@ import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
import io.dataease.plugins.common.base.domain.Datasource;
import io.dataease.plugins.common.base.mapper.DatasetTableFieldMapper;
import io.dataease.plugins.common.constants.DeTypeConstants;
import io.dataease.plugins.common.constants.SqlServerSQLConstants;
import io.dataease.plugins.common.constants.SQLConstants;
import io.dataease.plugins.common.constants.SqlServerSQLConstants;
import io.dataease.plugins.common.dto.chart.ChartCustomFilterItemDTO;
import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
@ -891,50 +891,67 @@ public class SqlserverQueryProvider extends QueryProvider {
List<SQLObj> list = new ArrayList<>();
for (ChartExtFilterRequest request : requestList) {
List<String> value = request.getValue();
DatasetTableField field = request.getDatasetTableField();
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
List<String> whereNameList = new ArrayList<>();
List<DatasetTableField> fieldList = new ArrayList<>();
if (request.getIsTree()) {
fieldList.addAll(request.getDatasetTableFieldList());
} else {
fieldList.add(request.getDatasetTableField());
}
for (DatasetTableField field : fieldList) {
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
String whereName = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(SqlServerSQLConstants.STRING_TO_DATE, originName);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(SqlServerSQLConstants.LONG_TO_DATE, originName + "/1000");
whereName = String.format(SqlServerSQLConstants.FROM_UNIXTIME, cast);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(SqlServerSQLConstants.CONVERT, SqlServerSQLConstants.DEFAULT_FLOAT_FORMAT, originName);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(SqlServerSQLConstants.UNIX_TIMESTAMP, originName);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
whereNameList.add(whereName);
}
String whereName = "";
if (request.getIsTree()) {
whereName = "CONCAT(" + StringUtils.join(whereNameList, ",',',") + ")";
} else {
whereName = whereNameList.get(0);
}
String whereTerm = transMysqlFilterTerm(request.getOperator());
String whereValue = "";
String originName;
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originName = calcFieldRegex(field.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
originName = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} else {
originName = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
}
if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(SqlServerSQLConstants.STRING_TO_DATE, originName);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(SqlServerSQLConstants.LONG_TO_DATE, originName + "/1000");
whereName = String.format(SqlServerSQLConstants.FROM_UNIXTIME, cast);
}
if (field.getDeExtractType() == 1) {
whereName = originName;
}
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(SqlServerSQLConstants.CONVERT, SqlServerSQLConstants.DEFAULT_FLOAT_FORMAT, originName);
}
if (field.getDeExtractType() == 1) {
whereName = String.format(SqlServerSQLConstants.UNIX_TIMESTAMP, originName);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereName = originName;
}
} else {
whereName = originName;
}
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereValue = "('" + StringUtils.join(value, "','") + "')";
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {

View File

@ -542,8 +542,10 @@ public class ChartViewService {
if (ObjectUtils.isEmpty(view)) {
throw new RuntimeException(Translator.get("i18n_chart_delete"));
}
Type tokenType = new TypeToken<List<ChartViewFieldDTO>>() {}.getType();
Type filterTokenType = new TypeToken<List<ChartFieldCustomFilterDTO>>() {}.getType();
Type tokenType = new TypeToken<List<ChartViewFieldDTO>>() {
}.getType();
Type filterTokenType = new TypeToken<List<ChartFieldCustomFilterDTO>>() {
}.getType();
List<ChartViewFieldDTO> viewFields = gson.fromJson(view.getViewFields(), tokenType);
Map<String, List<ChartViewFieldDTO>> extFieldsMap = null;
@ -638,26 +640,55 @@ public class ChartViewService {
for (ChartExtFilterRequest request : requestList.getFilter()) {
// 解析多个fieldId,fieldId是一个逗号分隔的字符串
String fieldId = request.getFieldId();
if (request.getIsTree() == null) {
request.setIsTree(false);
}
if (StringUtils.isNotEmpty(fieldId)) {
String[] fieldIds = fieldId.split(",");
for (String fId : fieldIds) {
if (request.getIsTree()) {
ChartExtFilterRequest filterRequest = new ChartExtFilterRequest();
BeanUtils.copyBean(filterRequest, request);
filterRequest.setFieldId(fId);
DatasetTableField datasetTableField = dataSetTableFieldsService.get(fId);
if (datasetTableField == null) {
continue;
filterRequest.setDatasetTableFieldList(new ArrayList<>());
for (String fId : fieldIds) {
DatasetTableField datasetTableField = dataSetTableFieldsService.get(fId);
if (datasetTableField == null) {
continue;
}
if (!desensitizationList.contains(datasetTableField.getDataeaseName()) && dataeaseNames.contains(datasetTableField.getDataeaseName())) {
if (StringUtils.equalsIgnoreCase(datasetTableField.getTableId(), view.getTableId())) {
if (CollectionUtils.isNotEmpty(filterRequest.getViewIds())) {
if (filterRequest.getViewIds().contains(view.getId())) {
filterRequest.getDatasetTableFieldList().add(datasetTableField);
}
} else {
filterRequest.getDatasetTableFieldList().add(datasetTableField);
}
}
}
}
if (!desensitizationList.contains(datasetTableField.getDataeaseName()) && dataeaseNames.contains(datasetTableField.getDataeaseName())) {
filterRequest.setDatasetTableField(datasetTableField);
if (StringUtils.equalsIgnoreCase(datasetTableField.getTableId(), view.getTableId())) {
if (CollectionUtils.isNotEmpty(filterRequest.getViewIds())) {
if (filterRequest.getViewIds().contains(view.getId())) {
if (CollectionUtils.isNotEmpty(filterRequest.getDatasetTableFieldList())) {
extFilterList.add(filterRequest);
}
} else {
for (String fId : fieldIds) {
ChartExtFilterRequest filterRequest = new ChartExtFilterRequest();
BeanUtils.copyBean(filterRequest, request);
filterRequest.setFieldId(fId);
DatasetTableField datasetTableField = dataSetTableFieldsService.get(fId);
if (datasetTableField == null) {
continue;
}
if (!desensitizationList.contains(datasetTableField.getDataeaseName()) && dataeaseNames.contains(datasetTableField.getDataeaseName())) {
filterRequest.setDatasetTableField(datasetTableField);
if (StringUtils.equalsIgnoreCase(datasetTableField.getTableId(), view.getTableId())) {
if (CollectionUtils.isNotEmpty(filterRequest.getViewIds())) {
if (filterRequest.getViewIds().contains(view.getId())) {
extFilterList.add(filterRequest);
}
} else {
extFilterList.add(filterRequest);
}
} else {
extFilterList.add(filterRequest);
}
}
}

View File

@ -6,4 +6,6 @@ import java.util.List;
public interface DataSetFieldService {
List<Object> fieldValues(String fieldId, Long userId, Boolean userPermissions) throws Exception;
List<Object> fieldValues(List<String> fieldIds, Long userId, Boolean userPermissions, Boolean needMapping) throws Exception;
}

View File

@ -1,6 +1,8 @@
package io.dataease.service.dataset.impl.direct;
import com.google.gson.Gson;
import io.dataease.commons.model.BaseTreeNode;
import io.dataease.commons.utils.TreeUtils;
import io.dataease.plugins.common.base.domain.DatasetTable;
import io.dataease.plugins.common.base.domain.DatasetTableField;
import io.dataease.plugins.common.base.domain.Datasource;
@ -22,9 +24,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@ -45,6 +45,14 @@ public class DirectFieldService implements DataSetFieldService {
@Override
public List<Object> fieldValues(String fieldId, Long userId, Boolean userPermissions) throws Exception {
List<String> filedIds = new ArrayList<>();
filedIds.add(fieldId);
return fieldValues(filedIds, userId, userPermissions, false);
}
@Override
public List<Object> fieldValues(List<String> fieldIds, Long userId, Boolean userPermissions, Boolean needMapping) throws Exception {
String fieldId = fieldIds.get(0);
DatasetTableField field = dataSetTableFieldsService.selectByPrimaryKey(fieldId);
if (field == null || StringUtils.isEmpty(field.getTableId())) return null;
@ -54,15 +62,23 @@ public class DirectFieldService implements DataSetFieldService {
DatasetTableField datasetTableField = DatasetTableField.builder().tableId(field.getTableId()).checked(Boolean.TRUE).build();
List<DatasetTableField> fields = dataSetTableFieldsService.list(datasetTableField);
List<DatasetTableField> permissionFields = fields;
List<ChartFieldCustomFilterDTO> customFilter = new ArrayList<>();
if(userPermissions){
//列权限
List<String> desensitizationList = new ArrayList<>();
fields = permissionService.filterColumnPermissons(fields, desensitizationList, datasetTable.getId(), userId);
//禁用的
if(!fields.stream().map(DatasetTableField::getId).collect(Collectors.toList()).contains(fieldId)){
permissionFields = fields.stream().filter(node -> fieldIds.stream().anyMatch(item -> StringUtils.equals(node.getId(), item))).collect(Collectors.toList());
if (CollectionUtils.isEmpty(permissionFields)) {
return new ArrayList<>();
}
//禁用的
/*if(!fields.stream().map(DatasetTableField::getId).collect(Collectors.toList()).contains(fieldId)){
return new ArrayList<>();
}*/
if (CollectionUtils.isNotEmpty(desensitizationList) && desensitizationList.contains(field.getDataeaseName())) {
List<Object> results = new ArrayList<>();
results.add(ColumnPermissionConstants.Desensitization_desc);
@ -87,18 +103,18 @@ public class DirectFieldService implements DataSetFieldService {
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "db")) {
datasourceRequest.setTable(dataTableInfoDTO.getTable());
datasourceRequest.setQuery(qp.createQuerySQL(dataTableInfoDTO.getTable(), Collections.singletonList(field), true, ds, customFilter));
datasourceRequest.setQuery(qp.createQuerySQL(dataTableInfoDTO.getTable(), permissionFields, true, ds, customFilter));
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql")) {
datasourceRequest.setQuery(qp.createQuerySQLAsTmp(dataTableInfoDTO.getSql(), Collections.singletonList(field), true, customFilter));
datasourceRequest.setQuery(qp.createQuerySQLAsTmp(dataTableInfoDTO.getSql(), permissionFields, true, customFilter));
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "custom")) {
DataTableInfoDTO dt = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class);
List<DataSetTableUnionDTO> listUnion = dataSetTableUnionService.listByTableId(dt.getList().get(0).getTableId());
String sql = dataSetTableService.getCustomSQLDatasource(dt, listUnion, ds);
datasourceRequest.setQuery(qp.createQuerySQLAsTmp(sql, Collections.singletonList(field), true, customFilter));
datasourceRequest.setQuery(qp.createQuerySQLAsTmp(sql, permissionFields, true, customFilter));
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "union")) {
DataTableInfoDTO dt = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class);
String sql = (String) dataSetTableService.getUnionSQLDatasource(dt, ds).get("sql");
datasourceRequest.setQuery(qp.createQuerySQLAsTmp(sql, Collections.singletonList(field), true, customFilter));
datasourceRequest.setQuery(qp.createQuerySQLAsTmp(sql, permissionFields, true, customFilter));
}
} else if (datasetTable.getMode() == 1) {// 抽取
// 连接doris构建doris数据源查询
@ -109,11 +125,39 @@ public class DirectFieldService implements DataSetFieldService {
String tableName = "ds_" + datasetTable.getId().replaceAll("-", "_");
datasourceRequest.setTable(tableName);
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
datasourceRequest.setQuery(qp.createQuerySQL(tableName, Collections.singletonList(field), true, null, customFilter));
datasourceRequest.setQuery(qp.createQuerySQL(tableName, permissionFields, true, null, customFilter));
}
List<String[]> rows = datasourceProvider.getData(datasourceRequest);
List<Object> results = rows.stream().map(row -> row[0]).distinct().collect(Collectors.toList());
return results;
if (!needMapping) {
List<Object> results = rows.stream().map(row -> row[0]).distinct().collect(Collectors.toList());
return results;
}
Set<String> pkSet = new HashSet<>();
List<BaseTreeNode> treeNodes = rows.stream().map(row -> buildTreeNode(row, pkSet)).flatMap(Collection::stream).collect(Collectors.toList());
List tree = TreeUtils.mergeDuplicateTree(treeNodes, TreeUtils.DEFAULT_ROOT);
return tree;
}
private List<BaseTreeNode> buildTreeNode(String [] row, Set<String> pkSet) {
List<BaseTreeNode> nodes = new ArrayList<>();
List<String> parentPkList = new ArrayList<>();
for (int i = 0; i < row.length; i++) {
String text = row[i];
parentPkList.add(text);
String val = parentPkList.stream().collect(Collectors.joining(TreeUtils.SEPARATOR));
String parentVal = i == 0 ? TreeUtils.DEFAULT_ROOT : row[i - 1];
String pk = parentPkList.stream().collect(Collectors.joining(TreeUtils.SEPARATOR));
if (pkSet.contains(pk)) continue;
pkSet.add(pk);
BaseTreeNode node = new BaseTreeNode(val, parentVal, text, pk + TreeUtils.SEPARATOR + i);
nodes.add(node);
}
return nodes;
}
}

View File

@ -146,11 +146,21 @@ export function post(url, data, showLoading = true, timeout = 60000) {
})
}
export function fieldValues(fieldId) {
export function mappingFieldValues(data) {
return request({
url: '/dataset/field/fieldValues/' + fieldId,
url: '/dataset/field/mappingFieldValues',
method: 'post',
loading: true
loading: true,
data
})
}
export function linkMappingFieldValues(data) {
return request({
url: '/dataset/field/linkMappingFieldValues',
method: 'post',
loading: true,
data
})
}

View File

@ -0,0 +1,37 @@
/*
* @moduleName:
* @Author: dawdler
* @LastModifiedBy: dawdler
* @Date: 2019-03-22 14:47:35
* @LastEditTime: 2019-03-22 16:31:38
*/
export const on = (function() {
if (document.addEventListener) {
return function(element, event, handler) {
if (element && event && handler) {
element.addEventListener(event, handler, false)
}
}
} else {
return function(element, event, handler) {
if (element && event && handler) {
element.attachEvent('on' + event, handler)
}
}
}
})()
export const off = (function() {
if (document.removeEventListener) {
return function(element, event, handler) {
if (element && event) {
element.removeEventListener(event, handler, false)
}
}
} else {
return function(element, event, handler) {
if (element && event) {
element.detachEvent('on' + event, handler)
}
}
}
})()

View File

@ -0,0 +1,594 @@
<!--
* @moduleName: 下拉树组件
* @Author: dawdler
* @Date: 2018-12-19 14:03:03
* @LastModifiedBy: dawdler
* @LastEditTime: 2020-12-26 14:51:20
-->
<template>
<div class="el-tree-select" :class="selectClass">
<!-- 下拉文本 -->
<el-select
:id="'el-tree-select-' + guid"
ref="select"
v-model="labels"
v-popover:popover
:style="styles"
class="el-tree-select-input"
:disabled="disabled"
popper-class="select-option"
v-bind="selectParams"
:popper-append-to-body="false"
:filterable="false"
:multiple="selectParams.multiple"
:title="labels"
@remove-tag="_selectRemoveTag"
@clear="_selectClearFun"
@focus="_popoverShowFun"
/>
<!-- 弹出框 -->
<el-popover ref="popover" v-model="visible" :placement="placement" :transition="transition" :popper-class="popperClass" :width="width" trigger="click">
<!-- 是否显示搜索框 -->
<el-input v-if="treeParams.filterable" v-model="keywords" size="mini" class="input-with-select mb10" @change="_searchFun">
<el-button slot="append" icon="el-icon-search" />
</el-input>
<el-scrollbar tag="div" wrap-class="el-select-dropdown__wrap" view-class="el-select-dropdown__list" class="is-empty">
<!-- 树列表 -->
<el-tree
v-show="data.length > 0"
ref="tree"
v-bind="treeParams"
:data="data"
:node-key="propsValue"
:draggable="false"
:current-node-key="ids.length > 0 ? ids[0] : ''"
:show-checkbox="selectParams.multiple"
:filter-node-method="filterNodeMethod ? filterNodeMethod : _filterFun"
:render-content="treeRenderFun"
@node-click="_treeNodeClickFun"
@check="_treeCheckFun"
/>
<!-- 暂无数据 -->
<div v-if="data.length === 0" class="no-data">暂无数据</div>
</el-scrollbar>
</el-popover>
</div>
</template>
<script>
import { on, off } from './dom'
import { each, guid } from './utils'
// @group api
export default {
name: 'ElTreeSelect',
components: {},
props: {
// v-model,treeParams.dataid
value: {
// `String` / `Array` / `Number`
type: [String, Array, Number],
// `''`
default() {
return ''
}
},
// el-select
styles: {
type: Object,
// {}
default() {
return {}
}
},
//
selectClass: {
type: String,
default() {
return ''
}
},
// popover
popoverClass: {
type: String,
default() {
return ''
}
},
//
disabled: {
type: Boolean,
// false
default() {
return false
}
},
//
placement: {
type: String,
// bottom
default() {
return 'bottom'
}
},
//
transition: {
type: String,
// el-zoom-in-top
default() {
return 'el-zoom-in-top'
}
},
// el-tree Function(h, { node, data, store }) {}
treeRenderFun: Function,
// el-tree Function(h, { value, data, node }) {}
filterNodeMethod: Function,
/*
文本框参数几乎支持el-select所有的API<br>
取消参数<br>
设定下拉框的弹出框隐藏<br>
`:popper-append-to-body="false"` <br>
搜索从弹出框里面执行 <br>
`filterable="false"`
*/
selectParams: {
type: Object,
/*
Object默认参数<br><br>
是否可以清空选项<br>
`clearable: true,`<br><br>
是否禁用<br>
`disabled: false,`<br><br>
搜索框placeholder文字<br>
`placeholder: '请选择',`<br><br>
*/
default() {
return {
clearable: true,
disabled: false,
placeholder: '请选择'
}
}
},
/*
下拉树参数几乎支持el-tree所有的API<br>
取消参数:<br>
`:show-checkbox="selectParams.multiple"`<br>
使用下拉框参数multiple判断是否对树进行多选<br>
取消对el-tree的人为传参show-checkbox<br>
`:node-key="propsValue"` 自动获取treeParams.props.value<br>
`:draggable="false"` 屏蔽拖动
*/
treeParams: {
type: Object,
/*
Object默认参数<br><br>
在有子级的情况下是否点击父级关闭弹出框,false 只能点击子级关闭弹出框<br><br>
`clickParent: false`<br><br>
是否显示搜索框<br><br>
`filterable: false`<br><br>
是否只是叶子节点<br><br>
`leafOnly: false`<br><br>
是否包含半选节点<br><br>
`includeHalfChecked: false`<br><br>
下拉树的数据<br><br>
`data:[]`<br><br>
下拉树的props<br><br>
`props: {`<br>
`children: 'children',`<br>
`label: 'name',`<br>
`value: 'flowId',`<br>
`disabled: 'disabled'`<br>
`}`
*/
default() {
return {
clickParent: false,
filterable: false,
leafOnly: false,
includeHalfChecked: false,
data: [],
showParent: false,
props: {
children: 'children',
label: 'name',
code: 'code',
value: 'flowId',
disabled: 'disabled'
}
}
}
}
},
data() {
return {
guid: guid(),
propsValue: 'flowId',
propsLabel: 'name',
propsCode: null, //
propsDisabled: 'disabled',
propsChildren: 'children',
leafOnly: false,
includeHalfChecked: false,
data: [],
keywords: '',
labels: '', //
ids: [], // id
visible: false, // popover v-model
width: 150,
showParent: false
}
},
computed: {
popperClass() {
const _c = 'el-tree-select-popper ' + this.popoverClass
return this.disabled ? _c + ' disabled ' : _c
}
},
watch: {
ids: function(val) {
if (val !== undefined) {
this.$nextTick(() => {
this._setSelectNodeFun(val)
})
}
},
value: function(val) {
if (this.ids !== val) {
this._setMultipleFun()
if (this.selectParams.multiple) {
this.ids = [...val]
} else {
this.ids = val === '' ? [] : [val]
}
}
}
},
created() {
const { props, data, leafOnly, includeHalfChecked, showParent } = this.treeParams
this._setMultipleFun()
this.propsValue = props.value
this.propsLabel = props.label
this.propsCode = props.code || null //
this.propsDisabled = props.disabled
this.propsChildren = props.children
this.leafOnly = leafOnly
this.includeHalfChecked = includeHalfChecked
this.data = data.length > 0 ? [...data] : []
if (this.selectParams.multiple) {
this.labels = []
this.ids = this.value
} else {
this.labels = ''
this.ids = this.value instanceof Array ? this.value : [this.value]
}
this.showParent = showParent
},
mounted() {
this._updateH()
this.$nextTick(() => {
on(document, 'mouseup', this._popoverHideFun)
})
},
beforeDestroy() {
off(document, 'mouseup', this._popoverHideFun)
},
methods: {
//
_setMultipleFun() {
let multiple = false
if (this.value instanceof Array) {
multiple = true
}
this.$set(this.selectParams, 'multiple', multiple)
},
//
_searchFun() {
/*
对外抛出搜索方法自行判断是走后台查询还是前端过滤<br>
前端过滤this.$refs.treeSelect.$refs.tree.filter(value);<br>
后台查询this.$refs.treeSelect.treeDataUpdateFun(data);
*/
this.$emit('searchFun', this.keywords)
},
// id
_setSelectNodeFun(ids) {
const el = this.$refs.tree
if (!el) {
throw new Error('找不到tree dom')
}
const { multiple } = this.selectParams
// 0
if (ids.length === 0 || this.data.length === 0) {
this.labels = multiple ? [] : ''
if (multiple) {
el.setCheckedKeys([])
} else {
el.setCurrentKey(null)
}
return
}
if (multiple) {
// element-ui bug. el.setCheckedKeys([id]);el.getCheckedNodes()
el.getCheckedNodes(this.leafOnly, this.includeHalfChecked).forEach(item => {
el.setChecked(item, false)
})
ids.forEach(id => {
el.setChecked(id, true)
})
const nodes = el.getCheckedNodes(this.leafOnly, this.includeHalfChecked)
if (!this.showParent) {
if (this.propsCode) {
// code labels=code(name)
this.labels = nodes.map(item => (item[this.propsCode] ? item[this.propsLabel] + '(' + item[this.propsCode] + ')' : item[this.propsLabel])) || []
} else {
this.labels = nodes.map(item => item[this.propsLabel]) || []
}
} else {
this.labels = nodes.map(item => this.cascadeLabels(item)) || []
}
} else {
el.setCurrentKey(ids[0])
const node = el.getCurrentNode()
if (node) {
if (!this.showParent) {
if (this.propsCode) {
// code labels=code(name)
this.labels = node[this.propsCode] ? node[this.propsLabel] + '(' + node[this.propsCode] + ')' : node[this.propsLabel]
} else {
this.labels = node[this.propsLabel]
}
} else {
this.labels = this.cascadeLabels(node)
}
} else {
this.labels = ''
}
}
this._updatePopoverLocationFun()
},
parentNodes(node) {
const results = []
let currentNode = node
while (currentNode && currentNode.data && !(currentNode.data instanceof Array)) {
results.push(currentNode)
currentNode = currentNode.parent
}
return results
},
cascadeLabels(data) {
const cNode = this.$refs.tree.getNode(data)
const linkedNodes = this.parentNodes(cNode)
const labels = linkedNodes.map(item => item.data[this.propsLabel]).reverse().join(':')
return labels
},
// popover
_updatePopoverLocationFun() {
// dom
setTimeout(() => {
this.$refs.popover.updatePopper()
}, 50)
},
// MouseEvent.path ie11,edge,chrome,firefox,safari
_getEventPath(evt) {
const path = (evt.composedPath && evt.composedPath()) || evt.path
const target = evt.target
if (path != null) {
return path.indexOf(window) < 0 ? path.concat(window) : path
}
if (target === window) {
return [window]
}
function getParents(node, memo) {
memo = memo || []
const parentNode = node.parentNode
if (!parentNode) {
return memo
} else {
return getParents(parentNode, memo.concat(parentNode))
}
}
return [target].concat(getParents(target), window)
},
//
_filterFun(value, data, node) {
if (!value) return true
return data[this.propsLabel].indexOf(value) !== -1
},
//
_treeNodeClickFun(data, node, vm) {
const { multiple } = this.selectParams
const { clickParent } = this.treeParams
const checkStrictly = this.treeParams['check-strictly']
const { propsValue, propsChildren, propsDisabled } = this
const children = data[propsChildren] || []
if (data[propsDisabled]) {
//
return
}
if (node.checked) {
const value = data[propsValue]
this.ids = this.ids.filter(id => id !== value)
if (!checkStrictly && children.length) {
children.forEach(item => {
this.ids = this.ids.filter(id => id !== item[propsValue])
})
}
} else {
if (!multiple) {
//
if (!clickParent) {
// ,
if (children.length === 0) {
this.ids = [data[propsValue]]
this.visible = false
} else {
//
return false
}
} else {
this.ids = [data[propsValue]]
this.visible = false
}
} else {
if (!clickParent && children.length === 0) {
//
this.ids.push(data[propsValue])
} else if (clickParent) {
//
this.ids.push(data[propsValue])
// push
if (!checkStrictly && children.length) {
children.forEach(item => {
this.ids.push(item[propsValue])
})
}
}
}
}
this._emitFun()
/*
点击节点对外抛出 `data, node, vm`<br>
`data:` 当前点击的节点数据<br>
`node:` 当前点击的node<br>
`vm:` 当前组件的vm
*/
this.$emit('node-click', data, node, vm)
},
//
_treeCheckFun(data, node, vm) {
this.ids = []
const { propsValue } = this
node.checkedNodes.forEach(item => {
this.ids.push(item[propsValue])
})
/*
点击复选框对外抛出 `data, node, vm`<br>
`data:` 当前点击的节点数据<br>
`node:` 当前点击的node<br>
`vm:` 当前组件的vm
*/
this.$emit('check', data, node, vm)
this._emitFun()
},
// tag
_selectRemoveTag(tag) {
const { data, propsValue, propsLabel, propsChildren } = this
each(
data,
item => {
const labels = this.showParent ? this.cascadeLabels(item) : item[propsLabel]
if (labels === tag) {
const value = item[propsValue]
this.ids = this.ids.filter(id => id !== value)
}
},
propsChildren
)
this.$refs.tree.setCheckedKeys(this.ids)
this.$emit('removeTag', this.ids, tag)
this._emitFun()
},
//
_selectClearFun() {
this.ids = []
const { multiple } = this.selectParams
// ``this.$emit('input', multiple ? [] : '');`
this.$emit('input', multiple ? [] : '')
// ``this.$emit('select-clear');`
this.$emit('select-clear')
this._updatePopoverLocationFun()
},
// id
_emitFun() {
const { multiple } = this.selectParams
this.$emit('input', multiple ? this.ids : this.ids.length > 0 ? this.ids[0] : '')
this._updatePopoverLocationFun()
},
//
_updateH() {
this.$nextTick(() => {
this.width = this.$refs.select.$el.getBoundingClientRect().width
})
},
// el
_popoverShowFun(val) {
this._updateH()
},
//
_popoverHideFun(e) {
const path = this._getEventPath(e)
const isInside = path.some(list => {
//
return list.className && typeof list.className === 'string' && list.className.indexOf('el-tree-select') !== -1
})
if (!isInside) {
this.visible = false
}
},
/**
* @vuese
* 树列表更新数据
* @arg Array
*/
treeDataUpdateFun(data) {
this.data = data
//
if (data.length > 0) {
setTimeout(() => {
this._setSelectNodeFun(this.ids)
}, 300)
}
},
/**
* @vuese
* 本地过滤方法
* @arg String
*/
filterFun(val) {
this.$refs.tree.filter(val)
}
}
}
</script>
<style>
.el-tree-select .select-option {
display: none !important;
}
[aria-disabled='true'] > .el-tree-node__content {
color: inherit !important;
background: transparent !important;
cursor: no-drop !important;
}
.el-tree-select-popper {
max-height: 400px;
overflow: auto;
}
.el-tree-select-popper.disabled {
display: none !important;
}
.el-tree-select-popper .el-button--small {
width: 25px !important;
min-width: 25px !important;
}
.el-tree-select-popper[x-placement^='bottom'] {
margin-top: 5px;
}
.mb10 {
margin-bottom: 10px;
}
.no-data {
height: 32px;
line-height: 32px;
font-size: 14px;
color: #cccccc;
text-align: center;
}
</style>

View File

@ -0,0 +1,78 @@
/*
* @moduleName:通用工具类
* @Author: dawdler
* @Date: 2019-01-09 15:30:18
* @LastModifiedBy: dawdler
* @LastEditTime: 2020-12-26 14:06:09
*/
export default {
getTreeData,
each
}
/*
each(arr, (item, children) => {
item.value = xx;
// 该item 包含children因此直接赋值,不需要单独处理children里面的值
});
* [_each description] 倒查展平数据回调返回回当前一条数据和子集
* @param {[Array]} data [description]
* @param {Function} callback [description]
* @param {String} childName[description]
* @return {[Array]} [description]
* 默认使用副本,在callback处理数据如果不使用副本那么需要重新对treeData赋值
treeData = each(treeData, (item, children) => {
item.value = xx;
});
*/
export function each(data, callback, childName = 'children') {
let current
let children
for (let i = 0, len = data.length; i < len; i++) {
current = data[i]
children = []
if (current[childName] && current[childName].length > 0) {
children = current[childName]
}
callback && callback(current, children)
if (children.length > 0) {
each(children, callback, childName)
}
}
}
/**
* @Author yihuang",
* @param data 数据
* @param id 要比对的名称
* @param val 要比对的值
* @param name 要返回的名称
* @param children 子集名称
* @param isRow 是否返回这一行的数据
* @ 迭代判断多层
* //=======================
* 返回这一条数据的中文名
* let name=utils.getTreeData(arr, 'flowId', item.decategoryId, 'name');
* //=======================
* 返回所有匹配的数据
* let arr=utils.getTreeData(arr, 'flowId', item.decategoryId, 'name','children',true);
*/
export function getTreeData(data, id = 'id', val = '', name = 'name', children = 'children', isRow = false) {
const arr = []
each(
data,
item => {
if (item[id] === val) {
arr.push(item)
}
},
children
)
return arr.length > 0 ? (isRow ? arr : arr[0][name]) : null
}
export function guid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = (Math.random() * 16) | 0
const v = c === 'x' ? r : (r & 0x3) | 0x8
return v.toString(16)
})
}

View File

@ -82,6 +82,7 @@ import CanvasOptBar from '@/components/canvas/components/Editor/CanvasOptBar'
import UserViewMobileDialog from '@/components/canvas/custom-component/UserViewMobileDialog'
import bus from '@/utils/bus'
import { buildFilterMap } from '@/utils/conditionUtil'
import { hasDataPermission } from '@/utils/permission'
export default {
components: { UserViewMobileDialog, ComponentWrapper, UserViewDialog, CanvasOptBar },
model: {
@ -176,7 +177,7 @@ export default {
showUnpublishedArea() {
// return this.panelInfo.status === 'unpublished'
if (this.mainActiveName === 'PanelMain' && this.activeTab === 'PanelList') {
return this.panelInfo.status === 'unpublished' && this.panelInfo.privileges.indexOf('manage') === -1
return this.panelInfo.status === 'unpublished' && !hasDataPermission('manage', this.panelInfo.privileges)
} else {
return this.panelInfo.status === 'unpublished'
}
@ -270,12 +271,15 @@ export default {
this._isMobile()
const _this = this
const erd = elementResizeDetectorMaker()
const canvasMain = document.getElementById('canvasInfoMain')
// div
erd.listenTo(document.getElementById('canvasInfoMain'), element => {
_this.$nextTick(() => {
_this.restore()
if (canvasMain) {
erd.listenTo(canvasMain, element => {
_this.$nextTick(() => {
_this.restore()
})
})
})
}
// div
const tempCanvas = document.getElementById('canvasInfoTemp')
if (tempCanvas) {

View File

@ -0,0 +1,332 @@
<template>
<el-tree-select
v-if="element.options!== null && element.options.attrs!==null && show"
ref="deSelectTree"
v-model="value"
popover-class="test-class-wrap"
:is-single="isSingle"
:data="datas"
:select-params="selectParams"
:tree-params="treeParams"
:filter-node-method="_filterFun"
:tree-render-fun="_renderFun"
@searchFun="_searchFun"
@node-click="changeNode"
@removeTag="changeNodeIds"
@check="changeCheckNode"
@select-clear="selectClear"
/>
</template>
<script>
import { mappingFieldValues, linkMappingFieldValues } from '@/api/dataset/dataset'
import bus from '@/utils/bus'
import { getLinkToken, getToken } from '@/utils/auth'
import ElTreeSelect from '@/components/ElTreeSelect'
export default {
components: { ElTreeSelect },
props: {
element: {
type: Object,
default: () => {}
},
inDraw: {
type: Boolean,
default: true
},
inScreen: {
type: Boolean,
required: false,
default: true
},
size: String
},
data() {
return {
showNumber: false,
selectOptionWidth: 0,
show: true,
datas: [],
value: this.isSingle ? '' : [],
selectParams: {
clearable: true,
placeholder: this.$t(this.element.options.attrs.placeholder)
},
treeParams: {
showParent: true,
clickParent: true,
filterable: true,
//
leafOnly: false,
includeHalfChecked: false,
'check-strictly': false,
'default-expand-all': false,
'expand-on-click-node': false,
'render-content': this._renderFun,
data: [],
props: {
children: 'children',
label: 'text',
rootId: 'root',
disabled: 'disabled',
parentId: 'pid',
value: 'id'
}
}
}
},
computed: {
operator() {
return this.element.options.attrs.multiple ? 'in' : 'eq'
},
defaultValueStr() {
if (!this.element || !this.element.options || !this.element.options.value) return ''
return this.element.options.value.toString()
},
viewIds() {
if (!this.element || !this.element.options || !this.element.options.attrs.viewIds) return ''
return this.element.options.attrs.viewIds.toString()
},
manualModify() {
return !!this.element.options.manualModify
},
panelInfo() {
return this.$store.state.panel.panelInfo
},
isSingle() {
return this.element.options.attrs.multiple
}
},
watch: {
'viewIds': function(value, old) {
if (typeof value === 'undefined' || value === old) return
this.setCondition()
},
'defaultValueStr': function(value, old) {
if (value === old) return
this.value = this.fillValueDerfault()
this.changeValue(value)
},
'element.options.attrs.fieldId': function(value, old) {
if (value === null || typeof value === 'undefined' || value === old) return
this.datas = []
let method = mappingFieldValues
const token = this.$store.getters.token || getToken()
const linkToken = this.$store.getters.linkToken || getLinkToken()
if (!token && linkToken) {
method = linkMappingFieldValues
}
const param = { fieldIds: this.element.options.attrs.fieldId.split(',') }
if (this.panelInfo.proxy) {
param.userId = this.panelInfo.proxy
}
this.element.options.attrs.fieldId &&
this.element.options.attrs.fieldId.length > 0 &&
method(param).then(res => {
this.datas = this.optionDatas(res.data)
this.$nextTick(() => {
this.$refs.deSelectTree && this.$refs.deSelectTree.treeDataUpdateFun(this.datas)
})
}) || (this.element.options.value = '')
},
'element.options.attrs.multiple': function(value, old) {
if (typeof old === 'undefined' || value === old) return
if (!this.inDraw) {
this.value = value ? [] : null
this.element.options.value = ''
}
this.show = false
this.$nextTick(() => {
this.show = true
})
}
},
created() {
this.initLoad()
},
mounted() {
bus.$on('onScroll', () => {
})
bus.$on('reset-default-value', id => {
if (this.inDraw && this.manualModify && this.element.id === id) {
this.value = this.fillValueDerfault()
this.changeValue(this.value)
}
})
},
methods: {
selectClear() {
this.changeValue(this.value)
},
changeNode(data, node) {
this.changeValue(this.value)
},
changeCheckNode(data, obj) {
const { checkedKeys } = obj
if (checkedKeys) this.value = checkedKeys
this.changeValue(this.value)
},
changeNodeIds(ids) {
this.value = ids
this.changeValue(this.value)
},
initLoad() {
this.value = this.fillValueDerfault()
this.datas = []
if (this.element.options.attrs.fieldId) {
let method = mappingFieldValues
const token = this.$store.getters.token || getToken()
const linkToken = this.$store.getters.linkToken || getLinkToken()
if (!token && linkToken) {
method = linkMappingFieldValues
}
method({ fieldIds: this.element.options.attrs.fieldId.split(',') }).then(res => {
this.datas = this.optionDatas(res.data)
this.$nextTick(() => {
this.$refs.deSelectTree && this.$refs.deSelectTree.treeDataUpdateFun(this.datas)
})
})
}
if (this.element.options.value) {
this.value = this.fillValueDerfault()
this.changeValue(this.value)
}
},
changeValue(value) {
if (!this.inDraw) {
if (value === null) {
this.element.options.value = ''
} else {
this.element.options.value = Array.isArray(value) ? value.join() : value
}
this.element.options.manualModify = false
} else {
this.element.options.manualModify = true
}
this.setCondition()
this.showNumber = false
this.$nextTick(() => {
if (!this.element.options.attrs.multiple || !this.$refs.deSelect || !this.$refs.deSelect.$refs.tags) {
return
}
const kids = this.$refs.deSelect.$refs.tags.children[0].children
let contentWidth = 0
kids.forEach(kid => {
contentWidth += kid.offsetWidth
})
this.showNumber = contentWidth > ((this.$refs.deSelectTree.$refs.tags.clientWidth - 30) * 0.9)
})
},
setCondition() {
const param = {
component: this.element,
value: this.formatFilterValue(),
operator: this.operator,
isTree: true
}
this.inDraw && this.$store.commit('addViewFilter', param)
},
formatFilterValue() {
const SEPARATOR = '-de-'
if (this.value === null) return []
if (Array.isArray(this.value)) {
const results = []
const duplicateMap = {}
this.value.forEach(item => {
const links = item.split(SEPARATOR)
let temp = ''
for (let index = 0; index < links.length; index++) {
const isLast = index === (links.length - 1)
const isFirst = index === 0
const node = links[index]
temp += ((isFirst ? '' : SEPARATOR) + node)
if (duplicateMap[temp] && !isLast) {
delete duplicateMap[temp]
}
}
duplicateMap[item] = true
})
for (const key in duplicateMap) {
if (Object.hasOwnProperty.call(duplicateMap, key) && duplicateMap[key]) {
const node = key.replaceAll(SEPARATOR, ',')
results.push(node)
}
}
return results
// return this.value
}
return this.value.split(',')
},
fillValueDerfault() {
const defaultV = this.element.options.value === null ? '' : this.element.options.value.toString()
if (this.element.options.attrs.multiple) {
if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '' || defaultV === '[object Object]') return []
return defaultV.split(',')
} else {
if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '' || defaultV === '[object Object]') return null
return defaultV.split(',')[0]
}
},
optionDatas(datas) {
if (!datas) return null
return datas.filter(item => !!item)
},
setOptionWidth(event) {
//
this.$nextTick(() => {
// this.selectOptionWidth = event.srcElement.offsetWidth + 'px'
this.selectOptionWidth = event.srcElement.parentElement.parentElement.offsetWidth + 'px'
})
},
/* 下面是树的渲染方法 */
_filterFun(value, data, node) {
if (!value) return true
return data.id.toString().indexOf(value.toString()) !== -1
},
//
_nodeClickFun(data, node, vm) {
console.log('this _nodeClickFun', this.value, data, node)
},
//
_searchFun(value) {
console.log(value, '<--_searchFun')
//
this.$refs.treeSelect.filterFun(value)
//
// this.$refs.treeSelect.treeDataUpdateFun(treeData);
},
// render
_renderFun(h, { node, data, store }) {
const { props, clickParent } = this.treeParams
return (
<span class={['custom-tree-node', !clickParent && data[props.children] && data[props.children].length ? 'disabled' : null]}>
<span>{node.label}</span>
</span>
)
}
}
}
</script>
<style lang="scss" scoped>
</style>

View File

@ -5,11 +5,12 @@
* viewIds 过滤视图范围
*/
export class Condition {
constructor(componentId, fieldId, operator, value, viewIds) {
constructor(componentId, fieldId, operator, value, viewIds, isTree) {
this.componentId = componentId
this.fieldId = fieldId
this.operator = operator || 'eq'
this.value = value
this.viewIds = viewIds
this.isTree = isTree || false
}
}

View File

@ -0,0 +1,108 @@
import { WidgetService } from '../service/WidgetService'
const leftPanel = {
icon: 'iconfont icon-xialashu',
label: 'detextselectTree.label',
defaultClass: 'text-filter'
}
const dialogPanel = {
options: {
attrs: {
multiple: false,
placeholder: 'detextselectTree.placeholder',
viewIds: [],
datas: [],
key: 'id',
label: 'text',
value: 'id',
fieldId: '',
dragItems: []
},
value: '',
manualModify: false
},
defaultClass: 'text-filter',
component: 'de-select-tree',
miniSizex: 1,
miniSizey: 1
}
const drawPanel = {
type: 'custom',
style: {
width: 300,
height: 90,
fontSize: 14,
fontWeight: 500,
lineHeight: '',
letterSpacing: 0,
textAlign: '',
color: '',
hPosition: 'left',
vPosition: 'center'
},
component: 'de-select-tree'
}
class TextSelectTreeServiceImpl extends WidgetService {
constructor(options = {}) {
Object.assign(options, { name: 'textSelectTreeWidget' })
super(options)
this.filterDialog = true
this.showSwitch = true
}
initLeftPanel() {
const value = JSON.parse(JSON.stringify(leftPanel))
return value
}
initFilterDialog() {
const value = JSON.parse(JSON.stringify(dialogPanel))
return value
}
initDrawPanel() {
const value = JSON.parse(JSON.stringify(drawPanel))
return value
}
filterFieldMethod(fields) {
return fields.filter(field => {
return field['deType'] === 0
})
}
optionDatas(datas) {
if (!datas) return null
return datas.filter(item => !!item).map(item => {
return {
id: item,
text: item
}
})
}
getParam(element) {
const value = this.fillValueDerfault(element)
const param = {
component: element,
value: !value ? [] : Array.isArray(value) ? value : value.toString().split(','),
operator: element.options.attrs.multiple ? 'in' : 'eq'
}
return param
}
fillValueDerfault(element) {
const defaultV = element.options.value === null ? '' : element.options.value.toString()
if (element.options.attrs.multiple) {
if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '' || defaultV === '[object Object]') return []
return defaultV.split(',')
} else {
if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '' || defaultV === '[object Object]') return null
return defaultV.split(',')[0]
}
}
}
const textSelectTreeServiceImpl = new TextSelectTreeServiceImpl()
export default textSelectTreeServiceImpl

View File

@ -1886,6 +1886,10 @@ export default {
label: 'Text selector',
placeholder: 'Please select'
},
detextselectTree: {
label: 'Tree selector',
placeholder: 'Please select'
},
detextgridselect: {
label: 'Text list',
placeholder: 'Please select'

View File

@ -1898,6 +1898,10 @@ export default {
label: '文本下拉',
placeholder: '請選擇'
},
detextselectTree: {
label: '下拉树',
placeholder: '請選擇'
},
detextgridselect: {
label: '文本列錶',
placeholder: '請選擇'

View File

@ -1331,7 +1331,7 @@ export default {
sql_ds_union_error: '直连模式下SQL数据集不支持关联',
api_data: 'API 数据集'
},
driver:{
driver: {
driver: '驱动',
please_choose_driver: '请选择驱动',
mgm: '驱动管理',
@ -1906,6 +1906,10 @@ export default {
label: '文本下拉',
placeholder: '请选择'
},
detextselectTree: {
label: '下拉树',
placeholder: '请选择'
},
detextgridselect: {
label: '文本列表',
placeholder: '请选择'

View File

@ -26,10 +26,10 @@ export const valueValid = condition => {
}
export const formatCondition = obj => {
const { component, value, operator } = obj
const { component, value, operator, isTree } = obj
const fieldId = component.options.attrs.fieldId
const viewIds = component.options.attrs.viewIds
const condition = new Condition(component.id, fieldId, operator, value, viewIds)
const condition = new Condition(component.id, fieldId, operator, value, viewIds, isTree)
return condition
}

View File

@ -468,7 +468,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position'
'position-v'
],
'tooltip-selector-ant-v': [
'show',
@ -540,7 +540,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position'
'position-v'
],
'tooltip-selector-ant-v': [
'show',
@ -605,7 +605,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position'
'position-v'
],
'tooltip-selector-ant-v': [
'show',
@ -670,7 +670,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position'
'position-h'
],
'tooltip-selector-ant-v': [
'show',
@ -743,7 +743,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position'
'position-h'
],
'tooltip-selector-ant-v': [
'show',
@ -815,7 +815,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position'
'position-pie'
],
'tooltip-selector-ant-v': [
'show',
@ -866,7 +866,8 @@ export const TYPE_CONFIGS = [
'label-selector-ant-v': [
'show',
'fontSize',
'color'
'color',
'position-pie'
],
'tooltip-selector-ant-v': [
'show',
@ -919,7 +920,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position'
'position-v'
],
'tooltip-selector-ant-v': [
'show',
@ -1113,7 +1114,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position'
'position-h'
],
'tooltip-selector-ant-v': [
'show',
@ -1308,7 +1309,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position',
'position-v',
'formatter',
'gaugeFormatter'
],
@ -1512,7 +1513,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position',
'position-v',
'formatter'
],
'tooltip-selector': [
@ -1594,7 +1595,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position',
'position-v',
'formatter'
],
'tooltip-selector': [
@ -1668,7 +1669,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position',
'position-v',
'formatter'
],
'tooltip-selector': [
@ -1742,7 +1743,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position',
'position-h',
'formatter'
],
'tooltip-selector': [
@ -1817,7 +1818,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position',
'position-h',
'formatter'
],
'tooltip-selector': [
@ -1892,7 +1893,7 @@ export const TYPE_CONFIGS = [
'labelLine',
'fontSize',
'color',
'position',
'position-v',
'formatter'
],
'tooltip-selector': [
@ -1951,7 +1952,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position',
'position-pie',
'formatter'
],
'tooltip-selector': [
@ -2009,7 +2010,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position',
'position-v',
'formatter'
],
'tooltip-selector': [
@ -2123,7 +2124,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position',
'position-v',
'formatter'
],
'tooltip-selector': [
@ -2193,7 +2194,7 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position',
'position-h',
'formatter'
],
'tooltip-selector': [
@ -2249,7 +2250,6 @@ export const TYPE_CONFIGS = [
'show',
'fontSize',
'color',
'position',
'formatter'
],
'tooltip-selector': [

View File

@ -17,9 +17,19 @@
<el-form-item v-show="showProperty('color')" :label="$t('chart.text_color')" class="form-item">
<el-color-picker v-model="labelForm.color" class="color-picker-style" :predefine="predefineColors" @change="changeLabelAttr('color')" />
</el-form-item>
<el-form-item v-show="showProperty('position') && chart.type !== 'map'" :label="$t('chart.label_position')" class="form-item">
<el-form-item v-show="showProperty('position-pie') " :label="$t('chart.label_position')" class="form-item">
<el-select v-model="labelForm.position" :placeholder="$t('chart.label_position')" @change="changeLabelAttr('position')">
<el-option v-for="option in labelPosition" :key="option.value" :label="option.name" :value="option.value" />
<el-option v-for="option in labelPositionPie" :key="option.value" :label="option.name" :value="option.value" />
</el-select>
</el-form-item>
<el-form-item v-show="showProperty('position-h') " :label="$t('chart.label_position')" class="form-item">
<el-select v-model="labelForm.position" :placeholder="$t('chart.label_position')" @change="changeLabelAttr('position')">
<el-option v-for="option in labelPositionH" :key="option.value" :label="option.name" :value="option.value" />
</el-select>
</el-form-item>
<el-form-item v-show="showProperty('position-v') " :label="$t('chart.label_position')" class="form-item">
<el-select v-model="labelForm.position" :placeholder="$t('chart.label_position')" @change="changeLabelAttr('position')">
<el-option v-for="option in labelPositionV" :key="option.value" :label="option.name" :value="option.value" />
</el-select>
</el-form-item>
<el-form-item v-show="showProperty('formatter')" class="form-item">

View File

@ -14,9 +14,19 @@
<el-form-item v-show="showProperty('color')" :label="$t('chart.text_color')" class="form-item">
<el-color-picker v-model="labelForm.color" class="color-picker-style" :predefine="predefineColors" @change="changeLabelAttr('color')" />
</el-form-item>
<el-form-item v-show="showProperty('position')" :label="$t('chart.label_position')" class="form-item">
<el-form-item v-show="showProperty('position-v')" :label="$t('chart.label_position')" class="form-item">
<el-select v-model="labelForm.position" :placeholder="$t('chart.label_position')" @change="changeLabelAttr('position')">
<el-option v-for="option in labelPosition" :key="option.value" :label="option.name" :value="option.value" />
<el-option v-for="option in labelPositionV" :key="option.value" :label="option.name" :value="option.value" />
</el-select>
</el-form-item>
<el-form-item v-show="showProperty('position-pie')" :label="$t('chart.label_position')" class="form-item">
<el-select v-model="labelForm.position" :placeholder="$t('chart.label_position')" @change="changeLabelAttr('position')">
<el-option v-for="option in labelPositionPie" :key="option.value" :label="option.name" :value="option.value" />
</el-select>
</el-form-item>
<el-form-item v-show="showProperty('position-h')" :label="$t('chart.label_position')" class="form-item">
<el-select v-model="labelForm.position" :placeholder="$t('chart.label_position')" @change="changeLabelAttr('position')">
<el-option v-for="option in labelPositionH" :key="option.value" :label="option.name" :value="option.value" />
</el-select>
</el-form-item>
</div>

View File

@ -5,6 +5,7 @@
</el-row>
<chart-style
v-if="mixProperties&&batchOptChartInfo"
class="chart-style-main"
:param="param"
:view="batchOptChartInfo"
:chart="batchOptChartInfo"
@ -81,10 +82,10 @@ export default {
this.batchOptChange('customStyle', 'xAxis', val)
},
onChangeYAxisForm(val) {
this.batchOptChange('customStyle', 'xAxis', val)
this.batchOptChange('customStyle', 'yAxis', val)
},
onChangeYAxisExtForm(val) {
this.batchOptChange('customStyle', 'yAxis', val)
this.batchOptChange('customStyle', 'yAxisExt', val)
},
onChangeSplitForm(val) {
this.batchOptChange('customStyle', 'split', val)
@ -130,6 +131,10 @@ export default {
border-left: 1px solid #E6E6E6
}
.chart-style-main{
height: calc(100% - 40px)!important;
}
.view-title-name {
display: -moz-inline-box;
display: inline-block;

View File

@ -67,7 +67,7 @@ export default {
showDetails(params) {
this.$store.commit('initCurMultiplexingComponents')
const _this = this
_this.selectedPanel = params
_this.selectedPanel = null
if (params.showType === 'panel') {
_this.showPosition = 'multiplexing'
_this.panelLoading = true
@ -76,6 +76,7 @@ export default {
panelDataPrepare(JSON.parse(response.data.panelData), JSON.parse(response.data.panelStyle), function(rsp) {
_this.componentData = rsp.componentData
_this.canvasStyleData = rsp.componentStyle
_this.selectedPanel = params
})
})
} else if (params.showType === 'view') {
@ -95,6 +96,7 @@ export default {
}
_this.$nextTick(() => {
_this.componentData.push(userView)
_this.selectedPanel = params
})
}
}

View File

@ -55,7 +55,8 @@ export default {
'文本过滤组件': [
'textSelectWidget',
'textSelectGridWidget',
'textInputWidget'
'textInputWidget',
'textSelectTreeWidget'
],
'数字过滤组件': [
'numberSelectWidget',

View File

@ -0,0 +1,150 @@
<!--
* @Author: dawdler
* @Date: 2020-12-26 11:52:05
* @Description: demo
* @LastModifiedBy: dawdler
-->
<template>
<el-tree-select
ref="treeSelect"
v-model="values"
popover-class="test-class-wrap"
:styles="styles"
:select-params="selectParams"
:tree-params="treeParams"
:filter-node-method="_filterFun"
:tree-render-fun="_renderFun"
@searchFun="_searchFun"
/>
</template>
<script>
import ElTreeSelect from '@/components/ElTreeSelect'
export default {
name: 'MyTreeSelect',
components: { ElTreeSelect },
props: {
params: Object,
isSingle: {
type: Boolean,
default() {
return false
}
}
},
data() {
return {
styles: {
width: '300px'
},
// value
values: this.isSingle ? '' : [],
selectParams: {
clearable: true,
placeholder: '请输入内容'
},
treeParams: {
clickParent: false,
filterable: true,
//
leafOnly: false,
includeHalfChecked: false,
'check-strictly': false,
'default-expand-all': true,
'expand-on-click-node': false,
'render-content': this._renderFun,
data: [],
props: {
children: 'children',
label: 'name',
rootId: '0',
disabled: 'disabled',
parentId: 'parentId',
value: 'id'
},
...this.params
}
}
},
watch: {},
created() {},
mounted() {
//
const data = []
const { label, children, parentId, value, rootId } = this.treeParams.props
for (let i = 0; i < 5; i++) {
const rootNode = {
[label]: `节点${i}`,
[parentId]: rootId,
[value]: i,
[children]: []
}
for (let a = 0; a < 5; a++) {
const subId = `${rootNode[value]}_${a}`
const subNode = {
[label]: `子节点${subId}`,
[parentId]: rootNode[value],
[value]: subId,
[children]: []
}
for (let b = 0; b < 5; b++) {
const endId = `${subId}_${b}`
const endNode = {
[label]: `末级节点${endId}`,
[parentId]: subNode[value],
[value]: endId,
[children]: []
}
subNode[children].push(endNode)
}
rootNode[children].push(subNode)
}
data.push(rootNode)
}
const myNode = {
[label]: '测试超长节点啊啊啊测试超长节点啊啊啊测试超长节点啊啊啊测试超长节点啊啊啊测试超长节点啊啊啊测试超长节点啊啊啊',
[parentId]: rootId,
[value]: 1000,
[children]: []
}
data.push(myNode)
this.$nextTick(() => {
this.$refs.treeSelect.treeDataUpdateFun(data)
})
},
methods: {
_filterFun(value, data, node) {
if (!value) return true
return data.id.toString().indexOf(value.toString()) !== -1
},
//
_nodeClickFun(data, node, vm) {
console.log('this _nodeClickFun', this.values, data, node)
},
//
_searchFun(value) {
console.log(value, '<--_searchFun')
//
this.$refs.treeSelect.filterFun(value)
//
// this.$refs.treeSelect.treeDataUpdateFun(treeData);
},
// render
_renderFun(h, { node, data, store }) {
const { props, clickParent } = this.treeParams
return (
<span class={['custom-tree-node', !clickParent && data[props.children] && data[props.children].length ? 'disabled' : null]}>
<span>{node.label}</span>
</span>
)
}
}
}
</script>
<style lang="less">
.disabled {
cursor: no-drop;
}
.custom-tree-node {
width: calc(100% - 40px);
}
</style>

View File

@ -0,0 +1,69 @@
<!--
* @moduleName: 测试el-tree-select
* @Author: dawdler
* @Date: 2018-12-19 14:03:03
* @LastModifiedBy: dawdler
-->
<template>
<div id="app111">
<el-form label-width="120px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="单选">
<MyTree :is-single="true" :params="{ clickParent: true, showParent: true }" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="多选">
<MyTree :params="{ clickParent: true, showParent: true }" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="弹框关闭调试">
<el-select v-model="test" multiple placeholder="请选择" @change="_selectChange">
<el-option v-for="item in testData" :key="item" :label="item" :value="item" />
</el-select>
<div>
测试焦点触发
<svg>
<circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red" />
</svg>
</div>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
</template>
<script>
import MyTree from './MyTree'
export default {
name: 'App111',
components: { MyTree },
data() {
return {
test: '',
testData: ['test1', 'test2']
}
},
created() {},
mounted() {},
methods: {
//
_selectChange(val) {
console.log(val, '<-select change')
}
}
}
</script>
<style lang="less">
#app111 {
display: flex;
justify-content: space-between;
width: 100%;
}
.el-select {
width: 300px;
}
</style>