forked from github/dataease
Merge pull request #2041 from dataease/pr@dev@refactor_check-view-title
refactor: 视图编辑时检验title是否重复
This commit is contained in:
commit
d149075373
@ -39,7 +39,7 @@ public interface ExtChartViewMapper {
|
||||
|
||||
void copyToCache(@Param("id") String id );
|
||||
|
||||
void deleteCacheWithPanel(@Param("panelId") String panelId );
|
||||
void deleteCacheWithPanel(@Param("viewIds") List<String> 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<String> viewIds,@Param("panelId") String panelId );
|
||||
}
|
||||
|
@ -152,23 +152,23 @@
|
||||
chart_view_cache.id = #{sourceViewId}
|
||||
</insert>
|
||||
|
||||
<!-- <select id="searchOne" resultMap="BaseResultMapDTO">-->
|
||||
<!-- select-->
|
||||
<!-- id, `name`, scene_id, table_id, `type`, title, create_by, create_time, update_time,-->
|
||||
<!-- style_priority,x_axis, y_axis, custom_attr, custom_style, custom_filter, snapshot-->
|
||||
<!-- from chart_view-->
|
||||
<!-- <where>-->
|
||||
<!-- <if test="sceneId != null">-->
|
||||
<!-- and scene_id = #{sceneId,jdbcType=VARCHAR}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="id != null">-->
|
||||
<!-- and id = #{id,jdbcType=VARCHAR}-->
|
||||
<!-- </if>-->
|
||||
<!-- </where>-->
|
||||
<!-- <if test="sort != null">-->
|
||||
<!-- order by ${sort}-->
|
||||
<!-- </if>-->
|
||||
<!-- </select>-->
|
||||
<!-- <select id="searchOne" resultMap="BaseResultMapDTO">-->
|
||||
<!-- select-->
|
||||
<!-- id, `name`, scene_id, table_id, `type`, title, create_by, create_time, update_time,-->
|
||||
<!-- style_priority,x_axis, y_axis, custom_attr, custom_style, custom_filter, snapshot-->
|
||||
<!-- from chart_view-->
|
||||
<!-- <where>-->
|
||||
<!-- <if test="sceneId != null">-->
|
||||
<!-- and scene_id = #{sceneId,jdbcType=VARCHAR}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="id != null">-->
|
||||
<!-- and id = #{id,jdbcType=VARCHAR}-->
|
||||
<!-- </if>-->
|
||||
<!-- </where>-->
|
||||
<!-- <if test="sort != null">-->
|
||||
<!-- order by ${sort}-->
|
||||
<!-- </if>-->
|
||||
<!-- </select>-->
|
||||
|
||||
<select id="search" resultMap="BaseResultMapDTO">
|
||||
select
|
||||
@ -407,7 +407,7 @@
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="searchViewsWithPanelId" resultMap="BaseResultMapDTO">
|
||||
<select id="searchViewsWithPanelId" resultMap="BaseResultMapDTO">
|
||||
SELECT * FROM chart_view
|
||||
WHERE
|
||||
id IN (
|
||||
@ -421,12 +421,14 @@
|
||||
</select>
|
||||
|
||||
<delete id="deleteCacheWithPanel">
|
||||
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}
|
||||
<if test="viewIds != null and viewIds.size() > 0">
|
||||
and id not in
|
||||
<foreach collection="viewIds" item="viewId" open='(' separator=',' close=')'>
|
||||
#{viewId}
|
||||
</foreach>
|
||||
</if>
|
||||
</delete>
|
||||
<delete id="deleteViewCache">
|
||||
delete from chart_view_cache where id = #{viewId}
|
||||
@ -434,35 +436,35 @@
|
||||
|
||||
<update id="copyCacheToView">
|
||||
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
|
||||
<foreach collection="viewIds" item="viewId" open='(' separator=',' close=')'>
|
||||
#{viewId}
|
||||
</foreach>
|
||||
@ -500,4 +502,15 @@
|
||||
cv.data_from = cve.data_from
|
||||
where cve.id = cv.id and cv.id =#{viewId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteNoUseView">
|
||||
delete from chart_view
|
||||
where scene_id = #{panelId}
|
||||
<if test="viewIds != null and viewIds.size() > 0">
|
||||
and id not in
|
||||
<foreach collection="viewIds" item="viewId" open='(' separator=',' close=')'>
|
||||
#{viewId}
|
||||
</foreach>
|
||||
</if>
|
||||
</delete>
|
||||
</mapper>
|
||||
|
@ -155,4 +155,10 @@ public class ChartViewController {
|
||||
chartViewCacheService.refreshCache(id);
|
||||
}
|
||||
|
||||
@ApiOperation("校验视图Title")
|
||||
@PostMapping("/checkTitle")
|
||||
public String checkTitle( @RequestBody ChartViewCacheRequest request) {
|
||||
return chartViewService.checkTitle(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<ChartViewCache> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
})
|
||||
}
|
||||
|
@ -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',
|
||||
|
@ -655,6 +655,7 @@ export default {
|
||||
kettle_setting: 'Kettle 設置'
|
||||
},
|
||||
chart: {
|
||||
title_repeat: '当前标题已存在',
|
||||
save_snapshot: '保存縮略圖',
|
||||
datalist: '視圖',
|
||||
add_group: '添加分組',
|
||||
|
@ -656,6 +656,7 @@ export default {
|
||||
kettle_setting: 'Kettle 设置'
|
||||
},
|
||||
chart: {
|
||||
title_repeat: '当前标题已存在',
|
||||
save_snapshot: '保存缩略图',
|
||||
datalist: '视图',
|
||||
add_group: '添加分组',
|
||||
|
@ -50,6 +50,7 @@
|
||||
|
||||
<script>
|
||||
import { COLOR_PANEL, DEFAULT_TITLE_STYLE } from '../../chart/chart'
|
||||
import { checkTitle } from '@/api/chart/chart'
|
||||
|
||||
export default {
|
||||
name: 'TitleSelector',
|
||||
@ -114,10 +115,18 @@ export default {
|
||||
this.titleForm.title = this.chart.title
|
||||
return
|
||||
}
|
||||
if (!this.titleForm.show) {
|
||||
this.isSetting = false
|
||||
}
|
||||
this.$emit('onTextChange', this.titleForm)
|
||||
checkTitle({ id: this.chart.id, title: this.titleForm.title, sceneId: this.chart.sceneId }).then((rsp) => {
|
||||
if (rsp.data === 'success') {
|
||||
if (!this.titleForm.show) {
|
||||
this.isSetting = false
|
||||
}
|
||||
this.$emit('onTextChange', this.titleForm)
|
||||
} else {
|
||||
this.$error(this.$t('chart.title_repeat'))
|
||||
this.titleForm.title = this.chart.title
|
||||
return
|
||||
}
|
||||
})
|
||||
},
|
||||
inputOnInput: function(e) {
|
||||
this.$forceUpdate()
|
||||
|
@ -877,7 +877,7 @@
|
||||
@onLegendChange="onLegendChange"
|
||||
/>
|
||||
</el-collapse-item>
|
||||
<el-collapse-item v-if="chart.customStyle && chart.customStyle.background" name="background" :title="$t('chart.background')">
|
||||
<el-collapse-item v-if="chart.customStyle && view.customStyle.background" name="background" :title="$t('chart.background')">
|
||||
<background-color-selector
|
||||
:param="param"
|
||||
class="attr-selector"
|
||||
|
Loading…
Reference in New Issue
Block a user