BalanceChangeRecordsModal.tsx
2.65 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import EllipsisDiv from '@/components/Div/EllipsisDiv';
import { postCanrdApiUserCenterInfo } from '@/services';
import { ModalForm, ProTable } from '@ant-design/pro-components';
import { Form } from 'antd';
import { BALANCE_CHANGE_COLUMNS } from '../constant';
import '../index.less';
// import { cloneDeep } from 'lodash';
export default ({ setVisible, userInfoObj, onClose }) => {
const [form] = Form.useForm<{ name: string; company: string }>();
const uid = userInfoObj?.uid;
const balanceColumnsInit = () => {
let columns = BALANCE_CHANGE_COLUMNS.map((item) => {
let newItem = { ...item };
let dataIndex = item.dataIndex;
newItem.render = (text, record) => {
let textValue = record[dataIndex];
return <EllipsisDiv text={textValue} />;
};
return newItem;
});
return columns;
};
return (
<div className="prepaid-index">
<ModalForm<{
name: string;
company: string;
}>
width={1000}
open
title="余额变动记录"
form={form}
autoFocusFirstInput
submitter={{
submitButtonProps: {
style: {
display: 'none',
},
},
}}
modalProps={{
okText: '通过',
cancelText: '关闭',
destroyOnClose: true,
onCancel: () => {
setVisible(false);
},
}}
onFinish={async (values) => {
console.log(values);
onClose();
}}
onOpenChange={setVisible}
>
<ProTable
columns={balanceColumnsInit()}
cardBordered
pagination={{
pageSize: 10,
}}
request={async (params) => {
const res = await postCanrdApiUserCenterInfo({
data: { ...params, uid: uid, type: 4 },
});
return {
data: res?.data?.data || [],
total: res?.data?.total || 0,
};
}}
columnsState={{
persistenceKey: 'pro-table-singe-balance',
persistenceType: 'localStorage',
defaultValue: {
option: { fixed: 'right', disable: true },
},
onChange(value) {
console.log('value: ', value);
},
}}
rowKey="id"
search={false}
options={{
setting: {
listsHeight: 400,
},
}}
form={{}}
dateFormatter="string"
headerTitle="余额变动记录"
scroll={{ x: 1400 }}
toolBarRender={() => []}
/>
</ModalForm>
</div>
);
};