import { Notification } from 'element-ui'; import Bus from '@/utils/bus.js' const MSMQ = { msgTypeMap: { "Success": "success", "Error": "error", "Warning": "warning", "Info": "info", }, moduleMap: {//消息模块映射 "Model": "模型文件管理" }, handleMsg (message, projects, userId, unreadNum ) { let data try { data = JSON.parse(message.body) } catch (err) { return false } if(data.ProjectId && projects.some((item) => {return item.id == data.ProjectId})) { //判断消息是否是当前用户拥有的项目 if(!data.UserList || (userId && data.UserList && data.UserList.includes(userId))){//判断消息接收人是否是当前用户 if(data.Module && data.Module == 'Model'){ //模型文件的消息触发模型文件列表刷新事件 Bus.$emit('modelStatusChange', data) } Notification({ title: `${data.Title?data.Title:''}`, dangerouslyUseHTMLString: true, message: `【${this.moduleMap[data.Module]?this.moduleMap[data.Module]:data.Module}】${data.Content?data.Content.Message?data.Content.Message:'':''}`, type: this.msgTypeMap[data.Type]?this.msgTypeMap[data.Type]:'info' }) // Notification.info({ title: '消息',dangerouslyUseHTMLString: true, message: `项目编号:${data.projectId}
消息类型:${data.type}
描述信息:${data.description}
` }) unreadNum++ Bus.$emit('messageListUpdate', data)//消息驱动消息列表刷新 return unreadNum } } } } export default MSMQ