Browse Source

调试消息中心

zhangyu 5 years ago
parent
commit
b2bbc81e7c

+ 9 - 0
src/api/msgsever.js

@@ -44,4 +44,13 @@ export function messgeQuery(param, success) {
 export function messgeUpdate(param, success) {
 export function messgeUpdate(param, success) {
   let url = `${baseUrl}/message-center/message/update`;
   let url = `${baseUrl}/message-center/message/update`;
   http.postJson(url, param, success)
   http.postJson(url, param, success)
+}
+
+/**
+ * title: 根据接收人将消息置为已读
+ * info: 已读Read = true,*UserId
+ */
+export function messgeUpdateState(param, success) {
+  let url = `${baseUrl}/message-center/message/update-state`;
+  http.postJson(url, param, success)
 }
 }

File diff suppressed because it is too large
+ 46 - 18
src/framework/components/messagesever/index.vue


+ 30 - 10
src/framework/components/messagesever/msmq.js

@@ -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
-    // }
+    }
   }
   }
 }
 }
 
 

+ 2 - 2
src/router/system.js

@@ -119,8 +119,8 @@ export default [
             {
             {
                 path: 'file',
                 path: 'file',
                 name: 'modelFile',
                 name: 'modelFile',
-                component: Dasboard,
-                // component: modelFile,
+                // component: Dasboard,
+                component: modelFile,
                 meta: { keepAlive: false, breadcrumbs: [{ label: '模型管理', path: '/model/file' }, { label: '模型文件管理' }] }
                 meta: { keepAlive: false, breadcrumbs: [{ label: '模型管理', path: '/model/file' }, { label: '模型文件管理' }] }
             },
             },
             {
             {