forked from github/dataease
Merge branch 'dev' into pr@dv@feat_group_line
This commit is contained in:
commit
017bb8e252
@ -18,12 +18,13 @@ public class VAuthModelDTO extends VAuthModelWithBLOBs implements ITreeBase<VAut
|
||||
|
||||
private List<VAuthModelDTO> children;
|
||||
|
||||
private long allLeafs = 0l;
|
||||
private long allLeafs = 0L;
|
||||
|
||||
private String innerId;
|
||||
|
||||
private Boolean isPlugin = false;
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return this.getName();
|
||||
}
|
||||
|
@ -45,13 +45,10 @@ public class VAuthModelService {
|
||||
return result;
|
||||
}
|
||||
if (request.getPrivileges() != null) {
|
||||
result = result.stream().filter(vAuthModelDTO -> {
|
||||
if (vAuthModelDTO.getNodeType().equalsIgnoreCase("spine") || (vAuthModelDTO.getNodeType().equalsIgnoreCase("leaf") && vAuthModelDTO.getPrivileges() != null && vAuthModelDTO.getPrivileges().contains(request.getPrivileges()))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
result = result.stream().filter(vAuthModelDTO -> "spine".equalsIgnoreCase(vAuthModelDTO.getNodeType())
|
||||
|| ("leaf".equalsIgnoreCase(vAuthModelDTO.getNodeType())
|
||||
&& vAuthModelDTO.getPrivileges() != null
|
||||
&& vAuthModelDTO.getPrivileges().contains(request.getPrivileges()))).collect(Collectors.toList());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -60,10 +57,10 @@ public class VAuthModelService {
|
||||
if (CollectionUtils.isEmpty(result)) {
|
||||
return;
|
||||
}
|
||||
Iterator iterator = result.listIterator();
|
||||
Iterator<VAuthModelDTO> iterator = result.listIterator();
|
||||
while (iterator.hasNext()) {
|
||||
VAuthModelDTO tmp = (VAuthModelDTO) iterator.next();
|
||||
if (tmp.getNodeType().equalsIgnoreCase("spine") && tmp.getAllLeafs() == 0) {
|
||||
VAuthModelDTO tmp = iterator.next();
|
||||
if ("spine".equalsIgnoreCase(tmp.getNodeType()) && tmp.getAllLeafs() == 0) {
|
||||
iterator.remove();
|
||||
} else {
|
||||
removeEmptyDir(tmp.getChildren());
|
||||
@ -77,9 +74,9 @@ public class VAuthModelService {
|
||||
vAuthModelDTO.setAllLeafs(0);
|
||||
continue;
|
||||
}
|
||||
long leafs = 0l;
|
||||
long leafs = 0L;
|
||||
for (VAuthModelDTO child : vAuthModelDTO.getChildren()) {
|
||||
if (child.getNodeType().equalsIgnoreCase("leaf")) {
|
||||
if ("leaf".equalsIgnoreCase(child.getNodeType())) {
|
||||
leafs = leafs + 1;
|
||||
} else {
|
||||
leafs = +leafs + getLeafs(child);
|
||||
@ -90,13 +87,13 @@ public class VAuthModelService {
|
||||
}
|
||||
|
||||
private long getLeafs(VAuthModelDTO child) {
|
||||
long leafs = 0l;
|
||||
long leafs = 0L;
|
||||
if (CollectionUtils.isEmpty(child.getChildren())) {
|
||||
child.setAllLeafs(0);
|
||||
return leafs;
|
||||
}
|
||||
for (VAuthModelDTO childChild : child.getChildren()) {
|
||||
if (childChild.getNodeType().equalsIgnoreCase("leaf")) {
|
||||
if ("leaf".equalsIgnoreCase(childChild.getNodeType())) {
|
||||
leafs = leafs + 1;
|
||||
} else {
|
||||
leafs = +leafs + getLeafs(childChild);
|
||||
|
@ -149,7 +149,7 @@ public class DataSetTableService {
|
||||
@Value("${upload.file.path}")
|
||||
private String path;
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ClassloaderResponsity.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(ClassloaderResponsity.class);
|
||||
|
||||
@DeCleaner(value = DePermissionType.DATASET, key = "sceneId")
|
||||
public List<DatasetTable> batchInsert(List<DataSetTableRequest> datasetTable) throws Exception {
|
||||
@ -185,7 +185,7 @@ public class DataSetTableService {
|
||||
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
@DeCleaner(value = DePermissionType.DATASET, key = "sceneId")
|
||||
public List<DatasetTable> saveExcel(DataSetTableRequest datasetTable) throws Exception {
|
||||
public List<DatasetTable> saveExcel(DataSetTableRequest datasetTable) {
|
||||
List<String> datasetIdList = new ArrayList<>();
|
||||
|
||||
if (StringUtils.isEmpty(datasetTable.getId())) {
|
||||
@ -234,10 +234,9 @@ public class DataSetTableService {
|
||||
list.add(sheetTable);
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.CREATE, SysLogConstants.SOURCE_TYPE.DATASET, datasetTable.getId(), datasetTable.getSceneId(), null, null);
|
||||
}
|
||||
datasetIdList.forEach(datasetId -> {
|
||||
commonThreadPool.addTask(() -> extractDataService.extractExcelData(datasetId, "all_scope", "初始导入",
|
||||
null, datasetIdList));
|
||||
});
|
||||
datasetIdList.forEach(datasetId -> commonThreadPool.addTask(() ->
|
||||
extractDataService.extractExcelData(datasetId, "all_scope", "初始导入",
|
||||
null, datasetIdList)));
|
||||
} else {
|
||||
for (ExcelSheetData sheet : datasetTable.getSheets()) {
|
||||
String[] fieldArray = sheet.getFields().stream().map(TableField::getFieldName)
|
||||
@ -269,10 +268,9 @@ public class DataSetTableService {
|
||||
list.add(sheetTable);
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFY, SysLogConstants.SOURCE_TYPE.DATASET, datasetTable.getId(), datasetTable.getSceneId(), null, null);
|
||||
}
|
||||
datasetIdList.forEach(datasetId -> {
|
||||
commonThreadPool.addTask(() -> extractDataService.extractExcelData(datasetId, "all_scope", "初始导入",
|
||||
null, datasetIdList));
|
||||
});
|
||||
datasetIdList.forEach(datasetId -> commonThreadPool.addTask(() ->
|
||||
extractDataService.extractExcelData(datasetId, "all_scope", "初始导入",
|
||||
null, datasetIdList)));
|
||||
}
|
||||
|
||||
return list;
|
||||
@ -303,15 +301,15 @@ public class DataSetTableService {
|
||||
DataTableInfoDTO info = new DataTableInfoDTO();
|
||||
info.setExcelSheetDataList(excelSheetDataList);
|
||||
datasetTable.setInfo(new Gson().toJson(info));
|
||||
int update = datasetTableMapper.updateByPrimaryKeySelective(datasetTable);
|
||||
datasetTableMapper.updateByPrimaryKeySelective(datasetTable);
|
||||
// 替換時,先不刪除旧字段;同步成功后再删除
|
||||
if (datasetTable.getEditType() == 0) {
|
||||
commonThreadPool.addTask(() -> extractDataService.extractExcelData(datasetTable.getId(), "all_scope", "替换",
|
||||
saveExcelTableField(datasetTable.getId(), datasetTable.getSheets().get(0).getFields(), false),
|
||||
Arrays.asList(datasetTable.getId())));
|
||||
Collections.singletonList(datasetTable.getId())));
|
||||
} else if (datasetTable.getEditType() == 1) {
|
||||
commonThreadPool.addTask(() -> extractDataService.extractExcelData(datasetTable.getId(), "add_scope", "追加",
|
||||
null, Arrays.asList(datasetTable.getId())));
|
||||
null, Collections.singletonList(datasetTable.getId())));
|
||||
}
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFY, SysLogConstants.SOURCE_TYPE.DATASET, datasetTable.getId(), datasetTable.getSceneId(), null, null);
|
||||
return Collections.singletonList(datasetTable);
|
||||
@ -362,12 +360,12 @@ public class DataSetTableService {
|
||||
return datasetTable;
|
||||
}
|
||||
|
||||
public void alter(DataSetTableRequest request) throws Exception {
|
||||
public void alter(DataSetTableRequest request) {
|
||||
checkName(request);
|
||||
datasetTableMapper.updateByPrimaryKeySelective(request);
|
||||
}
|
||||
|
||||
public void delete(String id) throws Exception {
|
||||
public void delete(String id) {
|
||||
DatasetTable table = datasetTableMapper.selectByPrimaryKey(id);
|
||||
SysLogDTO sysLogDTO = DeLogUtils.buildLog(SysLogConstants.OPERATE_TYPE.DELETE, SysLogConstants.SOURCE_TYPE.DATASET, table.getId(), table.getSceneId(), null, null);
|
||||
datasetTableMapper.deleteByPrimaryKey(id);
|
||||
@ -489,9 +487,8 @@ public class DataSetTableService {
|
||||
List<DataSetTableDTO> res = new ArrayList<>();
|
||||
Map<String, DataSetTableDTO> map = new TreeMap<>();
|
||||
group.forEach(ele -> map.put(ele.getId(), ele));
|
||||
Iterator<Map.Entry<String, DataSetTableDTO>> iterator = map.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
res.add(iterator.next().getValue());
|
||||
for (Map.Entry<String, DataSetTableDTO> stringDataSetTableDTOEntry : map.entrySet()) {
|
||||
res.add(stringDataSetTableDTOEntry.getValue());
|
||||
}
|
||||
res.sort(Comparator.comparing(DatasetTable::getName));
|
||||
res.addAll(ds);
|
||||
@ -521,8 +518,7 @@ public class DataSetTableService {
|
||||
return datasourceProvider.getTableFields(datasourceRequest);
|
||||
}
|
||||
|
||||
public Map<String, List<DatasetTableField>> getFieldsFromDE(DataSetTableRequest dataSetTableRequest)
|
||||
throws Exception {
|
||||
public Map<String, List<DatasetTableField>> getFieldsFromDE(DataSetTableRequest dataSetTableRequest) {
|
||||
DatasetTableField datasetTableField = DatasetTableField.builder().build();
|
||||
datasetTableField.setTableId(dataSetTableRequest.getId());
|
||||
datasetTableField.setChecked(Boolean.TRUE);
|
||||
@ -1015,15 +1011,11 @@ public class DataSetTableService {
|
||||
break;
|
||||
case "TEXT":
|
||||
sqlVariableDetails = sqlVariableDetails.stream().filter(item -> item.getType().get(0).contains("TEXT")).collect(Collectors.toList());
|
||||
sqlVariableDetails.forEach(item -> {
|
||||
item.setAlias(item.getVariableName());
|
||||
});
|
||||
sqlVariableDetails.forEach(item -> item.setAlias(item.getVariableName()));
|
||||
break;
|
||||
case "NUM":
|
||||
sqlVariableDetails = sqlVariableDetails.stream().filter(item -> item.getType().get(0).contains("LONG") || item.getType().get(0).contains("DOUBLE")).collect(Collectors.toList());
|
||||
sqlVariableDetails.forEach(item -> {
|
||||
item.setAlias(item.getVariableName());
|
||||
});
|
||||
sqlVariableDetails.forEach(item -> item.setAlias(item.getVariableName()));
|
||||
break;
|
||||
}
|
||||
return sqlVariableDetails;
|
||||
@ -1087,15 +1079,15 @@ public class DataSetTableService {
|
||||
if (select.getSelectBody() instanceof PlainSelect) {
|
||||
return handlePlainSelect((PlainSelect) select.getSelectBody(), select, dsType);
|
||||
} else {
|
||||
String result = "";
|
||||
StringBuilder result = new StringBuilder();
|
||||
SetOperationList setOperationList = (SetOperationList) select.getSelectBody();
|
||||
for (int i = 0; i < setOperationList.getSelects().size(); i++) {
|
||||
result = result + handlePlainSelect((PlainSelect) setOperationList.getSelects().get(i), null, dsType);
|
||||
result.append(handlePlainSelect((PlainSelect) setOperationList.getSelects().get(i), null, dsType));
|
||||
if (i < setOperationList.getSelects().size() - 1) {
|
||||
result = result + " " + setOperationList.getOperations().get(i).toString() + " ";
|
||||
result.append(" ").append(setOperationList.getOperations().get(i).toString()).append(" ");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1140,14 +1132,14 @@ public class DataSetTableService {
|
||||
builder.append(" ");
|
||||
for (Iterator<WithItem> iter = select.getWithItemsList().iterator(); iter.hasNext(); ) {
|
||||
WithItem withItem = iter.next();
|
||||
builder.append(withItem.getName() + " AS ( " + removeVariables(withItem.getSubSelect().toString(), dsType) + " ) ");
|
||||
builder.append(withItem.getName()).append(" AS ( ").append(removeVariables(withItem.getSubSelect().toString(), dsType)).append(" ) ");
|
||||
if (iter.hasNext()) {
|
||||
builder.append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
builder.append(" " + plainSelect);
|
||||
builder.append(" ").append(plainSelect);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@ -1230,7 +1222,7 @@ public class DataSetTableService {
|
||||
String sqlAsTable = qp.createSQLPreview(sql, null);
|
||||
datasourceRequest.setQuery(sqlAsTable);
|
||||
|
||||
Map<String, List> result = new HashMap<>();
|
||||
Map<String, List> result;
|
||||
try {
|
||||
datasetSqlLog.setStartTime(System.currentTimeMillis());
|
||||
result = datasourceProvider.fetchResultAndField(datasourceRequest);
|
||||
@ -1275,7 +1267,7 @@ public class DataSetTableService {
|
||||
|
||||
public Map<String, Object> getUnionPreview(DataSetTableRequest dataSetTableRequest) throws Exception {
|
||||
DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class);
|
||||
Map<String, Object> sqlMap = new HashMap<>();
|
||||
Map<String, Object> sqlMap;
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
Datasource ds;
|
||||
if (dataSetTableRequest.getMode() == 0) {
|
||||
@ -1289,7 +1281,6 @@ public class DataSetTableService {
|
||||
}
|
||||
String sql = (String) sqlMap.get("sql");
|
||||
List<DatasetTableField> fieldList = (List<DatasetTableField>) sqlMap.get("field");
|
||||
List<UnionParamDTO> join = (List<UnionParamDTO>) sqlMap.get("join");
|
||||
|
||||
Map<String, Object> res = new HashMap<>();
|
||||
// 处理结果
|
||||
@ -1423,9 +1414,7 @@ public class DataSetTableService {
|
||||
DataTableInfoCustomUnion first = dataTableInfoDTO.getList().get(0);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
StringBuilder field = new StringBuilder();
|
||||
Iterator<Map.Entry<String, String[]>> iterator = customInfo.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, String[]> next = iterator.next();
|
||||
for (Map.Entry<String, String[]> next : customInfo.entrySet()) {
|
||||
field.append(StringUtils.join(next.getValue(), ",")).append(",");
|
||||
}
|
||||
String f = field.substring(0, field.length() - 1);
|
||||
@ -1493,9 +1482,7 @@ public class DataSetTableService {
|
||||
String tableName = new Gson().fromJson(table.getInfo(), DataTableInfoDTO.class).getTable();
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
StringBuilder field = new StringBuilder();
|
||||
Iterator<Map.Entry<String, String[]>> iterator = customInfo.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, String[]> next = iterator.next();
|
||||
for (Map.Entry<String, String[]> next : customInfo.entrySet()) {
|
||||
field.append(StringUtils.join(next.getValue(), ",")).append(",");
|
||||
}
|
||||
String f = field.substring(0, field.length() - 1);
|
||||
@ -1601,9 +1588,7 @@ public class DataSetTableService {
|
||||
if (CollectionUtils.isNotEmpty(unionList)) {
|
||||
// field
|
||||
StringBuilder field = new StringBuilder();
|
||||
Iterator<Map.Entry<String, String[]>> iterator = checkedInfo.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, String[]> next = iterator.next();
|
||||
for (Map.Entry<String, String[]> next : checkedInfo.entrySet()) {
|
||||
field.append(StringUtils.join(next.getValue(), ",")).append(",");
|
||||
}
|
||||
String f = subPrefixSuffixChar(field.toString());
|
||||
@ -1664,8 +1649,7 @@ public class DataSetTableService {
|
||||
// 递归计算出所有子级的checkedFields和unionParam
|
||||
private void getUnionSQLDorisJoin(List<UnionDTO> childrenDs, Map<String, String[]> checkedInfo,
|
||||
List<UnionParamDTO> unionList, List<DatasetTableField> checkedFields) {
|
||||
for (int i = 0; i < childrenDs.size(); i++) {
|
||||
UnionDTO unionDTO = childrenDs.get(i);
|
||||
for (UnionDTO unionDTO : childrenDs) {
|
||||
String tableId = unionDTO.getCurrentDs().getId();
|
||||
String table = TableUtils.tableName(tableId);
|
||||
DatasetTable datasetTable = datasetTableMapper.selectByPrimaryKey(tableId);
|
||||
@ -1752,9 +1736,7 @@ public class DataSetTableService {
|
||||
if (CollectionUtils.isNotEmpty(unionList)) {
|
||||
// field
|
||||
StringBuilder field = new StringBuilder();
|
||||
Iterator<Map.Entry<String, String[]>> iterator = checkedInfo.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, String[]> next = iterator.next();
|
||||
for (Map.Entry<String, String[]> next : checkedInfo.entrySet()) {
|
||||
field.append(StringUtils.join(next.getValue(), ",")).append(",");
|
||||
}
|
||||
String f = subPrefixSuffixChar(field.toString());
|
||||
@ -1825,9 +1807,7 @@ public class DataSetTableService {
|
||||
// 递归计算出所有子级的checkedFields和unionParam
|
||||
private void getUnionSQLDatasourceJoin(List<UnionDTO> childrenDs, Map<String, String[]> checkedInfo,
|
||||
List<UnionParamDTO> unionList, String keyword, List<DatasetTableField> checkedFields) {
|
||||
for (int i = 0; i < childrenDs.size(); i++) {
|
||||
UnionDTO unionDTO = childrenDs.get(i);
|
||||
|
||||
for (UnionDTO unionDTO : childrenDs) {
|
||||
DatasetTable datasetTable = datasetTableMapper.selectByPrimaryKey(unionDTO.getCurrentDs().getId());
|
||||
String tableId = unionDTO.getCurrentDs().getId();
|
||||
if (ObjectUtils.isEmpty(datasetTable)) {
|
||||
@ -1976,7 +1956,7 @@ public class DataSetTableService {
|
||||
Map<String, Object> sqlMap = getUnionSQLDoris(dataTableInfoDTO);
|
||||
String sql = (String) sqlMap.get("sql");
|
||||
List<DatasetTableField> fieldList = (List<DatasetTableField>) sqlMap.get("field");
|
||||
List<UnionParamDTO> join = (List<UnionParamDTO>) sqlMap.get("join");
|
||||
|
||||
|
||||
// custom 创建doris视图
|
||||
createDorisView(TableUtils.tableName(datasetTable.getId()), sql);
|
||||
@ -2003,7 +1983,7 @@ public class DataSetTableService {
|
||||
Map<String, Object> sqlMap = getUnionSQLDatasource(dt, ds);
|
||||
String sql = (String) sqlMap.get("sql");
|
||||
List<DatasetTableField> fieldList = (List<DatasetTableField>) sqlMap.get("field");
|
||||
List<UnionParamDTO> join = (List<UnionParamDTO>) sqlMap.get("join");
|
||||
|
||||
|
||||
datasourceRequest.setQuery(sql);
|
||||
fields = datasourceProvider.fetchResultField(datasourceRequest);
|
||||
@ -2157,16 +2137,15 @@ public class DataSetTableService {
|
||||
private void checkColumes(DatasetTableIncrementalConfig datasetTableIncrementalConfig) throws Exception {
|
||||
DatasetTable datasetTable = datasetTableMapper.selectByPrimaryKey(datasetTableIncrementalConfig.getTableId());
|
||||
List<DatasetTableField> datasetTableFields = dataSetTableFieldsService.getFieldsByTableId(datasetTable.getId())
|
||||
.stream().filter(datasetTableField -> datasetTableField.getExtField() == 0).collect(Collectors.toList());
|
||||
datasetTableFields.sort((o1, o2) -> {
|
||||
if (o1.getColumnIndex() == null) {
|
||||
return -1;
|
||||
}
|
||||
if (o2.getColumnIndex() == null) {
|
||||
return 1;
|
||||
}
|
||||
return o1.getColumnIndex().compareTo(o2.getColumnIndex());
|
||||
});
|
||||
.stream().filter(datasetTableField -> datasetTableField.getExtField() == 0).sorted((o1, o2) -> {
|
||||
if (o1.getColumnIndex() == null) {
|
||||
return -1;
|
||||
}
|
||||
if (o2.getColumnIndex() == null) {
|
||||
return 1;
|
||||
}
|
||||
return o1.getColumnIndex().compareTo(o2.getColumnIndex());
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
List<String> originNameFields = datasetTableFields.stream().map(DatasetTableField::getOriginName)
|
||||
.collect(Collectors.toList());
|
||||
@ -2184,9 +2163,7 @@ public class DataSetTableService {
|
||||
List<String> sqlFields = new ArrayList<>();
|
||||
try {
|
||||
datasourceProvider.fetchResultField(datasourceRequest).stream().map(TableField::getFieldName)
|
||||
.forEach(field -> {
|
||||
sqlFields.add(field);
|
||||
});
|
||||
.forEach(sqlFields::add);
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(Translator.get("i18n_check_sql_error") + e.getMessage());
|
||||
}
|
||||
@ -2204,7 +2181,7 @@ public class DataSetTableService {
|
||||
List<String> sqlFields = new ArrayList<>();
|
||||
try {
|
||||
datasourceProvider.fetchResultField(datasourceRequest).stream().map(TableField::getFieldName)
|
||||
.forEach(field -> sqlFields.add(field));
|
||||
.forEach(sqlFields::add);
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(Translator.get("i18n_check_sql_error") + e.getMessage());
|
||||
}
|
||||
@ -2228,7 +2205,7 @@ public class DataSetTableService {
|
||||
criteria.andNameEqualTo(datasetTable.getName());
|
||||
}
|
||||
List<DatasetTable> list = datasetTableMapper.selectByExample(datasetTableExample);
|
||||
if (list.size() > 0) {
|
||||
if (!list.isEmpty()) {
|
||||
throw new RuntimeException(Translator.get("i18n_name_cant_repeat_same_group"));
|
||||
}
|
||||
}
|
||||
@ -2253,7 +2230,7 @@ public class DataSetTableService {
|
||||
criteria.andNameIn(new ArrayList<>(nameSet));
|
||||
}
|
||||
List<DatasetTable> list = datasetTableMapper.selectByExample(datasetTableExample);
|
||||
if (list.size() > 0) {
|
||||
if (!list.isEmpty()) {
|
||||
throw new RuntimeException(Translator.get("i18n_name_cant_repeat_same_group"));
|
||||
}
|
||||
}
|
||||
@ -2278,8 +2255,7 @@ public class DataSetTableService {
|
||||
|
||||
if (StringUtils.isNotEmpty(tableId)) {
|
||||
List<DatasetTableField> fields = dataSetTableFieldsService.getFieldsByTableId(tableId);
|
||||
List<DatasetTableField> datasetTableFields = fields.stream().filter(datasetTableField -> datasetTableField.getExtField() == 0).collect(Collectors.toList());
|
||||
datasetTableFields.sort((o1, o2) -> {
|
||||
List<DatasetTableField> datasetTableFields = fields.stream().filter(datasetTableField -> datasetTableField.getExtField() == 0).sorted((o1, o2) -> {
|
||||
if (o1.getColumnIndex() == null) {
|
||||
return -1;
|
||||
}
|
||||
@ -2287,7 +2263,7 @@ public class DataSetTableService {
|
||||
return 1;
|
||||
}
|
||||
return o1.getColumnIndex().compareTo(o2.getColumnIndex());
|
||||
});
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
List<String> oldFields = datasetTableFields.stream().map(DatasetTableField::getOriginName).collect(Collectors.toList());
|
||||
|
||||
@ -2299,7 +2275,7 @@ public class DataSetTableService {
|
||||
returnSheetDataList.add(excelSheetData);
|
||||
}
|
||||
}
|
||||
if (returnSheetDataList.size() == 0) {
|
||||
if (returnSheetDataList.isEmpty()) {
|
||||
DataEaseException.throwException(Translator.get("i18n_excel_column_change"));
|
||||
}
|
||||
} else {
|
||||
@ -2321,22 +2297,19 @@ public class DataSetTableService {
|
||||
for (ExcelSheetData excelSheetData : excelSheetDataList) {
|
||||
List<TableField> tableFields = excelSheetData.getFields();
|
||||
List<String> newFields = tableFields.stream().map(TableField::getRemarks).collect(Collectors.toList());
|
||||
if (oldFields.equals(newFields)) {
|
||||
excelSheetData.setChangeFiled(false);
|
||||
} else {
|
||||
excelSheetData.setChangeFiled(true);
|
||||
}
|
||||
excelSheetData.setChangeFiled(!oldFields.equals(newFields));
|
||||
boolean effectExtField = false;
|
||||
for (String extFieldsRefName : extFieldsRefNames) {
|
||||
if (!newFields.contains(extFieldsRefName)) {
|
||||
effectExtField = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
excelSheetData.setEffectExtField(effectExtField);
|
||||
|
||||
returnSheetDataList.add(excelSheetData);
|
||||
}
|
||||
if (returnSheetDataList.size() == 0) {
|
||||
if (returnSheetDataList.isEmpty()) {
|
||||
DataEaseException.throwException(Translator.get("i18n_excel_column_change"));
|
||||
}
|
||||
}
|
||||
@ -2403,7 +2376,7 @@ public class DataSetTableService {
|
||||
}
|
||||
List<List<String>> data = new ArrayList<>();
|
||||
int num = 1;
|
||||
String line = null;
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (num > 100) {
|
||||
break;
|
||||
@ -2450,7 +2423,7 @@ public class DataSetTableService {
|
||||
try {
|
||||
double d = cell.getNumericCellValue();
|
||||
try {
|
||||
Double value = new Double(d);
|
||||
Double value = d;
|
||||
double eps = 1e-10;
|
||||
if (value - Math.floor(value) < eps) {
|
||||
if (cellType) {
|
||||
@ -2469,7 +2442,7 @@ public class DataSetTableService {
|
||||
return nf.format(value);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
BigDecimal b = new BigDecimal(d);
|
||||
BigDecimal b = BigDecimal.valueOf(d);
|
||||
return b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() + "";
|
||||
}
|
||||
} catch (IllegalStateException e) {
|
||||
@ -2502,7 +2475,7 @@ public class DataSetTableService {
|
||||
} else {
|
||||
double d = cell.getNumericCellValue();
|
||||
try {
|
||||
Double value = new Double(d);
|
||||
Double value = d;
|
||||
double eps = 1e-10;
|
||||
if (value - Math.floor(value) < eps) {
|
||||
if (cellType) {
|
||||
@ -2521,7 +2494,7 @@ public class DataSetTableService {
|
||||
return nf.format(value);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
BigDecimal b = new BigDecimal(d);
|
||||
BigDecimal b = BigDecimal.valueOf(d);
|
||||
return b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() + "";
|
||||
}
|
||||
}
|
||||
@ -2655,18 +2628,14 @@ public class DataSetTableService {
|
||||
* 判断数组中是否有重复的值
|
||||
*/
|
||||
public static boolean checkIsRepeat(String[] array) {
|
||||
HashSet<String> hashSet = new HashSet<String>();
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
if (StringUtils.isEmpty(array[i])) {
|
||||
HashSet<String> hashSet = new HashSet<>();
|
||||
for (String s : array) {
|
||||
if (StringUtils.isEmpty(s)) {
|
||||
throw new RuntimeException(Translator.get("i18n_excel_empty_column"));
|
||||
}
|
||||
hashSet.add(array[i]);
|
||||
}
|
||||
if (hashSet.size() == array.length) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
hashSet.add(s);
|
||||
}
|
||||
return hashSet.size() != array.length;
|
||||
}
|
||||
|
||||
public DatasetTable syncDatasetTableField(String id) throws Exception {
|
||||
@ -2857,7 +2826,7 @@ public class DataSetTableService {
|
||||
return expressionDeParser;
|
||||
}
|
||||
|
||||
static private boolean hasVariable(String sql) {
|
||||
private static boolean hasVariable(String sql) {
|
||||
return sql.contains(SubstitutedParams);
|
||||
}
|
||||
|
||||
@ -2936,7 +2905,7 @@ public class DataSetTableService {
|
||||
//设置列的宽度
|
||||
detailsSheet.setColumnWidth(j, 255 * 20);
|
||||
} else {
|
||||
if ((fields.get(j).getDeType() == DeTypeConstants.DE_INT || fields.get(j).getDeType() == DeTypeConstants.DE_FLOAT) && StringUtils.isNotEmpty(rowData.get(j))) {
|
||||
if ((fields.get(j).getDeType().equals(DeTypeConstants.DE_INT) || fields.get(j).getDeType() == DeTypeConstants.DE_FLOAT) && StringUtils.isNotEmpty(rowData.get(j))) {
|
||||
try {
|
||||
cell.setCellValue(Double.valueOf(rowData.get(j)));
|
||||
} catch (Exception e) {
|
||||
|
@ -4,3 +4,7 @@ ALTER TABLE `sys_log`
|
||||
CHANGE COLUMN `nick_name` `nick_name` VARCHAR (255) NULL COMMENT '姓名';
|
||||
|
||||
UPDATE `sys_menu` SET `component` = 'dataset/Form' WHERE (`menu_id` = '800');
|
||||
|
||||
|
||||
UPDATE `sys_menu` SET `component` = 'msg/All' WHERE (`component` = 'msg/all');
|
||||
UPDATE `sys_menu` SET `component` = 'msg/Setting' WHERE (`component` = 'msg/setting');
|
||||
|
@ -11,6 +11,7 @@
|
||||
:terminal="terminal"
|
||||
:element="config"
|
||||
:canvas-id="canvasId"
|
||||
:chart="chart"
|
||||
:show-position="showPosition"
|
||||
@showViewDetails="showViewDetails"
|
||||
/>
|
||||
@ -65,6 +66,7 @@
|
||||
:screen-shot="screenShot"
|
||||
:canvas-style-data="canvasStyleData"
|
||||
:show-position="showPosition"
|
||||
@fill-chart-2-parent="setChartData"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -146,7 +148,8 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
previewVisible: false
|
||||
previewVisible: false,
|
||||
chart: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -211,6 +214,9 @@ export default {
|
||||
runAnimation(this.$el, this.config.animations)
|
||||
},
|
||||
methods: {
|
||||
setChartData(chart) {
|
||||
this.chart = chart
|
||||
},
|
||||
getStyle,
|
||||
getShapeStyleIntDeDrag(style, prop) {
|
||||
if (prop === 'rotate') {
|
||||
|
@ -107,6 +107,7 @@
|
||||
:canvas-style-data="canvasStyleData"
|
||||
@input="handleInput"
|
||||
@trigger-plugin-edit="pluginEditHandler"
|
||||
@fill-chart-2-parent="setChartData"
|
||||
/>
|
||||
</de-drag>
|
||||
<!--拖拽阴影部分-->
|
||||
@ -1096,6 +1097,13 @@ export default {
|
||||
created() {
|
||||
},
|
||||
methods: {
|
||||
setChartData(chart) {
|
||||
this.componentData.forEach((item, index) => {
|
||||
if (item.type === 'view' && item.component === 'user-view' && item.propValue.viewId === chart.id) {
|
||||
this.$refs['deDragRef'][index].setChartData(chart)
|
||||
}
|
||||
})
|
||||
},
|
||||
triggerResetButton() {
|
||||
this.triggerSearchButton(true)
|
||||
},
|
||||
|
@ -94,7 +94,7 @@
|
||||
>
|
||||
<i
|
||||
class="icon iconfont icon-shezhi"
|
||||
style="margin-top:2px"
|
||||
style="margin-top:2px; width: 16px;"
|
||||
/>
|
||||
</span>
|
||||
</setting-menu>
|
||||
@ -140,6 +140,11 @@
|
||||
<i class="icon iconfont icon-com-jump" />
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<map-layer-controller
|
||||
v-if="chart && showMapLayerController"
|
||||
:chart="chart"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!--跳转设置-->
|
||||
@ -185,9 +190,10 @@ import toast from '@/components/canvas/utils/toast'
|
||||
import FieldsList from '@/components/canvas/components/editor/FieldsList'
|
||||
import LinkJumpSet from '@/views/panel/linkJumpSet'
|
||||
import Background from '@/views/background/index'
|
||||
import MapLayerController from '@/views/chart/components/map/MapLayerController'
|
||||
|
||||
export default {
|
||||
components: { Background, LinkJumpSet, FieldsList, SettingMenu, LinkageField },
|
||||
components: { Background, LinkJumpSet, FieldsList, SettingMenu, LinkageField, MapLayerController },
|
||||
|
||||
props: {
|
||||
canvasId: {
|
||||
@ -226,6 +232,10 @@ export default {
|
||||
type: String,
|
||||
required: false,
|
||||
default: 'NotProvided'
|
||||
},
|
||||
chart: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@ -249,6 +259,13 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
yaxis() {
|
||||
if (!this.chart) return []
|
||||
return JSON.parse(this.chart.yaxis)
|
||||
},
|
||||
showMapLayerController() {
|
||||
return this.curComponent.type === 'view' && this.terminal === 'pc' && this.curComponent.propValue.innerType === 'map' && this.yaxis.length > 1
|
||||
},
|
||||
detailsShow() {
|
||||
return this.curComponent.type === 'view' && this.terminal === 'pc' && this.curComponent.propValue.innerType !== 'richTextView'
|
||||
},
|
||||
@ -519,7 +536,7 @@ export default {
|
||||
background-color: var(--primary, #3370ff);
|
||||
}
|
||||
|
||||
.bar-main i {
|
||||
.bar-main ::v-deep i {
|
||||
color: white;
|
||||
float: right;
|
||||
margin-right: 3px;
|
||||
|
@ -518,6 +518,9 @@ export default {
|
||||
this.chartScale(this.changeScaleIndex)
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
'chart.yaxis': function(newVal, oldVal) {
|
||||
this.$emit('fill-chart-2-parent', this.chart)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@ -691,6 +694,7 @@ export default {
|
||||
// 将视图传入echart组件
|
||||
if (response.success) {
|
||||
this.chart = response.data
|
||||
this.$emit('fill-chart-2-parent', this.chart)
|
||||
this.getDataOnly(response.data, dataBroadcast)
|
||||
this.chart['position'] = this.inTab ? 'tab' : 'panel'
|
||||
// 记录当前数据
|
||||
|
@ -39,6 +39,7 @@
|
||||
:active-model="'edit'"
|
||||
:canvas-id="canvasId"
|
||||
:element="element"
|
||||
:chart="chart"
|
||||
@showViewDetails="showViewDetails"
|
||||
@amRemoveItem="amRemoveItem"
|
||||
@amAddItem="amAddItem"
|
||||
@ -384,6 +385,7 @@ export default {
|
||||
},
|
||||
data: function() {
|
||||
return {
|
||||
chart: null,
|
||||
contentDisplay: true,
|
||||
// 当画布在tab中是 宽度左右拓展的余量
|
||||
parentWidthTabOffset: 40,
|
||||
@ -802,6 +804,9 @@ export default {
|
||||
this.beforeDestroyFunction()
|
||||
},
|
||||
methods: {
|
||||
setChartData(chart) {
|
||||
this.chart = chart
|
||||
},
|
||||
// 重置边界和鼠标状态
|
||||
resetBoundsAndMouseState() {
|
||||
this.mouseClickPosition = { mouseX: 0, mouseY: 0, x: 0, y: 0, w: 0, h: 0 }
|
||||
|
@ -58,7 +58,7 @@ export default {
|
||||
mounted() {
|
||||
if (!this.isFilterComponent) return
|
||||
this.typeTransform().forEach(item => {
|
||||
const nodeCache = this.$refs.deOutWidget?.$refs[item].$el.querySelector('.el-input__inner') || this.$refs.deOutWidget.$refs[item].$el
|
||||
const nodeCache = this.$refs.deOutWidget?.$refs[item].$el.querySelector('.el-input__inner') || this.$refs.deOutWidget?.$refs[item].$el
|
||||
this.styleAttrs.forEach(ele => {
|
||||
nodeCache.style[this.attrsMap[ele]] = this.element.style[ele]
|
||||
this[this.element.serviceName] && this[this.element.serviceName](this.selectRange(item), ele, this.element.style[ele])
|
||||
@ -70,9 +70,11 @@ export default {
|
||||
let nodeCache = ''
|
||||
this.styleAttrs.forEach(ele => {
|
||||
if (!nodeCache) {
|
||||
nodeCache = this.$refs.deOutWidget?.$refs[type].$el.querySelector('.el-input__inner') || this.$refs.deOutWidget.$refs[type].$el
|
||||
nodeCache = this.$refs.deOutWidget?.$refs[type].$el.querySelector('.el-input__inner') || this.$refs.deOutWidget?.$refs[type].$el
|
||||
}
|
||||
if (nodeCache) {
|
||||
nodeCache.style[this.attrsMap[ele]] = newValue[ele]
|
||||
}
|
||||
nodeCache.style[this.attrsMap[ele]] = newValue[ele]
|
||||
this[this.element.serviceName] && this[this.element.serviceName](this.selectRange(type), ele, newValue[ele])
|
||||
})
|
||||
},
|
||||
|
@ -915,6 +915,7 @@ export default {
|
||||
password_input_error: 'Original password input error'
|
||||
},
|
||||
chart: {
|
||||
layer_controller: 'Quota switch',
|
||||
suspension: 'Suspension',
|
||||
chart_background: 'Component background',
|
||||
solid_color: 'Solid color',
|
||||
|
@ -915,6 +915,7 @@ export default {
|
||||
password_input_error: '原始密碼輸入錯誤'
|
||||
},
|
||||
chart: {
|
||||
layer_controller: '指標切換',
|
||||
suspension: '懸浮',
|
||||
chart_background: '組件背景',
|
||||
solid_color: '純色',
|
||||
|
@ -914,6 +914,7 @@ export default {
|
||||
password_input_error: '原始密码输入错误'
|
||||
},
|
||||
chart: {
|
||||
layer_controller: '指标切换',
|
||||
suspension: '悬浮',
|
||||
chart_background: '组件背景',
|
||||
solid_color: '纯色',
|
||||
|
@ -41,8 +41,22 @@ export function baseMapOption(chart_option, chart, themeStyle, curAreaCode) {
|
||||
// 处理shape attr
|
||||
let customAttr = {}
|
||||
let isGradient = false
|
||||
let seriesIndex = 0
|
||||
if (chart.customAttr) {
|
||||
customAttr = JSON.parse(chart.customAttr)
|
||||
if (chart.yaxis && chart.yaxis.length > 1) {
|
||||
let currentSeriesId = customAttr.currentSeriesId
|
||||
const yAxis = JSON.parse(chart.yaxis)
|
||||
if (!currentSeriesId || !yAxis.some(item => item.id === currentSeriesId)) {
|
||||
currentSeriesId = yAxis[0].id
|
||||
}
|
||||
chart.data.series.forEach((item, index) => {
|
||||
if (item.data[0].quotaList[0].id === currentSeriesId) {
|
||||
seriesIndex = index
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (customAttr.color) {
|
||||
const colorValue = customAttr.color.value
|
||||
@ -57,7 +71,7 @@ export function baseMapOption(chart_option, chart, themeStyle, curAreaCode) {
|
||||
const tooltip = JSON.parse(JSON.stringify(customAttr.tooltip))
|
||||
const reg = new RegExp('\n', 'g')
|
||||
const text = tooltip.formatter.replace(reg, '<br/>')
|
||||
tooltip.formatter = function(params) {
|
||||
tooltip.formatter = params => {
|
||||
const a = params.seriesName
|
||||
const b = params.name
|
||||
const c = params.value ? params.value : ''
|
||||
@ -74,14 +88,14 @@ export function baseMapOption(chart_option, chart, themeStyle, curAreaCode) {
|
||||
if (chart.data) {
|
||||
chart_option.title.text = chart.title
|
||||
if (chart.data.series && chart.data.series.length > 0) {
|
||||
chart_option.series[0].name = chart.data.series[0].name
|
||||
chart_option.series[0].name = chart.data.series[seriesIndex].name
|
||||
chart_option.series[0].selectedMode = true
|
||||
chart_option.series[0].select = BASE_ECHARTS_SELECT
|
||||
// label
|
||||
if (customAttr.label) {
|
||||
const text = customAttr.label.formatter
|
||||
chart_option.series[0].label = customAttr.label
|
||||
chart_option.series[0].label.formatter = function(params) {
|
||||
chart_option.series[0].label.formatter = params => {
|
||||
const a = params.seriesName
|
||||
const b = params.name
|
||||
const c = params.value ? params.value : ''
|
||||
@ -97,12 +111,12 @@ export function baseMapOption(chart_option, chart, themeStyle, curAreaCode) {
|
||||
}
|
||||
chart_option.series[0].itemStyle.emphasis.label.show = customAttr.label.show
|
||||
}
|
||||
const valueArr = chart.data.series[0].data
|
||||
const valueArr = chart.data.series[seriesIndex].data
|
||||
// visualMap
|
||||
if (!isGradient) {
|
||||
if (valueArr && valueArr.length > 0) {
|
||||
const values = []
|
||||
valueArr.forEach(function(ele) {
|
||||
valueArr.forEach(ele => {
|
||||
values.push(ele.value)
|
||||
})
|
||||
chart_option.visualMap.min = Math.min(...values)
|
||||
|
@ -12,41 +12,14 @@
|
||||
style="width: 100%;height: 100%;overflow: hidden;"
|
||||
:style="{ borderRadius: borderRadius}"
|
||||
/>
|
||||
<div
|
||||
|
||||
<map-controller
|
||||
v-if="chart.type === 'map' && showSuspension"
|
||||
class="map-zoom-box"
|
||||
>
|
||||
<div style="margin-bottom: 0.5em;">
|
||||
<el-button
|
||||
:style="{'background': buttonTextColor ? 'none' : '', 'opacity': buttonTextColor ? '0.75': '', 'color': buttonTextColor, 'borderColor': buttonTextColor}"
|
||||
size="mini"
|
||||
icon="el-icon-plus"
|
||||
circle
|
||||
@click="roamMap(true)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 0.5em;">
|
||||
<el-button
|
||||
:style="{'background': buttonTextColor ? 'none' : '', 'opacity': buttonTextColor ? '0.75': '', 'color': buttonTextColor, 'borderColor': buttonTextColor}"
|
||||
size="mini"
|
||||
icon="el-icon-refresh"
|
||||
circle
|
||||
@click="resetZoom()"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<el-button
|
||||
:style="{'background': buttonTextColor ? 'none' : '', 'opacity': buttonTextColor ? '0.75': '', 'color': buttonTextColor, 'borderColor': buttonTextColor}"
|
||||
size="mini"
|
||||
icon="el-icon-minus"
|
||||
circle
|
||||
@click="roamMap(false)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
:chart="chart"
|
||||
:button-text-color="buttonTextColor"
|
||||
@roam-map="roamMap"
|
||||
@reset-zoom="resetZoom"
|
||||
/>
|
||||
<div
|
||||
:class="loading ? 'symbol-map-loading' : 'symbol-map-loaded'"
|
||||
/>
|
||||
@ -81,12 +54,14 @@ import { uuid } from 'vue-uuid'
|
||||
import { geoJson } from '@/api/map/map'
|
||||
import ViewTrackBar from '@/components/canvas/components/editor/ViewTrackBar'
|
||||
import { reverseColor } from '../chart/common/common'
|
||||
import MapController from './map/MapController.vue'
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
import bus from '@/utils/bus'
|
||||
export default {
|
||||
name: 'ChartComponent',
|
||||
components: {
|
||||
ViewTrackBar
|
||||
ViewTrackBar,
|
||||
MapController
|
||||
},
|
||||
props: {
|
||||
chart: {
|
||||
@ -178,9 +153,11 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
bus.$on('change-series-id', this.changeSeriesId)
|
||||
this.preDraw()
|
||||
},
|
||||
beforeDestroy() {
|
||||
bus.$off('change-series-id', this.changeSeriesId)
|
||||
window.removeEventListener('resize', this.myChart.resize)
|
||||
this.myChart.dispose()
|
||||
this.myChart = null
|
||||
@ -189,6 +166,15 @@ export default {
|
||||
this.loadThemeStyle()
|
||||
},
|
||||
methods: {
|
||||
changeSeriesId(param) {
|
||||
const { id, seriesId } = param
|
||||
if (id !== this.chart.id) {
|
||||
return
|
||||
}
|
||||
const customAttr = JSON.parse(this.chart.customAttr)
|
||||
customAttr.currentSeriesId = seriesId
|
||||
this.chart.customAttr = JSON.stringify(customAttr)
|
||||
},
|
||||
reDrawView() {
|
||||
this.myChart.dispatchAction({
|
||||
type: 'unselect',
|
||||
|
93
frontend/src/views/chart/components/map/MapController.vue
Normal file
93
frontend/src/views/chart/components/map/MapController.vue
Normal file
@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<div
|
||||
class="map-zoom-box"
|
||||
>
|
||||
<div style="margin-bottom: 0.5em;">
|
||||
<el-button
|
||||
:style="{'background': buttonTextColor ? 'none' : '', 'opacity': buttonTextColor ? '0.75': '', 'color': buttonTextColor, 'borderColor': buttonTextColor}"
|
||||
size="mini"
|
||||
icon="el-icon-plus"
|
||||
circle
|
||||
@click="callParent('roamMap', true)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 0.5em;">
|
||||
<el-button
|
||||
:style="{'background': buttonTextColor ? 'none' : '', 'opacity': buttonTextColor ? '0.75': '', 'color': buttonTextColor, 'borderColor': buttonTextColor}"
|
||||
size="mini"
|
||||
icon="el-icon-refresh"
|
||||
circle
|
||||
@click="callParent('resetZoom')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<el-button
|
||||
:style="{'background': buttonTextColor ? 'none' : '', 'opacity': buttonTextColor ? '0.75': '', 'color': buttonTextColor, 'borderColor': buttonTextColor}"
|
||||
size="mini"
|
||||
icon="el-icon-minus"
|
||||
circle
|
||||
@click="callParent('roamMap', false)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'MapController',
|
||||
props: {
|
||||
chart: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
buttonTextColor: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
yaxis() {
|
||||
return JSON.parse(this.chart.yaxis)
|
||||
},
|
||||
layerOption() {
|
||||
return this.yaxis.map(this.buildOption)
|
||||
},
|
||||
customAttr() {
|
||||
const attr = JSON.parse(this.chart.customAttr)
|
||||
if (!attr.currentSeriesId || !this.layerOption.some(item => item.id === attr.currentSeriesId)) {
|
||||
attr.currentSeriesId = this.layerOption[0].id
|
||||
}
|
||||
return attr
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.init()
|
||||
},
|
||||
methods: {
|
||||
buildOption({ id, name }) {
|
||||
return ({ id, name })
|
||||
},
|
||||
changeSeriesId(val) {
|
||||
this.chart.customAttr = JSON.stringify(this.customAttr)
|
||||
},
|
||||
callParent(methodName, param) {
|
||||
this.$emit(methodName, param)
|
||||
},
|
||||
init() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
126
frontend/src/views/chart/components/map/MapLayerController.vue
Normal file
126
frontend/src/views/chart/components/map/MapLayerController.vue
Normal file
@ -0,0 +1,126 @@
|
||||
<template>
|
||||
|
||||
<el-popover
|
||||
placement="right"
|
||||
title=""
|
||||
width="150"
|
||||
trigger="click"
|
||||
>
|
||||
<i
|
||||
slot="reference"
|
||||
:title="$t('chart.layer_controller')"
|
||||
class="icon iconfont icon-xuanfu"
|
||||
style="margin-left: 4px;cursor: pointer;font-size: 14px;"
|
||||
/>
|
||||
<div>
|
||||
<ul class="de-ul">
|
||||
<li
|
||||
v-for="(node, i) in layerOption"
|
||||
:key="node.id"
|
||||
:index="i"
|
||||
class="de-sort-field-span"
|
||||
:class="currentSeriesId === node.id ? 'de-active-li': ''"
|
||||
@click="changeSeries(node)"
|
||||
>
|
||||
<span :title="node.name">{{ node.name }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</el-popover>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import bus from '@/utils/bus'
|
||||
export default {
|
||||
name: 'MapLayerController',
|
||||
props: {
|
||||
chart: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
currentSeriesId: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
yaxis() {
|
||||
return JSON.parse(this.chart.yaxis)
|
||||
},
|
||||
layerOption() {
|
||||
return this.yaxis.map(this.buildOption)
|
||||
},
|
||||
customAttr() {
|
||||
const attr = JSON.parse(this.chart.customAttr)
|
||||
if (!attr.currentSeriesId || !this.layerOption.some(item => item.id === attr.currentSeriesId)) {
|
||||
attr.currentSeriesId = this.layerOption[0].id
|
||||
}
|
||||
return attr
|
||||
}
|
||||
|
||||
},
|
||||
created() {
|
||||
this.init()
|
||||
},
|
||||
methods: {
|
||||
buildOption({ id, name }) {
|
||||
return ({ id, name })
|
||||
},
|
||||
changeSeries(node) {
|
||||
if (node.id === this.currentSeriesId) return
|
||||
this.currentSeriesId = node.id
|
||||
const param = {
|
||||
id: this.chart.id,
|
||||
seriesId: this.currentSeriesId
|
||||
}
|
||||
bus.$emit('change-series-id', param)
|
||||
},
|
||||
|
||||
init() {
|
||||
this.currentSeriesId = this.customAttr.currentSeriesId
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
.de-ul li {
|
||||
margin: 5px 2px;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
color: #409EFF;
|
||||
border-color: rgb(198, 226, 255);
|
||||
background-color: rgb(236, 245, 255);
|
||||
}
|
||||
|
||||
&:before {
|
||||
content: "";
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
display: inline-block;
|
||||
border-radius: 50%;
|
||||
vertical-align: middle;
|
||||
margin-right: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.de-active-li {
|
||||
&:before {
|
||||
background: #409EFF;
|
||||
}
|
||||
}
|
||||
.de-sort-field-span {
|
||||
display: inline-flexbox;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
span {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
@ -2075,9 +2075,7 @@ export default {
|
||||
}
|
||||
})
|
||||
}
|
||||
if (view.type === 'map' && view.yaxis.length > 1) {
|
||||
view.yaxis = [view.yaxis[0]]
|
||||
}
|
||||
|
||||
view.yaxis.forEach(function(ele) {
|
||||
if (!ele.chartType) {
|
||||
ele.chartType = 'bar'
|
||||
@ -2829,7 +2827,7 @@ export default {
|
||||
addYaxis(e) {
|
||||
this.dragCheckType(this.view.yaxis, 'q')
|
||||
this.dragMoveDuplicate(this.view.yaxis, e)
|
||||
if ((this.view.type === 'map' || this.view.type === 'waterfall' || this.view.type === 'word-cloud' || this.view.type.includes('group')) && this.view.yaxis.length > 1) {
|
||||
if ((this.view.type === 'waterfall' || this.view.type === 'word-cloud' || this.view.type.includes('group')) && this.view.yaxis.length > 1) {
|
||||
this.view.yaxis = [this.view.yaxis[0]]
|
||||
}
|
||||
this.calcData(true)
|
||||
|
Loading…
Reference in New Issue
Block a user