Browse Source

消息页面跳转

chris 3 years ago
parent
commit
cf8ec68b58

+ 54 - 9
src/views/common/msg.vue

@@ -14,6 +14,9 @@
         dataForm: {}
       }
     },
+    mounted () {
+      // this.test()
+    },
     computed: {
       // 监听消息变化
       listenWebsocket () {
@@ -29,21 +32,13 @@
         if (!data || data.indexOf('[') !== 0) {
           return
         }
-        const h = this.$createElement
         let newMsgCollections = parseJsonStr(data)
         // console.log('newMsgCollections = ' + JSON.stringify(newMsgCollections))
         if (newMsgCollections) {
           this.updateMsgCollections(newMsgCollections)
           if (newMsgCollections.length <= 5) {
             newMsgCollections.forEach((item) => {
-              this.$notify({
-                title: item.title,
-                message: h('div', {}, [
-                  h('p', {}, '消息类别:' + this.getMsgType(item.type)),
-                  h('p', {}, '消息内容:' + item.content)
-                ]),
-                duration: 0
-              })
+              this.notice(item)
             })
           }
         }
@@ -53,6 +48,56 @@
       }
     },
     methods: {
+      test () {
+        let item = {
+          type: 1,
+          title: '测试标题',
+          content: '这是一条测试消息'
+        }
+        this.notice(item)
+      },
+      // 通知
+      notice (item) {
+        const h = this.$createElement
+        this.$notify({
+          title: item.title,
+          message: h('div', {}, [
+            h('p', {}, '消息类别:' + this.getMsgType(item.type)),
+            h('p', {}, '消息内容:' + item.content),
+            h('p', {
+              style: 'text-align: left;margin-top: 10px;color:#43c39d',
+              on: {
+                click: () => {
+                  this.detail(item)
+                }
+              }
+            }, '点击查看详情')
+          ]),
+          duration: 0,
+          offset: 60
+        })
+      },
+      // 跳转到消息页面
+      detail (row) {
+        if (!row) return
+        if (row.type === 1) {
+          this.$router.push({name: 'msgAnnouncement',
+            params: {notice: {
+              noticeId: row.noticeId,
+              businessId: row.businessId
+            }}})
+        } else if (row.type === 2) {
+          this.$router.push({name: 'msgApprove',
+            params: {notice: {
+              noticeId: row.noticeId,
+              businessId: row.businessId
+            }}})
+        } else {
+          this.$message.warning('消息类型不支持')
+        }
+        // console.log('item = ' + JSON.stringify(row))
+      },
+      // 获取消息类型
       getMsgType (type) {
         if (!type) return '未知消息类型'
         if (type === 1) {

+ 6 - 6
src/views/modules/msg-center/announcement.vue

@@ -125,14 +125,14 @@
     },
     computed: {
       // 监听消息ID
-      listenNoticeId () {
-        return this.$route.params.noticeId
+      listenNotice () {
+        return this.$route.params.notice
       }
     },
     watch: {
-      listenNoticeId: function (noticeId) {
-        console.log('noticeId = ' + noticeId)
-        this.dataForm.noticeId = noticeId
+      listenNotice: function (notice) {
+        this.dataForm.noticeId = notice.noticeId
+        this.dataForm.businessId = notice.businessId
         this.queryData()
       }
     },
@@ -165,7 +165,7 @@
           'size': this.pageSize,
           'createTime': this.dataForm.createTime ? this.dataForm.createTime : null,
           'state': this.dataForm.state ? this.dataForm.state : null,
-          'noticeId': this.dataForm.noticeId ? this.dataForm.noticeId : null
+          'businessId': this.dataForm.businessId ? this.dataForm.businessId : null
         }
         getAnnouncementList(params).then(({data}) => {
           if (data && data.code === '200') {

+ 6 - 6
src/views/modules/msg-center/approve.vue

@@ -143,14 +143,14 @@
     },
     computed: {
       // 监听消息ID
-      listenNoticeId () {
-        return this.$route.params.noticeId
+      listenNotice () {
+        return this.$route.params.notice
       }
     },
     watch: {
-      listenNoticeId: function (noticeId) {
-        console.log('noticeId = ' + noticeId)
-        this.dataForm.noticeId = noticeId
+      listenNotice: function (notice) {
+        this.dataForm.noticeId = notice.noticeId
+        this.dataForm.businessId = notice.businessId
         this.queryData()
       }
     },
@@ -215,7 +215,7 @@
           'createTime': this.dataForm.createTime ? this.dataForm.createTime : null,
           'state': this.dataForm.state ? this.dataForm.state : null,
           'businessType': this.dataForm.businessType ? this.dataForm.businessType : null,
-          'noticeId': this.dataForm.noticeId ? this.dataForm.noticeId : null
+          'businessId': this.dataForm.businessId ? this.dataForm.businessId : null
         }
         getApprovalList(params).then(({data}) => {
           if (data && data.code === '200') {

+ 11 - 3
src/views/modules/msg-center/notice.vue

@@ -147,11 +147,19 @@
       // 查看消息
       detailHandle (row) {
         if (row.type === 1) {
-          this.$router.push({name: 'msgAnnouncement', params: {noticeId: row.noticeId}})
+          this.$router.push({name: 'msgAnnouncement',
+            params: {notice: {
+              noticeId: row.noticeId,
+              businessId: row.businessId
+            }}})
         } else if (row.type === 2) {
-          this.$router.push({name: 'msgApprove', params: {noticeId: row.noticeId}})
+          this.$router.push({name: 'msgApprove',
+            params: {notice: {
+              noticeId: row.noticeId,
+              businessId: row.businessId
+            }}})
         } else {
-          this.$message.warning('没有找到消息类型')
+          this.$message.warning('消息类型不支持')
         }
       }
     }