86133 | aaa3f5d | 2025-04-20 21:33:29 +0800 | [diff] [blame^] | 1 | import React from 'react'; |
| 2 | import { Descriptions, Modal } from 'antd'; |
| 3 | import { useIntl, FormattedMessage } from '@umijs/max'; |
| 4 | import { DictValueEnumObj } from '@/components/DictTag'; |
| 5 | import { getValueEnumLabel } from '@/utils/options'; |
| 6 | |
| 7 | export type OperlogFormData = Record<string, unknown> & Partial<API.Monitor.Operlog>; |
| 8 | |
| 9 | export type OperlogFormProps = { |
| 10 | onCancel: (flag?: boolean, formVals?: OperlogFormData) => void; |
| 11 | onSubmit: (values: OperlogFormData) => Promise<void>; |
| 12 | open: boolean; |
| 13 | values: Partial<API.Monitor.Operlog>; |
| 14 | businessTypeOptions: DictValueEnumObj; |
| 15 | operatorTypeOptions: DictValueEnumObj; |
| 16 | statusOptions: DictValueEnumObj; |
| 17 | }; |
| 18 | |
| 19 | const OperlogDetailForm: React.FC<OperlogFormProps> = (props) => { |
| 20 | |
| 21 | const { values, businessTypeOptions, operatorTypeOptions, statusOptions, } = props; |
| 22 | |
| 23 | const intl = useIntl(); |
| 24 | const handleOk = () => {}; |
| 25 | const handleCancel = () => { |
| 26 | props.onCancel(); |
| 27 | }; |
| 28 | |
| 29 | return ( |
| 30 | <Modal |
| 31 | width={640} |
| 32 | title={intl.formatMessage({ |
| 33 | id: 'monitor.operlog.title', |
| 34 | defaultMessage: '编辑操作日志记录', |
| 35 | })} |
| 36 | open={props.open} |
| 37 | destroyOnClose |
| 38 | onOk={handleOk} |
| 39 | onCancel={handleCancel} |
| 40 | > |
| 41 | <Descriptions column={24}> |
| 42 | <Descriptions.Item |
| 43 | span={12} |
| 44 | label={<FormattedMessage id="monitor.operlog.module" defaultMessage="操作模块" />} |
| 45 | > |
| 46 | {`${values.title}/${getValueEnumLabel(businessTypeOptions, values.businessType)}`} |
| 47 | </Descriptions.Item> |
| 48 | <Descriptions.Item |
| 49 | span={12} |
| 50 | label={<FormattedMessage id="monitor.operlog.request_method" defaultMessage="请求方式" />} |
| 51 | > |
| 52 | {values.requestMethod} |
| 53 | </Descriptions.Item> |
| 54 | <Descriptions.Item |
| 55 | span={12} |
| 56 | label={<FormattedMessage id="monitor.operlog.oper_name" defaultMessage="操作人员" />} |
| 57 | > |
| 58 | {`${values.operName}/${values.operIp}`} |
| 59 | </Descriptions.Item> |
| 60 | <Descriptions.Item |
| 61 | span={12} |
| 62 | label={<FormattedMessage id="monitor.operlog.operator_type" defaultMessage="操作类别" />} |
| 63 | > |
| 64 | {getValueEnumLabel(operatorTypeOptions, values.operatorType)} |
| 65 | </Descriptions.Item> |
| 66 | <Descriptions.Item |
| 67 | span={24} |
| 68 | label={<FormattedMessage id="monitor.operlog.method" defaultMessage="方法名称" />} |
| 69 | > |
| 70 | {values.method} |
| 71 | </Descriptions.Item> |
| 72 | <Descriptions.Item |
| 73 | span={24} |
| 74 | label={<FormattedMessage id="monitor.operlog.oper_url" defaultMessage="请求URL" />} |
| 75 | > |
| 76 | {values.operUrl} |
| 77 | </Descriptions.Item> |
| 78 | <Descriptions.Item |
| 79 | span={24} |
| 80 | label={<FormattedMessage id="monitor.operlog.oper_param" defaultMessage="请求参数" />} |
| 81 | > |
| 82 | {values.operParam} |
| 83 | </Descriptions.Item> |
| 84 | <Descriptions.Item |
| 85 | span={24} |
| 86 | label={<FormattedMessage id="monitor.operlog.json_result" defaultMessage="返回参数" />} |
| 87 | > |
| 88 | {values.jsonResult} |
| 89 | </Descriptions.Item> |
| 90 | <Descriptions.Item |
| 91 | span={24} |
| 92 | label={<FormattedMessage id="monitor.operlog.error_msg" defaultMessage="错误消息" />} |
| 93 | > |
| 94 | {values.errorMsg} |
| 95 | </Descriptions.Item> |
| 96 | <Descriptions.Item |
| 97 | span={12} |
| 98 | label={<FormattedMessage id="monitor.operlog.status" defaultMessage="操作状态" />} |
| 99 | > |
| 100 | {getValueEnumLabel(statusOptions, values.status)} |
| 101 | </Descriptions.Item> |
| 102 | <Descriptions.Item |
| 103 | span={12} |
| 104 | label={<FormattedMessage id="monitor.operlog.oper_time" defaultMessage="操作时间" />} |
| 105 | > |
| 106 | {values.operTime?.toString()} |
| 107 | </Descriptions.Item> |
| 108 | </Descriptions> |
| 109 | </Modal> |
| 110 | ); |
| 111 | }; |
| 112 | |
| 113 | export default OperlogDetailForm; |