From 060c41380ceaff0549b5a1615fa36d6f5853d7a1 Mon Sep 17 00:00:00 2001 From: junjie Date: Fri, 18 Jun 2021 11:19:55 +0800 Subject: [PATCH 01/15] =?UTF-8?q?feat(fix):cron=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/service/ScheduleService.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/ScheduleService.java b/backend/src/main/java/io/dataease/service/ScheduleService.java index af00535edf..7ef72699fc 100644 --- a/backend/src/main/java/io/dataease/service/ScheduleService.java +++ b/backend/src/main/java/io/dataease/service/ScheduleService.java @@ -30,17 +30,21 @@ public class ScheduleService { scheduleManager.getDefaultJobDataMap(datasetTableTask.getTableId(), datasetTableTask.getCron(), datasetTableTask.getId(), datasetTableTask.getType())); } else if (StringUtils.equalsIgnoreCase(datasetTableTask.getRate(), ScheduleType.CRON.toString())) { Date endTime; - if (datasetTableTask.getEndTime() == null || datasetTableTask.getEndTime() == 0) { - endTime = null; - } else { - endTime = new Date(datasetTableTask.getEndTime()); + if (StringUtils.equalsIgnoreCase(datasetTableTask.getEnd(), "1")) { + if (datasetTableTask.getEndTime() == null || datasetTableTask.getEndTime() == 0) { + endTime = null; + } else { + endTime = new Date(datasetTableTask.getEndTime()); // if (endTime.before(new Date())) { // return; // } - if (endTime.before(new Date())) { - deleteSchedule(datasetTableTask); - return; + if (endTime.before(new Date())) { + deleteSchedule(datasetTableTask); + return; + } } + } else { + endTime = null; } scheduleManager.addOrUpdateCronJob(new JobKey(datasetTableTask.getId(), datasetTableTask.getTableId()), From d1bb60bf9a4b9208f1f4eaa0c6f6e7dcb42f62bc Mon Sep 17 00:00:00 2001 From: fit2cloudrd Date: Fri, 18 Jun 2021 15:01:40 +0800 Subject: [PATCH 02/15] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6c0ea644dd..e9546218fa 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ DataEase 是开源的数据可视化分析工具,帮助用户分析数据、 curl -sSL https://github.com/dataease/dataease/releases/latest/download/quick_start.sh | sh ``` -- [在线文档](https://dataease.io/docs/) +- [在线文档](https://docs.dataease.io/) - [演示视频](https://dataease.oss-cn-hangzhou.aliyuncs.com/video/de-v1-demo.mp4) ## 微信群 @@ -155,7 +155,7 @@ curl -sSL https://github.com/dataease/dataease/releases/latest/download/quick_st 数据源 数据源管理 - 支持 MySQL 和 SQL Server 类型的数据源 + 支持 MySQL 数据源 支持对数据源有效性校验 From cdecd61131b5440b074139e308e0ab8c99fce526 Mon Sep 17 00:00:00 2001 From: xuwei-fit2cloud Date: Fri, 18 Jun 2021 17:24:18 +0800 Subject: [PATCH 03/15] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=AD=90?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 6 ++++++ dataease-plugin-xpack | 1 + dataease-plugins | 1 + 3 files changed, 8 insertions(+) create mode 100644 .gitmodules create mode 160000 dataease-plugin-xpack create mode 160000 dataease-plugins diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..e683525269 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "dataease-plugins"] + path = dataease-plugins + url = git@github.com:dataease/dataease-plugins.git +[submodule "dataease-plugin-xpack"] + path = dataease-plugin-xpack + url = git@github.com:dataease/dataease-plugin-xpack.git diff --git a/dataease-plugin-xpack b/dataease-plugin-xpack new file mode 160000 index 0000000000..9879b705aa --- /dev/null +++ b/dataease-plugin-xpack @@ -0,0 +1 @@ +Subproject commit 9879b705aa4a5105056109ecf5b9da70b783969d diff --git a/dataease-plugins b/dataease-plugins new file mode 160000 index 0000000000..2541de3d2c --- /dev/null +++ b/dataease-plugins @@ -0,0 +1 @@ +Subproject commit 2541de3d2c82f37dcf9916fda70ada0ca3fc6132 From 976db21091dd7bf09cc497625dfe8bb5c14ee52c Mon Sep 17 00:00:00 2001 From: taojinlong Date: Fri, 18 Jun 2021 18:20:44 +0800 Subject: [PATCH 04/15] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=8D=A2=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dataset/ExtractDataService.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java index ff19e54bd2..958098b5e2 100644 --- a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java +++ b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java @@ -763,12 +763,11 @@ public class ExtractDataService { userDefinedJavaClassMeta.setFieldInfo(fields); List definitions = new ArrayList(); String tmp_code = code.replace("alterColumnTypeCode", needToChangeColumnType).replace("Column_Fields", String.join(",", datasetTableFields.stream().map(DatasetTableField::getOriginName).collect(Collectors.toList()))); + tmp_code = tmp_code.replace("handleWraps", handleWraps); if(isExcel){ tmp_code = tmp_code.replace("handleExcelIntColumn", handleExcelIntColumn); - tmp_code = tmp_code.replace("handleExcelWraps", handleExcelWraps); }else { tmp_code = tmp_code.replace("handleExcelIntColumn", ""); - tmp_code = tmp_code.replace("handleExcelWraps", ""); } UserDefinedJavaClassDef userDefinedJavaClassDef = new UserDefinedJavaClassDef(UserDefinedJavaClassDef.ClassType.TRANSFORM_CLASS, "Processor", tmp_code); @@ -861,13 +860,12 @@ public class ExtractDataService { " }catch (Exception e){}\n" + " }"; - private static String handleExcelWraps = " \n" + - " if(tmp != null ){\n" + - " tmp = tmp.trim();\n" + - " tmp = tmp.replaceAll(\"\\r\",\" \");\n" + - " tmp = tmp.replaceAll(\"\\n\",\" \");\n" + - " get(Fields.Out, filed).setValue(r, tmp);\n" + - " }"; + private static String handleWraps = " if(tmp != null && ( tmp.contains(\"\\r\") || tmp.contains(\"\\n\"))){\n" + + "\t\t\ttmp = tmp.trim();\n" + + " tmp = tmp.replaceAll(\"\\r\",\" \");\n" + + " tmp = tmp.replaceAll(\"\\n\",\" \");\n" + + " get(Fields.Out, filed).setValue(r, tmp);\n" + + " } "; private static String code = "import org.pentaho.di.core.row.ValueMetaInterface;\n" + "import java.util.List;\n" + @@ -898,7 +896,7 @@ public class ExtractDataService { " List fileds = Arrays.asList(\"Column_Fields\".split(\",\"));\n" + " for (String filed : fileds) {\n" + " String tmp = get(Fields.In, filed).getString(r);\n" + - "handleExcelWraps \n" + + "handleWraps \n" + "alterColumnTypeCode \n" + "handleExcelIntColumn \n" + " str = str + tmp;\n" + From 38013f98faa54d763e96425d2881e45dd9446e91 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Fri, 18 Jun 2021 18:23:09 +0800 Subject: [PATCH 05/15] =?UTF-8?q?feat:=20=E6=9B=B4=E6=8D=A2=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/layout/components/Topbar.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/layout/components/Topbar.vue b/frontend/src/layout/components/Topbar.vue index e68f484a9d..ace9260a18 100644 --- a/frontend/src/layout/components/Topbar.vue +++ b/frontend/src/layout/components/Topbar.vue @@ -38,7 +38,7 @@ From 1758bf490416e12835447c7caea95999a15acf8b Mon Sep 17 00:00:00 2001 From: junjie Date: Sat, 19 Jun 2021 11:11:58 +0800 Subject: [PATCH 06/15] =?UTF-8?q?feat(fix):=E8=A7=86=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E5=BA=95=E9=83=A8=E9=81=AE=E6=8C=A1=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/components/table/TableNormal.vue | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/frontend/src/views/chart/components/table/TableNormal.vue b/frontend/src/views/chart/components/table/TableNormal.vue index b9d5c865e0..3c3b6cc3a8 100644 --- a/frontend/src/views/chart/components/table/TableNormal.vue +++ b/frontend/src/views/chart/components/table/TableNormal.vue @@ -117,23 +117,24 @@ export default { } }, calcHeight() { - const that = this - this.$nextTick(function() { - if (that.$refs.tableContainer) { - const currentHeight = that.$refs.tableContainer.offsetHeight - const tableMaxHeight = currentHeight - that.$refs.title.offsetHeight - let tableHeight - if (that.chart.data) { - tableHeight = (that.chart.data.tableRow.length + 2) * 36 - } else { - tableHeight = 0 + this.$nextTick(() => { + setTimeout(() => { + if (this.$refs.tableContainer) { + const currentHeight = this.$refs.tableContainer.offsetHeight + const tableMaxHeight = currentHeight - this.$refs.title.offsetHeight + let tableHeight + if (this.chart.data) { + tableHeight = (this.chart.data.tableRow.length + 2) * 36 + } else { + tableHeight = 0 + } + if (tableHeight > tableMaxHeight) { + this.height = tableMaxHeight + 'px' + } else { + this.height = 'auto' + } } - if (tableHeight > tableMaxHeight) { - that.height = tableMaxHeight + 'px' - } else { - that.height = 'auto' - } - } + }, 100) }) }, initStyle() { From cdaba0eb03395a884dde739d4aee05470f539417 Mon Sep 17 00:00:00 2001 From: junjie Date: Sat, 19 Jun 2021 11:42:14 +0800 Subject: [PATCH 07/15] =?UTF-8?q?feat(feat):=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=EF=BC=8C=E8=A7=86=E5=9B=BE=E5=88=86=E7=BB=84=E6=A0=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E5=8E=BB=E9=99=A4=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/mapper/ext/ExtChartGroupMapper.java | 1 - .../chart/ChartGroupController.java | 5 + .../controller/chart/ChartViewController.java | 5 + .../dataset/DataSetGroupController.java | 10 +- .../dataset/DataSetTableController.java | 5 + .../io/dataease/dto/chart/ChartViewDTO.java | 3 + .../dataease/dto/dataset/DataSetTableDTO.java | 3 + .../service/chart/ChartGroupService.java | 10 + .../service/chart/ChartViewService.java | 36 +- .../service/dataset/DataSetGroupService.java | 10 + .../service/dataset/DataSetTableService.java | 35 +- frontend/src/views/chart/group/Group.vue | 425 +++++++++----- frontend/src/views/chart/index.vue | 10 +- frontend/src/views/chart/view/ChartEdit.vue | 17 +- .../src/views/chart/view/TableSelector.vue | 7 +- frontend/src/views/dataset/add/AddCustom.vue | 3 +- frontend/src/views/dataset/add/AddDB.vue | 3 +- frontend/src/views/dataset/add/AddExcel.vue | 3 +- frontend/src/views/dataset/add/AddSQL.vue | 3 +- .../dataset/common/DatasetGroupSelector.vue | 43 +- .../common/DatasetGroupSelectorTree.vue | 471 +++++++++++++++ .../views/dataset/group/DsMoveSelector.vue | 2 +- frontend/src/views/dataset/group/Group.vue | 543 ++++++++++++------ frontend/src/views/dataset/index.vue | 11 +- 24 files changed, 1297 insertions(+), 367 deletions(-) create mode 100644 frontend/src/views/dataset/common/DatasetGroupSelectorTree.vue diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/ExtChartGroupMapper.java b/backend/src/main/java/io/dataease/base/mapper/ext/ExtChartGroupMapper.java index 6fa66b7e6a..58157b6b3b 100644 --- a/backend/src/main/java/io/dataease/base/mapper/ext/ExtChartGroupMapper.java +++ b/backend/src/main/java/io/dataease/base/mapper/ext/ExtChartGroupMapper.java @@ -1,6 +1,5 @@ package io.dataease.base.mapper.ext; -import io.dataease.controller.request.BaseTreeRequest; import io.dataease.controller.request.chart.ChartGroupRequest; import io.dataease.dto.chart.ChartGroupDTO; diff --git a/backend/src/main/java/io/dataease/controller/chart/ChartGroupController.java b/backend/src/main/java/io/dataease/controller/chart/ChartGroupController.java index 4d62d8a8cb..b321f97891 100644 --- a/backend/src/main/java/io/dataease/controller/chart/ChartGroupController.java +++ b/backend/src/main/java/io/dataease/controller/chart/ChartGroupController.java @@ -26,6 +26,11 @@ public class ChartGroupController { return chartGroupService.tree(ChartGroup); } + @PostMapping("/treeNode") + public List treeNode(@RequestBody ChartGroupRequest ChartGroup) { + return chartGroupService.tree(ChartGroup); + } + @PostMapping("/delete/{id}") public void tree(@PathVariable String id) { chartGroupService.delete(id); diff --git a/backend/src/main/java/io/dataease/controller/chart/ChartViewController.java b/backend/src/main/java/io/dataease/controller/chart/ChartViewController.java index 11ea036799..73f4861455 100644 --- a/backend/src/main/java/io/dataease/controller/chart/ChartViewController.java +++ b/backend/src/main/java/io/dataease/controller/chart/ChartViewController.java @@ -32,6 +32,11 @@ public class ChartViewController { return chartViewService.list(chartViewRequest); } + @PostMapping("/listAndGroup") + public List listAndGroup(@RequestBody ChartViewRequest chartViewRequest) { + return chartViewService.listAndGroup(chartViewRequest); + } + @PostMapping("/get/{id}") public ChartViewWithBLOBs get(@PathVariable String id) { return chartViewService.get(id); diff --git a/backend/src/main/java/io/dataease/controller/dataset/DataSetGroupController.java b/backend/src/main/java/io/dataease/controller/dataset/DataSetGroupController.java index 0d9282dc45..91de251ca2 100644 --- a/backend/src/main/java/io/dataease/controller/dataset/DataSetGroupController.java +++ b/backend/src/main/java/io/dataease/controller/dataset/DataSetGroupController.java @@ -21,6 +21,7 @@ public class DataSetGroupController { private DataSetGroupService dataSetGroupService; @Resource private ExtractDataService extractDataService; + @PostMapping("/save") public DataSetGroupDTO save(@RequestBody DatasetGroup datasetGroup) { return dataSetGroupService.save(datasetGroup); @@ -31,8 +32,13 @@ public class DataSetGroupController { return dataSetGroupService.tree(datasetGroup); } + @PostMapping("/treeNode") + public List treeNode(@RequestBody DataSetGroupRequest datasetGroup) { + return dataSetGroupService.treeNode(datasetGroup); + } + @PostMapping("/delete/{id}") - public void tree(@PathVariable String id) throws Exception{ + public void tree(@PathVariable String id) throws Exception { dataSetGroupService.delete(id); } @@ -42,7 +48,7 @@ public class DataSetGroupController { } @PostMapping("/isKettleRunning") - public boolean isKettleRunning(){ + public boolean isKettleRunning() { return extractDataService.isKettleRunning(); } } diff --git a/backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java b/backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java index b40d009e66..3fe41d449a 100644 --- a/backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java +++ b/backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java @@ -44,6 +44,11 @@ public class DataSetTableController { return dataSetTableService.list(dataSetTableRequest); } + @PostMapping("listAndGroup") + public List listAndGroup(@RequestBody DataSetTableRequest dataSetTableRequest) { + return dataSetTableService.listAndGroup(dataSetTableRequest); + } + @PostMapping("get/{id}") public DatasetTable get(@PathVariable String id) { return dataSetTableService.get(id); diff --git a/backend/src/main/java/io/dataease/dto/chart/ChartViewDTO.java b/backend/src/main/java/io/dataease/dto/chart/ChartViewDTO.java index 0d7b40becd..2adf9f6453 100644 --- a/backend/src/main/java/io/dataease/dto/chart/ChartViewDTO.java +++ b/backend/src/main/java/io/dataease/dto/chart/ChartViewDTO.java @@ -16,4 +16,7 @@ public class ChartViewDTO extends ChartViewWithBLOBs { private Map data; private String privileges; + + private Boolean isLeaf; + private String pid; } diff --git a/backend/src/main/java/io/dataease/dto/dataset/DataSetTableDTO.java b/backend/src/main/java/io/dataease/dto/dataset/DataSetTableDTO.java index 26fe50bcdc..d9ec015bb5 100644 --- a/backend/src/main/java/io/dataease/dto/dataset/DataSetTableDTO.java +++ b/backend/src/main/java/io/dataease/dto/dataset/DataSetTableDTO.java @@ -15,4 +15,7 @@ import java.util.List; public class DataSetTableDTO extends DatasetTable { private List children; private String privileges; + + private Boolean isLeaf; + private String pid; } diff --git a/backend/src/main/java/io/dataease/service/chart/ChartGroupService.java b/backend/src/main/java/io/dataease/service/chart/ChartGroupService.java index d71d72cd9e..6759f2e529 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartGroupService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartGroupService.java @@ -81,6 +81,16 @@ public class ChartGroupService { } public List tree(ChartGroupRequest chartGroup) { + chartGroup.setLevel(null); + chartGroup.setPid("0"); + chartGroup.setType("group"); + chartGroup.setUserId(String.valueOf(AuthUtils.getUser().getUserId())); + List treeInfo = extChartGroupMapper.search(chartGroup); + List result = TreeUtils.mergeTree(treeInfo); + return result; + } + + public List treeNode(ChartGroupRequest chartGroup) { chartGroup.setLevel(null); chartGroup.setPid(null); chartGroup.setUserId(String.valueOf(AuthUtils.getUser().getUserId())); diff --git a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index 56d2f90035..817458703f 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -4,21 +4,23 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import io.dataease.base.domain.*; import io.dataease.base.mapper.ChartViewMapper; +import io.dataease.base.mapper.ext.ExtChartGroupMapper; import io.dataease.base.mapper.ext.ExtChartViewMapper; import io.dataease.commons.utils.AuthUtils; import io.dataease.commons.utils.BeanUtils; import io.dataease.commons.utils.CommonBeanFactory; import io.dataease.controller.request.chart.ChartExtFilterRequest; import io.dataease.controller.request.chart.ChartExtRequest; +import io.dataease.controller.request.chart.ChartGroupRequest; import io.dataease.controller.request.chart.ChartViewRequest; +import io.dataease.controller.request.dataset.DataSetGroupRequest; import io.dataease.datasource.provider.DatasourceProvider; import io.dataease.datasource.provider.ProviderFactory; import io.dataease.datasource.request.DatasourceRequest; import io.dataease.datasource.service.DatasourceService; -import io.dataease.dto.chart.ChartCustomFilterDTO; -import io.dataease.dto.chart.ChartViewDTO; -import io.dataease.dto.chart.ChartViewFieldDTO; -import io.dataease.dto.chart.Series; +import io.dataease.dto.chart.*; +import io.dataease.dto.dataset.DataSetGroupDTO; +import io.dataease.dto.dataset.DataSetTableDTO; import io.dataease.dto.dataset.DataTableInfoDTO; import io.dataease.i18n.Translator; import io.dataease.provider.QueryProvider; @@ -51,6 +53,8 @@ public class ChartViewService { private DatasourceService datasourceService; @Resource private DataSetTableFieldsService dataSetTableFieldsService; + @Resource + private ExtChartGroupMapper extChartGroupMapper; public ChartViewWithBLOBs save(ChartViewWithBLOBs chartView) { checkName(chartView); @@ -72,6 +76,30 @@ public class ChartViewService { return extChartViewMapper.search(chartViewRequest); } + public List listAndGroup(ChartViewRequest chartViewRequest) { + chartViewRequest.setUserId(String.valueOf(AuthUtils.getUser().getUserId())); + List charts = extChartViewMapper.search(chartViewRequest); + charts.forEach(ele -> ele.setIsLeaf(true)); + // 获取group下的子group + ChartGroupRequest chartGroupRequest = new ChartGroupRequest(); + chartGroupRequest.setLevel(null); + chartGroupRequest.setType("group"); + chartGroupRequest.setPid(chartViewRequest.getSceneId()); + chartGroupRequest.setUserId(String.valueOf(AuthUtils.getUser().getUserId())); + List groups = extChartGroupMapper.search(chartGroupRequest); + List group = groups.stream().map(ele -> { + ChartViewDTO dto = new ChartViewDTO(); + dto.setId(ele.getId()); + dto.setName(ele.getName()); + dto.setIsLeaf(false); + dto.setType("group"); + dto.setPid(ele.getPid()); + return dto; + }).collect(Collectors.toList()); + group.addAll(charts); + return group; + } + public ChartViewWithBLOBs get(String id) { return chartViewMapper.selectByPrimaryKey(id); } diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetGroupService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetGroupService.java index 55ea4eb284..50a3cd790d 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetGroupService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetGroupService.java @@ -87,6 +87,16 @@ public class DataSetGroupService { } } + public List treeNode(DataSetGroupRequest datasetGroup) { + datasetGroup.setLevel(null); + datasetGroup.setPid("0"); + datasetGroup.setType("group"); + datasetGroup.setUserId(String.valueOf(AuthUtils.getUser().getUserId())); + List treeInfo = extDataSetGroupMapper.search(datasetGroup); + List result = TreeUtils.mergeTree(treeInfo); + return result; + } + public List tree(DataSetGroupRequest datasetGroup) { datasetGroup.setLevel(null); datasetGroup.setPid(null); diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 0200ea4a5f..55e2cb486b 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -5,21 +5,19 @@ import com.fit2cloud.quartz.anno.QuartzScheduled; import com.google.gson.Gson; import io.dataease.base.domain.*; import io.dataease.base.mapper.*; +import io.dataease.base.mapper.ext.ExtDataSetGroupMapper; import io.dataease.base.mapper.ext.ExtDataSetTableMapper; import io.dataease.base.mapper.ext.UtilMapper; import io.dataease.commons.constants.JobStatus; import io.dataease.commons.utils.*; +import io.dataease.controller.request.dataset.DataSetGroupRequest; import io.dataease.controller.request.dataset.DataSetTableRequest; import io.dataease.datasource.dto.TableFiled; import io.dataease.datasource.provider.DatasourceProvider; import io.dataease.datasource.provider.JdbcProvider; import io.dataease.datasource.provider.ProviderFactory; import io.dataease.datasource.request.DatasourceRequest; -import io.dataease.dto.dataset.DataSetPreviewPage; -import io.dataease.dto.dataset.DataSetTableDTO; -import io.dataease.dto.dataset.DataSetTableUnionDTO; -import io.dataease.dto.dataset.DataTableInfoCustomUnion; -import io.dataease.dto.dataset.DataTableInfoDTO; +import io.dataease.dto.dataset.*; import io.dataease.i18n.Translator; import io.dataease.provider.DDLProvider; import io.dataease.provider.QueryProvider; @@ -81,6 +79,8 @@ public class DataSetTableService { private QrtzSchedulerStateMapper qrtzSchedulerStateMapper; @Resource private DatasetTableTaskLogMapper datasetTableTaskLogMapper; + @Resource + private ExtDataSetGroupMapper extDataSetGroupMapper; private static String lastUpdateTime = "${__last_update_time__}"; private static String currentUpdateTime = "${__current_update_time__}"; @@ -186,6 +186,31 @@ public class DataSetTableService { return extDataSetTableMapper.search(dataSetTableRequest); } + public List listAndGroup(DataSetTableRequest dataSetTableRequest) { + dataSetTableRequest.setUserId(String.valueOf(AuthUtils.getUser().getUserId())); + dataSetTableRequest.setTypeFilter(dataSetTableRequest.getTypeFilter()); + List ds = extDataSetTableMapper.search(dataSetTableRequest); + ds.forEach(ele -> ele.setIsLeaf(true)); + // 获取group下的子group + DataSetGroupRequest datasetGroup = new DataSetGroupRequest(); + datasetGroup.setLevel(null); + datasetGroup.setType("group"); + datasetGroup.setPid(dataSetTableRequest.getSceneId()); + datasetGroup.setUserId(String.valueOf(AuthUtils.getUser().getUserId())); + List groups = extDataSetGroupMapper.search(datasetGroup); + List group = groups.stream().map(ele -> { + DataSetTableDTO dto = new DataSetTableDTO(); + dto.setId(ele.getId()); + dto.setName(ele.getName()); + dto.setIsLeaf(false); + dto.setType("group"); + dto.setPid(ele.getPid()); + return dto; + }).collect(Collectors.toList()); + group.addAll(ds); + return group; + } + public DatasetTable get(String id) { return datasetTableMapper.selectByPrimaryKey(id); } diff --git a/frontend/src/views/chart/group/Group.vue b/frontend/src/views/chart/group/Group.vue index 633aad4e0f..be15db1292 100644 --- a/frontend/src/views/chart/group/Group.vue +++ b/frontend/src/views/chart/group/Group.vue @@ -6,17 +6,20 @@ {{ $t('chart.datalist') }} + + + - - - {{ $t('chart.add_group') }} - - - {{ $t('chart.add_scene') }} - - + + + + + + + + @@ -35,24 +38,29 @@
- + - - - - - - - - + + + + + + + + {{ data.name }} @@ -69,8 +77,11 @@ {{ $t('chart.group') }} - - {{ $t('chart.scene') }} + + + + + {{ $t('chart.add_chart') }} @@ -96,6 +107,33 @@ + + + + {{ data.name }} + + + + + + + + + + + + + {{ $t('chart.delete') }} + + + + + +
@@ -115,110 +153,147 @@ - - - - {{ currGroup.name }} - - - - - - - - - {{ $t('chart.add_chart') }} - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - {{ sceneData }} - - - - - {{ data.name }} - - - - - - - - - - - - - {{ $t('chart.delete') }} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + @@ -240,6 +315,13 @@ import { export default { name: 'Group', components: { TableSelector }, + props: { + saveStatus: { + type: Object, + required: false, + default: null + } + }, data() { return { sceneMode: false, @@ -278,14 +360,19 @@ export default { selectTableFlag: false, table: {}, tables: [], - chartName: this.$t('chart.chartName') + chartName: this.$t('chart.chartName'), + treeProps: { + label: 'name', + children: 'children', + isLeaf: 'isLeaf' + } } }, computed: { - sceneData: function() { - this.reviewChartList() - return this.$store.state.chart.chartSceneData - } + // sceneData: function() { + // this.reviewChartList() + // return this.$store.state.chart.chartSceneData + // } }, watch: { search(val) { @@ -294,18 +381,26 @@ export default { } else { this.chartData = JSON.parse(JSON.stringify(this.tables)) } + }, + saveStatus() { + this.refreshNodeBy(this.saveStatus.sceneId) } }, mounted() { - this.groupTree(this.groupForm) + this.treeNode(this.groupForm) this.refresh() - this.chartTree() + // this.chartTree() }, methods: { clickAdd(param) { - this.add(param.type) - this.groupForm.pid = param.data.id - this.groupForm.level = param.data.level + 1 + this.currGroup = param.data + if (param.type === 'group') { + this.add(param.type) + this.groupForm.pid = param.data.id + this.groupForm.level = param.data.level + 1 + } else { + this.selectTable() + } }, beforeClickAdd(type, data, node) { @@ -369,7 +464,7 @@ export default { type: 'success', showClose: true }) - this.groupTree(this.groupForm) + this.treeNode(this.groupForm) }) } else { // this.$message({ @@ -392,7 +487,8 @@ export default { type: 'success', showClose: true }) - this.chartTree() + // this.chartTree() + this.refreshNodeBy(view.sceneId) // this.$router.push('/chart/home') this.$emit('switchComponent', { name: '' }) this.$store.dispatch('chart/setTable', null) @@ -420,7 +516,7 @@ export default { message: this.$t('chart.delete_success'), showClose: true }) - this.groupTree(this.groupForm) + this.treeNode(this.groupForm) }) }).catch(() => { }) @@ -438,7 +534,8 @@ export default { message: this.$t('chart.delete_success'), showClose: true }) - this.chartTree() + // this.chartTree() + this.refreshNodeBy(data.sceneId) // this.$router.push('/chart/home') this.$emit('switchComponent', { name: '' }) this.$store.dispatch('chart/setTable', null) @@ -473,6 +570,12 @@ export default { }) }, + treeNode(group) { + post('/chart/group/treeNode', group).then(res => { + this.data = res.data + }) + }, + chartTree() { this.tables = [] this.chartData = [] @@ -488,12 +591,15 @@ export default { }, nodeClick(data, node) { - if (data.type === 'scene') { - this.sceneMode = true - this.currGroup = data - this.$store.dispatch('chart/setSceneId', this.currGroup.id) - this.chartTree() + if (data.type !== 'group') { + this.$emit('switchComponent', { name: 'ChartEdit', param: { 'id': data.id }}) } + // if (data.type === 'scene') { + // this.sceneMode = true + // this.currGroup = data + // this.$store.dispatch('chart/setSceneId', this.currGroup.id) + // this.chartTree() + // } // if (node.expanded) { // this.expandedArray.push(data.id) // } else { @@ -516,15 +622,6 @@ export default { } }, - addDB() { - this.$router.push({ - name: 'add_db', - params: { - scene: this.currGroup - } - }) - }, - sceneClick(data, node) { // this.$store.dispatch('chart/setViewId', null) // this.$store.dispatch('chart/setViewId', data.id) @@ -598,7 +695,8 @@ export default { // this.$router.push('/chart/chart-edit') this.$emit('switchComponent', { name: 'ChartEdit', param: { 'id': response.data.id }}) // this.$store.dispatch('chart/setViewId', response.data.id) - this.chartTree() + // this.chartTree() + this.refreshNodeBy(view.sceneId) }) }, @@ -626,6 +724,35 @@ export default { if (data.id) { this.expandedArray.splice(this.expandedArray.indexOf(data.id), 1) } + }, + + loadNode(node, resolve) { + // if (!this.isTreeSearch) { + if (node.level > 0) { + this.tables = [] + this.chartData = [] + if (node.data.id) { + post('/chart/view/listAndGroup', { + sort: 'name asc,create_time desc', + sceneId: node.data.id + }).then(response => { + this.tables = response.data + this.chartData = JSON.parse(JSON.stringify(this.tables)) + resolve(this.chartData) + }) + } + } + // } + }, + + refreshNodeBy(id) { + if (!id || id === '0') { + this.treeNode(this.groupForm) + } else { + const node = this.$refs.asyncTree.getNode(id) // 通过节点id找到对应树节点对象 + node.loaded = false + node.expand() // 主动调用展开节点方法,重新查询该节点下的所有子节点 + } } } } diff --git a/frontend/src/views/chart/index.vue b/frontend/src/views/chart/index.vue index df5e2c6de1..e6eb53f69c 100644 --- a/frontend/src/views/chart/index.vue +++ b/frontend/src/views/chart/index.vue @@ -2,12 +2,12 @@ - + - + @@ -28,7 +28,8 @@ export default { data() { return { component: ChartHome, - param: {} + param: {}, + saveStatus: null } }, mounted() { @@ -45,6 +46,9 @@ export default { this.component = ChartHome break } + }, + saveSuccess(val) { + this.saveStatus = val } } } diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index 8a8ac11cb1..d72cbfed81 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -98,7 +98,7 @@
@@ -481,7 +481,7 @@ export default { return true }) }, - save(getData, trigger) { + save(getData, trigger, needRefreshGroup = false) { const view = JSON.parse(JSON.stringify(this.view)) view.id = this.view.id view.sceneId = this.view.sceneId @@ -549,8 +549,11 @@ export default { this.getChart(response.data.id) } - this.$store.dispatch('chart/setChartSceneData', null) - this.$store.dispatch('chart/setChartSceneData', response.data) + // this.$store.dispatch('chart/setChartSceneData', null) + // this.$store.dispatch('chart/setChartSceneData', response.data) + if (needRefreshGroup) { + this.refreshGroup(view) + } }) }, @@ -797,7 +800,7 @@ export default { onTextChange(val) { this.view.customStyle.text = val this.view.title = val.title - this.save() + this.save(false, '', true) }, onLegendChange(val) { @@ -921,6 +924,10 @@ export default { yAxis: [], type: '' } + }, + + refreshGroup(view) { + this.$emit('saveSuccess', view) } } } diff --git a/frontend/src/views/chart/view/TableSelector.vue b/frontend/src/views/chart/view/TableSelector.vue index 07ae57dbbd..5ce2a2610b 100644 --- a/frontend/src/views/chart/view/TableSelector.vue +++ b/frontend/src/views/chart/view/TableSelector.vue @@ -1,7 +1,7 @@