Commit 8e15e91e authored by 曾沂轮's avatar 曾沂轮

Merge branch 'feature-addMessageTip' into 'master'

Feat: 消息模块根据业务码跳转到指定tab页

See merge request !4
parents 4d4ff769 a34f8a71
......@@ -30,10 +30,6 @@
<span v-if="userInfo.RealName" @click="handleUserClick">{{ userInfo.RealName }}</span>
<span v-else @click="handleRelogin">登录</span>
</a>
<!-- <a href="javascript:;" class="quit-user gutter" @click="logout">
<i class="iconfont icon-tuichu"></i>
<span>退出</span>
</a> -->
<el-button v-if="userInfo.RealName" class="quit-user gutter" type="text"
size="small" icon="iconfont icon-tuichu" :loading="isLoadingout" @click="logout">
退出
......@@ -78,7 +74,27 @@ export default {
return {
serviceUrl,
isLoadingout: false,
websocket: null
websocket: null,
messageType: [{
id: 'doingWork',
name: '在办工作',
status: [100, 101, 102, 103, 104, 105, 106, 109, 113, 112]
},
{
id: 'returnBox',
name: '退件箱',
status: [108]
},
{
id: 'suspendWork',
name: '已挂工作',
status: [110, 111]
},
{
id: 'finishedWork',
name: '办结工作',
status: [107]
}] // 消息类型
};
},
......@@ -103,20 +119,88 @@ export default {
methods: {
init() {
if (this.userInfo && this.userInfo.userId && window.WebSocket) {
const that = this;
this.websocket = new WebSocket(`ws:${baseUrl}/MessageWebsocket?userId=${this.userInfo.userId}`);
this.websocket.onopen = function(event) {
};
this.websocket.onclose = function(event) {
};
this.websocket.onmessage = (event) => {
// state.unreadMessage = event.data
// this.unreadMessage = event.data;
this.$store.dispatch('setUnreadMessage', event.data);
this.websocket.onmessage = function(event) {
if (event.data) that.handleReceiveMessage(event.data);
};
this.websocket.onerror = function(event) {
};
}
},
/**
* 接受消息后的处理
*/
handleReceiveMessage(data) {
// data = JSON.parse(data);
this.$store.dispatch('setUnreadMessage', data.count);
const type = data.content ? this.handleMessageType(data.content.businessType) : 9999;
const h = this.$createElement;
if (parseInt(data.count, 10) === 0) return false;
this.$notify({
title: data.content ? data.content.title : this.convertTypeToObjectInfo(type).name,
position: 'bottom-right',
type: 'info',
dangerouslyUseHTMLString: true,
duration: 5000,
message: h('div', {
style: {
display: 'flex',
alignItems: 'center'
}
}, [
h('span', null
, data.content ? data.content.content : '您有新的处理任务,请及时处理!'),
h('el-button', {
style: {
marginLeft: '5px'
},
attrs: {
size: 'small',
type: 'text'
},
on: {
click: () => { this.handleLinkToTargetTab(type);}
}
}, '查看')
])
});
},
/**
* 跳转链接
*/
handleLinkToTargetTab(type) {
openTab({
id: this.convertTypeToObjectInfo(type).id,
name: this.convertTypeToObjectInfo(type).name,
componentName: this.convertTypeToObjectInfo(type).id
});
},
/**
* 数据类型转换
*/
convertTypeToObjectInfo(type) {
return this.messageType[type] || { id: 'appMessage', name: '我的消息'};
},
/**
* 处理消息类型
*/
handleMessageType(type) {
type = parseInt(type, 10) || 9999;
let flag = false;
for (let i = 0; i < this.messageType.length; i++) {
if (this.messageType[i].status.indexOf(type) >= 0) {
type = i;
flag = true;
}
if (flag) break;
}
return type;
},
/**
* 查看消息
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment