diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/ExtChartViewMapper.java b/backend/src/main/java/io/dataease/base/mapper/ext/ExtChartViewMapper.java index d35a55d2fd..d1c87fcafe 100644 --- a/backend/src/main/java/io/dataease/base/mapper/ext/ExtChartViewMapper.java +++ b/backend/src/main/java/io/dataease/base/mapper/ext/ExtChartViewMapper.java @@ -39,7 +39,7 @@ public interface ExtChartViewMapper { void copyToCache(@Param("id") String id ); - void deleteCacheWithPanel(@Param("panelId") String panelId ); + void deleteCacheWithPanel(@Param("viewIds") List viewIds,@Param("panelId") String panelId ); void deleteViewCache(@Param("viewId") String viewId ); @@ -48,4 +48,6 @@ public interface ExtChartViewMapper { int updateToCache(@Param("viewId") String viewId ); void copyCache(@Param("sourceViewId") String sourceViewId,@Param("newViewId") String newViewId); + + void deleteNoUseView(@Param("viewIds") List viewIds,@Param("panelId") String panelId ); } diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/ExtChartViewMapper.xml b/backend/src/main/java/io/dataease/base/mapper/ext/ExtChartViewMapper.xml index 531b19914b..7e8766504d 100644 --- a/backend/src/main/java/io/dataease/base/mapper/ext/ExtChartViewMapper.xml +++ b/backend/src/main/java/io/dataease/base/mapper/ext/ExtChartViewMapper.xml @@ -152,23 +152,23 @@ chart_view_cache.id = #{sourceViewId} - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - DELETE cvc - FROM - chart_view_cache cvc - INNER JOIN panel_view pv ON cvc.id = pv.chart_view_id - WHERE - pv.panel_id = #{panelId} + delete from chart_view_cache + where scene_id = #{panelId} + + and id not in + + #{viewId} + + delete from chart_view_cache where id = #{viewId} @@ -434,35 +436,35 @@ UPDATE chart_view cv, - chart_view_cache cve - SET cv.`name` = cve.`name`, - cv.title = cve.title, - cv.scene_id = cve.scene_id, - cv.table_id = cve.table_id, - cv.`type` = cve.`type`, - cv.render = cve.render, - cv.result_count = cve.result_count, - cv.result_mode = cve.result_mode, - cv.create_by = cve.create_by, - cv.create_time = cve.create_time, - cv.update_time = cve.update_time, - cv.style_priority = cve.style_priority, - cv.chart_type = cve.chart_type, - cv.is_plugin = cve.is_plugin, - cv.x_axis = cve.x_axis, - cv.x_axis_ext = cve.x_axis_ext, - cv.y_axis = cve.y_axis, - cv.y_axis_ext = cve.y_axis_ext, - cv.ext_stack = cve.ext_stack, - cv.ext_bubble = cve.ext_bubble, - cv.custom_attr = cve.custom_attr, - cv.custom_style = cve.custom_style, - cv.custom_filter = cve.custom_filter, - cv.drill_fields = cve.drill_fields, - cv.senior = cve.senior, + chart_view_cache cve + SET cv.`name` = cve.`name`, + cv.title = cve.title, + cv.scene_id = cve.scene_id, + cv.table_id = cve.table_id, + cv.`type` = cve.`type`, + cv.render = cve.render, + cv.result_count = cve.result_count, + cv.result_mode = cve.result_mode, + cv.create_by = cve.create_by, + cv.create_time = cve.create_time, + cv.update_time = cve.update_time, + cv.style_priority = cve.style_priority, + cv.chart_type = cve.chart_type, + cv.is_plugin = cve.is_plugin, + cv.x_axis = cve.x_axis, + cv.x_axis_ext = cve.x_axis_ext, + cv.y_axis = cve.y_axis, + cv.y_axis_ext = cve.y_axis_ext, + cv.ext_stack = cve.ext_stack, + cv.ext_bubble = cve.ext_bubble, + cv.custom_attr = cve.custom_attr, + cv.custom_style = cve.custom_style, + cv.custom_filter = cve.custom_filter, + cv.drill_fields = cve.drill_fields, + cv.senior = cve.senior, cv.SNAPSHOT = cve.SNAPSHOT, cv.data_from = cve.data_from - where cve.id = cv.id and cv.id in + where cve.id = cv.id and cv.id in #{viewId} @@ -500,4 +502,15 @@ cv.data_from = cve.data_from where cve.id = cv.id and cv.id =#{viewId} + + + delete from chart_view + where scene_id = #{panelId} + + and id not in + + #{viewId} + + + 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 e23370eb14..04b1f2845b 100644 --- a/backend/src/main/java/io/dataease/controller/chart/ChartViewController.java +++ b/backend/src/main/java/io/dataease/controller/chart/ChartViewController.java @@ -155,4 +155,10 @@ public class ChartViewController { chartViewCacheService.refreshCache(id); } + @ApiOperation("校验视图Title") + @PostMapping("/checkTitle") + public String checkTitle( @RequestBody ChartViewCacheRequest request) { + return chartViewService.checkTitle(request); + } + } 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 8b17f545af..eb5fdd4caf 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -115,6 +115,16 @@ public class ChartViewService { return getOne(chartView.getId(), "panel_edit"); } + public String checkTitle(ChartViewCacheRequest chartView){ + ChartViewCacheExample example = new ChartViewCacheExample(); + example.createCriteria().andTitleEqualTo(chartView.getTitle()).andSceneIdEqualTo(chartView.getSceneId()).andIdNotEqualTo(chartView.getId()); + List result = chartViewCacheMapper.selectByExample(example); + if(CollectionUtils.isNotEmpty(result)){ + return "fail"; + }else{ + return "success"; + } + } public ChartViewWithBLOBs newOne(ChartViewWithBLOBs chartView) { long timestamp = System.currentTimeMillis(); @@ -1030,7 +1040,7 @@ public class ChartViewService { extChartViewMapper.chartCopy(newChartId, id, panelId); extChartViewMapper.copyCache(id,newChartId); extPanelGroupExtendDataMapper.copyExtendData(id,newChartId,panelId); - chartViewCacheService.refreshCache(id); + chartViewCacheService.refreshCache(newChartId); return newChartId; } @@ -1061,7 +1071,7 @@ public class ChartViewService { } public void initViewCache(String panelId) { - extChartViewMapper.deleteCacheWithPanel(panelId); + extChartViewMapper.deleteCacheWithPanel(null,panelId); } } diff --git a/backend/src/main/java/io/dataease/service/panel/PanelViewService.java b/backend/src/main/java/io/dataease/service/panel/PanelViewService.java index 99d438324c..08ed7fcbe1 100644 --- a/backend/src/main/java/io/dataease/service/panel/PanelViewService.java +++ b/backend/src/main/java/io/dataease/service/panel/PanelViewService.java @@ -127,9 +127,10 @@ public class PanelViewService { //将视图从cache表中更新到正式表中 viewIds = panelViewInsertDTOList.stream().map(panelView ->panelView.getChartViewId()).collect(Collectors.toList()); extChartViewMapper.copyCacheToView(viewIds); - extChartViewMapper.deleteCacheWithPanel(panelId); } } + extChartViewMapper.deleteCacheWithPanel(viewIds,panelId); + extChartViewMapper.deleteNoUseView(viewIds,panelId); panelGroup.setMobileLayout(mobileLayout); return viewIds; } diff --git a/frontend/src/api/chart/chart.js b/frontend/src/api/chart/chart.js index 607f23eb21..aa379278ae 100644 --- a/frontend/src/api/chart/chart.js +++ b/frontend/src/api/chart/chart.js @@ -108,3 +108,12 @@ export function resetViewCache(viewId, panelId) { loading: false }) } + +export function checkTitle(data) { + return request({ + url: '/chart/view/checkTitle', + method: 'post', + data: data, + loading: false + }) +} diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index 9758b4c53b..1b42f95804 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -653,6 +653,7 @@ export default { kettle_setting: 'Kettle Setting' }, chart: { + title_repeat: 'The Title Already Exist', save_snapshot: 'Save Snapshot', datalist: 'Chart', add_group: 'Add Group', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 8a8bfa1c4b..a72a0b0de1 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -655,6 +655,7 @@ export default { kettle_setting: 'Kettle 設置' }, chart: { + title_repeat: '当前标题已存在', save_snapshot: '保存縮略圖', datalist: '視圖', add_group: '添加分組', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index f29106533f..543b426f68 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -656,6 +656,7 @@ export default { kettle_setting: 'Kettle 设置' }, chart: { + title_repeat: '当前标题已存在', save_snapshot: '保存缩略图', datalist: '视图', add_group: '添加分组', diff --git a/frontend/src/views/chart/components/component-style/TitleSelector.vue b/frontend/src/views/chart/components/component-style/TitleSelector.vue index 7ef8543423..edbe488e67 100644 --- a/frontend/src/views/chart/components/component-style/TitleSelector.vue +++ b/frontend/src/views/chart/components/component-style/TitleSelector.vue @@ -50,6 +50,7 @@