wsj
3 days ago 71719ffa0eeb4a28a1b736f87499bcda2847a848
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { useCallback, useMemo, useState } from 'react';
import { ProTable } from '@ant-design/pro-components';
import { createAuditLogColumns } from './columns';
import AuditLogDetailDrawer from './components/AuditLogDetailDrawer';
import { getAuditLogList } from './service';
import type { AuditLogListQuery, AuditLogVO } from './types';
 
const AuditLogs = () => {
  const [detail, setDetail] = useState<AuditLogVO | null>(null);
 
  const openDetail = useCallback((record: AuditLogVO) => {
    setDetail(record);
  }, []);
 
  const closeDetail = useCallback(() => {
    setDetail(null);
  }, []);
 
  const columns = useMemo(() => createAuditLogColumns({ onDetail: openDetail }), [openDetail]);
 
  const fetchList = useCallback(
    (params: AuditLogListQuery) =>
      getAuditLogList({
        page: params.current,
        size: params.pageSize,
        module: params.module,
        action: params.action,
        entityType: params.entityType,
        resultStatus: params.resultStatus,
        operatorId: params.operatorId,
        start: params.start,
        end: params.end,
      }).then((result) => ({
        data: result.records ?? [],
        total: result.total ?? 0,
        success: true,
      })),
    [],
  );
 
  return (
    <div className="audit-log-page">
      <ProTable<AuditLogVO, AuditLogListQuery>
        rowKey="logId"
        columns={columns}
        cardProps={{ bodyStyle: { padding: 20 } }}
        search={{ labelWidth: 'auto', defaultCollapsed: false }}
        scroll={{ x: 1430 }}
        options={false}
        pagination={{
          defaultPageSize: 10,
          showSizeChanger: true,
          hideOnSinglePage: false,
          showTotal: (total) => `共 ${total} 条`,
        }}
        request={fetchList}
      />
 
      <AuditLogDetailDrawer open={detail !== null} record={detail} onClose={closeDetail} />
    </div>
  );
};
 
export default AuditLogs;