Browse Source

处理已处理消息

chris 3 years ago
parent
commit
1b8aa431e1
3 changed files with 22 additions and 10 deletions
  1. 7 0
      src/utils/msg.js
  2. 13 8
      src/views/common/msg.vue
  3. 2 2
      src/views/modules/common/approve-component.vue

+ 7 - 0
src/utils/msg.js

@@ -30,3 +30,10 @@ export function readNotice (that, noticeId) {
   arr.push(noticeId)
   that.$store.dispatch('websocket/WEBSOCKET_SEND', JSON.stringify({'noticeIds': arr}))
 }
+
+export function readNotices (that, noticeIds) {
+  if (!noticeIds || noticeIds.length === 0) return
+  noticeIds.forEach((item) => {
+    readNotice(that, item)
+  })
+}

+ 13 - 8
src/views/common/msg.vue

@@ -5,7 +5,7 @@
 
 <script>
   import {parseJsonStr} from '@/utils/common'
-  import {routeMsg} from '@/utils/msg'
+  import {routeMsg, readNotices} from '@/utils/msg'
   export default {
     name: 'msg',
     data () {
@@ -31,15 +31,20 @@
     },
     watch: {
       listenWebsocket: function (data) {
-        if (!data || data.indexOf('[') !== 0) {
+        if (!data) return
+        let json = parseJsonStr(data)
+        console.log('json = ' + JSON.stringify(json))
+        if (data.indexOf('{"approved') > -1) {
+          readNotices(this, json['approved'])
           return
         }
-        let newMsgCollections = parseJsonStr(data)
-        // console.log('newMsgCollections = ' + JSON.stringify(newMsgCollections))
-        if (newMsgCollections) {
-          this.updateMsgCollections(newMsgCollections)
-          if (newMsgCollections.length <= 5) {
-            newMsgCollections.forEach((item) => {
+        if (data.indexOf('[') !== 0) {
+          return
+        }
+        if (json) {
+          this.updateMsgCollections(json)
+          if (json.length <= 5) {
+            json.forEach((item) => {
               this.notice(item)
             })
           }

+ 2 - 2
src/views/modules/common/approve-component.vue

@@ -36,8 +36,8 @@
     },
     methods: {
       async init (businessType, businessId) {
-        console.log('[approve-component]businessType = ' + businessType)
-        console.log('[approve-component]businessId = ' + businessId)
+        // console.log('[approve-component]businessType = ' + businessType)
+        // console.log('[approve-component]businessId = ' + businessId)
         this.visible = true
         this.dataForm = {
           busiType: businessType || '',