Commit fc246c99 authored by 陈前坚's avatar 陈前坚

perf: 登录日志

parent aaa9afd5
......@@ -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: 200,
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.message,
description: res.msg,
});
}
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: 10,
defaultPageSize: 20,
showQuickJumper: true,
showSizeChanger: true,
}}
......
......@@ -17,7 +17,7 @@
color:rgba(0,0,0,0.85);
}
.ant-table-content{
height:calc(100vh - 518px);
height:calc(100vh - 172px);
border-right: white;
overflow: auto !important;
}
......
......@@ -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) => {
result.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.message,
description: res.msg,
});
}
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>
......
......@@ -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) => {
result.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.message,
description: res.msg,
});
}
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>
......
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