提交 dadeb745 authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw

feat: 增加数据集同步消息提醒

上级 25203a6b
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);
}
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;
}
}
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);
}
<?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 @@ ...@@ -46,9 +46,9 @@
</select> </select>
<select id="queryUserIdWithRoleIds" > <select id="queryUserIdWithRoleIds" resultType="java.lang.Long" >
select user_id select user_id
from sys_user from sys_users_roles
where role_id in where role_id in
<foreach collection="roleIds" item="roleId" open='(' separator=',' close=')'> <foreach collection="roleIds" item="roleId" open='(' separator=',' close=')'>
#{roleId} #{roleId}
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
</select> </select>
<select id="queryUserIdWithDeptIds" > <select id="queryUserIdWithDeptIds" resultType="java.lang.Long" >
select user_id select user_id
from sys_user from sys_user
where dept_id in where dept_id in
......
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;
}
package io.dataease.commons.utils; package io.dataease.commons.utils;
import io.dataease.auth.api.dto.CurrentUserDto; 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.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.Set;
@Component @Component
public class AuthUtils { public class AuthUtils {
private static SysUserService sysUserService; private static ExtAuthService extAuthService;
@Autowired @Autowired
public void setSysUserService(SysUserService sysUserService) { public void setExtAuthService(ExtAuthService extAuthService) {
AuthUtils.sysUserService = sysUserService; AuthUtils.extAuthService = extAuthService;
} }
public static CurrentUserDto getUser(){ public static CurrentUserDto getUser(){
CurrentUserDto userDto = (CurrentUserDto)SecurityUtils.getSubject().getPrincipal(); CurrentUserDto userDto = (CurrentUserDto)SecurityUtils.getSubject().getPrincipal();
return userDto; 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; ...@@ -10,10 +10,8 @@ import io.dataease.commons.constants.JdbcConstants;
import io.dataease.commons.constants.JobStatus; import io.dataease.commons.constants.JobStatus;
import io.dataease.commons.constants.ScheduleType; import io.dataease.commons.constants.ScheduleType;
import io.dataease.commons.constants.UpdateType; import io.dataease.commons.constants.UpdateType;
import io.dataease.commons.utils.CommonBeanFactory; import io.dataease.commons.model.AuthURD;
import io.dataease.commons.utils.DorisTableUtils; import io.dataease.commons.utils.*;
import io.dataease.commons.utils.HttpClientUtil;
import io.dataease.commons.utils.LogUtil;
import io.dataease.datasource.constants.DatasourceTypes; import io.dataease.datasource.constants.DatasourceTypes;
import io.dataease.datasource.dto.DorisConfigration; import io.dataease.datasource.dto.DorisConfigration;
import io.dataease.datasource.dto.MysqlConfigration; import io.dataease.datasource.dto.MysqlConfigration;
...@@ -27,6 +25,7 @@ import io.dataease.dto.dataset.DataTableInfoDTO; ...@@ -27,6 +25,7 @@ import io.dataease.dto.dataset.DataTableInfoDTO;
import io.dataease.exception.DataEaseException; import io.dataease.exception.DataEaseException;
import io.dataease.listener.util.CacheUtils; import io.dataease.listener.util.CacheUtils;
import io.dataease.provider.QueryProvider; import io.dataease.provider.QueryProvider;
import io.dataease.service.message.DeMsgutil;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -77,8 +76,7 @@ import java.io.File; ...@@ -77,8 +76,7 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -209,10 +207,12 @@ public class ExtractDataService { ...@@ -209,10 +207,12 @@ public class ExtractDataService {
extractData(datasetTable, "all_scope"); extractData(datasetTable, "all_scope");
replaceTable(DorisTableUtils.dorisName(datasetTableId)); replaceTable(DorisTableUtils.dorisName(datasetTableId));
saveSucessLog(datasetTableTaskLog); saveSucessLog(datasetTableTaskLog);
sendWebMsg(datasetTable, taskId,true);
deleteFile("all_scope", datasetTableId); deleteFile("all_scope", datasetTableId);
updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, execTime); updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, execTime);
}catch (Exception e){ }catch (Exception e){
saveErrorLog(datasetTableId, taskId, e); saveErrorLog(datasetTableId, taskId, e);
sendWebMsg(datasetTable, taskId,false);
updateTableStatus(datasetTableId, datasetTable, JobStatus.Error, null); updateTableStatus(datasetTableId, datasetTable, JobStatus.Error, null);
dropDorisTable(DorisTableUtils.dorisTmpName(DorisTableUtils.dorisName(datasetTableId))); dropDorisTable(DorisTableUtils.dorisTmpName(DorisTableUtils.dorisName(datasetTableId)));
deleteFile("all_scope", datasetTableId); deleteFile("all_scope", datasetTableId);
...@@ -233,6 +233,7 @@ public class ExtractDataService { ...@@ -233,6 +233,7 @@ public class ExtractDataService {
Long execTime = System.currentTimeMillis(); Long execTime = System.currentTimeMillis();
extractData(datasetTable, "incremental_add"); extractData(datasetTable, "incremental_add");
saveSucessLog(datasetTableTaskLog); saveSucessLog(datasetTableTaskLog);
sendWebMsg(datasetTable, taskId,true);
updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, execTime); updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, execTime);
}else { }else {
DatasetTableIncrementalConfig datasetTableIncrementalConfig = dataSetTableService.incrementalConfig(datasetTableId); DatasetTableIncrementalConfig datasetTableIncrementalConfig = dataSetTableService.incrementalConfig(datasetTableId);
...@@ -270,12 +271,14 @@ public class ExtractDataService { ...@@ -270,12 +271,14 @@ public class ExtractDataService {
extractData(datasetTable, "incremental_delete"); extractData(datasetTable, "incremental_delete");
} }
saveSucessLog(datasetTableTaskLog); saveSucessLog(datasetTableTaskLog);
sendWebMsg(datasetTable, taskId,true);
deleteFile("incremental_add", datasetTableId); deleteFile("incremental_add", datasetTableId);
deleteFile("incremental_delete", datasetTableId); deleteFile("incremental_delete", datasetTableId);
updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, execTime); updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, execTime);
} }
}catch (Exception e){ }catch (Exception e){
saveErrorLog(datasetTableId, taskId, e); saveErrorLog(datasetTableId, taskId, e);
sendWebMsg(datasetTable, taskId,false);
updateTableStatus(datasetTableId, datasetTable, JobStatus.Error, null); updateTableStatus(datasetTableId, datasetTable, JobStatus.Error, null);
deleteFile("incremental_add", datasetTableId); deleteFile("incremental_add", datasetTableId);
deleteFile("incremental_delete", datasetTableId); deleteFile("incremental_delete", datasetTableId);
...@@ -297,6 +300,20 @@ public class ExtractDataService { ...@@ -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) { private void updateTableStatus(String datasetTableId, DatasetTable datasetTable, JobStatus completed, Long execTime) {
datasetTable.setSyncStatus(completed.name()); datasetTable.setSyncStatus(completed.name());
if(execTime != null){ if(execTime != null){
......
...@@ -16,8 +16,8 @@ public class DeMsgutil { ...@@ -16,8 +16,8 @@ public class DeMsgutil {
@PostConstruct @PostConstruct
public void init() { public void init() {
routerMap = new HashMap<>(); routerMap = new HashMap<>();
routerMap.put(0, "/panel/index"); routerMap.put(0, "panel");
routerMap.put(1, "/dataset/index"); routerMap.put(1, "dataset");
} }
private static SysMsgService sysMsgService; private static SysMsgService sysMsgService;
...@@ -38,4 +38,16 @@ public class DeMsgutil { ...@@ -38,4 +38,16 @@ public class DeMsgutil {
sysMsgService.save(sysMsg); 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);
}
} }
package io.dataease.service.panel; package io.dataease.service.panel;
import com.google.gson.Gson;
import io.dataease.auth.api.dto.CurrentRoleDto; import io.dataease.auth.api.dto.CurrentRoleDto;
import io.dataease.auth.api.dto.CurrentUserDto; import io.dataease.auth.api.dto.CurrentUserDto;
import io.dataease.base.domain.PanelGroup;
import io.dataease.base.domain.PanelShare; import io.dataease.base.domain.PanelShare;
import io.dataease.base.domain.PanelShareExample; import io.dataease.base.domain.PanelShareExample;
import io.dataease.base.mapper.PanelGroupMapper;
import io.dataease.base.mapper.PanelShareMapper; import io.dataease.base.mapper.PanelShareMapper;
import io.dataease.base.mapper.ext.ExtPanelShareMapper; import io.dataease.base.mapper.ext.ExtPanelShareMapper;
import io.dataease.base.mapper.ext.query.GridExample; 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.AuthUtils;
import io.dataease.commons.utils.BeanUtils; import io.dataease.commons.utils.BeanUtils;
import io.dataease.commons.utils.CommonBeanFactory; import io.dataease.commons.utils.CommonBeanFactory;
...@@ -31,12 +35,15 @@ public class ShareService { ...@@ -31,12 +35,15 @@ public class ShareService {
@Autowired(required = false) @Autowired(required = false)
private PanelShareMapper mapper; private PanelShareMapper mapper;
@Resource
private PanelGroupMapper panelGroupMapper;
@Resource @Resource
private ExtPanelShareMapper extPanelShareMapper; private ExtPanelShareMapper extPanelShareMapper;
@Transactional @Transactional
public void save(PanelShareRequest request){ public void save(PanelShareRequest request){
List<PanelGroup> panelGroups = queryGroup(request.getPanelIds());
//1.先根据仪表板删除所有已经分享的 //1.先根据仪表板删除所有已经分享的
Integer type = request.getType(); Integer type = request.getType();
List<String> panelIds = request.getPanelIds(); List<String> panelIds = request.getPanelIds();
...@@ -67,26 +74,32 @@ public class ShareService { ...@@ -67,26 +74,32 @@ public class ShareService {
// 下面是发送提醒消息逻辑 // 下面是发送提醒消息逻辑
Set<Long> userIdSet = new HashSet<Long>(); Set<Long> userIdSet = new HashSet<Long>();
AuthURD authURD = new AuthURD();
if (type == 0) { if (type == 0) {
userIdSet.addAll(targetIds); authURD.setUserIds(targetIds);
}else if(type == 1) { }
Map<String, List<Long>> param = new HashMap<>(); if (type == 1) {
param.put("roleIds", targetIds); authURD.setRoleIds(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);
} }
if(type == 2) {
authURD.setDeptIds(targetIds);
}
userIdSet = AuthUtils.userIdsByURD(authURD);
CurrentUserDto user = AuthUtils.getUser(); CurrentUserDto user = AuthUtils.getUser();
String msg = StringUtils.joinWith(",", panelGroups.stream().map(PanelGroup::getName).collect(Collectors.toList()));
Gson gson = new Gson();
userIdSet.forEach(userId -> { 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建了索引 效率不会很差 * panel_group_id建了索引 效率不会很差
* @param panel_group_id * @param panel_group_id
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
> >
<div style="height: 30px;"> <div style="height: 30px;">
<div style="float: left;font-size:16px;font-weight:bold;"> <div style="float: left;font-size:16px;font-weight:bold;">
<span>站内消息通知</span> <span>{{ $t('webmsg.web_msg') }}</span>
</div> </div>
<div v-if="showSetting" style="float: right;"> <div v-if="showSetting" style="float: right;">
<a href="#" style="text-detext-decoratext-decoration:none;cursor:point;" @click="msgSetting">消息规则</a> <a href="#" style="text-detext-decoratext-decoration:none;cursor:point;" @click="msgSetting">消息规则</a>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<div class="start-item"> <div class="start-item">
<div class="filter-db-row star-item-content" @click="showDetail(scope.row)"> <div class="filter-db-row star-item-content" @click="showDetail(scope.row)">
<!-- <svg-icon icon-class="panel" class="ds-icon-scene" /> --> <!-- <svg-icon icon-class="panel" class="ds-icon-scene" /> -->
<div class="title-div"><span>{{ getTypeName(scope.row.type) }}&nbsp;&nbsp;{{ scope.row.content }}</span></div> <div class="title-div"><span>{{ $t(getTypeName(scope.row.type)) }}&nbsp;&nbsp;{{ scope.row.content }}</span></div>
<div class="title-div"><span>{{ scope.row.createTime | timestampFormatDate }}</span></div> <div class="title-div"><span>{{ scope.row.createTime | timestampFormatDate }}</span></div>
</div> </div>
<!-- <div class="star-item-close"> <!-- <div class="star-item-close">
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
</el-table> </el-table>
<div class="msg-foot-class"> <div class="msg-foot-class">
<el-row style="padding: 5px 0;margin-bottom: -5px;cursor:point;" @click="showMore"> <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> </el-row>
</div> </div>
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
class-name="notification" class-name="notification"
icon-class="notification" icon-class="notification"
/> />
<span class="msg-number">9</span> <span v-if="paginationConfig.total" class="msg-number">{{ paginationConfig.total }}</span>
</div> </div>
</div> </div>
</el-popover> </el-popover>
...@@ -81,15 +81,19 @@ export default { ...@@ -81,15 +81,19 @@ export default {
}, },
created() { created() {
this.search() this.search()
// 每30s定时刷新拉取消息
setInterval(() => {
this.search()
}, 30000)
}, },
methods: { methods: {
handClick(lang) { handClick(lang) {
console.log(lang) console.log(lang)
}, },
showDetail(row) { showDetail(row) {
const param = { ...{ msgNotification: true, msgType: row.type }} const param = { ...{ msgNotification: true, msgType: row.type, sourceParam: row.param }}
this.visible = false this.visible = false
this.$router.push({ name: 'panel', params: param }) this.$router.push({ name: row.router, params: param })
this.setReaded(row.msgId) this.setReaded(row.msgId)
}, },
remove(row) { remove(row) {
...@@ -105,7 +109,9 @@ export default { ...@@ -105,7 +109,9 @@ export default {
this.$emit('refresh-top-bar') this.$emit('refresh-top-bar')
}, },
search() { search() {
const param = {} const param = {
status: false
}
const { currentPage, pageSize } = this.paginationConfig const { currentPage, pageSize } = this.paginationConfig
query(currentPage, pageSize, param).then(response => { query(currentPage, pageSize, param).then(response => {
this.data = response.data.listObject this.data = response.data.listObject
......
...@@ -1132,5 +1132,12 @@ export default { ...@@ -1132,5 +1132,12 @@ export default {
can_not_move_change_sort: 'Cannot move to change sort', 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', can_not_move_parent_to_children: 'Parent organization cannot move to its own child node',
move_success: 'Mobile success' 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 { ...@@ -1174,5 +1174,12 @@ export default {
can_not_move_change_sort: '不能移動以改變排序', can_not_move_change_sort: '不能移動以改變排序',
can_not_move_parent_to_children: '父組織不能移動到自己的子節點下', can_not_move_parent_to_children: '父組織不能移動到自己的子節點下',
move_success: '移動成功' move_success: '移動成功'
},
webmsg: {
web_msg: '站內消息通知',
show_more: '查看更多',
all_type: '全部類型',
panel_type: '儀表板分享',
dataset_type: '數據集同步'
} }
} }
...@@ -1133,5 +1133,12 @@ export default { ...@@ -1133,5 +1133,12 @@ export default {
can_not_move_change_sort: '不能移动以改变排序', can_not_move_change_sort: '不能移动以改变排序',
can_not_move_parent_to_children: '父组织不能移动到自己的子节点下', can_not_move_parent_to_children: '父组织不能移动到自己的子节点下',
move_success: '移动成功' move_success: '移动成功'
},
webmsg: {
web_msg: '站内消息通知',
show_more: '查看更多',
all_type: '全部类型',
panel_type: '仪表板分享',
dataset_type: '数据集同步'
} }
} }
export const msgTypes = [ export const msgTypes = [
{ value: -1, label: '全部类型' }, // { value: -1, label: '全部类型' },
{ value: 0, label: '仪表板分享' }, // { value: 0, label: '仪表板分享' },
{ value: 1, 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 => { export const getTypeName = value => {
......
...@@ -103,6 +103,9 @@ export default { ...@@ -103,6 +103,9 @@ export default {
'param': function() { 'param': function() {
this.initTable(this.param) this.initTable(this.param)
} }
},
created() {
}, },
mounted() { mounted() {
this.initTable(this.param) this.initTable(this.param)
...@@ -187,6 +190,10 @@ export default { ...@@ -187,6 +190,10 @@ export default {
return { return {
'type': type 'type': type
} }
},
msg2Current(sourceParam) {
this.tabActive = 'updateInfo'
this.table.msgTaskId = sourceParam.taskId
} }
} }
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<de-main-container> <de-main-container>
<!--<router-view/>--> <!--<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-main-container>
</de-container> </de-container>
</template> </template>
...@@ -40,6 +40,27 @@ export default { ...@@ -40,6 +40,27 @@ export default {
mounted() { mounted() {
removeClass(document.body, 'showRightPanel') 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: { methods: {
switchComponent(c) { switchComponent(c) {
this.param = c.param this.param = c.param
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]"> <layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]">
<el-radio-group v-model="selectType" style="margin-bottom: 15px;" @change="typeChange"> <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> </el-radio-group>
<complex-table <complex-table
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<el-table-column prop="type" :label="$t('datasource.type')" width="120"> <el-table-column prop="type" :label="$t('datasource.type')" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ getTypeName(scope.row.type) }}</span> <span>{{ $t(getTypeName(scope.row.type)) }}</span>
</template> </template>
</el-table-column> </el-table-column>
...@@ -104,8 +104,8 @@ export default { ...@@ -104,8 +104,8 @@ export default {
this.search() this.search()
}, },
toDetail(row) { toDetail(row) {
const param = { ...{ msgNotification: true, msgType: row.type }} const param = { ...{ msgNotification: true, msgType: row.type, sourceParam: row.param }}
this.$router.push({ name: 'panel', params: param }) this.$router.push({ name: row.router, params: param })
this.setReaded(row) this.setReaded(row)
}, },
// 设置已读 // 设置已读
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]"> <layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]">
<el-radio-group v-model="selectType" style="margin-bottom: 15px;" @change="typeChange"> <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> </el-radio-group>
<complex-table <complex-table
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<el-table-column prop="type" :label="$t('datasource.type')" width="120"> <el-table-column prop="type" :label="$t('datasource.type')" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ getTypeName(scope.row.type) }}</span> <span>{{ $t(getTypeName(scope.row.type)) }}</span>
</template> </template>
</el-table-column> </el-table-column>
...@@ -87,10 +87,9 @@ export default { ...@@ -87,10 +87,9 @@ export default {
search() { search() {
const param = {} const param = {}
param.status = true
if (this.selectType >= 0) { if (this.selectType >= 0) {
param.type = this.selectType param.type = this.selectType
param.status = true
} }
const { currentPage, pageSize } = this.paginationConfig const { currentPage, pageSize } = this.paginationConfig
query(currentPage, pageSize, param).then(response => { query(currentPage, pageSize, param).then(response => {
...@@ -105,8 +104,8 @@ export default { ...@@ -105,8 +104,8 @@ export default {
this.search() this.search()
}, },
toDetail(row) { toDetail(row) {
const param = { ...{ msgNotification: true, msgType: row.type }} const param = { ...{ msgNotification: true, msgType: row.type, sourceParam: row.param }}
this.$router.push({ name: 'panel', params: param }) this.$router.push({ name: row.router, params: param })
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]"> <layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]">
<el-radio-group v-model="selectType" style="margin-bottom: 15px;" @change="typeChange"> <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> </el-radio-group>
<complex-table <complex-table
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<el-table-column prop="type" :label="$t('datasource.type')" width="120"> <el-table-column prop="type" :label="$t('datasource.type')" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ getTypeName(scope.row.type) }}</span> <span>{{ $t(getTypeName(scope.row.type)) }}</span>
</template> </template>
</el-table-column> </el-table-column>
...@@ -87,10 +87,9 @@ export default { ...@@ -87,10 +87,9 @@ export default {
search() { search() {
const param = {} const param = {}
param.status = false
if (this.selectType >= 0) { if (this.selectType >= 0) {
param.type = this.selectType param.type = this.selectType
param.status = false
} }
const { currentPage, pageSize } = this.paginationConfig const { currentPage, pageSize } = this.paginationConfig
query(currentPage, pageSize, param).then(response => { query(currentPage, pageSize, param).then(response => {
...@@ -105,8 +104,8 @@ export default { ...@@ -105,8 +104,8 @@ export default {
this.search() this.search()
}, },
toDetail(row) { toDetail(row) {
const param = { ...{ msgNotification: true, msgType: row.type }} const param = { ...{ msgNotification: true, msgType: row.type, sourceParam: row.param }}
this.$router.push({ name: 'panel', params: param }) this.$router.push({ name: row.router, params: param })
this.setReaded(row) this.setReaded(row)
}, },
// 设置已读 // 设置已读
......
<template> <template>
<div> <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 slot-scope="{ data }" class="custom-tree-node">
<span> <span :class="!!data.msgNode ? 'msg-node-class': ''">
<span v-if="!!data.id"> <span v-if="!!data.id">
<el-button <el-button
icon="el-icon-picture-outline" icon="el-icon-picture-outline"
...@@ -23,24 +23,35 @@ import { uuid } from 'vue-uuid' ...@@ -23,24 +23,35 @@ import { uuid } from 'vue-uuid'
import { get } from '@/api/panel/panel' import { get } from '@/api/panel/panel'
export default { export default {
name: 'ShareTree', name: 'ShareTree',
props: {
msgPanelIds: {
type: Array,
default: null
}
},
data() { data() {
return { return {
datas: [], datas: [],
defaultProps: { defaultProps: {
children: 'children', children: 'children',
label: 'name' label: 'name'
} },
expandNodes: []
} }
}, },
created() { created() {
this.initData() this.initData().then(res => {
this.datas = res.data
if (this.msgPanelIds && this.msgPanelIds.length > 0) {
this.expandMsgNode(this.msgPanelIds)
}
})
}, },
methods: { methods: {
initData() { initData() {
const param = {} const param = {}
loadTree(param).then(res => { return loadTree(param)
this.datas = res.data
})
}, },
handleNodeClick(data) { handleNodeClick(data) {
get('panel/group/findOne/' + data.id).then(response => { get('panel/group/findOne/' + data.id).then(response => {
...@@ -58,7 +69,35 @@ export default { ...@@ -58,7 +69,35 @@ export default {
} }
return data 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> </script>
<style lang="scss" scoped>
.msg-node-class {
color: red;
>>> i{
color: red;
}
}
</style>
...@@ -53,11 +53,10 @@ export default { ...@@ -53,11 +53,10 @@ export default {
let routerParam let routerParam
if ((routerParam = this.$router.currentRoute.params) !== null && routerParam.msgNotification) { if ((routerParam = this.$router.currentRoute.params) !== null && routerParam.msgNotification) {
// 说明是从消息通知跳转过来的 // 说明是从消息通知跳转过来的
console.log(this.$router.currentRoute.params)
if (routerParam.msgType === 0) { // 是仪表板分享 if (routerParam.msgType === 0) { // 是仪表板分享
this.componentName = 'PanelMain' this.componentName = 'PanelMain'
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.panel_main.msg2Current() this.$refs.panel_main.msg2Current(routerParam.sourceParam)
}) })
} }
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</el-tab-pane> </el-tab-pane>
<el-tab-pane name="panels_share" :lazy="true"> <el-tab-pane name="panels_share" :lazy="true">
<span slot="label"><i class="el-icon-share" />{{ $t('panel.share') }}</span> <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-tab-pane>
</el-tabs> </el-tabs>
</de-aside-container> </de-aside-container>
...@@ -38,7 +38,8 @@ export default { ...@@ -38,7 +38,8 @@ export default {
return { return {
activeName: 'PanelList', activeName: 'PanelList',
showShare: false, showShare: false,
showEnshrine: false showEnshrine: false,
msgPanelIds: null
} }
}, },
computed: { computed: {
...@@ -87,9 +88,19 @@ export default { ...@@ -87,9 +88,19 @@ export default {
}) })
this.$store.dispatch('panel/setMainActiveName', 'PanelMain') this.$store.dispatch('panel/setMainActiveName', 'PanelMain')
}, },
msg2Current() { msg2Current(panelIds) {
this.activeName = 'panels_share'
this.refreshShare() this.refreshShare()
this.$nextTick(() => {
if (panelIds) {
try {
panelIds = JSON.parse(panelIds)
this.msgPanelIds = panelIds
this.activeName = 'panels_share'
} catch (error) {
console.error(error)
}
}
})
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论