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 @@