| | |
| | | |
| | | import React, { useState, useRef, useEffect } from 'react'; |
| | | import { Button, message, Modal } from 'antd'; |
| | | import { Button, message, Modal, Tag } from 'antd'; |
| | | import { |
| | | FooterToolbar, |
| | | PageContainer, |
| | |
| | | import Http from '@/utils/http'; |
| | | import Edit from './components/edit' |
| | | import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch' |
| | | import { repairBug } from '@/utils/common-util'; |
| | | |
| | | const TABLE_KEY = "pro-table-operationRecord"; |
| | | |
| | | const resultMap = { |
| | | 0: { |
| | | color: '#cd201f', |
| | | text: '失败', |
| | | }, |
| | | 1: { |
| | | color: '#3b5999', |
| | | text: '成功', |
| | | }, |
| | | }; |
| | | |
| | | const handleSave = async (val) => { |
| | | const hide = message.loading('正在添加'); |
| | |
| | | width: 48, |
| | | }, |
| | | { |
| | | title: '名称空间', |
| | | title: '接口名', |
| | | dataIndex: 'namespace', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | copyable: true, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='namespace' |
| | |
| | | dataIndex: 'url', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | width: 180, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='url' |
| | | {...props} |
| | |
| | | dataIndex: 'appkey', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='appkey' |
| | | {...props} |
| | |
| | | dataIndex: 'timestamp', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='timestamp' |
| | | {...props} |
| | |
| | | dataIndex: 'clientIp', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='clientIp' |
| | | {...props} |
| | |
| | | dataIndex: 'request', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | ellipsis: true, |
| | | copyable: true, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='request' |
| | | {...props} |
| | |
| | | dataIndex: 'response', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | ellipsis: true, |
| | | copyable: true, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='response' |
| | | {...props} |
| | |
| | | dataIndex: 'spendTime', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='spendTime' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | render: (_, record) => { |
| | | return <span><span style={{ fontWeight: 'bold' }}>{_}</span><span> ms</span></span> |
| | | } |
| | | }, |
| | | { |
| | | title: '异常内容', |
| | | dataIndex: 'err', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='err' |
| | | {...props} |
| | |
| | | dataIndex: 'result$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | width: 100, |
| | | filterDropdown: (props) => <SelectFilter |
| | | name='result' |
| | | {...props} |
| | |
| | | { label: '失败', value: 0 }, |
| | | ]} |
| | | />, |
| | | render: (_, record) => { |
| | | const result = resultMap[record.result] |
| | | return <Tag color={result.color}>{result.text}</Tag> |
| | | }, |
| | | }, |
| | | { |
| | | title: '用户', |
| | | dataIndex: 'userId$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <LinkFilter |
| | | name='userId' |
| | | major='user' |
| | |
| | | dataIndex: 'createTime$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <DatetimeRangeFilter |
| | | name='createTime' |
| | | {...props} |
| | |
| | | dataIndex: 'memo', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='memo' |
| | | {...props} |
| | |
| | | { |
| | | title: '操作', |
| | | dataIndex: 'option', |
| | | width: 140, |
| | | valueType: 'option', |
| | | hidden: true, |
| | | render: (_, record) => [ |
| | | <Button |
| | | type="link" |
| | | key="edit" |
| | | hidden="true" |
| | | onClick={() => { |
| | | setModalVisible(true); |
| | | setCurrentRow(record); |
| | |
| | | type="link" |
| | | danger |
| | | key="batchRemove" |
| | | hidden="true" |
| | | onClick={async () => { |
| | | Modal.confirm({ |
| | | title: '删除', |
| | |
| | | ]; |
| | | |
| | | return ( |
| | | <PageContainer> |
| | | <PageContainer |
| | | header={{ |
| | | breadcrumb: {}, |
| | | }} |
| | | > |
| | | <div style={{ width: '100%', float: 'right' }}> |
| | | <ProTable |
| | | key="operationRecord" |
| | |
| | | cardBordered |
| | | scroll={{ x: 1300 }} |
| | | dateFormatter="string" |
| | | pagination={{ pageSize: 20 }} |
| | | pagination={{ pageSize: 16 }} |
| | | search={false} |
| | | style={{ |
| | | marginBottom: '20px' |
| | | }} |
| | | toolbar={{ |
| | | search: { |
| | | onSearch: (value) => { |
| | |
| | | <Button |
| | | type="primary" |
| | | key="save" |
| | | hidden="true" |
| | | onClick={async () => { |
| | | setModalVisible(true) |
| | | }} |
| | |
| | | } |
| | | }) |
| | | } |
| | | rowSelection={{ |
| | | onChange: (ids, rows) => { |
| | | setSelectedRows(rows); |
| | | } |
| | | }} |
| | | rowSelection={undefined} |
| | | columnsState={{ |
| | | persistenceKey: 'pro-table-operationRecord', |
| | | persistenceKey: TABLE_KEY, |
| | | persistenceType: 'localStorage', |
| | | defaultValue: { |
| | | appkey: { show: repairBug(TABLE_KEY, 'appkey', false) }, |
| | | err: { show: repairBug(TABLE_KEY, 'err', false) }, |
| | | timestamp: { show: repairBug(TABLE_KEY, 'timestamp', false) }, |
| | | memo: { show: repairBug(TABLE_KEY, 'memo', false) }, |
| | | option: { fixed: 'right', disable: true }, |
| | | }, |
| | | onChange(value) { |
| | |
| | | /> |
| | | </div> |
| | | |
| | | {selectedRows?.length > 0 && ( |
| | | {selectedRows?.length > 0 && false && ( |
| | | <FooterToolbar |
| | | extra={ |
| | | <div> |