Merge pull request #1848 from dataease/v1.8

V1.8
This commit is contained in:
王嘉豪 2022-02-28 18:30:58 +08:00 committed by GitHub
commit 4828f7d25e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 141 additions and 71 deletions

View File

@ -26,4 +26,8 @@ public interface ExtChartViewMapper {
ChartViewDTO searchOneWithPrivileges(@Param("userId") String userId,@Param("id") String id ); ChartViewDTO searchOneWithPrivileges(@Param("userId") String userId,@Param("id") String id );
void chartCopyWithPanel(@Param("copyId") String copyId); void chartCopyWithPanel(@Param("copyId") String copyId);
void deleteCircleView(@Param("pid") String pid);
void deleteCircleGroup(@Param("pid") String pid);
} }

View File

@ -228,4 +228,12 @@
) pv_copy ) pv_copy
LEFT JOIN chart_view ON chart_view.id = pv_copy.copy_from_view LEFT JOIN chart_view ON chart_view.id = pv_copy.copy_from_view
</insert> </insert>
<delete id="deleteCircleView">
delete chart_view from (select GET_CHART_GROUP_WITH_CHILDREN(#{pid}) cids) t,chart_view where FIND_IN_SET(chart_view.id,cids) and chart_type='public'
</delete>
<delete id="deleteCircleGroup">
delete chart_group from (select GET_CHART_GROUP_WITH_CHILDREN(#{pid}) cids) t,chart_group where FIND_IN_SET(chart_group.id,cids)
</delete>
</mapper> </mapper>

View File

@ -135,43 +135,10 @@
<select id="queryAuthViewsOriginal" resultMap="ExtResultMap"> <select id="queryAuthViewsOriginal" resultMap="ExtResultMap">
select * from (
SELECT SELECT
chart_group.id, *
chart_group.id AS 'inner_id',
chart_group.NAME,
chart_group.NAME AS 'label',
chart_group.pid AS pid,
chart_group.type AS 'model_inner_type',
'spine' AS node_type,
'view' AS model_type
FROM FROM
chart_group v_history_chart_view viewsOriginal
UNION ALL
SELECT
distinct
chart_view.id,
chart_view.id AS 'inner_id',
chart_view.NAME,
chart_view.NAME AS 'label',
chart_view.scene_id AS pid,
chart_view.type AS 'model_inner_type',
'leaf' AS node_type,
'view' AS model_type
FROM
chart_view
LEFT JOIN panel_view ON panel_view.chart_view_id = chart_view.id
<where>
<if test="record.pids != null and record.pids.size() > 0">
and panel_view.panel_id in
<foreach collection="record.pids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
) viewsOriginal
ORDER BY viewsOriginal.node_type desc, CONVERT(viewsOriginal.label using gbk) asc ORDER BY viewsOriginal.node_type desc, CONVERT(viewsOriginal.label using gbk) asc
</select> </select>

View File

@ -44,9 +44,9 @@ public class ChartGroupController {
@ApiIgnore @ApiIgnore
@ApiOperation("删除") @ApiOperation("删除")
@PostMapping("/delete/{id}") @PostMapping("/deleteCircle/{id}")
public void tree(@PathVariable String id) { public void tree(@PathVariable String id) {
chartGroupService.delete(id); chartGroupService.deleteCircle(id);
} }
@ApiIgnore @ApiIgnore

View File

@ -72,8 +72,8 @@ public class DatasourceController {
@DePermission(type = DePermissionType.DATASOURCE, level = ResourceAuthLevel.DATASOURCE_LEVEL_MANAGE) @DePermission(type = DePermissionType.DATASOURCE, level = ResourceAuthLevel.DATASOURCE_LEVEL_MANAGE)
@ApiOperation("删除数据源") @ApiOperation("删除数据源")
@PostMapping("/delete/{datasourceID}") @PostMapping("/delete/{datasourceID}")
public void deleteDatasource(@PathVariable(value = "datasourceID") String datasourceID) throws Exception { public ResultHolder deleteDatasource(@PathVariable(value = "datasourceID") String datasourceID) throws Exception {
datasourceService.deleteDatasource(datasourceID); return datasourceService.deleteDatasource(datasourceID);
} }
@RequiresPermissions("datasource:read") @RequiresPermissions("datasource:read")

View File

@ -3,6 +3,7 @@ package io.dataease.service.chart;
import io.dataease.base.domain.*; import io.dataease.base.domain.*;
import io.dataease.base.mapper.ChartGroupMapper; import io.dataease.base.mapper.ChartGroupMapper;
import io.dataease.base.mapper.ext.ExtChartGroupMapper; import io.dataease.base.mapper.ext.ExtChartGroupMapper;
import io.dataease.base.mapper.ext.ExtChartViewMapper;
import io.dataease.base.mapper.ext.ExtDataSetGroupMapper; import io.dataease.base.mapper.ext.ExtDataSetGroupMapper;
import io.dataease.commons.utils.AuthUtils; import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.BeanUtils; import io.dataease.commons.utils.BeanUtils;
@ -15,6 +16,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -36,6 +38,8 @@ public class ChartGroupService {
private ExtDataSetGroupMapper extDataSetGroupMapper; private ExtDataSetGroupMapper extDataSetGroupMapper;
@Resource @Resource
private SysAuthService sysAuthService; private SysAuthService sysAuthService;
@Resource
private ExtChartViewMapper extChartViewMapper;
public ChartGroupDTO save(ChartGroup chartGroup) { public ChartGroupDTO save(ChartGroup chartGroup) {
checkName(chartGroup); checkName(chartGroup);
@ -53,26 +57,13 @@ public class ChartGroupService {
return ChartGroupDTO; return ChartGroupDTO;
} }
public void delete(String id) { @Transactional
public void deleteCircle(String id) {
Assert.notNull(id, "id cannot be null"); Assert.notNull(id, "id cannot be null");
sysAuthService.checkTreeNoManageCount("chart",id); //存量视图删除
extChartViewMapper.deleteCircleView(id);
ChartGroup cg = chartGroupMapper.selectByPrimaryKey(id); //存量分组删除
ChartGroupRequest ChartGroup = new ChartGroupRequest(); extChartViewMapper.deleteCircleGroup(id);
BeanUtils.copyBean(ChartGroup, cg);
Map<String, String> stringStringMap = extDataSetGroupMapper.searchIds(id, "chart");
String[] split = stringStringMap.get("ids").split(",");
List<String> ids = new ArrayList<>();
for (String dsId : split) {
if (StringUtils.isNotEmpty(dsId)) {
ids.add(dsId);
}
}
ChartGroupExample ChartGroupExample = new ChartGroupExample();
ChartGroupExample.createCriteria().andIdIn(ids);
chartGroupMapper.deleteByExample(ChartGroupExample);
// 删除所有chart
deleteChart(ids);
} }
public void deleteChart(List<String> sceneIds) { public void deleteChart(List<String> sceneIds) {

View File

@ -163,16 +163,17 @@ public class DatasourceService {
} }
@DeCleaner(DePermissionType.DATASOURCE) @DeCleaner(DePermissionType.DATASOURCE)
public void deleteDatasource(String datasourceId) throws Exception { public ResultHolder deleteDatasource(String datasourceId) throws Exception {
DatasetTableExample example = new DatasetTableExample(); DatasetTableExample example = new DatasetTableExample();
example.createCriteria().andDataSourceIdEqualTo(datasourceId); example.createCriteria().andDataSourceIdEqualTo(datasourceId);
List<DatasetTable> datasetTables = datasetTableMapper.selectByExample(example); List<DatasetTable> datasetTables = datasetTableMapper.selectByExample(example);
if(CollectionUtils.isNotEmpty(datasetTables)){ if(CollectionUtils.isNotEmpty(datasetTables)){
DataEaseException.throwException(datasetTables.size() + Translator.get("i18n_datasource_not_allow_delete_msg")); return ResultHolder.error(datasetTables.size() + Translator.get("i18n_datasource_not_allow_delete_msg"));
} }
Datasource datasource = datasourceMapper.selectByPrimaryKey(datasourceId); Datasource datasource = datasourceMapper.selectByPrimaryKey(datasourceId);
datasourceMapper.deleteByPrimaryKey(datasourceId); datasourceMapper.deleteByPrimaryKey(datasourceId);
handleConnectionPool(datasource, "delete"); handleConnectionPool(datasource, "delete");
return ResultHolder.success("success");
} }
public void updateDatasource(Datasource datasource) { public void updateDatasource(Datasource datasource) {

File diff suppressed because one or more lines are too long

View File

@ -66,3 +66,12 @@ export function pluginTypes() {
method: 'post' method: 'post'
}) })
} }
export function deleteCircle(id) {
return request({
url: '/chart/group/deleteCircle/' + id,
method: 'post',
loading: true
})
}

View File

@ -4,7 +4,7 @@
<span v-if="chart.type" v-show="title_show" ref="title" :style="title_class" style="cursor: default;display: block;"> <span v-if="chart.type" v-show="title_show" ref="title" :style="title_class" style="cursor: default;display: block;">
<p style="padding:6px 10px 0 10px;margin: 0;overflow: hidden;white-space: pre;text-overflow: ellipsis;">{{ chart.title }}</p> <p style="padding:6px 10px 0 10px;margin: 0;overflow: hidden;white-space: pre;text-overflow: ellipsis;">{{ chart.title }}</p>
</span> </span>
<div ref="tableContainer" style="width: 100%;overflow: hidden;padding: 8px;" :style="{background:container_bg_class.background}"> <div ref="tableContainer" style="width: 100%;overflow: hidden;" :style="{background:container_bg_class.background}">
<div v-if="chart.type === 'table-normal'" :id="chartId" style="width: 100%;overflow: hidden;" :class="chart.drill ? 'table-dom-normal-drill' : 'table-dom-normal'" /> <div v-if="chart.type === 'table-normal'" :id="chartId" style="width: 100%;overflow: hidden;" :class="chart.drill ? 'table-dom-normal-drill' : 'table-dom-normal'" />
<div v-if="chart.type === 'table-info'" :id="chartId" style="width: 100%;overflow: hidden;" :class="chart.drill ? 'table-dom-info-drill' : 'table-dom-info'" /> <div v-if="chart.type === 'table-info'" :id="chartId" style="width: 100%;overflow: hidden;" :class="chart.drill ? 'table-dom-info-drill' : 'table-dom-info'" />
<div v-if="chart.type === 'table-pivot'" :id="chartId" style="width: 100%;overflow: hidden;" class="table-dom-normal" /> <div v-if="chart.type === 'table-pivot'" :id="chartId" style="width: 100%;overflow: hidden;" class="table-dom-normal" />

View File

@ -34,8 +34,8 @@
@check="checkChanged" @check="checkChanged"
@node-drag-end="dragEnd" @node-drag-end="dragEnd"
> >
<span slot-scope="{ node, data }" class="custom-tree-node"> <span slot-scope="{ node, data }" class="custom-tree-node-list father">
<span> <span style="display: flex; flex: 1 1 0%; width: 0px;">
<span v-if="data.modelInnerType==='history'"> <span v-if="data.modelInnerType==='history'">
<i class="el-icon-collection" /> <i class="el-icon-collection" />
</span> </span>
@ -48,7 +48,17 @@
<span v-else> <span v-else>
<svg-icon :icon-class="data.modelInnerType" style="width: 14px;height: 14px" /> <svg-icon :icon-class="data.modelInnerType" style="width: 14px;height: 14px" />
</span> </span>
<span style="margin-left: 6px;font-size: 14px">{{ data.name }}</span> <span style="margin-left: 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">{{ data.name }}</span>
</span>
<span v-if="data.mode===1" class="child">
<span @click.stop>
<el-button
icon="el-icon-delete"
type="text"
size="small"
@click="deleteHistory(data, node)"
/>
</span>
</span> </span>
</span> </span>
</el-tree> </el-tree>
@ -63,6 +73,8 @@ import { deepCopy } from '@/components/canvas/utils/utils'
import eventBus from '@/components/canvas/utils/eventBus' import eventBus from '@/components/canvas/utils/eventBus'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import { queryPanelViewTree } from '@/api/panel/panel' import { queryPanelViewTree } from '@/api/panel/panel'
import { deleteCircle } from '@/api/chart/chart'
import { delUser } from '@/api/system/user'
export default { export default {
name: 'ViewSelect', name: 'ViewSelect',
@ -176,8 +188,20 @@ export default {
component.auxiliaryMatrix = this.canvasStyleData.auxiliaryMatrix component.auxiliaryMatrix = this.canvasStyleData.auxiliaryMatrix
component.moveStatus = 'start' component.moveStatus = 'start'
return component return component
},
deleteHistory(data, node) {
deleteCircle(data.id).then(() => {
this.$success(this.$t('commons.delete_success'))
this.remove(node, data)
// this.loadData()
})
},
remove(node, data) {
const parent = node.parent
const children = parent.data.children || parent.data
const index = children.findIndex(d => d.id === data.id)
children.splice(index, 1)
} }
} }
} }
</script> </script>
@ -198,4 +222,22 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.father .child {
/*display: none;*/
visibility: hidden;
}
.father:hover .child {
/*display: inline;*/
visibility: visible;
}
.custom-tree-node-list {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding:0 8px;
}
</style> </style>

View File

@ -268,9 +268,16 @@ export default {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
delDs(datasource.id).then(res => { delDs(datasource.id).then(res => {
this.$success(this.$t('commons.delete_success')) if(res.success){
this.switchMain('DataHome', {}, this.tData) this.$success(this.$t('commons.delete_success'))
this.refreshType(datasource) this.switchMain('DataHome', {}, this.tData)
this.refreshType(datasource)
}else {
this.$message({
type: 'error',
message: res.message
})
}
}) })
}).catch(() => { }).catch(() => {
this.$message({ this.$message({