From ac4341ea6b66ae02427d39d35f41d42d78b2eb2e Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 14 二月 2025 10:08:32 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/pages/system/operationRecord/index.jsx | 235 +++++++++++++++-------------------------------------------
1 files changed, 61 insertions(+), 174 deletions(-)
diff --git a/zy-asrs-flow/src/pages/system/operationRecord/index.jsx b/zy-asrs-flow/src/pages/system/operationRecord/index.jsx
index f5c235c..a4ce3f8 100644
--- a/zy-asrs-flow/src/pages/system/operationRecord/index.jsx
+++ b/zy-asrs-flow/src/pages/system/operationRecord/index.jsx
@@ -1,85 +1,42 @@
import React, { useState, useRef, useEffect } from 'react';
-import { Button, message, Modal } from 'antd';
+import { Button, message, Modal, Tag } from 'antd';
import {
FooterToolbar,
PageContainer,
ProTable,
LightFilter,
} from '@ant-design/pro-components';
+import { FormattedMessage, useIntl } from '@umijs/max';
import { PlusOutlined, ExportOutlined } from '@ant-design/icons';
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 handleSave = async (val) => {
- const hide = message.loading('姝e湪娣诲姞');
- try {
- const resp = await Http.doPost('api/operationRecord/save', val);
- if (resp.code === 200) {
- message.success('娣诲姞鎴愬姛');
- return true;
- } else {
- message.error(resp.msg);
- return false;
- }
- } catch (error) {
- message.error('娣诲姞澶辫触璇烽噸璇曪紒');
- return false;
- } finally {
- hide();
- }
+const TABLE_KEY = "pro-table-operationRecord";
+
+const resultMap = {
+ 0: {
+ color: '#cd201f',
+ text: '澶辫触',
+ },
+ 1: {
+ color: '#3b5999',
+ text: '鎴愬姛',
+ },
};
-const handleUpdate = async (val) => {
- const hide = message.loading('姝e湪鏇存柊');
- try {
- const resp = await Http.doPost('api/operationRecord/update', val);
- if (resp.code === 200) {
- message.success('鏇存柊鎴愬姛');
- return true;
- } else {
- message.error(resp.msg);
- return false;
- }
- } catch (error) {
- message.error('閰嶇疆澶辫触璇烽噸璇曪紒');
- return false;
- } finally {
- hide();
- }
-};
-
-const handleRemove = async (rows) => {
- if (!rows) return true;
- const hide = message.loading('姝e湪鍒犻櫎');
- try {
- const resp = await Http.doPost('api/operationRecord/remove/' + rows.map((row) => row.id).join(','));
- if (resp.code === 200) {
- message.success('鍒犻櫎鎴愬姛');
- return true;
- } else {
- message.error(resp.msg);
- return false;
- }
- } catch (error) {
- message.error('鍒犻櫎澶辫触锛岃閲嶈瘯');
- return false;
- } finally {
- hide();
- }
-};
-
-const handleExport = async () => {
- const hide = message.loading('姝e湪瀵煎嚭');
+const handleExport = async (intl) => {
+ const hide = message.loading(intl.formatMessage({ id: 'page.exporting', defaultMessage: '姝e湪瀵煎嚭' }));
try {
const resp = await Http.doPostBlob('api/operationRecord/export');
const blob = new Blob([resp], { type: 'application/vnd.ms-excel' });
window.location.href = window.URL.createObjectURL(blob);
- message.success('瀵煎嚭鎴愬姛');
+ message.success(intl.formatMessage({ id: 'page.export.success', defaultMessage: '瀵煎嚭鎴愬姛' }));
return true;
} catch (error) {
- message.error('瀵煎嚭澶辫触锛岃閲嶈瘯');
+ message.error(intl.formatMessage({ id: 'page.export.fail', defaultMessage: '瀵煎嚭澶辫触锛岃閲嶈瘯' }));
return false;
} finally {
hide();
@@ -88,6 +45,7 @@
const Main = () => {
+ const intl = useIntl();
const formTableRef = useRef();
const actionRef = useRef();
const [selectedRows, setSelectedRows] = useState([]);
@@ -101,17 +59,19 @@
const columns = [
{
- title: 'No',
+ title: intl.formatMessage({
+ id: 'page.table.no',
+ defaultMessage: 'No'
+ }),
dataIndex: 'index',
valueType: 'indexBorder',
width: 48,
},
{
- title: '鍚嶇О绌洪棿',
+ title: '鎺ュ彛鍚�',
dataIndex: 'namespace',
valueType: 'text',
hidden: false,
- width: 140,
copyable: true,
filterDropdown: (props) => <TextFilter
name='namespace'
@@ -125,7 +85,7 @@
dataIndex: 'url',
valueType: 'text',
hidden: false,
- width: 140,
+ width: 180,
filterDropdown: (props) => <TextFilter
name='url'
{...props}
@@ -138,7 +98,6 @@
dataIndex: 'appkey',
valueType: 'text',
hidden: false,
- width: 140,
filterDropdown: (props) => <TextFilter
name='appkey'
{...props}
@@ -151,7 +110,6 @@
dataIndex: 'timestamp',
valueType: 'text',
hidden: false,
- width: 140,
filterDropdown: (props) => <TextFilter
name='timestamp'
{...props}
@@ -164,7 +122,6 @@
dataIndex: 'clientIp',
valueType: 'text',
hidden: false,
- width: 140,
filterDropdown: (props) => <TextFilter
name='clientIp'
{...props}
@@ -175,9 +132,10 @@
{
title: '璇锋眰鍐呭',
dataIndex: 'request',
- valueType: 'code',
+ valueType: 'text',
hidden: false,
- width: 140,
+ ellipsis: true,
+ copyable: true,
filterDropdown: (props) => <TextFilter
name='request'
{...props}
@@ -188,9 +146,10 @@
{
title: '鍝嶅簲鍐呭',
dataIndex: 'response',
- valueType: 'code',
+ valueType: 'text',
hidden: false,
- width: 140,
+ ellipsis: true,
+ copyable: true,
filterDropdown: (props) => <TextFilter
name='response'
{...props}
@@ -203,20 +162,21 @@
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}
@@ -229,7 +189,7 @@
dataIndex: 'result$',
valueType: 'text',
hidden: false,
- width: 140,
+ width: 100,
filterDropdown: (props) => <SelectFilter
name='result'
{...props}
@@ -240,13 +200,16 @@
{ 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'
@@ -260,7 +223,6 @@
dataIndex: 'createTime$',
valueType: 'text',
hidden: false,
- width: 140,
filterDropdown: (props) => <DatetimeRangeFilter
name='createTime'
{...props}
@@ -273,7 +235,6 @@
dataIndex: 'memo',
valueType: 'text',
hidden: false,
- width: 140,
filterDropdown: (props) => <TextFilter
name='memo'
{...props}
@@ -285,46 +246,19 @@
{
title: '鎿嶄綔',
dataIndex: 'option',
- width: 140,
valueType: 'option',
+ hidden: true,
render: (_, record) => [
- <Button
- type="link"
- key="edit"
- onClick={() => {
- setModalVisible(true);
- setCurrentRow(record);
- }}
- >
- 缂栬緫
- </Button>,
- <Button
- type="link"
- danger
- key="batchRemove"
- onClick={async () => {
- Modal.confirm({
- title: '鍒犻櫎',
- content: '纭畾鍒犻櫎璇ラ」鍚楋紵',
- onOk: async () => {
- const success = await handleRemove([record]);
- if (success) {
- if (actionRef.current) {
- actionRef.current.reload();
- }
- }
- },
- });
- }}
- >
- 鍒犻櫎
- </Button>,
],
},
];
return (
- <PageContainer>
+ <PageContainer
+ header={{
+ breadcrumb: {},
+ }}
+ >
<div style={{ width: '100%', float: 'right' }}>
<ProTable
key="operationRecord"
@@ -335,8 +269,11 @@
cardBordered
scroll={{ x: 1300 }}
dateFormatter="string"
- pagination={{ pageSize: 20 }}
+ pagination={{ pageSize: 16 }}
search={false}
+ style={{
+ marginBottom: '20px'
+ }}
toolbar={{
search: {
onSearch: (value) => {
@@ -356,23 +293,13 @@
),
actions: [
<Button
- type="primary"
- key="save"
- onClick={async () => {
- setModalVisible(true)
- }}
- >
- <PlusOutlined />
- 娣诲姞
- </Button>,
- <Button
key="export"
onClick={async () => {
- handleExport();
+ handleExport(intl);
}}
>
<ExportOutlined />
- 瀵煎嚭
+ <FormattedMessage id='page.export' defaultMessage='瀵煎嚭' />
</Button>,
],
}}
@@ -385,15 +312,15 @@
}
})
}
- 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) {
@@ -401,38 +328,6 @@
}}
/>
</div>
-
- {selectedRows?.length > 0 && (
- <FooterToolbar
- extra={
- <div>
- 宸查�夋嫨
- <a style={{ fontWeight: 600 }}>{selectedRows.length}</a>
- 椤�
- </div>
- }
- >
- <Button
- key="remove"
- danger
- onClick={async () => {
- Modal.confirm({
- title: '鍒犻櫎',
- content: '纭畾鍒犻櫎璇ラ」鍚楋紵',
- onOk: async () => {
- const success = await handleRemove(selectedRows);
- if (success) {
- setSelectedRows([]);
- actionRef.current?.reloadAndRest?.();
- }
- },
- });
- }}
- >
- 鎵归噺鍒犻櫎
- </Button>
- </FooterToolbar>
- )}
<Edit
open={modalVisible}
@@ -444,18 +339,10 @@
}
}
onSubmit={async (values) => {
- let ok = false;
- if (values.id) {
- ok = await handleUpdate({ ...values })
- } else {
- ok = await handleSave({ ...values })
- }
- if (ok) {
- setModalVisible(false);
- setCurrentRow(undefined);
- if (actionRef.current) {
- actionRef.current.reload();
- }
+ setModalVisible(false);
+ setCurrentRow(undefined);
+ if (actionRef.current) {
+ actionRef.current.reload();
}
}
}
--
Gitblit v1.9.1