Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
smart-web-router
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SVI
svi-templates
smart-web-router
Commits
1d0678c2
Commit
1d0678c2
authored
Nov 29, 2019
by
陈珠河
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feat: 添加消息模块功能
parent
a311256e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
143 additions
and
46 deletions
+143
-46
App.vue
template/src/App.vue
+141
-1
index.js
template/src/router/index.js
+0
-1
Header.vue
template/src/views/common/Header.vue
+2
-44
No files found.
template/src/App.vue
View file @
1d0678c2
...
@@ -6,7 +6,147 @@
...
@@ -6,7 +6,147 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
{
baseUrl
}
from
'@config/http.config'
;
export
default
{
export
default
{
name
:
'App'
name
:
'App'
,
computed
:
{
userInfo
()
{
return
this
.
$store
.
state
.
userInfo
;
}
},
data
()
{
return
{
userLogin
:
false
,
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
]
}]
// 消息类型
};
},
watch
:
{
userInfo
(
val
)
{
if
(
val
)
{
this
.
init
();
}
else
{
window
.
WebSocket
&&
this
.
websocket
&&
this
.
websocket
.
close
();
}
}
},
mounted
()
{
this
.
init
();
},
beforeDestroy
()
{
window
.
WebSocket
&&
this
.
websocket
&&
this
.
websocket
.
close
();
this
.
websocket
=
null
;
},
methods
:
{
init
()
{
if
(
this
.
websocket
)
return
false
;
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
)
{
// console.log(event)
};
this
.
websocket
.
onclose
=
function
(
event
)
{
// console.log(event)
};
this
.
websocket
.
onmessage
=
(
event
)
=>
{
if
(
event
.
data
)
that
.
handleReceiveMessage
(
event
.
data
);
};
this
.
websocket
.
onerror
=
function
(
event
)
{
this
.
websocket
=
null
;
};
}
},
/**
* 接受消息后的处理
*/
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
)
{
this
.
$router
.
push
(
'/'
+
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
;
},
}
};
};
</
script
>
</
script
>
template/src/router/index.js
View file @
1d0678c2
...
@@ -67,7 +67,6 @@ router.beforeEach((to, from, next) => {
...
@@ -67,7 +67,6 @@ router.beforeEach((to, from, next) => {
next
();
next
();
return
;
return
;
}
}
if
(
store
.
state
.
platformInfo
&&
if
(
store
.
state
.
platformInfo
&&
store
.
state
.
platformInfo
.
systemId
&&
store
.
state
.
platformInfo
.
systemId
&&
to
.
query
.
sysCode
===
from
.
query
.
sysCode
)
{
to
.
query
.
sysCode
===
from
.
query
.
sysCode
)
{
...
...
template/src/views/common/Header.vue
View file @
1d0678c2
...
@@ -35,10 +35,6 @@
...
@@ -35,10 +35,6 @@
<span
v-if=
"userInfo.RealName"
@
click=
"handleUserClick"
>
{{
userInfo
.
RealName
}}
</span>
<span
v-if=
"userInfo.RealName"
@
click=
"handleUserClick"
>
{{
userInfo
.
RealName
}}
</span>
<span
v-else
@
click=
"handleRelogin"
>
登录
</span>
<span
v-else
@
click=
"handleRelogin"
>
登录
</span>
</a>
</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"
<el-button
v-if=
"userInfo.RealName"
class=
"quit-user gutter"
type=
"text"
size=
"small"
icon=
"iconfont icon-tuichu"
:loading=
"isLoadingout"
@
click=
"logout"
>
size=
"small"
icon=
"iconfont icon-tuichu"
:loading=
"isLoadingout"
@
click=
"logout"
>
退出
退出
...
@@ -50,7 +46,7 @@
...
@@ -50,7 +46,7 @@
<
script
>
<
script
>
import
Api
from
'@/api'
;
import
Api
from
'@/api'
;
import
{
baseUrl
,
serviceUrl
}
from
'@config/http.config'
;
import
{
serviceUrl
}
from
'@config/http.config'
;
import
Logo
from
'./Logo.vue'
;
import
Logo
from
'./Logo.vue'
;
import
AppBreadcrumb
from
'./Breadcrumb'
;
import
AppBreadcrumb
from
'./Breadcrumb'
;
...
@@ -83,49 +79,11 @@ export default {
...
@@ -83,49 +79,11 @@ export default {
data
()
{
data
()
{
return
{
return
{
serviceUrl
,
serviceUrl
,
isLoadingout
:
false
,
isLoadingout
:
false
websocket
:
null
};
};
},
},
watch
:
{
userInfo
(
val
)
{
if
(
val
)
{
this
.
init
();
}
else
{
window
.
WebSocket
&&
this
.
websocket
&&
this
.
websocket
.
close
();
}
}
},
mounted
()
{
this
.
init
();
},
beforeDestroy
()
{
window
.
WebSocket
&&
this
.
websocket
&&
this
.
websocket
.
close
();
},
methods
:
{
methods
:
{
init
()
{
if
(
this
.
userInfo
&&
this
.
userInfo
.
userId
&&
window
.
WebSocket
)
{
this
.
websocket
=
new
WebSocket
(
`ws:
${
baseUrl
}
/MessageWebsocket?userId=
${
this
.
userInfo
.
userId
}
`
);
this
.
websocket
.
onopen
=
function
(
event
)
{
// console.log(event)
};
this
.
websocket
.
onclose
=
function
(
event
)
{
// console.log(event)
};
this
.
websocket
.
onmessage
=
(
event
)
=>
{
// state.unreadMessage = event.data
// this.unreadMessage = event.data;
this
.
$store
.
dispatch
(
'setUnreadMessage'
,
event
.
data
);
};
this
.
websocket
.
onerror
=
function
(
event
)
{
// console.log(event)
};
}
},
/**
/**
* 查看消息
* 查看消息
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment