forked from github/dataease
refactor: 优化新建视图操作
This commit is contained in:
parent
02df8cb956
commit
0c0f6d2f8b
@ -9,6 +9,7 @@ import io.dataease.commons.constants.DePermissionType;
|
||||
import io.dataease.commons.constants.ResourceAuthLevel;
|
||||
import io.dataease.controller.request.chart.ChartCalRequest;
|
||||
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.response.ChartDetail;
|
||||
import io.dataease.dto.chart.ChartViewDTO;
|
||||
@ -36,8 +37,15 @@ public class ChartViewController {
|
||||
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
|
||||
@ApiOperation("保存")
|
||||
@PostMapping("/save/{panelId}")
|
||||
public ChartViewDTO save(@PathVariable String panelId, @RequestBody ChartViewCacheWithBLOBs chartViewWithBLOBs) {
|
||||
return chartViewService.save(chartViewWithBLOBs);
|
||||
public ChartViewDTO save(@PathVariable String panelId, @RequestBody ChartViewCacheRequest request) {
|
||||
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)
|
||||
|
@ -0,0 +1,15 @@
|
||||
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 {
|
||||
private ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
// 直接保存统一到缓存表
|
||||
public ChartViewDTO save(ChartViewCacheWithBLOBs chartView) {
|
||||
public ChartViewDTO save(ChartViewCacheRequest chartView) {
|
||||
long timestamp = System.currentTimeMillis();
|
||||
chartView.setUpdateTime(timestamp);
|
||||
chartViewCacheMapper.updateByPrimaryKeySelective(chartView);
|
||||
@ -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) {
|
||||
long timestamp = System.currentTimeMillis();
|
||||
@ -1761,6 +1777,7 @@ public class ChartViewService {
|
||||
|
||||
public void resetViewCache (String viewId){
|
||||
extChartViewMapper.deleteViewCache(viewId);
|
||||
|
||||
extChartViewMapper.copyToCache(viewId);
|
||||
}
|
||||
}
|
||||
|
@ -104,9 +104,11 @@ public class PanelGroupService {
|
||||
@DeCleaner(DePermissionType.PANEL)
|
||||
// @Transactional
|
||||
public PanelGroup saveOrUpdate(PanelGroupRequest request) {
|
||||
Boolean mobileLayout = panelViewService.syncPanelViews(request);
|
||||
request.setMobileLayout(mobileLayout);
|
||||
String panelId = request.getId();
|
||||
if(StringUtils.isNotEmpty(panelId)){
|
||||
Boolean mobileLayout = panelViewService.syncPanelViews(request);
|
||||
request.setMobileLayout(mobileLayout);
|
||||
}
|
||||
if (StringUtils.isEmpty(panelId)) {
|
||||
// 新建
|
||||
checkPanelName(request.getName(), request.getPid(), PanelConstants.OPT_TYPE_INSERT, null, request.getNodeType());
|
||||
|
@ -784,7 +784,7 @@ export default {
|
||||
view.extBubble = JSON.stringify([])
|
||||
this.setChartDefaultOptions(view)
|
||||
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.$store.dispatch('chart/setTableId', null)
|
||||
this.$store.dispatch('chart/setTableId', this.table.id)
|
||||
|
@ -1,5 +1,5 @@
|
||||
<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-button class="el-icon-d-arrow-right" style="position:absolute;left: 4px;top: 5px;z-index: 1000" size="mini" circle @click="closePanelEdit" />
|
||||
</el-tooltip>
|
||||
|
@ -237,7 +237,7 @@
|
||||
</el-row>
|
||||
<el-row>
|
||||
<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>
|
||||
</el-row>
|
||||
</div>
|
||||
@ -976,17 +976,21 @@ export default {
|
||||
this.clearCurrentInfo()
|
||||
this.$store.commit('setCurComponent', { component: component, index: this.componentData.length - 1 })
|
||||
|
||||
// 编辑时临时保存 当前修改的画布
|
||||
this.$store.dispatch('panel/setComponentDataTemp', JSON.stringify(this.componentData))
|
||||
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)
|
||||
bus.$emit('PanelSwitchComponent', {
|
||||
name: 'ChartEdit',
|
||||
param: { 'id': this.curComponent.propValue.viewId, 'optType': 'edit' }
|
||||
})
|
||||
}
|
||||
// 打开属性栏
|
||||
bus.$emit('change_panel_right_draw', true)
|
||||
|
||||
//
|
||||
// // 编辑时临时保存 当前修改的画布
|
||||
// this.$store.dispatch('panel/setComponentDataTemp', JSON.stringify(this.componentData))
|
||||
// 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)
|
||||
// bus.$emit('PanelSwitchComponent', {
|
||||
// name: 'ChartEdit',
|
||||
// param: { 'id': this.curComponent.propValue.viewId, 'optType': 'edit' }
|
||||
// })
|
||||
// }
|
||||
},
|
||||
canvasScroll(event) {
|
||||
this.scrollLeft = event.target.scrollLeft
|
||||
|
Loading…
Reference in New Issue
Block a user