flat:客户端操作日志
This commit is contained in:
@@ -59,7 +59,7 @@ const DictTag: React.FC<DictTagProps> = (props) => {
|
||||
return '';
|
||||
}
|
||||
if (props.enums) {
|
||||
const item = props.enums[value];
|
||||
const item = props.enums[value] || {};
|
||||
return item.label;
|
||||
}
|
||||
if (props.options) {
|
||||
@@ -81,7 +81,7 @@ const DictTag: React.FC<DictTagProps> = (props) => {
|
||||
return 'default';
|
||||
}
|
||||
if (props.enums) {
|
||||
const item = props.enums[value];
|
||||
const item = props.enums[value] || {};
|
||||
return item.listClass || 'default';
|
||||
}
|
||||
if (props.options) {
|
||||
|
||||
113
src/pages/Monitor/Mobilelog/detail.tsx
Normal file
113
src/pages/Monitor/Mobilelog/detail.tsx
Normal file
@@ -0,0 +1,113 @@
|
||||
import React from 'react';
|
||||
import { Descriptions, Modal } from 'antd';
|
||||
import { useIntl, FormattedMessage } from '@umijs/max';
|
||||
import { DictValueEnumObj } from '@/components/DictTag';
|
||||
import { getValueEnumLabel } from '@/utils/options';
|
||||
|
||||
export type MobilelogFormData = Record<string, unknown> & Partial<API.Monitor.Mobilelog>;
|
||||
|
||||
export type MobilelogFormProps = {
|
||||
onCancel: (flag?: boolean, formVals?: MobilelogFormData) => void;
|
||||
onSubmit: (values: MobilelogFormData) => Promise<void>;
|
||||
open: boolean;
|
||||
values: Partial<API.Monitor.Operlog>;
|
||||
businessTypeOptions: DictValueEnumObj;
|
||||
operatorTypeOptions: DictValueEnumObj;
|
||||
statusOptions: DictValueEnumObj;
|
||||
};
|
||||
|
||||
const OperlogDetailForm: React.FC<MobilelogFormProps> = (props) => {
|
||||
|
||||
const { values, businessTypeOptions, operatorTypeOptions, statusOptions, } = props;
|
||||
|
||||
const intl = useIntl();
|
||||
const handleOk = () => {};
|
||||
const handleCancel = () => {
|
||||
props.onCancel();
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
width={640}
|
||||
title={intl.formatMessage({
|
||||
id: 'monitor.operlog.title',
|
||||
defaultMessage: '编辑操作日志记录',
|
||||
})}
|
||||
open={props.open}
|
||||
destroyOnClose
|
||||
onOk={handleOk}
|
||||
onCancel={handleCancel}
|
||||
>
|
||||
<Descriptions column={24}>
|
||||
<Descriptions.Item
|
||||
span={12}
|
||||
label={<FormattedMessage id="monitor.operlog.module" defaultMessage="操作模块" />}
|
||||
>
|
||||
{`${values.title}/${getValueEnumLabel(businessTypeOptions, values.businessType)}`}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item
|
||||
span={12}
|
||||
label={<FormattedMessage id="monitor.operlog.request_method" defaultMessage="请求方式" />}
|
||||
>
|
||||
{values.requestMethod}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item
|
||||
span={12}
|
||||
label={<FormattedMessage id="monitor.operlog.oper_name" defaultMessage="操作人员" />}
|
||||
>
|
||||
{`${values.operName}/${values.operIp}`}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item
|
||||
span={12}
|
||||
label={<FormattedMessage id="monitor.operlog.operator_type" defaultMessage="操作类别" />}
|
||||
>
|
||||
{getValueEnumLabel(operatorTypeOptions, values.operatorType)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item
|
||||
span={24}
|
||||
label={<FormattedMessage id="monitor.operlog.method" defaultMessage="方法名称" />}
|
||||
>
|
||||
{values.method}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item
|
||||
span={24}
|
||||
label={<FormattedMessage id="monitor.operlog.oper_url" defaultMessage="请求URL" />}
|
||||
>
|
||||
{values.operUrl}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item
|
||||
span={24}
|
||||
label={<FormattedMessage id="monitor.operlog.oper_param" defaultMessage="请求参数" />}
|
||||
>
|
||||
{values.operParam}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item
|
||||
span={24}
|
||||
label={<FormattedMessage id="monitor.operlog.json_result" defaultMessage="返回参数" />}
|
||||
>
|
||||
{values.jsonResult}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item
|
||||
span={24}
|
||||
label={<FormattedMessage id="monitor.operlog.error_msg" defaultMessage="错误消息" />}
|
||||
>
|
||||
{values.errorMsg}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item
|
||||
span={12}
|
||||
label={<FormattedMessage id="monitor.operlog.status" defaultMessage="操作状态" />}
|
||||
>
|
||||
{getValueEnumLabel(statusOptions, values.status)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item
|
||||
span={12}
|
||||
label={<FormattedMessage id="monitor.operlog.oper_time" defaultMessage="操作时间" />}
|
||||
>
|
||||
{values.operTime?.toString()}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default OperlogDetailForm;
|
||||
304
src/pages/Monitor/Mobilelog/index.tsx
Normal file
304
src/pages/Monitor/Mobilelog/index.tsx
Normal file
@@ -0,0 +1,304 @@
|
||||
import React, { useState, useRef, useEffect, useMemo } from 'react';
|
||||
import {addMobilelog, getMobileLogList, removeMobilelog, updateMobilelog} from "@/services/monitor/mobilelog";
|
||||
import { ActionType, FooterToolbar, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
|
||||
import { useIntl, FormattedMessage, useAccess } from '@umijs/max';
|
||||
import { PlusOutlined, DeleteOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
|
||||
import { Button, message, Modal } from 'antd';
|
||||
import DictTag from "@/components/DictTag";
|
||||
import {getDictValueEnum} from "@/services/system/dict";
|
||||
import UpdateForm from './detail';
|
||||
import {addOperlog, removeOperlog, updateOperlog} from "@/services/monitor/operlog";
|
||||
/**
|
||||
* 添加节点
|
||||
*
|
||||
* @param fields
|
||||
*/
|
||||
const handleAdd = async (fields: API.Monitor.Operlog) => {
|
||||
const hide = message.loading('正在添加');
|
||||
try {
|
||||
const resp = await addMobilelog({ ...fields });
|
||||
hide();
|
||||
if (resp.code === 200) {
|
||||
message.success('添加成功');
|
||||
} else {
|
||||
message.error(resp.msg);
|
||||
}
|
||||
return true;
|
||||
} catch (error) {
|
||||
hide();
|
||||
message.error('添加失败请重试!');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 更新节点
|
||||
*
|
||||
* @param fields
|
||||
*/
|
||||
const handleUpdate = async (fields: API.Monitor.Operlog) => {
|
||||
const hide = message.loading('正在更新');
|
||||
try {
|
||||
const resp = await updateMobilelog(fields);
|
||||
hide();
|
||||
if (resp.code === 200) {
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
message.error(resp.msg);
|
||||
}
|
||||
return true;
|
||||
} catch (error) {
|
||||
hide();
|
||||
message.error('配置失败请重试!');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除节点
|
||||
*
|
||||
* @param selectedRows
|
||||
*/
|
||||
const handleRemove = async (selectedRows: API.Monitor.Operlog[]) => {
|
||||
const hide = message.loading('正在删除');
|
||||
if (!selectedRows) return true;
|
||||
try {
|
||||
const resp = await removeMobilelog(selectedRows.map((row) => row.operId).join(','));
|
||||
hide();
|
||||
if (resp.code === 200) {
|
||||
message.success('删除成功,即将刷新');
|
||||
} else {
|
||||
message.error(resp.msg);
|
||||
}
|
||||
return true;
|
||||
} catch (error) {
|
||||
hide();
|
||||
message.error('删除失败,请重试');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const MobileLog: React.FC = () => {
|
||||
// ref
|
||||
const formTableRef = useRef<FormInstance>();
|
||||
const access = useAccess();
|
||||
const actionRef = useRef<ActionType>();
|
||||
// status
|
||||
const [params, useParams] = useState({})
|
||||
const [modalVisible, setModalVisible] = useState<boolean>(false);
|
||||
const [currentRow, setCurrentRow] = useState<API.Monitor.Mobilelog>();
|
||||
const [selectedRows, setSelectedRows] = useState<API.Monitor.Mobilelog[]>([]);
|
||||
// 枚举
|
||||
const [businessTypeOptions, setBusinessTypeOptions] = useState<any>([]);
|
||||
const [operatorTypeOptions, setOperatorTypeOptions] = useState<any>([]);
|
||||
const [statusOptions, setStatusOptions] = useState<any>([]);
|
||||
|
||||
// 初始化
|
||||
useEffect(() => {
|
||||
getDictValueEnum('sys_oper_type', true).then((data) => {
|
||||
setBusinessTypeOptions(data);
|
||||
});
|
||||
getDictValueEnum('sys_oper_type', true).then((data) => {
|
||||
setOperatorTypeOptions(data);
|
||||
});
|
||||
getDictValueEnum('sys_common_status', true).then((data) => {
|
||||
setStatusOptions(data);
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
||||
const columns: ProColumns<API.Monitor.Mobilelog>[] = useMemo(() => [
|
||||
{
|
||||
title: '日志主键',
|
||||
dataIndex: 'operId',
|
||||
valueType: 'text',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: "操作模块",
|
||||
dataIndex: 'title',
|
||||
valueType: 'text',
|
||||
},
|
||||
{
|
||||
title: "业务类型",
|
||||
dataIndex: 'businessType',
|
||||
valueType: 'select',
|
||||
valueEnum: businessTypeOptions,
|
||||
render: (_, record) => {
|
||||
return (<DictTag enums={businessTypeOptions} value={record.businessType} />);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "请求方式",
|
||||
dataIndex: 'requestMethod',
|
||||
valueType: 'text',
|
||||
},
|
||||
{
|
||||
title: "操作类别",
|
||||
dataIndex: 'operatorType',
|
||||
valueType: 'select',
|
||||
valueEnum: operatorTypeOptions,
|
||||
render: (_, record) => {
|
||||
return (<DictTag enums={operatorTypeOptions} value={record.operatorType} />);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "操作人员",
|
||||
dataIndex: 'operName',
|
||||
valueType: 'text',
|
||||
},
|
||||
{
|
||||
title: "主机地址",
|
||||
dataIndex: 'operIp',
|
||||
valueType: 'text',
|
||||
},
|
||||
{
|
||||
title: "操作地点",
|
||||
dataIndex: 'operLocation',
|
||||
valueType: 'text',
|
||||
},
|
||||
{
|
||||
title: "操作状态",
|
||||
dataIndex: 'status',
|
||||
valueType: 'select',
|
||||
valueEnum: statusOptions,
|
||||
render: (_, record) => {
|
||||
return (<DictTag key="status" enums={statusOptions} value={record.status} />);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "操作时间",
|
||||
dataIndex: 'operTime',
|
||||
valueType: 'dateTime',
|
||||
},
|
||||
{
|
||||
title: <FormattedMessage id="pages.searchTable.titleOption" defaultMessage="操作" />,
|
||||
dataIndex: 'option',
|
||||
width: '120px',
|
||||
valueType: 'option',
|
||||
render: (_, record) => [
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
key="edit"
|
||||
hidden={!access.hasPerms('system:operlog:edit')}
|
||||
onClick={() => {
|
||||
setModalVisible(true);
|
||||
setCurrentRow(record);
|
||||
}}
|
||||
>
|
||||
详细
|
||||
</Button>,
|
||||
],
|
||||
},
|
||||
], [businessTypeOptions, operatorTypeOptions, statusOptions])
|
||||
|
||||
return <>
|
||||
<PageContainer>
|
||||
<div style={{ width: '100%', float: 'right' }}>
|
||||
<ProTable
|
||||
// params 是需要自带的参数
|
||||
// 这个参数优先级更高,会覆盖查询表单的参数
|
||||
actionRef={actionRef}
|
||||
formRef={formTableRef}
|
||||
rowKey="operId"
|
||||
columns={columns}
|
||||
search={{
|
||||
labelWidth: 120,
|
||||
}}
|
||||
rowSelection={{
|
||||
onChange: (_, selectedRows) => {
|
||||
setSelectedRows(selectedRows);
|
||||
},
|
||||
}}
|
||||
request={(params) =>
|
||||
getMobileLogList({ ...params } as API.Monitor.MobilelogListParams).then((res) => {
|
||||
const result = {
|
||||
data: res.rows,
|
||||
total: res.total,
|
||||
success: true,
|
||||
};
|
||||
return result;
|
||||
})
|
||||
}
|
||||
toolBarRender={() => [
|
||||
// <Button
|
||||
// type="primary"
|
||||
// key="add"
|
||||
// hidden={!access.hasPerms('system:operlog:add')}
|
||||
// onClick={async () => {
|
||||
// setCurrentRow(undefined);
|
||||
// setModalVisible(true);
|
||||
// }}
|
||||
// >
|
||||
// <PlusOutlined /> <FormattedMessage id="pages.searchTable.new" defaultMessage="新建" />
|
||||
// </Button>,
|
||||
<Button
|
||||
type="primary"
|
||||
key="remove"
|
||||
danger
|
||||
hidden={selectedRows?.length === 0 || !access.hasPerms('system:operlog:remove')}
|
||||
onClick={async () => {
|
||||
Modal.confirm({
|
||||
title: '是否确认删除所选数据项?',
|
||||
icon: <ExclamationCircleOutlined />,
|
||||
content: '请谨慎操作',
|
||||
async onOk() {
|
||||
const success = await handleRemove(selectedRows);
|
||||
if (success) {
|
||||
setSelectedRows([]);
|
||||
actionRef.current?.reloadAndRest?.();
|
||||
}
|
||||
},
|
||||
onCancel() { },
|
||||
});
|
||||
}}
|
||||
>
|
||||
<DeleteOutlined />
|
||||
<FormattedMessage id="pages.searchTable.delete" defaultMessage="删除" />
|
||||
</Button>,
|
||||
<Button
|
||||
type="primary"
|
||||
key="export"
|
||||
hidden={!access.hasPerms('system:operlog:export')}
|
||||
onClick={async () => {
|
||||
handleExport();
|
||||
}}
|
||||
>
|
||||
<PlusOutlined />
|
||||
<FormattedMessage id="pages.searchTable.export" defaultMessage="导出" />
|
||||
</Button>,
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
<UpdateForm
|
||||
onSubmit={async (values) => {
|
||||
let success = false;
|
||||
if (values.operId) {
|
||||
success = await handleUpdate({ ...values } as API.Monitor.Mobilelog);
|
||||
} else {
|
||||
success = await handleAdd({ ...values } as API.Monitor.Mobilelog);
|
||||
}
|
||||
if (success) {
|
||||
setModalVisible(false);
|
||||
setCurrentRow(undefined);
|
||||
if (actionRef.current) {
|
||||
actionRef.current.reload();
|
||||
}
|
||||
}
|
||||
}}
|
||||
onCancel={() => {
|
||||
setModalVisible(false);
|
||||
setCurrentRow(undefined);
|
||||
}}
|
||||
open={modalVisible}
|
||||
values={currentRow || {}}
|
||||
businessTypeOptions={businessTypeOptions}
|
||||
operatorTypeOptions={operatorTypeOptions}
|
||||
statusOptions={statusOptions}
|
||||
/>
|
||||
</PageContainer>
|
||||
|
||||
</>
|
||||
};
|
||||
|
||||
export default MobileLog
|
||||
@@ -233,17 +233,17 @@ const OperlogTableList: React.FC = () => {
|
||||
labelWidth: 120,
|
||||
}}
|
||||
toolBarRender={() => [
|
||||
<Button
|
||||
type="primary"
|
||||
key="add"
|
||||
hidden={!access.hasPerms('system:operlog:add')}
|
||||
onClick={async () => {
|
||||
setCurrentRow(undefined);
|
||||
setModalVisible(true);
|
||||
}}
|
||||
>
|
||||
<PlusOutlined /> <FormattedMessage id="pages.searchTable.new" defaultMessage="新建" />
|
||||
</Button>,
|
||||
// <Button
|
||||
// type="primary"
|
||||
// key="add"
|
||||
// hidden={!access.hasPerms('system:operlog:add')}
|
||||
// onClick={async () => {
|
||||
// setCurrentRow(undefined);
|
||||
// setModalVisible(true);
|
||||
// }}
|
||||
// >
|
||||
// <PlusOutlined /> <FormattedMessage id="pages.searchTable.new" defaultMessage="新建" />
|
||||
// </Button>,
|
||||
<Button
|
||||
type="primary"
|
||||
key="remove"
|
||||
|
||||
45
src/services/monitor/mobilelog.ts
Normal file
45
src/services/monitor/mobilelog.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { request } from '@umijs/max';
|
||||
import { downLoadXlsx } from '@/utils/downloadfile';
|
||||
|
||||
// 查询操作日志记录列表
|
||||
export async function getMobileLogList(params?: API.Monitor.MobilelogListParams) {
|
||||
return request<API.Monitor.OperlogPageResult>('/api/cms/operlog/list', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
},
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
// 修改操作日志记录
|
||||
export async function updateMobilelog(params: API.Monitor.Mobilelog) {
|
||||
return request<API.Result>('/api/cms/operlog', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
},
|
||||
data: params
|
||||
});
|
||||
}
|
||||
// 新增操作日志记录
|
||||
export async function addMobilelog(params: API.Monitor.Mobilelog) {
|
||||
return request<API.Result>('/api/cms/operlog', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
},
|
||||
data: params
|
||||
});
|
||||
}
|
||||
|
||||
// 删除操作日志记录
|
||||
export async function removeMobilelog(ids: string) {
|
||||
return request<API.Result>(`/api/cms/operlog/${ids}`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
}
|
||||
|
||||
export function exportMobilelog(params?: API.Monitor.OperlogListParams) {
|
||||
return downLoadXlsx(`/api/cms/operlog/export`, { params }, `operlog_${new Date().getTime()}.xlsx`);
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import { request } from '@umijs/max';
|
||||
|
||||
// 获取服务器信息
|
||||
export async function getServerInfo() {
|
||||
return request('/api/monitor/server', {
|
||||
return request('/api/monitor/service', {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
57
src/types/monitor/mobilelog.d.ts
vendored
Normal file
57
src/types/monitor/mobilelog.d.ts
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
declare namespace API.Monitor {
|
||||
|
||||
export interface Mobilelog {
|
||||
operId: number;
|
||||
title: string;
|
||||
businessType: number;
|
||||
method: string;
|
||||
requestMethod: string;
|
||||
operatorType: number;
|
||||
operName: string;
|
||||
deptName: string;
|
||||
operUrl: string;
|
||||
operIp: string;
|
||||
operLocation: string;
|
||||
operParam: string;
|
||||
jsonResult: string;
|
||||
status: number;
|
||||
errorMsg: string;
|
||||
operTime: Date;
|
||||
}
|
||||
|
||||
export interface MobilelogListParams {
|
||||
operId?: string;
|
||||
title?: string;
|
||||
businessType?: string;
|
||||
method?: string;
|
||||
requestMethod?: string;
|
||||
operatorType?: string;
|
||||
operName?: string;
|
||||
deptName?: string;
|
||||
operUrl?: string;
|
||||
operIp?: string;
|
||||
operLocation?: string;
|
||||
operParam?: string;
|
||||
jsonResult?: string;
|
||||
status?: string;
|
||||
errorMsg?: string;
|
||||
operTime?: string;
|
||||
pageSize?: string;
|
||||
current?: string;
|
||||
}
|
||||
|
||||
export interface MobilelogInfoResult {
|
||||
code: number;
|
||||
msg: string;
|
||||
data: Mobilelog;
|
||||
}
|
||||
|
||||
export interface MobilelogPageResult {
|
||||
code: number;
|
||||
msg: string;
|
||||
total: number;
|
||||
rows: Array<Mobilelog>;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user