forked from github/dataease
feat: 完善分享列表
This commit is contained in:
parent
d171a6ccfa
commit
9d1a7e4e0f
@ -3,6 +3,7 @@ package io.dataease.base.mapper.ext;
|
||||
import io.dataease.base.domain.PanelShare;
|
||||
import io.dataease.base.mapper.ext.query.GridExample;
|
||||
import io.dataease.dto.panel.PanelShareDto;
|
||||
import io.dataease.dto.panel.PanelSharePo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@ -11,7 +12,7 @@ public interface ExtPanelShareMapper {
|
||||
|
||||
int batchInsert(@Param("shares") List<PanelShare> shares);
|
||||
|
||||
List<PanelShareDto> query(GridExample example);
|
||||
List<PanelSharePo> query(GridExample example);
|
||||
|
||||
List<PanelShare> queryWithResource(GridExample example);
|
||||
}
|
||||
|
@ -2,11 +2,10 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="io.dataease.base.mapper.ext.ExtPanelShareMapper">
|
||||
|
||||
<resultMap id="treeNodeMap" type="io.dataease.dto.panel.PanelShareDto">
|
||||
<resultMap id="treeNodeMap" type="io.dataease.dto.panel.PanelSharePo">
|
||||
<id column="id" property="id" />
|
||||
<result column="name" property="name" />
|
||||
<result column="pid" property="pid" />
|
||||
<result column="creator" property="create_by" />
|
||||
<result column="creator" property="creator" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchInsert" parameterType="io.dataease.base.domain.PanelShare">
|
||||
@ -18,7 +17,7 @@
|
||||
</insert>
|
||||
|
||||
<select id="query" parameterType="io.dataease.base.mapper.ext.query.GridExample" resultMap="treeNodeMap">
|
||||
select s.panel_group_id as id, g.create_by as pid, g.name
|
||||
select s.panel_group_id as id, g.create_by as creator, g.name
|
||||
from panel_share s
|
||||
left join panel_group g on g.id = s.panel_group_id
|
||||
<if test="_parameter != null">
|
||||
|
@ -1,21 +1,15 @@
|
||||
package io.dataease.dto.panel;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class PanelShareDto {
|
||||
@NoArgsConstructor
|
||||
public class PanelShareDto extends PanelSharePo{
|
||||
|
||||
@ApiModelProperty("节点ID")
|
||||
private String id;
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
@ApiModelProperty("节点父ID")
|
||||
private String creator;
|
||||
@ApiModelProperty("子节点")
|
||||
private List<PanelShareDto> children;
|
||||
|
||||
|
@ -0,0 +1,20 @@
|
||||
package io.dataease.dto.panel;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class PanelSharePo {
|
||||
|
||||
@ApiModelProperty("节点ID")
|
||||
private String id;
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
@ApiModelProperty("节点父ID")
|
||||
private String creator;
|
||||
|
||||
|
||||
}
|
@ -7,11 +7,13 @@ import io.dataease.base.mapper.PanelShareMapper;
|
||||
import io.dataease.base.mapper.ext.ExtPanelShareMapper;
|
||||
import io.dataease.base.mapper.ext.query.GridExample;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.controller.request.panel.PanelShareRequest;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.base.ConditionEntity;
|
||||
import io.dataease.dto.panel.PanelShareDto;
|
||||
import io.dataease.dto.panel.PanelSharePo;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -96,14 +98,20 @@ public class ShareService {
|
||||
request.setConditions(new ArrayList<ConditionEntity>(){{add(condition);}});
|
||||
|
||||
GridExample example = request.convertExample();
|
||||
List<PanelShareDto> datas = extPanelShareMapper.query(example);
|
||||
return convertTree(datas);
|
||||
List<PanelSharePo> datas = extPanelShareMapper.query(example);
|
||||
List<PanelShareDto> dtoLists = datas.stream().map(po -> BeanUtils.copyBean(new PanelShareDto(), po)).collect(Collectors.toList());
|
||||
return convertTree(dtoLists);
|
||||
}
|
||||
|
||||
//List构建Tree
|
||||
private List<PanelShareDto> convertTree(List<PanelShareDto> datas){
|
||||
Map<String, List<PanelShareDto>> map = datas.stream().collect(Collectors.groupingBy(PanelShareDto::getCreator));
|
||||
return map.entrySet().stream().map(entry -> PanelShareDto.builder().name(entry.getKey()).children(entry.getValue()).build()).collect(Collectors.toList());
|
||||
return map.entrySet().stream().map(entry -> {
|
||||
PanelShareDto panelShareDto = new PanelShareDto();
|
||||
panelShareDto.setName(entry.getKey());
|
||||
panelShareDto.setChildren(entry.getValue());
|
||||
return panelShareDto;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<PanelShare> queryWithResource(BaseGridRequest request){
|
||||
|
@ -18,3 +18,12 @@ export function loadShares(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function loadTree(data) {
|
||||
return request({
|
||||
url: '/api/share/treeList',
|
||||
method: 'post',
|
||||
loading: true,
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
|
36
frontend/src/views/panel/GrantAuth/shareTree.vue
Normal file
36
frontend/src/views/panel/GrantAuth/shareTree.vue
Normal file
@ -0,0 +1,36 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
<el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { loadTree } from '@/api/panel/share'
|
||||
export default {
|
||||
name: 'ShareTree',
|
||||
data() {
|
||||
return {
|
||||
data: [],
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'name'
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.initData()
|
||||
},
|
||||
methods: {
|
||||
initData() {
|
||||
const param = {}
|
||||
loadTree(param).then(res => {
|
||||
this.data = res.data
|
||||
})
|
||||
},
|
||||
handleNodeClick(data) {
|
||||
console.log(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -2,7 +2,7 @@
|
||||
<de-container>
|
||||
|
||||
<de-aside-container>
|
||||
<el-tabs v-model="activeName" @tab-click="handleClick">
|
||||
<el-tabs v-model="activeName" :lazy="true" @tab-click="handleClick">
|
||||
<el-tab-pane name="PanelList">
|
||||
<span slot="label"><i class="el-icon-document" />列表</span>
|
||||
<PanelList @switchComponent="switchComponent" />
|
||||
@ -13,7 +13,7 @@
|
||||
</el-tab-pane>
|
||||
<el-tab-pane name="panels_share">
|
||||
<span slot="label"><i class="el-icon-share" />分享</span>
|
||||
开发中...
|
||||
<share-tree />
|
||||
</el-tab-pane>
|
||||
<!-- <el-tab-pane name="example">-->
|
||||
<!-- <span slot="label"><i class="el-icon-star-on"></i>示例</span>-->
|
||||
@ -38,10 +38,11 @@ import DeAsideContainer from '@/components/dataease/DeAsideContainer'
|
||||
import PanelList from './list/PanelList'
|
||||
import PanelView from './list/PanelView'
|
||||
import PanelViewShow from './list/PanelViewShow'
|
||||
import ShareTree from './GrantAuth/shareTree'
|
||||
|
||||
export default {
|
||||
name: 'Panel',
|
||||
components: { DeMainContainer, DeContainer, DeAsideContainer, PanelList, PanelView, PanelViewShow },
|
||||
components: { DeMainContainer, DeContainer, DeAsideContainer, PanelList, PanelView, PanelViewShow, ShareTree },
|
||||
data() {
|
||||
return {
|
||||
component: PanelViewShow,
|
||||
|
@ -232,29 +232,29 @@ export default {
|
||||
})
|
||||
},
|
||||
getData(id) {
|
||||
if (id) {
|
||||
post('/chart/view/getData/' + id, null).then(response => {
|
||||
this.view = response.data
|
||||
this.view.xaxis = this.view.xaxis ? JSON.parse(this.view.xaxis) : []
|
||||
this.view.yaxis = this.view.yaxis ? JSON.parse(this.view.yaxis) : []
|
||||
// if (id) {
|
||||
// post('/chart/view/getData/' + id, null).then(response => {
|
||||
// this.view = response.data
|
||||
// this.view.xaxis = this.view.xaxis ? JSON.parse(this.view.xaxis) : []
|
||||
// this.view.yaxis = this.view.yaxis ? JSON.parse(this.view.yaxis) : []
|
||||
|
||||
const chart = response.data
|
||||
const chart_option = JSON.parse(JSON.stringify(BASE_BAR))
|
||||
// console.log(chart_option);
|
||||
if (chart.data) {
|
||||
chart_option.title.text = chart.title
|
||||
chart_option.xAxis.data = chart.data.x
|
||||
chart.data.series.forEach(function(y) {
|
||||
chart_option.legend.data.push(y.name)
|
||||
chart_option.series.push(y)
|
||||
})
|
||||
}
|
||||
// console.log(chart_option);
|
||||
this.myEcharts(chart_option)
|
||||
})
|
||||
} else {
|
||||
this.view = {}
|
||||
}
|
||||
// const chart = response.data
|
||||
// const chart_option = JSON.parse(JSON.stringify(BASE_BAR))
|
||||
// // console.log(chart_option);
|
||||
// if (chart.data) {
|
||||
// chart_option.title.text = chart.title
|
||||
// chart_option.xAxis.data = chart.data.x
|
||||
// chart.data.series.forEach(function(y) {
|
||||
// chart_option.legend.data.push(y.name)
|
||||
// chart_option.series.push(y)
|
||||
// })
|
||||
// }
|
||||
// // console.log(chart_option);
|
||||
// this.myEcharts(chart_option)
|
||||
// })
|
||||
// } else {
|
||||
// this.view = {}
|
||||
// }
|
||||
},
|
||||
|
||||
// 左边往右边拖动时的事件
|
||||
|
Loading…
Reference in New Issue
Block a user