|
@@ -0,0 +1,93 @@
|
|
|
+import { queryLoginLogs } from '@/services/api/permission'
|
|
|
+import consts from '@/utils/consts'
|
|
|
+import dayjs from 'dayjs'
|
|
|
+import { PageContainer } from '@ant-design/pro-layout'
|
|
|
+import ProTable from '@ant-design/pro-table'
|
|
|
+import React, { useState } from 'react'
|
|
|
+import { Select } from 'antd'
|
|
|
+
|
|
|
+const timeTypeOptions = [
|
|
|
+ { label: '最近三天', value: 'days' },
|
|
|
+ { label: '最近一周', value: 'week' },
|
|
|
+ { label: '最近一个月', value: 'month' }
|
|
|
+]
|
|
|
+const LoginLog = () => {
|
|
|
+ const [state, setState] = useState({
|
|
|
+ params: {
|
|
|
+ search: null
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const columns: ProColumnType<API.LoginLogParams>[] = [
|
|
|
+ {
|
|
|
+ dataIndex: 'userID',
|
|
|
+ title: '账号',
|
|
|
+ onHeaderCell: () => ({ style: { textAlign: 'center' } })
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: 'account',
|
|
|
+ title: '姓名',
|
|
|
+ onHeaderCell: () => ({ style: { textAlign: 'center' } })
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: 'browser',
|
|
|
+ title: '登录设备',
|
|
|
+ align: 'center',
|
|
|
+ onHeaderCell: () => ({ style: { textAlign: 'center' } })
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: 'createTime',
|
|
|
+ title: '登录时间',
|
|
|
+ align: 'center',
|
|
|
+ onHeaderCell: () => ({ style: { textAlign: 'center' } }),
|
|
|
+ renderText: text => dayjs(text).format('YYYY-MM-DD')
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: 'ipInfo',
|
|
|
+ title: '登录地址',
|
|
|
+ align: 'center',
|
|
|
+ onHeaderCell: () => ({ style: { textAlign: 'center' } })
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ return (
|
|
|
+ <PageContainer title={false}>
|
|
|
+ <div className="h-full w-full flex flex-row">
|
|
|
+ <div className="w-full h-full bg-white">
|
|
|
+ <ProTable
|
|
|
+ rowKey="ID"
|
|
|
+ columns={columns}
|
|
|
+ search={false}
|
|
|
+ scroll={{ y: document.body.clientHeight - 315 }}
|
|
|
+ request={async (params, sort, filter) => {
|
|
|
+ const {
|
|
|
+ code = -1,
|
|
|
+ data: { items = [], total = 0 }
|
|
|
+ } = await queryLoginLogs({ ...params, ...sort, ...filter })
|
|
|
+ return {
|
|
|
+ data: items,
|
|
|
+ success: code === consts.RET_CODE.SUCCESS,
|
|
|
+ total
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ toolbar={{
|
|
|
+ search: {
|
|
|
+ onSearch: val => setState({ ...state, params: { ...state.params, search: val } }),
|
|
|
+ style: { width: '250px' },
|
|
|
+ placeholder: '请输入账号或姓名'
|
|
|
+ },
|
|
|
+ actions: [
|
|
|
+ <Select
|
|
|
+ style={{ width: '100px' }}
|
|
|
+ key="primary"
|
|
|
+ defaultValue={'days'}
|
|
|
+ options={timeTypeOptions}
|
|
|
+ />
|
|
|
+ ]
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </PageContainer>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+export default LoginLog
|