forked from github/dataease
refactor: 仪表板视图操作优化
This commit is contained in:
parent
59aa355ed9
commit
cfe1ed3fdc
@ -126,11 +126,11 @@
|
||||
`chart_type`,
|
||||
`senior`)
|
||||
SELECT #{newChartId},
|
||||
GET_CHART_VIEW_COPY_NAME(#{oldChartId}),
|
||||
`name`,
|
||||
#{panelId},
|
||||
`table_id`,
|
||||
`type`,
|
||||
GET_CHART_VIEW_COPY_NAME(#{oldChartId}),
|
||||
`title`,
|
||||
`x_axis`,
|
||||
`x_axis_ext`,
|
||||
`y_axis`,
|
||||
@ -151,7 +151,7 @@
|
||||
`result_mode`,
|
||||
'private',
|
||||
`senior`
|
||||
FROM chart_view
|
||||
FROM chart_view_cache
|
||||
WHERE id = #{oldChartId}
|
||||
</insert>
|
||||
|
||||
@ -293,8 +293,7 @@
|
||||
</select>
|
||||
|
||||
<delete id="deleteCacheWithPanel">
|
||||
DELETE cvc,
|
||||
pv
|
||||
DELETE cvc
|
||||
FROM
|
||||
chart_view_cache cvc
|
||||
INNER JOIN panel_view pv ON cvc.id = pv.chart_view_id
|
||||
|
@ -15,12 +15,16 @@ public interface ExtPanelGroupMapper {
|
||||
//会级联删除pid 下的所有数据
|
||||
int deleteCircle(@Param("pid") String pid);
|
||||
|
||||
int deleteCircleView(@Param("pid") String pid);
|
||||
|
||||
int deleteCircleViewCache(@Param("pid") String pid);
|
||||
|
||||
PanelGroupDTO findOneWithPrivileges(@Param("panelId") String panelId,@Param("userId") String userId);
|
||||
|
||||
void copyPanelView(@Param("pid") String panelId);
|
||||
|
||||
//移除未使用的视图
|
||||
void removeUselessViews(@Param("panelId") String panelId);
|
||||
void removeUselessViews(@Param("panelId") String panelId,@Param("viewIds") List<String> viewIds);
|
||||
|
||||
List<PanelGroupDTO> panelGroupInit();
|
||||
|
||||
|
@ -171,6 +171,14 @@
|
||||
delete from panel_group where FIND_IN_SET(panel_group.id,GET_PANEL_GROUP_WITH_CHILDREN(#{pid})) or FIND_IN_SET(panel_group.source,GET_PANEL_GROUP_WITH_CHILDREN(#{pid}))
|
||||
</delete>
|
||||
|
||||
<delete id="deleteCircleView">
|
||||
delete from chart_view where FIND_IN_SET(chart_view.scene_id,GET_PANEL_GROUP_WITH_CHILDREN(#{pid}))
|
||||
</delete>
|
||||
|
||||
<delete id="deleteCircleViewCache">
|
||||
delete from chart_view_cache where FIND_IN_SET(chart_view_cache.scene_id,GET_PANEL_GROUP_WITH_CHILDREN(#{pid}))
|
||||
</delete>
|
||||
|
||||
<insert id="copyPanelView">
|
||||
INSERT INTO panel_view ( id, panel_id, chart_view_id ) SELECT
|
||||
uuid(),
|
||||
@ -189,14 +197,13 @@
|
||||
WHERE
|
||||
chart_view.chart_type = 'private'
|
||||
AND chart_view.scene_id = #{panelId}
|
||||
AND id NOT IN (
|
||||
SELECT
|
||||
panel_view.chart_view_id
|
||||
FROM
|
||||
panel_view
|
||||
WHERE
|
||||
panel_view.panel_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>
|
||||
|
@ -39,6 +39,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
@ -98,7 +99,6 @@ public class ChartViewService {
|
||||
chartView.setCreateTime(timestamp);
|
||||
chartView.setUpdateTime(timestamp);
|
||||
chartViewMapper.insertSelective(chartView);
|
||||
|
||||
// 新建的视图也存入缓存表中
|
||||
extChartViewMapper.copyToCache(chartView.getId());
|
||||
|
||||
@ -221,6 +221,7 @@ public class ChartViewService {
|
||||
return extChartViewMapper.searchOneWithPrivileges(userId, id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ChartViewDTO getOne(String id,String queryFrom){
|
||||
ChartViewDTO result;
|
||||
//仪表板编辑页面 从缓存表中取数据 缓存表中没有数据则进行插入
|
||||
@ -1742,6 +1743,7 @@ public class ChartViewService {
|
||||
public String chartCopy(String id, String panelId) {
|
||||
String newChartId = UUID.randomUUID().toString();
|
||||
extChartViewMapper.chartCopy(newChartId, id, panelId);
|
||||
extChartViewMapper.copyToCache(newChartId);
|
||||
return newChartId;
|
||||
}
|
||||
|
||||
|
@ -105,9 +105,9 @@ public class PanelGroupService {
|
||||
// @Transactional
|
||||
public PanelGroup saveOrUpdate(PanelGroupRequest request) {
|
||||
String panelId = request.getId();
|
||||
List<String> viewIds = null;
|
||||
if(StringUtils.isNotEmpty(panelId)){
|
||||
Boolean mobileLayout = panelViewService.syncPanelViews(request);
|
||||
request.setMobileLayout(mobileLayout);
|
||||
viewIds = panelViewService.syncPanelViews(request);
|
||||
}
|
||||
if (StringUtils.isEmpty(panelId)) {
|
||||
// 新建
|
||||
@ -166,7 +166,7 @@ public class PanelGroupService {
|
||||
}
|
||||
|
||||
//移除没有用到的仪表板私有视图
|
||||
// extPanelGroupMapper.removeUselessViews(panelId);
|
||||
extPanelGroupMapper.removeUselessViews(panelId,viewIds);
|
||||
return panelGroupDTOList.get(0);
|
||||
}
|
||||
|
||||
@ -189,12 +189,18 @@ public class PanelGroupService {
|
||||
public void deleteCircle(String id) {
|
||||
Assert.notNull(id, "id cannot be null");
|
||||
sysAuthService.checkTreeNoManageCount("panel", id);
|
||||
|
||||
//清理view 和 view cache
|
||||
extPanelGroupMapper.deleteCircleView(id);
|
||||
extPanelGroupMapper.deleteCircleViewCache(id);
|
||||
|
||||
// 同时会删除对应默认仪表盘
|
||||
extPanelGroupMapper.deleteCircle(id);
|
||||
storeService.removeByPanelId(id);
|
||||
shareService.delete(id, null);
|
||||
panelLinkService.deleteByResourceId(id);
|
||||
|
||||
|
||||
//清理跳转信息
|
||||
extPanelLinkJumpMapper.deleteJumpTargetViewInfoWithPanel(id);
|
||||
extPanelLinkJumpMapper.deleteJumpInfoWithPanel(id);
|
||||
|
@ -84,7 +84,8 @@ public class PanelViewService {
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public Boolean syncPanelViews(PanelGroupWithBLOBs panelGroup) {
|
||||
public List<String> syncPanelViews(PanelGroupWithBLOBs panelGroup) {
|
||||
List<String> viewIds = new ArrayList<>();
|
||||
Boolean mobileLayout = null;
|
||||
String panelId = panelGroup.getId();
|
||||
Assert.notNull(panelId, "panelId cannot be null");
|
||||
@ -120,12 +121,13 @@ public class PanelViewService {
|
||||
if (CollectionUtils.isNotEmpty(panelViewInsertDTOList)) {
|
||||
extPanelViewMapper.savePanelView(panelViewInsertDTOList);
|
||||
//将视图从cache表中更新到正式表中
|
||||
List<String> viewIds = panelViewInsertDTOList.stream().map(panelView ->panelView.getChartViewId()).collect(Collectors.toList());
|
||||
viewIds = panelViewInsertDTOList.stream().map(panelView ->panelView.getChartViewId()).collect(Collectors.toList());
|
||||
extChartViewMapper.copyCacheToView(viewIds);
|
||||
extChartViewMapper.deleteCacheWithPanel(panelId);
|
||||
}
|
||||
}
|
||||
return mobileLayout;
|
||||
panelGroup.setMobileLayout(mobileLayout);
|
||||
return viewIds;
|
||||
}
|
||||
|
||||
public List<PanelViewTableDTO> detailList(String panelId) {
|
||||
|
@ -1281,7 +1281,8 @@ export default {
|
||||
drill: false,
|
||||
hasEdit: false,
|
||||
quotaItemCompare: {},
|
||||
showEditQuotaCompare: false
|
||||
showEditQuotaCompare: false,
|
||||
preChartId: ''
|
||||
|
||||
}
|
||||
},
|
||||
@ -1297,14 +1298,13 @@ export default {
|
||||
])
|
||||
},
|
||||
watch: {
|
||||
'param': function() {
|
||||
'param': function(val) {
|
||||
if (this.param.optType === 'new') {
|
||||
//
|
||||
} else {
|
||||
this.resetDrill()
|
||||
this.initFromPanel()
|
||||
// this.getData(this.param.id)
|
||||
this.getChart(this.param.id)
|
||||
} else if (this.param.id !== this.preChartId) {
|
||||
this.preChartId = this.param.id
|
||||
this.chartInit()
|
||||
// console.log('fromwatch:' + JSON.stringify(val))
|
||||
}
|
||||
},
|
||||
searchField(val) {
|
||||
@ -1323,12 +1323,11 @@ export default {
|
||||
// this.initAreas()
|
||||
},
|
||||
mounted() {
|
||||
debugger
|
||||
this.bindPluginEvent()
|
||||
// this.get(this.$store.state.chart.viewId);
|
||||
// this.getData(this.param.id)
|
||||
// this.getChart(this.param.id)
|
||||
// this.myEcharts();
|
||||
this.initFromPanel()
|
||||
this.chartInit()
|
||||
// console.log('mounted')
|
||||
},
|
||||
activated() {
|
||||
},
|
||||
@ -1337,6 +1336,11 @@ export default {
|
||||
initFromPanel() {
|
||||
this.hasEdit = (this.panelViewEditInfo[this.param.id] || false)
|
||||
},
|
||||
chartInit() {
|
||||
this.resetDrill()
|
||||
this.initFromPanel()
|
||||
this.getChart(this.param.id)
|
||||
},
|
||||
bindPluginEvent() {
|
||||
bus.$on('show-dimension-edit-filter', this.showDimensionEditFilter)
|
||||
bus.$on('show-rename', this.showRename)
|
||||
|
@ -225,9 +225,9 @@
|
||||
</el-row>
|
||||
</de-main-container>
|
||||
|
||||
<div v-if="!this.mobileLayoutStatus&&this.rightDrawOpen" class="tools-window-main">
|
||||
<div v-if="!mobileLayoutStatus&&rightDrawOpen" class="tools-window-main">
|
||||
<div v-if="showViewToolsAside">
|
||||
<chart-edit v-if="this.curComponent" ref="chartEditRef" :edit-from="'panel'" :param="chartEditParam" />
|
||||
<chart-edit v-if="curComponent" ref="chartEditRef" :edit-from="'panel'" :param="chartEditParam" />
|
||||
</div>
|
||||
<div v-if="!showViewToolsAside">
|
||||
<el-row style="height: 40px">
|
||||
@ -562,6 +562,7 @@ export default {
|
||||
this.$store.commit('resetViewEditInfo')
|
||||
},
|
||||
mounted() {
|
||||
debugger
|
||||
// this.insertToBody()
|
||||
bus.$on('component-on-drag', () => {
|
||||
this.show = false
|
||||
@ -618,6 +619,10 @@ export default {
|
||||
initPanelData(panelId, function() {
|
||||
// 初始化视图缓存
|
||||
initViewCache(panelId)
|
||||
// 初始化保存状态
|
||||
setTimeout(() => {
|
||||
_this.$store.commit('refreshSaveStatus')
|
||||
}, 500)
|
||||
// initPanelComponentsData(panelId, function(rsp) {
|
||||
// _this.$store.commit('initPanelComponents', rsp)// 初始化仪表板组件视图数据
|
||||
// _this.$store.commit('recordSnapshot', 'init')// 记录快照
|
||||
|
Loading…
Reference in New Issue
Block a user