Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivWeb
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
ReactWeb5
CivWeb
Commits
7bb5d72d
Commit
7bb5d72d
authored
2 years ago
by
杨思琦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 消息自定义模板修改
parent
505cb571
Pipeline
#64789
passed with stages
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
99 additions
and
66 deletions
+99
-66
message.js
src/layouts/AppLayout/notifier/message.js
+12
-0
notice.js
src/layouts/AppLayout/notifier/notice.js
+5
-4
index.js
src/layouts/AppLayout/notifier/templates/alarm/index.js
+3
-0
index.js
src/layouts/AppLayout/notifier/templates/case/index.js
+5
-0
index.js
src/layouts/AppLayout/notifier/templates/notice/index.js
+13
-8
index.js
src/layouts/AppLayout/notifier/templates/unknown/index.js
+10
-9
index.js
src/layouts/AppLayout/notifier/utils/index.js
+51
-45
No files found.
src/layouts/AppLayout/notifier/message.js
View file @
7bb5d72d
...
...
@@ -12,6 +12,9 @@ class Message {
webConfig
,
webPath
,
messType
,
defaultContent
,
webIcon
,
title
,
infoClasses
}
=
message
)
{
this
.
id
=
id
;
...
...
@@ -23,6 +26,9 @@ class Message {
this
.
webConfig
=
webConfig
;
this
.
webPath
=
webPath
;
this
.
messType
=
messType
;
// 方案名称 - 大类型下细类型
this
.
webIcon
=
webIcon
;
// 消息图标
this
.
title
=
title
;
// 消息标题
this
.
defaultContent
=
defaultContent
;
this
.
infoClasses
=
infoClasses
;
}
}
...
...
@@ -64,6 +70,9 @@ export const createMessageFromHis = (hisMessage, options = {}) => {
webConfig
:
hisMessage
.
web_config
,
webPath
:
hisMessage
.
web_path
,
messType
:
hisMessage
.
messType
,
defaultContent
:
(
_
.
isString
(
hisMessage
.
defaultContent
)
&&
hisMessage
.
defaultContent
.
replace
(
new
RegExp
(
/ /g
),
""
).
length
>
0
)
?
hisMessage
.
defaultContent
:
null
,
webIcon
:
(
_
.
isString
(
hisMessage
.
webIcon
)
&&
hisMessage
.
webIcon
.
replace
(
new
RegExp
(
/ /g
),
""
).
length
>
0
)
?
hisMessage
.
webIcon
:
null
,
title
:
(
_
.
isString
(
hisMessage
.
title
)
&&
hisMessage
.
title
.
replace
(
new
RegExp
(
/ /g
),
""
).
length
>
0
)
?
hisMessage
.
title
:
null
,
infoClasses
,
};
return
createMessage
(
template
);
...
...
@@ -101,6 +110,9 @@ export const createMessageFromReal = (realMesssage, options = {}) => {
webConfig
:
realMesssage
.
web_config
,
webPath
:
realMesssage
.
web_path
,
messType
:
realMesssage
.
messType
,
defaultContent
:
(
_
.
isString
(
realMesssage
.
defaultContent
)
&&
realMesssage
.
defaultContent
.
replace
(
new
RegExp
(
/ /g
),
""
).
length
>
0
)
?
realMesssage
.
defaultContent
:
null
,
webIcon
:
(
_
.
isString
(
realMesssage
.
webIcon
)
&&
realMesssage
.
webIcon
.
replace
(
new
RegExp
(
/ /g
),
""
).
length
>
0
)
?
realMesssage
.
webIcon
:
null
,
title
:
(
_
.
isString
(
realMesssage
.
title
)
&&
realMesssage
.
title
.
replace
(
new
RegExp
(
/ /g
),
""
).
length
>
0
)
?
realMesssage
.
title
:
null
,
infoClasses
,
}
...
...
This diff is collapsed.
Click to expand it.
src/layouts/AppLayout/notifier/notice.js
View file @
7bb5d72d
...
...
@@ -473,12 +473,13 @@ class Notifier {
};
speakOther
=
message
=>
{
// 类型区分‘全员公告’ 还是 ‘个人消息’
const
type
=
isEmpty
(
message
.
tousers
)
||
parseMessage
.
tousers
===
''
?
'公告'
:
'消息'
;
const
type
=
message
.
title
??
(
isEmpty
(
message
.
tousers
)
||
parseMessage
.
tousers
===
''
?
'公告'
:
'消息'
)
;
// 构建语音消息内容
const
{
infoContent
,
time
}
=
message
;
let
content
=
replaceSpeak
((
infoContent
?.
content
??
''
).
replace
(
/
\\
n/g
,
','
));
let
msg
=
`您有新的
${
type
}
:
${
content
.
substring
(
0
,
content
.
lastIndexOf
(
','
)).
replace
(
':'
,
','
)}
时间:
${
time
}
`
;
let
content
=
replaceSpeak
((
infoContent
?.
content
??
message
.
defaultContent
??
''
).
replace
(
/
\\
n/g
,
','
));
const
text
=
content
.
substring
(
0
,
content
.
lastIndexOf
(
','
)).
replace
(
':'
,
','
);
let
msg
=
`您有新的
${
type
}
:
${
text
!==
''
?
text
:
content
}
时间:
${
time
}
`
;
this
.
speak
(
msg
);
};
...
...
This diff is collapsed.
Click to expand it.
src/layouts/AppLayout/notifier/templates/alarm/index.js
View file @
7bb5d72d
import
React
from
'react'
;
import
_
from
'lodash'
;
// eslint-disable-next-line import/no-unresolved
import
classNames
from
'classnames'
;
import
{
findPathByWidget
,
isJSON
}
from
'@wisdom-utils/components/lib/AppLayout/helpers'
;
import
'../styles/common.less'
;
import
'./index.less'
;
import
{
ConfigProvider
}
from
'antd'
;
import
{
getMessageTypeIcon
}
from
'../../utils'
;
/* eslint-disable */
export
class
AlarmContent
{
constructor
({
...
...
@@ -62,6 +64,7 @@ const Alarm = ({ message, confirmRead, config }) => {
className
=
{
classNames
(
`
${
prefixCls
}
-notifier-message_scada`
,
`
${
prefixCls
}
-notifier-message-container`
)}
title
=
"点击查看详情"
onClick
=
{()
=>
goPath
(
message
)}
style
=
{{
backgroundImage
:
`url(
${
getMessageTypeIcon
(
message
)}
)`
}}
>
<
div
className
=
{
`
${
prefixCls
}
-notifier-message-title`
}
>
<
span
>
{
alarmType
}
<
/span
>
...
...
This diff is collapsed.
Click to expand it.
src/layouts/AppLayout/notifier/templates/case/index.js
View file @
7bb5d72d
import
React
from
'react'
;
import
{
ConfigProvider
}
from
'antd'
;
// eslint-disable-next-line import/no-unresolved
import
classNames
from
'classnames'
;
import
'../styles/common.less'
;
import
'./index.less'
;
import
{
getMessageTypeIcon
}
from
'../../utils'
;
// "caseType":"待办工单","flowName":"维修处理流程","nodeName":"审核关单","content":"请迅速到现场处理","time":"2020-11-03 09:11:12"
export
class
CaseContent
{
...
...
@@ -62,6 +64,7 @@ const Case = ({ message, confirmRead }) => {
className
=
{
classNames
(
`
${
prefixCls
}
-notifier-message_case`
,
`
${
prefixCls
}
-notifier-message-container`
)}
title
=
"点击查看详情"
onClick
=
{()
=>
goPath
(
message
)}
style
=
{{
backgroundImage
:
`url(
${
getMessageTypeIcon
(
message
)}
)`
}}
>
<
div
className
=
{
`
${
prefixCls
}
-notifier-message-title`
}
>
<
span
>
{
caseType
}
<
/span
>
...
...
@@ -72,7 +75,9 @@ const Case = ({ message, confirmRead }) => {
e
.
stopPropagation
();
confirmRead
(
false
,
[
message
.
id
]);
}}
// eslint-disable-next-line global-require
src
=
{
require
(
'../../images/oper/ok_line.png'
)}
alt
=
""
/>
<
/div
>
<
div
className
=
{
`
${
prefixCls
}
-notifier-message-content`
}
>
...
...
This diff is collapsed.
Click to expand it.
src/layouts/AppLayout/notifier/templates/notice/index.js
View file @
7bb5d72d
import
React
from
'react'
;
import
{
ConfigProvider
}
from
'antd'
;
// eslint-disable-next-line import/no-unresolved
import
classNames
from
'classnames'
;
import
'../styles/common.less'
;
import
'./index.less'
;
import
'./index.less'
;
import
{
getMessageTypeIcon
}
from
'../../utils'
;
export
class
NoticeContent
{
// eslint-disable-next-line no-undef
...
...
@@ -15,7 +16,6 @@ export class NoticeContent {
}
}
const
Notice
=
({
message
,
confirmRead
,
config
,
handlerSysDetail
})
=>
{
const
{
getPrefixCls
}
=
React
.
useContext
(
ConfigProvider
.
ConfigContext
);
const
prefixCls
=
getPrefixCls
();
...
...
@@ -25,26 +25,31 @@ const Notice = ({ message, confirmRead, config, handlerSysDetail }) => {
const
noticeContent
=
message
?.
infoContent
?.
noticeContent
??
''
;
// const remark = message?.infoContent?.remark;
const
goPath
=
(
item
)
=>
{
const
goPath
=
item
=>
{
confirmRead
(
false
,
[
message
.
id
]);
handlerSysDetail
&&
handlerSysDetail
(
message
);
};
return
(
<
div
className
=
{
classNames
(
`
${
prefixCls
}
-notifier-message_notice`
,
`
${
prefixCls
}
-notifier-message-container`
)}
title
=
"点击查看详情"
onClick
=
{()
=>
goPath
(
message
)}
style
=
{{
backgroundImage
:
`url(
${
getMessageTypeIcon
(
message
)}
)`
}}
>
<
div
className
=
{
`
${
prefixCls
}
-notifier-message-title`
}
>
<
span
>
{
noticeType
}{
noticeTitle
?
`:
${
noticeTitle
}
`
:
''
}
<
/span
>
<
span
>
{
noticeType
}
{
noticeTitle
?
`:
${
noticeTitle
}
`
:
''
}
<
/span
>
<
img
className
=
{
`
${
prefixCls
}
-notifier-message-confirm`
}
title
=
"点击标为已读"
onClick
=
{
(
e
)
=>
{
onClick
=
{
e
=>
{
e
.
stopPropagation
();
confirmRead
(
false
,
[
message
.
id
]);
}}
// eslint-disable-next-line global-require
src
=
{
require
(
'../../images/oper/ok_line.png'
)}
alt
=
""
/>
...
...
@@ -52,7 +57,7 @@ const Notice = ({ message, confirmRead, config, handlerSysDetail }) => {
<
div
className
=
{
`
${
prefixCls
}
-notifier-message-content`
}
>
<
p
>
{
noticeContent
}
<
/p
>
<
/div
>
<
p
className
=
{
`
${
prefixCls
}
-notifier-message-time`
}
>
{
message
.
time
}
<
/p
>
<
p
className
=
{
`
${
prefixCls
}
-notifier-message-time`
}
>
{
message
.
time
}
<
/p
>
<
/div
>
);
};
...
...
This diff is collapsed.
Click to expand it.
src/layouts/AppLayout/notifier/templates/unknown/index.js
View file @
7bb5d72d
import
React
from
'react'
;
import
{
ConfigProvider
}
from
'antd'
;
// eslint-disable-next-line import/no-unresolved
import
classNames
from
'classnames'
;
import
'../styles/common.less'
;
...
...
@@ -11,24 +12,23 @@ const Unknown = ({ message, confirmRead, handlerUnknowDetail }) => {
const
prefixCls
=
getPrefixCls
();
let
content
=
''
;
let
noticeTitle
=
''
;
const
{
infoContent
}
=
message
;
try
{
const
type
=
typeof
message
.
infoContent
;
switch
(
type
)
{
case
'object'
:
let
{
infoContent
}
=
message
;
noticeTitle
=
infoContent
.
title
||
''
;
content
=
infoContent
.
content
||
JSON
.
stringify
(
message
.
infoContent
);
break
;
case
'string'
:
content
=
message
.
infoContent
;
noticeTitle
=
message
.
title
||
infoContent
.
title
||
''
;
content
=
infoContent
.
content
||
message
.
defaultContent
||
JSON
.
stringify
(
message
.
infoContent
);
break
;
default
:
noticeTitle
=
message
.
title
||
''
;
content
=
message
.
defaultContent
||
message
.
infoContent
;
break
;
}
}
catch
(
e
)
{
// i
}
const
goPath
=
(
item
)
=>
{
const
goPath
=
item
=>
{
handlerUnknowDetail
&&
handlerUnknowDetail
(
message
);
confirmRead
(
false
,
[
message
.
id
]);
};
...
...
@@ -37,17 +37,18 @@ const Unknown = ({ message, confirmRead, handlerUnknowDetail }) => {
className
=
{
classNames
(
`
${
prefixCls
}
-notifier-message_unknown`
,
`
${
prefixCls
}
-notifier-message-container`
)}
title
=
"点击查看详情"
onClick
=
{()
=>
goPath
(
message
)}
style
=
{{
backgroundImage
:
`url(
${
getMessageTypeIcon
(
message
.
messType
)}
)`
}}
style
=
{{
backgroundImage
:
`url(
${
getMessageTypeIcon
(
message
)}
)`
}}
>
<
div
className
=
{
`
${
prefixCls
}
-notifier-message-title`
}
>
<
span
>
{
noticeTitle
}
<
/span
>
<
img
className
=
{
`
${
prefixCls
}
-notifier-message-confirm`
}
title
=
"点击标为已读"
onClick
=
{
(
e
)
=>
{
onClick
=
{
e
=>
{
e
.
stopPropagation
();
confirmRead
(
false
,
[
message
.
id
]);
}}
// eslint-disable-next-line global-require
src
=
{
require
(
'../../images/oper/ok_line.png'
)}
alt
=
""
/>
...
...
This diff is collapsed.
Click to expand it.
src/layouts/AppLayout/notifier/utils/index.js
View file @
7bb5d72d
import
{
MESSAGE_TYPE
}
from
'../constants'
;
import
parseMessageToJSON
from
'./parse'
;
import
alarm
_i
con
from
'../images/types/alarm.png'
;
import
approve
_i
con
from
'../images/types/approve.png'
;
import
meeting
_i
con
from
'../images/types/meeting.png'
;
import
notice
_i
con
from
'../images/types/notice.png'
;
import
task
_i
con
from
'../images/types/task.png'
;
import
work
_i
con
from
'../images/types/work.png'
;
import
write
_i
con
from
'../images/types/write.png'
;
import
other
_i
con
from
'../images/types/other.png'
;
import
alarm
I
con
from
'../images/types/alarm.png'
;
import
approve
I
con
from
'../images/types/approve.png'
;
import
meeting
I
con
from
'../images/types/meeting.png'
;
import
notice
I
con
from
'../images/types/notice.png'
;
import
task
I
con
from
'../images/types/task.png'
;
import
work
I
con
from
'../images/types/work.png'
;
import
write
I
con
from
'../images/types/write.png'
;
import
other
I
con
from
'../images/types/other.png'
;
export
const
getMessageTypeIcon
=
messageType
=>
{
let
icon
=
other_icon
;
export
const
getMessageTypeIcon
=
message
=>
{
const
{
webIcon
}
=
message
;
if
(
webIcon
)
return
`
${
window
.
location
.
origin
}
/
${
webIcon
}
`
;
const
{
messageType
,
infoType
}
=
message
;
let
icon
=
otherIcon
;
if
(
infoType
===
'通用报警'
)
{
icon
=
alarmIcon
;
}
else
if
(
infoType
===
'系统通知'
)
{
icon
=
noticeIcon
;
}
else
if
(
infoType
===
'工单提醒'
)
{
icon
=
workIcon
;
}
if
(
!
messageType
)
return
icon
;
if
(
messageType
===
'工时填报'
)
{
icon
=
write
_i
con
;
icon
=
write
I
con
;
}
else
if
(
messageType
.
indexOf
(
'审批'
)
>
-
1
)
{
icon
=
approve
_i
con
;
icon
=
approve
I
con
;
}
else
if
(
messageType
.
indexOf
(
'会议'
)
>
-
1
)
{
icon
=
meeting
_i
con
;
icon
=
meeting
I
con
;
}
else
if
(
messageType
.
indexOf
(
'任务'
)
>
-
1
)
{
icon
=
task
_i
con
;
icon
=
task
I
con
;
}
return
icon
;
};
export
const
getMessageClasses
=
messageType
=>
{
let
infoType
=
''
;
switch
(
messageType
)
{
// 报警类
case
'SCADA报警'
:
case
'通用报警'
:
infoType
=
MESSAGE_TYPE
.
ALARM_TYPE
;
break
;
// 工单类
case
'工单流程'
:
case
'工单提醒'
:
infoType
=
MESSAGE_TYPE
.
CASE_TYPE
;
break
;
// 系统消息类
case
'系统通知'
:
case
'系统消息'
:
infoType
=
MESSAGE_TYPE
.
SYS_TYPE
;
break
;
// 其他类
default
:
infoType
=
MESSAGE_TYPE
.
UNKNOWN
;
break
;
}
return
infoType
;
let
infoType
=
''
;
switch
(
messageType
)
{
// 报警类
case
'SCADA报警'
:
case
'通用报警'
:
infoType
=
MESSAGE_TYPE
.
ALARM_TYPE
;
break
;
// 工单类
case
'工单流程'
:
case
'工单提醒'
:
infoType
=
MESSAGE_TYPE
.
CASE_TYPE
;
break
;
// 系统消息类
case
'系统通知'
:
case
'系统消息'
:
infoType
=
MESSAGE_TYPE
.
SYS_TYPE
;
break
;
// 其他类
default
:
infoType
=
MESSAGE_TYPE
.
UNKNOWN
;
break
;
}
return
infoType
;
};
/**
* 消息语音单位转换
* 说明:消息通过语音播放时,需要将一些字母单位转换成文字,不然会当做字母播放。
...
...
@@ -76,16 +82,17 @@ export const replaceSpeak = msg => {
return
msg
;
};
// eslint-disable-next-line arrow-body-style
export
const
generatedId
=
()
=>
{
return
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.
replace
(
/
[
xy
]
/g
,
function
(
c
)
{
// eslint-disable-next-line no-bitwise
const
r
=
(
Math
.
random
()
*
16
)
|
0
;
// eslint-disable-next-line no-bitwise
const
v
=
c
===
'x'
?
r
:
(
r
&
0x3
)
|
0x8
;
return
v
.
toString
(
16
);
})
.
toUpperCase
();
};
export
{
parseMessageToJSON
,
}
\ No newline at end of file
export
{
parseMessageToJSON
};
This diff is collapsed.
Click to expand it.
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