|
@@ -2,20 +2,40 @@ import { Notification } from 'element-ui';
|
|
import Bus from '@/utils/bus.js'
|
|
import Bus from '@/utils/bus.js'
|
|
|
|
|
|
const MSMQ = {
|
|
const MSMQ = {
|
|
- handleMsg (message, projects, unreadNum ) {
|
|
|
|
|
|
+ msgTypeMap: {
|
|
|
|
+ "Success": "success",
|
|
|
|
+ "Error": "error",
|
|
|
|
+ "Warning": "warning",
|
|
|
|
+ "Info": "info",
|
|
|
|
+ },
|
|
|
|
+ moduleMap: {//消息模块映射
|
|
|
|
+ "Model": "模型文件管理"
|
|
|
|
+ },
|
|
|
|
+ handleMsg (message, projects, userId, unreadNum ) {
|
|
let data
|
|
let data
|
|
try {
|
|
try {
|
|
data = JSON.parse(message.body)
|
|
data = JSON.parse(message.body)
|
|
- } catch (err) {}
|
|
|
|
- // if(projects.some((item) => {return item.id == data.projectId})) { //判断消息是否是当前用户拥有的项目
|
|
|
|
- unreadNum++
|
|
|
|
- if(message.headers.destination == '/topic/model.manage'){ //模型文件的消息触发模型文件列表刷新事件
|
|
|
|
- Bus.$emit('modelStatusChange', data)
|
|
|
|
|
|
+ } 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.$notify({
|
|
|
|
+ title: `【${this.moduleMap[data.Module]?this.moduleMap[data.Module]:data.Module}}】${data.Title?data.Title:''}`,
|
|
|
|
+ dangerouslyUseHTMLString: true,
|
|
|
|
+ message: 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}<br>消息类型:${data.type}<br>描述信息:${data.description}<br>` })
|
|
|
|
+ unreadNum++
|
|
|
|
+ Bus.$emit('messageListUpdate', data)//消息驱动消息列表刷新
|
|
|
|
+ return unreadNum
|
|
}
|
|
}
|
|
- // Notification.info({ title: '消息',dangerouslyUseHTMLString: true, message: `项目编号:${data.projectId}<br>消息类型:${data.type}<br>描述信息:${data.description}<br>` })
|
|
|
|
- Notification.info({ title: '消息', dangerouslyUseHTMLString: true, message: `${JSON.stringify(data)}` })
|
|
|
|
- return unreadNum
|
|
|
|
- // }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|