add log component: prolist
This commit is contained in:
@@ -1,12 +1,88 @@
|
||||
import { Todo } from '@/components';
|
||||
import { PageContainer } from '@ant-design/pro-components';
|
||||
import { PageContainer, ProList } from '@ant-design/pro-components';
|
||||
import { Card } from 'antd';
|
||||
import moment from 'moment';
|
||||
import request from 'umi-request';
|
||||
import transInfo, { LogsItem } from './logItem';
|
||||
|
||||
const Logs: React.FC = () => {
|
||||
return (
|
||||
<PageContainer>
|
||||
<Card>
|
||||
<Todo />
|
||||
<ProList<LogsItem>
|
||||
search={{
|
||||
filterType: 'light',
|
||||
}}
|
||||
rowKey="op"
|
||||
headerTitle="日志列表"
|
||||
request={async (params = {} as Record<string, any>) =>
|
||||
request<{
|
||||
data: LogsItem[];
|
||||
}>('http://127.0.0.1:8000/admin/loglist', {
|
||||
params,
|
||||
})
|
||||
}
|
||||
pagination={{
|
||||
pageSize: 5,
|
||||
}}
|
||||
metas={{
|
||||
title: {
|
||||
dataIndex: 'op',
|
||||
title: '用户',
|
||||
},
|
||||
avatar: {
|
||||
dataIndex: 'avatar',
|
||||
search: false,
|
||||
},
|
||||
description: {
|
||||
dataIndex: ['time', 'operation', 'target', 'prev', 'curr'],
|
||||
search: false,
|
||||
render: (_, row) => {
|
||||
return (
|
||||
<div>
|
||||
{'于 ' +
|
||||
moment(row.time).format('lll') +
|
||||
' ' +
|
||||
transInfo(row.operation, 'operation') +
|
||||
'了 ' +
|
||||
transInfo(row.target, 'target') +
|
||||
':' +
|
||||
row.prev.info +
|
||||
' -> ' +
|
||||
row.curr.info}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
render: (text, row) => [
|
||||
<a href="" target="_blank" rel="noopener noreferrer" key="view">
|
||||
查看
|
||||
</a>,
|
||||
],
|
||||
search: false,
|
||||
},
|
||||
// status: {
|
||||
// // 自己扩展的字段,主要用于筛选,不在列表中显示
|
||||
// title: '更改部分',
|
||||
// valueType: 'select',
|
||||
// valueEnum: {
|
||||
// all: { text: '全部', status: 'Default' },
|
||||
// open: {
|
||||
// text: '未解决',
|
||||
// status: 'Error',
|
||||
// },
|
||||
// closed: {
|
||||
// text: '已解决',
|
||||
// status: 'Success',
|
||||
// },
|
||||
// processing: {
|
||||
// text: '解决中',
|
||||
// status: 'Processing',
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
</PageContainer>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
const operationMap: { [key: number]: string } = {
|
||||
0: '增加',
|
||||
1: '删除',
|
||||
2: '修改',
|
||||
};
|
||||
|
||||
const targetMap: { [key: number]: string } = {
|
||||
0: '值班表',
|
||||
1: '值班信息',
|
||||
2: '值班总结',
|
||||
};
|
||||
|
||||
export type LogsItem = {
|
||||
op: string;
|
||||
time: string;
|
||||
operation: number;
|
||||
target: number;
|
||||
prev: {
|
||||
id: number;
|
||||
info: string;
|
||||
};
|
||||
curr: {
|
||||
id: number;
|
||||
info: string;
|
||||
};
|
||||
};
|
||||
|
||||
const transInfo = (num: number, type: string) => {
|
||||
switch (type) {
|
||||
case 'operation':
|
||||
return operationMap[num];
|
||||
case 'target':
|
||||
return targetMap[num];
|
||||
}
|
||||
};
|
||||
|
||||
export default transInfo;
|
||||
@@ -1,7 +1,8 @@
|
||||
import Settings from '@/../config/defaultSettings';
|
||||
import oidcLogo from '@/assets/oidc-logo.svg';
|
||||
import { PageFooter } from '@/components';
|
||||
import { login } from '@/services/ant-design-pro/api';
|
||||
import { login } from '@/services/api';
|
||||
import { API } from '@/services/typings';
|
||||
import { LockOutlined, UserOutlined } from '@ant-design/icons';
|
||||
import { LoginForm, ProFormCheckbox, ProFormText } from '@ant-design/pro-components';
|
||||
import { Helmet, history, useModel } from '@umijs/max';
|
||||
|
||||
Reference in New Issue
Block a user