|
@@ -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) {
|