Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivManage
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
CivManage
Commits
fc246c99
Commit
fc246c99
authored
Dec 17, 2020
by
陈前坚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 登录日志
parent
aaa9afd5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
47 deletions
+69
-47
index.js
src/pages/log/loginLog/index.js
+58
-38
index.less
src/pages/log/loginLog/index.less
+1
-1
index.js
src/pages/log/omsLog/index.js
+5
-4
index.js
src/pages/log/serviceLog/index.js
+5
-4
No files found.
src/pages/log/loginLog/index.js
View file @
fc246c99
...
...
@@ -19,7 +19,10 @@ import styles from './index.less';
const
ServiceLog
=
()
=>
{
const
[
loading
,
setLoading
]
=
useState
(
false
);
// 源数据
const
[
data0
,
setData0
]
=
useState
([]);
// 源数据
const
[
IPCount
,
setIPCount
]
=
useState
([]);
// 接口调用次数,统计数据
const
[
LoginNameFilters
,
setLoginNameFilters
]
=
useState
([]);
// 用户列筛选
const
[
ShowNameFilters
,
setShowNameFilters
]
=
useState
([]);
// 用户列筛选
const
[
SystemTypeFilters
,
setSystemTypeFilters
]
=
useState
([]);
// 用户列筛选
// const [IPCount, setIPCount] = useState([]); // 接口调用次数,统计数据
const
[
startTime
,
setStartTime
]
=
useState
(
moment
().
startOf
(
'day'
));
// 默认值当天0点
const
[
endTime
,
setEndTime
]
=
useState
(
moment
(
new
Date
(),
'YYYY-MM-DD HH:mm:ss'
),
// 默认值当前时间
...
...
@@ -41,22 +44,28 @@ const ServiceLog = () => {
title
:
'登录名'
,
dataIndex
:
'LoginName'
,
key
:
'LoginName'
,
filters
:
LoginNameFilters
,
onFilter
:
(
value
,
record
)
=>
record
.
LoginName
===
value
,
},
{
title
:
'用户名'
,
dataIndex
:
'ShowName'
,
key
:
'ShowName'
,
filters
:
ShowNameFilters
,
onFilter
:
(
value
,
record
)
=>
record
.
ShowName
===
value
,
},
{
title
:
'系统类型'
,
dataIndex
:
'SystemType'
,
key
:
'SystemType'
,
filters
:
SystemTypeFilters
,
onFilter
:
(
value
,
record
)
=>
record
.
SystemType
===
value
,
},
{
title
:
'终端'
,
dataIndex
:
'Terminal'
,
key
:
'Terminal'
,
},
//
{
//
title: '终端',
//
dataIndex: 'Terminal',
//
key: 'Terminal',
//
},
];
// 在起止时间任意一个变化后获取数据
useEffect
(()
=>
{
...
...
@@ -67,8 +76,8 @@ const ServiceLog = () => {
},
[
startTime
,
endTime
]);
const
getData
=
()
=>
{
post
(
`
${
PUBLISH_SERVICE
}
/LogCenter/GetLoginLog`
,
{
PageIndex
:
0
,
PageSize
:
0
,
PageIndex
:
1
,
PageSize
:
20
0
,
DateFrom
:
startTime
.
format
(
'YYYY-MM-DD HH:mm:ss'
),
DateTo
:
endTime
.
format
(
'YYYY-MM-DD HH:mm:ss'
),
IP
:
''
,
...
...
@@ -79,13 +88,23 @@ const ServiceLog = () => {
})
.
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
setData0
(
res
.
data
);
dataTransforrm
(
res
.
data
);
console
.
log
(
res
.
data
);
setData0
(
res
.
data
.
list
);
// 过滤LoginName
let
arr1
=
res
.
data
.
list
.
map
(
item
=>
item
.
LoginName
);
arr1
=
arr1
.
filter
((
value
,
index
)
=>
arr1
.
indexOf
(
value
)
===
index
);
setLoginNameFilters
(
arr1
.
map
(
item
=>
({
text
:
item
,
value
:
item
})));
// 过滤ShowName
let
arr2
=
res
.
data
.
list
.
map
(
item
=>
item
.
ShowName
);
arr2
=
arr2
.
filter
((
value
,
index
)
=>
arr2
.
indexOf
(
value
)
===
index
);
setShowNameFilters
(
arr2
.
map
(
item
=>
({
text
:
item
,
value
:
item
})));
// 过滤系统类型SystemType
let
arr3
=
res
.
data
.
list
.
map
(
item
=>
item
.
SystemType
);
arr3
=
arr3
.
filter
((
value
,
index
)
=>
arr3
.
indexOf
(
value
)
===
index
);
setSystemTypeFilters
(
arr3
.
map
(
item
=>
({
text
:
item
,
value
:
item
})));
}
else
{
notification
.
error
({
message
:
'数据获取失败'
,
description
:
res
.
m
essage
,
description
:
res
.
m
sg
,
});
}
setLoading
(
false
);
...
...
@@ -95,29 +114,29 @@ const ServiceLog = () => {
setLoading
(
false
);
});
};
const
dataTransforrm
=
data
=>
{
data
.
map
((
item
,
index
)
=>
{
item
.
key
=
index
;
return
item
;
});
//
const dataTransforrm = data => {
//
data.map((item, index) => {
//
item.key = index;
//
return item;
//
});
const
dv1
=
new
DataSet
.
View
().
source
(
data
);
dv1
.
transform
({
type
:
'aggregate'
,
// 别名summary
fields
:
[
'IP'
],
// 统计字段集
operations
:
[
'count'
],
// 统计操作集
as
:
[
'计数'
],
// 存储字段集
groupBy
:
[
'IP'
],
// 分组字段集
})
.
transform
({
type
:
'sort-by'
,
fields
:
[
'计数'
],
// 根据指定的字段集进行排序,与lodash的sortBy行为一致
order
:
'DESC'
,
// 默认为 ASC,DESC 则为逆序
});
console
.
log
(
dv1
.
rows
);
setIPCount
(
dv1
.
rows
.
slice
(
0
,
20
));
};
//
const dv1 = new DataSet.View().source(data);
//
dv1
//
.transform({
//
type: 'aggregate', // 别名summary
//
fields: ['IP'], // 统计字段集
//
operations: ['count'], // 统计操作集
//
as: ['计数'], // 存储字段集
//
groupBy: ['IP'], // 分组字段集
//
})
//
.transform({
//
type: 'sort-by',
//
fields: ['计数'], // 根据指定的字段集进行排序,与lodash的sortBy行为一致
//
order: 'DESC', // 默认为 ASC,DESC 则为逆序
//
});
//
console.log(dv1.rows);
//
setIPCount(dv1.rows.slice(0, 20));
//
};
// DatePicker改变点击确定时
const
changeStartTime
=
time
=>
{
...
...
@@ -163,13 +182,14 @@ const ServiceLog = () => {
/
>
<
Button
onClick
=
{()
=>
setTime
(
1
)}
>
近
1
小时
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
6
)}
>
近
6
小时
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
12
)}
>
近
12
小时
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
24
)}
>
近
1
天
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
24
*
7
)}
>
近
1
周
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
14
*
24
)}
>
近
2
周
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
30
*
24
)}
>
近
1
月
<
/Button
>
<
/Col
>
<
/Row
>
<
Spin
spinning
=
{
loading
}
tip
=
"loading"
>
<
Row
className
=
{
styles
.
chart
}
>
{
/*
<Row className={styles.chart}>
<Col span={12}>
<Chart
height={316}
...
...
@@ -189,7 +209,7 @@ const ServiceLog = () => {
<Tooltip shared />
</Chart>
</Col>
<
/Row
>
</Row>
*/
}
<
div
className
=
{
styles
.
table
}
>
<
Table
size
=
"small"
...
...
@@ -201,7 +221,7 @@ const ServiceLog = () => {
showTotal
:
(
total
,
range
)
=>
`第
${
range
[
0
]}
-
${
range
[
1
]}
条/共
${
total
}
条`
,
pageSizeOptions
:
[
10
,
20
,
50
,
100
],
defaultPageSize
:
1
0
,
defaultPageSize
:
2
0
,
showQuickJumper
:
true
,
showSizeChanger
:
true
,
}}
...
...
src/pages/log/loginLog/index.less
View file @
fc246c99
...
...
@@ -17,7 +17,7 @@
color:rgba(0,0,0,0.85);
}
.ant-table-content{
height:calc(100vh -
518
px);
height:calc(100vh -
172
px);
border-right: white;
overflow: auto !important;
}
...
...
src/pages/log/omsLog/index.js
View file @
fc246c99
...
...
@@ -33,7 +33,7 @@ const ServiceLog = () => {
const
[
endTime
,
setEndTime
]
=
useState
(
moment
(
new
Date
(),
'YYYY-MM-DD HH:mm:ss'
),
// 默认值,当前时间
);
const
[
logType
,
setLogType
]
=
useState
(
-
1
);
// 请求参数,日志类型,默认是正常,0:成功 -1:错误 9999:全部
const
[
logType
,
setLogType
]
=
useState
(
0
);
// 请求参数,日志类型,默认是正常,0:成功 -1:错误 9999:全部
const
[
searchWord
,
setSearchWord
]
=
useState
(
''
);
// 关键字
// 计算时间间隔(分钟)
...
...
@@ -169,8 +169,9 @@ const ServiceLog = () => {
if
(
!
res
.
data
)
{
set
([]);
}
else
{
const
result
=
url
===
'/GetOMSLog'
?
res
.
data
.
list
:
res
.
data
;
set
(
res
.
data
.
map
((
item
,
index
)
=>
{
res
ult
.
map
((
item
,
index
)
=>
{
item
.
key
=
index
;
if
(
url
===
'/TrafficStatistics'
)
{
item
.
StartTime
=
item
.
StartTime
.
replace
(
' '
,
'-'
);
...
...
@@ -182,7 +183,7 @@ const ServiceLog = () => {
}
else
{
notification
.
error
({
message
:
'数据获取失败'
,
description
:
res
.
m
essage
,
description
:
res
.
m
sg
,
});
}
setLoading
(
false
);
...
...
@@ -255,7 +256,7 @@ const ServiceLog = () => {
<
Button
onClick
=
{()
=>
setTime
(
24
*
60
,
'3'
)}
>
近
1
天
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
24
*
7
*
60
,
'4'
)}
>
近
1
周
<
/Button
>
<
span
style
=
{{
marginLeft
:
'20px'
}}
>
返回状态:
<
/span
>
<
Select
defaultValue
=
"
错误
"
onChange
=
{
changeStatus
}
>
<
Select
defaultValue
=
"
正常
"
onChange
=
{
changeStatus
}
>
<
Option
value
=
"9999"
>
全部
<
/Option
>
<
Option
value
=
"0"
>
正常
<
/Option
>
<
Option
value
=
"-1"
>
错误
<
/Option
>
...
...
src/pages/log/serviceLog/index.js
View file @
fc246c99
...
...
@@ -33,7 +33,7 @@ const ServiceLog = () => {
const
[
endTime
,
setEndTime
]
=
useState
(
moment
(
new
Date
(),
'YYYY-MM-DD HH:mm:ss'
),
// 默认值,当前时间
);
const
[
logType
,
setLogType
]
=
useState
(
-
1
);
// 请求参数,日志类型,默认是正常,0:成功 -1:错误 9999:全部
const
[
logType
,
setLogType
]
=
useState
(
0
);
// 请求参数,日志类型,默认是正常,0:成功 -1:错误 9999:全部
const
[
searchWord
,
setSearchWord
]
=
useState
(
''
);
// 关键字
// 计算时间间隔(分钟)
...
...
@@ -169,8 +169,9 @@ const ServiceLog = () => {
if
(
!
res
.
data
)
{
set
([]);
}
else
{
const
result
=
url
===
'/GetOMSLog'
?
res
.
data
.
list
:
res
.
data
;
set
(
res
.
data
.
map
((
item
,
index
)
=>
{
res
ult
.
map
((
item
,
index
)
=>
{
item
.
key
=
index
;
if
(
url
===
'/TrafficStatistics'
)
{
item
.
StartTime
=
item
.
StartTime
.
replace
(
' '
,
'-'
);
...
...
@@ -182,7 +183,7 @@ const ServiceLog = () => {
}
else
{
notification
.
error
({
message
:
'数据获取失败'
,
description
:
res
.
m
essage
,
description
:
res
.
m
sg
,
});
}
setLoading
(
false
);
...
...
@@ -255,7 +256,7 @@ const ServiceLog = () => {
<
Button
onClick
=
{()
=>
setTime
(
24
*
60
,
'3'
)}
>
近
1
天
<
/Button
>
<
Button
onClick
=
{()
=>
setTime
(
24
*
7
*
60
,
'4'
)}
>
近
1
周
<
/Button
>
<
span
style
=
{{
marginLeft
:
'20px'
}}
>
返回状态:
<
/span
>
<
Select
defaultValue
=
"
错误
"
onChange
=
{
changeStatus
}
>
<
Select
defaultValue
=
"
正常
"
onChange
=
{
changeStatus
}
>
<
Option
value
=
"9999"
>
全部
<
/Option
>
<
Option
value
=
"0"
>
正常
<
/Option
>
<
Option
value
=
"-1"
>
错误
<
/Option
>
...
...
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