forked from github/dataease
feat: 增加数据集同步消息提醒
This commit is contained in:
parent
25203a6bb8
commit
dadeb745b4
@ -0,0 +1,12 @@
|
||||
package io.dataease.auth.service;
|
||||
|
||||
import io.dataease.commons.model.AuthURD;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface ExtAuthService {
|
||||
|
||||
Set<Long> userIdsByRD(AuthURD request);
|
||||
|
||||
AuthURD resourceTarget(String resourceId);
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package io.dataease.auth.service.impl;
|
||||
|
||||
import io.dataease.auth.service.ExtAuthService;
|
||||
import io.dataease.base.domain.SysAuth;
|
||||
import io.dataease.base.domain.SysAuthExample;
|
||||
import io.dataease.base.mapper.SysAuthMapper;
|
||||
import io.dataease.base.mapper.ext.ExtAuthMapper;
|
||||
import io.dataease.commons.model.AuthURD;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class ExtAuthServiceImpl implements ExtAuthService {
|
||||
|
||||
@Resource
|
||||
private ExtAuthMapper extAuthMapper;
|
||||
|
||||
@Resource
|
||||
private SysAuthMapper sysAuthMapper;
|
||||
|
||||
@Override
|
||||
public Set<Long> userIdsByRD(AuthURD request) {
|
||||
Set<Long> result = new HashSet<>();
|
||||
List<Long> roleIds = request.getRoleIds();
|
||||
List<Long> deptIds = request.getDeptIds();
|
||||
if (!CollectionUtils.isEmpty(roleIds)) {
|
||||
result.addAll(extAuthMapper.queryUserIdWithRoleIds(roleIds));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(deptIds)) {
|
||||
result.addAll(extAuthMapper.queryUserIdWithDeptIds(deptIds));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthURD resourceTarget(String resourceId) {
|
||||
AuthURD authURD = new AuthURD();
|
||||
SysAuthExample example = new SysAuthExample();
|
||||
example.createCriteria().andAuthSourceEqualTo(resourceId);
|
||||
List<SysAuth> sysAuths = sysAuthMapper.selectByExample(example);
|
||||
Map<String, List<SysAuth>> authMap = sysAuths.stream().collect(Collectors.groupingBy(SysAuth::getAuthTargetType));
|
||||
if (!CollectionUtils.isEmpty(authMap.get("user"))) {
|
||||
authURD.setUserIds(authMap.get("user").stream().map(item -> Long.parseLong(item.getAuthTarget())).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(authMap.get("role"))) {
|
||||
authURD.setUserIds(authMap.get("role").stream().map(item -> Long.parseLong(item.getAuthTarget())).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(authMap.get("dept"))) {
|
||||
authURD.setUserIds(authMap.get("dept").stream().map(item -> Long.parseLong(item.getAuthTarget())).collect(Collectors.toList()));
|
||||
}
|
||||
return authURD;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package io.dataease.base.mapper.ext;
|
||||
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface ExtAuthMapper {
|
||||
|
||||
List<Long> queryUserIdWithRoleIds(@Param("roleIds") List<Long> roleIds);
|
||||
|
||||
List<Long> queryUserIdWithDeptIds(@Param("deptIds") List<Long> deptIds);
|
||||
|
||||
|
||||
// Set<Long> queryUserIdWithRD(@Param("roleIds") List<Long> roleIds, @Param("deptIds") List<Long> deptIds);
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!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.ExtAuthMapper">
|
||||
|
||||
|
||||
<select id="queryUserIdWithRoleIds" resultType="java.lang.Long" >
|
||||
select user_id
|
||||
from sys_users_roles
|
||||
where role_id in
|
||||
<foreach collection="roleIds" item="roleId" open='(' separator=',' close=')'>
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryUserIdWithDeptIds" resultType="java.lang.Long" >
|
||||
select user_id
|
||||
from sys_user
|
||||
where dept_id in
|
||||
<foreach collection="deptIds" item="deptId" open='(' separator=',' close=')'>
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
@ -46,9 +46,9 @@
|
||||
|
||||
</select>
|
||||
|
||||
<select id="queryUserIdWithRoleIds" >
|
||||
<select id="queryUserIdWithRoleIds" resultType="java.lang.Long" >
|
||||
select user_id
|
||||
from sys_user
|
||||
from sys_users_roles
|
||||
where role_id in
|
||||
<foreach collection="roleIds" item="roleId" open='(' separator=',' close=')'>
|
||||
#{roleId}
|
||||
@ -56,7 +56,7 @@
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryUserIdWithDeptIds" >
|
||||
<select id="queryUserIdWithDeptIds" resultType="java.lang.Long" >
|
||||
select user_id
|
||||
from sys_user
|
||||
where dept_id in
|
||||
|
19
backend/src/main/java/io/dataease/commons/model/AuthURD.java
Normal file
19
backend/src/main/java/io/dataease/commons/model/AuthURD.java
Normal file
@ -0,0 +1,19 @@
|
||||
package io.dataease.commons.model;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AuthURD implements Serializable {
|
||||
|
||||
private List<Long> userIds;
|
||||
|
||||
private List<Long> deptIds;
|
||||
|
||||
private List<Long> roleIds;
|
||||
|
||||
|
||||
}
|
@ -1,23 +1,41 @@
|
||||
package io.dataease.commons.utils;
|
||||
|
||||
import io.dataease.auth.api.dto.CurrentUserDto;
|
||||
import io.dataease.service.sys.SysUserService;
|
||||
import io.dataease.auth.service.ExtAuthService;
|
||||
import io.dataease.commons.model.AuthURD;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class AuthUtils {
|
||||
|
||||
private static SysUserService sysUserService;
|
||||
private static ExtAuthService extAuthService;
|
||||
|
||||
@Autowired
|
||||
public void setSysUserService(SysUserService sysUserService) {
|
||||
AuthUtils.sysUserService = sysUserService;
|
||||
public void setExtAuthService(ExtAuthService extAuthService) {
|
||||
AuthUtils.extAuthService = extAuthService;
|
||||
}
|
||||
|
||||
public static CurrentUserDto getUser(){
|
||||
CurrentUserDto userDto = (CurrentUserDto)SecurityUtils.getSubject().getPrincipal();
|
||||
return userDto;
|
||||
}
|
||||
|
||||
//根据组织 角色 用户 获取下属用户ID
|
||||
public static Set<Long> userIdsByURD(AuthURD request) {
|
||||
Set<Long> userIds = extAuthService.userIdsByRD(request);
|
||||
if (!CollectionUtils.isEmpty(request.getUserIds())) {
|
||||
userIds.addAll(request.getUserIds());
|
||||
}
|
||||
return userIds;
|
||||
}
|
||||
|
||||
// 获取资源对那些人/角色/组织 有权限
|
||||
public static AuthURD authURDR(String resourceId) {
|
||||
return extAuthService.resourceTarget(resourceId);
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,8 @@ import io.dataease.commons.constants.JdbcConstants;
|
||||
import io.dataease.commons.constants.JobStatus;
|
||||
import io.dataease.commons.constants.ScheduleType;
|
||||
import io.dataease.commons.constants.UpdateType;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.commons.utils.DorisTableUtils;
|
||||
import io.dataease.commons.utils.HttpClientUtil;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.model.AuthURD;
|
||||
import io.dataease.commons.utils.*;
|
||||
import io.dataease.datasource.constants.DatasourceTypes;
|
||||
import io.dataease.datasource.dto.DorisConfigration;
|
||||
import io.dataease.datasource.dto.MysqlConfigration;
|
||||
@ -27,6 +25,7 @@ import io.dataease.dto.dataset.DataTableInfoDTO;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.listener.util.CacheUtils;
|
||||
import io.dataease.provider.QueryProvider;
|
||||
import io.dataease.service.message.DeMsgutil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -77,8 +76,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@ -209,10 +207,12 @@ public class ExtractDataService {
|
||||
extractData(datasetTable, "all_scope");
|
||||
replaceTable(DorisTableUtils.dorisName(datasetTableId));
|
||||
saveSucessLog(datasetTableTaskLog);
|
||||
sendWebMsg(datasetTable, taskId,true);
|
||||
deleteFile("all_scope", datasetTableId);
|
||||
updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, execTime);
|
||||
}catch (Exception e){
|
||||
saveErrorLog(datasetTableId, taskId, e);
|
||||
sendWebMsg(datasetTable, taskId,false);
|
||||
updateTableStatus(datasetTableId, datasetTable, JobStatus.Error, null);
|
||||
dropDorisTable(DorisTableUtils.dorisTmpName(DorisTableUtils.dorisName(datasetTableId)));
|
||||
deleteFile("all_scope", datasetTableId);
|
||||
@ -233,6 +233,7 @@ public class ExtractDataService {
|
||||
Long execTime = System.currentTimeMillis();
|
||||
extractData(datasetTable, "incremental_add");
|
||||
saveSucessLog(datasetTableTaskLog);
|
||||
sendWebMsg(datasetTable, taskId,true);
|
||||
updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, execTime);
|
||||
}else {
|
||||
DatasetTableIncrementalConfig datasetTableIncrementalConfig = dataSetTableService.incrementalConfig(datasetTableId);
|
||||
@ -270,12 +271,14 @@ public class ExtractDataService {
|
||||
extractData(datasetTable, "incremental_delete");
|
||||
}
|
||||
saveSucessLog(datasetTableTaskLog);
|
||||
sendWebMsg(datasetTable, taskId,true);
|
||||
deleteFile("incremental_add", datasetTableId);
|
||||
deleteFile("incremental_delete", datasetTableId);
|
||||
updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, execTime);
|
||||
}
|
||||
}catch (Exception e){
|
||||
saveErrorLog(datasetTableId, taskId, e);
|
||||
sendWebMsg(datasetTable, taskId,false);
|
||||
updateTableStatus(datasetTableId, datasetTable, JobStatus.Error, null);
|
||||
deleteFile("incremental_add", datasetTableId);
|
||||
deleteFile("incremental_delete", datasetTableId);
|
||||
@ -297,6 +300,20 @@ public class ExtractDataService {
|
||||
|
||||
}
|
||||
|
||||
private void sendWebMsg(DatasetTable datasetTable, String taskId, Boolean status) {
|
||||
String msg = status ? "成功" : "失败";
|
||||
String id = datasetTable.getId();
|
||||
AuthURD authURD = AuthUtils.authURDR(id);
|
||||
Set<Long> userIds = AuthUtils.userIdsByURD(authURD);
|
||||
Gson gson = new Gson();
|
||||
userIds.forEach(userId -> {
|
||||
Map<String,Object> param = new HashMap<>();
|
||||
param.put("tableId", id);
|
||||
param.put("taskId", taskId);
|
||||
DeMsgutil.sendMsg(userId, 1, "数据集【"+datasetTable.getName()+"】同步"+msg, gson.toJson(param));
|
||||
});
|
||||
}
|
||||
|
||||
private void updateTableStatus(String datasetTableId, DatasetTable datasetTable, JobStatus completed, Long execTime) {
|
||||
datasetTable.setSyncStatus(completed.name());
|
||||
if(execTime != null){
|
||||
|
@ -16,8 +16,8 @@ public class DeMsgutil {
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
routerMap = new HashMap<>();
|
||||
routerMap.put(0, "/panel/index");
|
||||
routerMap.put(1, "/dataset/index");
|
||||
routerMap.put(0, "panel");
|
||||
routerMap.put(1, "dataset");
|
||||
}
|
||||
|
||||
private static SysMsgService sysMsgService;
|
||||
@ -38,4 +38,16 @@ public class DeMsgutil {
|
||||
sysMsgService.save(sysMsg);
|
||||
}
|
||||
|
||||
public static void sendMsg(Long userId, int type, String content, String param) {
|
||||
SysMsg sysMsg = new SysMsg();
|
||||
sysMsg.setUserId(userId);
|
||||
sysMsg.setType(type);
|
||||
sysMsg.setContent(content);
|
||||
sysMsg.setRouter(routerMap.get(type));
|
||||
sysMsg.setStatus(false);
|
||||
sysMsg.setCreateTime(System.currentTimeMillis());
|
||||
sysMsg.setParam(param);
|
||||
sysMsgService.save(sysMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,16 @@
|
||||
package io.dataease.service.panel;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.auth.api.dto.CurrentRoleDto;
|
||||
import io.dataease.auth.api.dto.CurrentUserDto;
|
||||
import io.dataease.base.domain.PanelGroup;
|
||||
import io.dataease.base.domain.PanelShare;
|
||||
import io.dataease.base.domain.PanelShareExample;
|
||||
import io.dataease.base.mapper.PanelGroupMapper;
|
||||
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.model.AuthURD;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
@ -31,12 +35,15 @@ public class ShareService {
|
||||
@Autowired(required = false)
|
||||
private PanelShareMapper mapper;
|
||||
|
||||
@Resource
|
||||
private PanelGroupMapper panelGroupMapper;
|
||||
|
||||
@Resource
|
||||
private ExtPanelShareMapper extPanelShareMapper;
|
||||
|
||||
@Transactional
|
||||
public void save(PanelShareRequest request){
|
||||
|
||||
List<PanelGroup> panelGroups = queryGroup(request.getPanelIds());
|
||||
//1.先根据仪表板删除所有已经分享的
|
||||
Integer type = request.getType();
|
||||
List<String> panelIds = request.getPanelIds();
|
||||
@ -67,26 +74,32 @@ public class ShareService {
|
||||
|
||||
// 下面是发送提醒消息逻辑
|
||||
Set<Long> userIdSet = new HashSet<Long>();
|
||||
AuthURD authURD = new AuthURD();
|
||||
if (type == 0) {
|
||||
userIdSet.addAll(targetIds);
|
||||
}else if(type == 1) {
|
||||
Map<String, List<Long>> param = new HashMap<>();
|
||||
param.put("roleIds", targetIds);
|
||||
List<Long> userIdList = extPanelShareMapper.queryUserIdWithRoleIds(param);
|
||||
userIdSet.addAll(userIdList);
|
||||
} else if (type == 2) {
|
||||
Map<String, List<Long>> param = new HashMap<>();
|
||||
param.put("deptIds", targetIds);
|
||||
List<Long> userIdList = extPanelShareMapper.queryUserIdWithDeptIds(param);
|
||||
userIdSet.addAll(userIdList);
|
||||
authURD.setUserIds(targetIds);
|
||||
}
|
||||
if (type == 1) {
|
||||
authURD.setRoleIds(targetIds);
|
||||
}
|
||||
if(type == 2) {
|
||||
authURD.setDeptIds(targetIds);
|
||||
}
|
||||
userIdSet = AuthUtils.userIdsByURD(authURD);
|
||||
|
||||
CurrentUserDto user = AuthUtils.getUser();
|
||||
String msg = StringUtils.joinWith(",", panelGroups.stream().map(PanelGroup::getName).collect(Collectors.toList()));
|
||||
Gson gson = new Gson();
|
||||
userIdSet.forEach(userId -> {
|
||||
DeMsgutil.sendMsg(userId, 0, "用户 [" + user.getNickName()+"] 分享了仪表板给您,请查收!");
|
||||
// DeMsgutil.sendMsg(userId, 0, user.getNickName()+" 分享了仪表板【"+msg+"】给您,请查收!");
|
||||
DeMsgutil.sendMsg(userId, 0, user.getNickName()+" 分享了仪表板【"+msg+"】给您,请查收!", gson.toJson(panelIds));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private List<PanelGroup> queryGroup(List<String> panelIds) {
|
||||
return panelIds.stream().map(panelGroupMapper::selectByPrimaryKey).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* panel_group_id建了索引 效率不会很差
|
||||
* @param panel_group_id
|
||||
|
@ -11,7 +11,7 @@
|
||||
>
|
||||
<div style="height: 30px;">
|
||||
<div style="float: left;font-size:16px;font-weight:bold;">
|
||||
<span>站内消息通知</span>
|
||||
<span>{{ $t('webmsg.web_msg') }}</span>
|
||||
</div>
|
||||
<div v-if="showSetting" style="float: right;">
|
||||
<a href="#" style="text-detext-decoratext-decoration:none;cursor:point;" @click="msgSetting">消息规则</a>
|
||||
@ -31,7 +31,7 @@
|
||||
<div class="start-item">
|
||||
<div class="filter-db-row star-item-content" @click="showDetail(scope.row)">
|
||||
<!-- <svg-icon icon-class="panel" class="ds-icon-scene" /> -->
|
||||
<div class="title-div"><span>【{{ getTypeName(scope.row.type) }}】 {{ scope.row.content }}</span></div>
|
||||
<div class="title-div"><span>【{{ $t(getTypeName(scope.row.type)) }}】 {{ scope.row.content }}</span></div>
|
||||
<div class="title-div"><span>{{ scope.row.createTime | timestampFormatDate }}</span></div>
|
||||
</div>
|
||||
<!-- <div class="star-item-close">
|
||||
@ -43,7 +43,7 @@
|
||||
</el-table>
|
||||
<div class="msg-foot-class">
|
||||
<el-row style="padding: 5px 0;margin-bottom: -5px;cursor:point;" @click="showMore">
|
||||
<span @click="showMore">查看更多</span>
|
||||
<span @click="showMore">{{ $t('webmsg.show_more') }}</span>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
@ -53,7 +53,7 @@
|
||||
class-name="notification"
|
||||
icon-class="notification"
|
||||
/>
|
||||
<span class="msg-number">9</span>
|
||||
<span v-if="paginationConfig.total" class="msg-number">{{ paginationConfig.total }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-popover>
|
||||
@ -81,15 +81,19 @@ export default {
|
||||
},
|
||||
created() {
|
||||
this.search()
|
||||
// 每30s定时刷新拉取消息
|
||||
setInterval(() => {
|
||||
this.search()
|
||||
}, 30000)
|
||||
},
|
||||
methods: {
|
||||
handClick(lang) {
|
||||
console.log(lang)
|
||||
},
|
||||
showDetail(row) {
|
||||
const param = { ...{ msgNotification: true, msgType: row.type }}
|
||||
const param = { ...{ msgNotification: true, msgType: row.type, sourceParam: row.param }}
|
||||
this.visible = false
|
||||
this.$router.push({ name: 'panel', params: param })
|
||||
this.$router.push({ name: row.router, params: param })
|
||||
this.setReaded(row.msgId)
|
||||
},
|
||||
remove(row) {
|
||||
@ -105,7 +109,9 @@ export default {
|
||||
this.$emit('refresh-top-bar')
|
||||
},
|
||||
search() {
|
||||
const param = {}
|
||||
const param = {
|
||||
status: false
|
||||
}
|
||||
const { currentPage, pageSize } = this.paginationConfig
|
||||
query(currentPage, pageSize, param).then(response => {
|
||||
this.data = response.data.listObject
|
||||
|
@ -1132,5 +1132,12 @@ export default {
|
||||
can_not_move_change_sort: 'Cannot move to change sort',
|
||||
can_not_move_parent_to_children: 'Parent organization cannot move to its own child node',
|
||||
move_success: 'Mobile success'
|
||||
},
|
||||
webmsg: {
|
||||
web_msg: 'On site message notification',
|
||||
show_more: 'View more',
|
||||
all_type: 'All type',
|
||||
panel_type: 'Panel Share',
|
||||
dataset_type: 'Dataset sync'
|
||||
}
|
||||
}
|
||||
|
@ -1174,5 +1174,12 @@ export default {
|
||||
can_not_move_change_sort: '不能移動以改變排序',
|
||||
can_not_move_parent_to_children: '父組織不能移動到自己的子節點下',
|
||||
move_success: '移動成功'
|
||||
},
|
||||
webmsg: {
|
||||
web_msg: '站內消息通知',
|
||||
show_more: '查看更多',
|
||||
all_type: '全部類型',
|
||||
panel_type: '儀表板分享',
|
||||
dataset_type: '數據集同步'
|
||||
}
|
||||
}
|
||||
|
@ -1133,5 +1133,12 @@ export default {
|
||||
can_not_move_change_sort: '不能移动以改变排序',
|
||||
can_not_move_parent_to_children: '父组织不能移动到自己的子节点下',
|
||||
move_success: '移动成功'
|
||||
},
|
||||
webmsg: {
|
||||
web_msg: '站内消息通知',
|
||||
show_more: '查看更多',
|
||||
all_type: '全部类型',
|
||||
panel_type: '仪表板分享',
|
||||
dataset_type: '数据集同步'
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
export const msgTypes = [
|
||||
{ value: -1, label: '全部类型' },
|
||||
{ value: 0, label: '仪表板分享' },
|
||||
{ value: 1, label: '数据集同步' }
|
||||
// { value: -1, label: '全部类型' },
|
||||
// { value: 0, label: '仪表板分享' },
|
||||
// { value: 1, label: '数据集同步' }
|
||||
{ value: -1, label: 'webmsg.all_type' },
|
||||
{ value: 0, label: 'webmsg.panel_type' },
|
||||
{ value: 1, label: 'webmsg.dataset_type' }
|
||||
]
|
||||
|
||||
export const getTypeName = value => {
|
||||
|
@ -103,6 +103,9 @@ export default {
|
||||
'param': function() {
|
||||
this.initTable(this.param)
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
},
|
||||
mounted() {
|
||||
this.initTable(this.param)
|
||||
@ -187,6 +190,10 @@ export default {
|
||||
return {
|
||||
'type': type
|
||||
}
|
||||
},
|
||||
msg2Current(sourceParam) {
|
||||
this.tabActive = 'updateInfo'
|
||||
this.table.msgTaskId = sourceParam.taskId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
<de-main-container>
|
||||
<!--<router-view/>-->
|
||||
<component :is="component" :param="param" @switchComponent="switchComponent" @saveSuccess="saveSuccess" />
|
||||
<component :is="component" ref="dynamic_component" :param="param" @switchComponent="switchComponent" @saveSuccess="saveSuccess" />
|
||||
</de-main-container>
|
||||
</de-container>
|
||||
</template>
|
||||
@ -40,6 +40,27 @@ export default {
|
||||
mounted() {
|
||||
removeClass(document.body, 'showRightPanel')
|
||||
},
|
||||
created() {
|
||||
this.$store.dispatch('app/toggleSideBarHide', true)
|
||||
let routerParam
|
||||
if ((routerParam = this.$router.currentRoute.params) !== null && routerParam.msgNotification) {
|
||||
// 说明是从消息通知跳转过来的
|
||||
if (routerParam.msgType === 1) { // 是数据集同步
|
||||
if (routerParam.sourceParam) {
|
||||
try {
|
||||
const msgParam = JSON.parse(routerParam.sourceParam)
|
||||
this.param = msgParam.tableId
|
||||
this.component = ViewTable
|
||||
this.$nextTick(() => {
|
||||
this.$refs.dynamic_component.msg2Current(routerParam.sourceParam)
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
switchComponent(c) {
|
||||
this.param = c.param
|
||||
|
@ -2,7 +2,7 @@
|
||||
<layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]">
|
||||
|
||||
<el-radio-group v-model="selectType" style="margin-bottom: 15px;" @change="typeChange">
|
||||
<el-radio-button v-for="(item,index) in msgTypes" :key="index" class="de-msg-radio-class" :label="item.value">{{ item.label }}</el-radio-button>
|
||||
<el-radio-button v-for="(item,index) in msgTypes" :key="index" class="de-msg-radio-class" :label="item.value">{{ $t(item.label) }}</el-radio-button>
|
||||
|
||||
</el-radio-group>
|
||||
<complex-table
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
<el-table-column prop="type" :label="$t('datasource.type')" width="120">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ getTypeName(scope.row.type) }}</span>
|
||||
<span>{{ $t(getTypeName(scope.row.type)) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
@ -104,8 +104,8 @@ export default {
|
||||
this.search()
|
||||
},
|
||||
toDetail(row) {
|
||||
const param = { ...{ msgNotification: true, msgType: row.type }}
|
||||
this.$router.push({ name: 'panel', params: param })
|
||||
const param = { ...{ msgNotification: true, msgType: row.type, sourceParam: row.param }}
|
||||
this.$router.push({ name: row.router, params: param })
|
||||
this.setReaded(row)
|
||||
},
|
||||
// 设置已读
|
||||
|
@ -2,7 +2,7 @@
|
||||
<layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]">
|
||||
|
||||
<el-radio-group v-model="selectType" style="margin-bottom: 15px;" @change="typeChange">
|
||||
<el-radio-button v-for="(item,index) in msgTypes" :key="index" class="de-msg-radio-class" :label="item.value">{{ item.label }}</el-radio-button>
|
||||
<el-radio-button v-for="(item,index) in msgTypes" :key="index" class="de-msg-radio-class" :label="item.value">{{ $t(item.label) }}</el-radio-button>
|
||||
|
||||
</el-radio-group>
|
||||
<complex-table
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
<el-table-column prop="type" :label="$t('datasource.type')" width="120">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ getTypeName(scope.row.type) }}</span>
|
||||
<span>{{ $t(getTypeName(scope.row.type)) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
@ -87,10 +87,9 @@ export default {
|
||||
|
||||
search() {
|
||||
const param = {}
|
||||
|
||||
param.status = true
|
||||
if (this.selectType >= 0) {
|
||||
param.type = this.selectType
|
||||
param.status = true
|
||||
}
|
||||
const { currentPage, pageSize } = this.paginationConfig
|
||||
query(currentPage, pageSize, param).then(response => {
|
||||
@ -105,8 +104,8 @@ export default {
|
||||
this.search()
|
||||
},
|
||||
toDetail(row) {
|
||||
const param = { ...{ msgNotification: true, msgType: row.type }}
|
||||
this.$router.push({ name: 'panel', params: param })
|
||||
const param = { ...{ msgNotification: true, msgType: row.type, sourceParam: row.param }}
|
||||
this.$router.push({ name: row.router, params: param })
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
<layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]">
|
||||
|
||||
<el-radio-group v-model="selectType" style="margin-bottom: 15px;" @change="typeChange">
|
||||
<el-radio-button v-for="(item,index) in msgTypes" :key="index" class="de-msg-radio-class" :label="item.value">{{ item.label }}</el-radio-button>
|
||||
<el-radio-button v-for="(item,index) in msgTypes" :key="index" class="de-msg-radio-class" :label="item.value">{{ $t(item.label) }}</el-radio-button>
|
||||
|
||||
</el-radio-group>
|
||||
<complex-table
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
<el-table-column prop="type" :label="$t('datasource.type')" width="120">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ getTypeName(scope.row.type) }}</span>
|
||||
<span>{{ $t(getTypeName(scope.row.type)) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
@ -87,10 +87,9 @@ export default {
|
||||
|
||||
search() {
|
||||
const param = {}
|
||||
|
||||
param.status = false
|
||||
if (this.selectType >= 0) {
|
||||
param.type = this.selectType
|
||||
param.status = false
|
||||
}
|
||||
const { currentPage, pageSize } = this.paginationConfig
|
||||
query(currentPage, pageSize, param).then(response => {
|
||||
@ -105,8 +104,8 @@ export default {
|
||||
this.search()
|
||||
},
|
||||
toDetail(row) {
|
||||
const param = { ...{ msgNotification: true, msgType: row.type }}
|
||||
this.$router.push({ name: 'panel', params: param })
|
||||
const param = { ...{ msgNotification: true, msgType: row.type, sourceParam: row.param }}
|
||||
this.$router.push({ name: row.router, params: param })
|
||||
this.setReaded(row)
|
||||
},
|
||||
// 设置已读
|
||||
|
@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
<el-tree :data="datas" :props="defaultProps" @node-click="handleNodeClick">
|
||||
<el-tree :data="datas" :props="defaultProps" node-key="name" :default-expanded-keys="expandNodes" @node-click="handleNodeClick">
|
||||
<span slot-scope="{ data }" class="custom-tree-node">
|
||||
<span>
|
||||
<span :class="!!data.msgNode ? 'msg-node-class': ''">
|
||||
<span v-if="!!data.id">
|
||||
<el-button
|
||||
icon="el-icon-picture-outline"
|
||||
@ -23,24 +23,35 @@ import { uuid } from 'vue-uuid'
|
||||
import { get } from '@/api/panel/panel'
|
||||
export default {
|
||||
name: 'ShareTree',
|
||||
props: {
|
||||
msgPanelIds: {
|
||||
type: Array,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
datas: [],
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'name'
|
||||
}
|
||||
},
|
||||
expandNodes: []
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.initData()
|
||||
this.initData().then(res => {
|
||||
this.datas = res.data
|
||||
if (this.msgPanelIds && this.msgPanelIds.length > 0) {
|
||||
this.expandMsgNode(this.msgPanelIds)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
methods: {
|
||||
initData() {
|
||||
const param = {}
|
||||
loadTree(param).then(res => {
|
||||
this.datas = res.data
|
||||
})
|
||||
return loadTree(param)
|
||||
},
|
||||
handleNodeClick(data) {
|
||||
get('panel/group/findOne/' + data.id).then(response => {
|
||||
@ -58,7 +69,35 @@ export default {
|
||||
}
|
||||
|
||||
return data
|
||||
},
|
||||
expandMsgNode(panelIds) {
|
||||
console.log(panelIds)
|
||||
this.$nextTick(() => {
|
||||
this.getMsgNodes(panelIds)
|
||||
})
|
||||
},
|
||||
getMsgNodes(panelIds) {
|
||||
this.datas.forEach(item => {
|
||||
if (item.children && item.children.length > 0) {
|
||||
item.children.forEach(node => {
|
||||
if (panelIds.includes(node.id)) {
|
||||
node.msgNode = true
|
||||
this.expandNodes.push(item.name)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.msg-node-class {
|
||||
color: red;
|
||||
>>> i{
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -53,11 +53,10 @@ export default {
|
||||
let routerParam
|
||||
if ((routerParam = this.$router.currentRoute.params) !== null && routerParam.msgNotification) {
|
||||
// 说明是从消息通知跳转过来的
|
||||
console.log(this.$router.currentRoute.params)
|
||||
if (routerParam.msgType === 0) { // 是仪表板分享
|
||||
this.componentName = 'PanelMain'
|
||||
this.$nextTick(() => {
|
||||
this.$refs.panel_main.msg2Current()
|
||||
this.$refs.panel_main.msg2Current(routerParam.sourceParam)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
</el-tab-pane>
|
||||
<el-tab-pane name="panels_share" :lazy="true">
|
||||
<span slot="label"><i class="el-icon-share" />{{ $t('panel.share') }}</span>
|
||||
<share-tree v-if="showShare" />
|
||||
<share-tree v-if="showShare" ref="share_tree" :msg-panel-ids="msgPanelIds" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</de-aside-container>
|
||||
@ -38,7 +38,8 @@ export default {
|
||||
return {
|
||||
activeName: 'PanelList',
|
||||
showShare: false,
|
||||
showEnshrine: false
|
||||
showEnshrine: false,
|
||||
msgPanelIds: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -87,9 +88,19 @@ export default {
|
||||
})
|
||||
this.$store.dispatch('panel/setMainActiveName', 'PanelMain')
|
||||
},
|
||||
msg2Current() {
|
||||
this.activeName = 'panels_share'
|
||||
msg2Current(panelIds) {
|
||||
this.refreshShare()
|
||||
this.$nextTick(() => {
|
||||
if (panelIds) {
|
||||
try {
|
||||
panelIds = JSON.parse(panelIds)
|
||||
this.msgPanelIds = panelIds
|
||||
this.activeName = 'panels_share'
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user