提交 0c0f6d2f authored 作者: wangjiahao's avatar wangjiahao

refactor: 优化新建视图操作

上级 02df8cb9
...@@ -9,6 +9,7 @@ import io.dataease.commons.constants.DePermissionType; ...@@ -9,6 +9,7 @@ import io.dataease.commons.constants.DePermissionType;
import io.dataease.commons.constants.ResourceAuthLevel; import io.dataease.commons.constants.ResourceAuthLevel;
import io.dataease.controller.request.chart.ChartCalRequest; import io.dataease.controller.request.chart.ChartCalRequest;
import io.dataease.controller.request.chart.ChartExtRequest; import io.dataease.controller.request.chart.ChartExtRequest;
import io.dataease.controller.request.chart.ChartViewCacheRequest;
import io.dataease.controller.request.chart.ChartViewRequest; import io.dataease.controller.request.chart.ChartViewRequest;
import io.dataease.controller.response.ChartDetail; import io.dataease.controller.response.ChartDetail;
import io.dataease.dto.chart.ChartViewDTO; import io.dataease.dto.chart.ChartViewDTO;
...@@ -36,8 +37,15 @@ public class ChartViewController { ...@@ -36,8 +37,15 @@ public class ChartViewController {
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE) @DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
@ApiOperation("保存") @ApiOperation("保存")
@PostMapping("/save/{panelId}") @PostMapping("/save/{panelId}")
public ChartViewDTO save(@PathVariable String panelId, @RequestBody ChartViewCacheWithBLOBs chartViewWithBLOBs) { public ChartViewDTO save(@PathVariable String panelId, @RequestBody ChartViewCacheRequest request) {
return chartViewService.save(chartViewWithBLOBs); return chartViewService.save(request);
}
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
@ApiOperation("新建视图")
@PostMapping("/newOne/{panelId}")
public ChartViewWithBLOBs save(@PathVariable String panelId, @RequestBody ChartViewWithBLOBs chartViewWithBLOBs) {
return chartViewService.newOne(chartViewWithBLOBs);
} }
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE) @DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
......
package io.dataease.controller.request.chart;
import io.dataease.base.domain.ChartViewCacheWithBLOBs;
import lombok.Data;
/**
* Author: wangjiahao
* Date: 2022/3/10
* Description:
*/
@Data
public class ChartViewCacheRequest extends ChartViewCacheWithBLOBs {
private String savePosition = "cache";
}
...@@ -79,7 +79,7 @@ public class ChartViewService { ...@@ -79,7 +79,7 @@ public class ChartViewService {
private ReentrantLock lock = new ReentrantLock(); private ReentrantLock lock = new ReentrantLock();
// 直接保存统一到缓存表 // 直接保存统一到缓存表
public ChartViewDTO save(ChartViewCacheWithBLOBs chartView) { public ChartViewDTO save(ChartViewCacheRequest chartView) {
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
chartView.setUpdateTime(timestamp); chartView.setUpdateTime(timestamp);
chartViewCacheMapper.updateByPrimaryKeySelective(chartView); chartViewCacheMapper.updateByPrimaryKeySelective(chartView);
...@@ -90,6 +90,22 @@ public class ChartViewService { ...@@ -90,6 +90,22 @@ public class ChartViewService {
} }
public ChartViewWithBLOBs newOne(ChartViewWithBLOBs chartView) {
long timestamp = System.currentTimeMillis();
chartView.setUpdateTime(timestamp);
chartView.setId(UUID.randomUUID().toString());
chartView.setCreateBy(AuthUtils.getUser().getUsername());
chartView.setCreateTime(timestamp);
chartView.setUpdateTime(timestamp);
chartViewMapper.insertSelective(chartView);
// 新建的视图也存入缓存表中
extChartViewMapper.copyToCache(chartView.getId());
return chartView;
}
// 直接保存统一到缓存表 // 直接保存统一到缓存表
public void save2Cache(ChartViewCacheWithBLOBs chartView) { public void save2Cache(ChartViewCacheWithBLOBs chartView) {
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
...@@ -1761,6 +1777,7 @@ public class ChartViewService { ...@@ -1761,6 +1777,7 @@ public class ChartViewService {
public void resetViewCache (String viewId){ public void resetViewCache (String viewId){
extChartViewMapper.deleteViewCache(viewId); extChartViewMapper.deleteViewCache(viewId);
extChartViewMapper.copyToCache(viewId); extChartViewMapper.copyToCache(viewId);
} }
} }
...@@ -104,9 +104,11 @@ public class PanelGroupService { ...@@ -104,9 +104,11 @@ public class PanelGroupService {
@DeCleaner(DePermissionType.PANEL) @DeCleaner(DePermissionType.PANEL)
// @Transactional // @Transactional
public PanelGroup saveOrUpdate(PanelGroupRequest request) { public PanelGroup saveOrUpdate(PanelGroupRequest request) {
Boolean mobileLayout = panelViewService.syncPanelViews(request);
request.setMobileLayout(mobileLayout);
String panelId = request.getId(); String panelId = request.getId();
if(StringUtils.isNotEmpty(panelId)){
Boolean mobileLayout = panelViewService.syncPanelViews(request);
request.setMobileLayout(mobileLayout);
}
if (StringUtils.isEmpty(panelId)) { if (StringUtils.isEmpty(panelId)) {
// 新建 // 新建
checkPanelName(request.getName(), request.getPid(), PanelConstants.OPT_TYPE_INSERT, null, request.getNodeType()); checkPanelName(request.getName(), request.getPid(), PanelConstants.OPT_TYPE_INSERT, null, request.getNodeType());
......
...@@ -784,7 +784,7 @@ export default { ...@@ -784,7 +784,7 @@ export default {
view.extBubble = JSON.stringify([]) view.extBubble = JSON.stringify([])
this.setChartDefaultOptions(view) this.setChartDefaultOptions(view)
const _this = this const _this = this
post('/chart/view/save/' + this.panelInfo.id, view).then(response => { post('/chart/view/newOne/' + this.panelInfo.id, view).then(response => {
this.closeCreateChart() this.closeCreateChart()
this.$store.dispatch('chart/setTableId', null) this.$store.dispatch('chart/setTableId', null)
this.$store.dispatch('chart/setTableId', this.table.id) this.$store.dispatch('chart/setTableId', this.table.id)
......
<template> <template>
<el-row v-loading="loading" style="height: 100%;overflow-y: hidden;width: 100%;"> <el-row v-loading="loading" style="height: 100%;overflow-y: hidden;width: 100%;border-left: 1px solid #E6E6E6">
<el-tooltip :content="$t('chart.draw_back')"> <el-tooltip :content="$t('chart.draw_back')">
<el-button class="el-icon-d-arrow-right" style="position:absolute;left: 4px;top: 5px;z-index: 1000" size="mini" circle @click="closePanelEdit" /> <el-button class="el-icon-d-arrow-right" style="position:absolute;left: 4px;top: 5px;z-index: 1000" size="mini" circle @click="closePanelEdit" />
</el-tooltip> </el-tooltip>
......
...@@ -237,7 +237,7 @@ ...@@ -237,7 +237,7 @@
</el-row> </el-row>
<el-row> <el-row>
<div class="view-selected-message-class"> <div class="view-selected-message-class">
<span style="font-size: 14px;margin-left: 10px;font-weight: bold;line-height: 20px">{{$t('panel.select_view')}}</span> <span style="font-size: 14px;margin-left: 10px;font-weight: bold;line-height: 20px">{{ $t('panel.select_view') }}</span>
</div> </div>
</el-row> </el-row>
</div> </div>
...@@ -976,17 +976,21 @@ export default { ...@@ -976,17 +976,21 @@ export default {
this.clearCurrentInfo() this.clearCurrentInfo()
this.$store.commit('setCurComponent', { component: component, index: this.componentData.length - 1 }) this.$store.commit('setCurComponent', { component: component, index: this.componentData.length - 1 })
// 编辑时临时保存 当前修改的画布 // 打开属性栏
this.$store.dispatch('panel/setComponentDataTemp', JSON.stringify(this.componentData)) bus.$emit('change_panel_right_draw', true)
this.$store.dispatch('panel/setCanvasStyleDataTemp', JSON.stringify(this.canvasStyleData))
if (this.curComponent.type === 'view') { //
this.$store.dispatch('chart/setViewId', null) // // 编辑时临时保存 当前修改的画布
this.$store.dispatch('chart/setViewId', this.curComponent.propValue.viewId) // this.$store.dispatch('panel/setComponentDataTemp', JSON.stringify(this.componentData))
bus.$emit('PanelSwitchComponent', { // this.$store.dispatch('panel/setCanvasStyleDataTemp', JSON.stringify(this.canvasStyleData))
name: 'ChartEdit', // if (this.curComponent.type === 'view') {
param: { 'id': this.curComponent.propValue.viewId, 'optType': 'edit' } // this.$store.dispatch('chart/setViewId', null)
}) // this.$store.dispatch('chart/setViewId', this.curComponent.propValue.viewId)
} // bus.$emit('PanelSwitchComponent', {
// name: 'ChartEdit',
// param: { 'id': this.curComponent.propValue.viewId, 'optType': 'edit' }
// })
// }
}, },
canvasScroll(event) { canvasScroll(event) {
this.scrollLeft = event.target.scrollLeft this.scrollLeft = event.target.scrollLeft
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论