index.tsx
8.47 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
import React, { useState } from "react";
import {
Card,
Table,
Button,
Image,
Modal,
Input,
Row,
Col,
Badge,
message,
Popconfirm,
Select,
} from "antd";
import { PageHeaderWrapper } from "@ant-design/pro-layout";
import ProDescriptions from "@ant-design/pro-descriptions";
import usePagination from "@/hooks/usePagination";
import { debounce } from "lodash";
import { MemberRecordListApi, removeMemberRecordApi } from "./api";
import { placeholderImage } from "@/utils";
import moment from "moment";
import copy from "copy-to-clipboard";
import { CopyOutlined } from "@ant-design/icons";
import {
BadgeIcon,
StatusEnum,
useIdentifyInfoListHook,
} from "@/pages/identify/entity";
import FeeweeFilterOption from "@/pages/notice/components/FeeweeFilterOption";
const Column = Table.Column;
const Search = Input.Search;
export default function MemberRecord() {
const { list, loading, paginationConfig, setParams, setLoading } =
usePagination<MemberRecord.ListVO>(MemberRecordListApi, {}, {});
const [currentFile, setCurrentFile] = useState<string[]>([]);
const [filesView, setFilesView] = useState<boolean>(false);
const [extraData, setExtraData] = useState<string>();
const [extraDataVisible, setExtraDataVisible] = useState<boolean>(false);
const { Databases } = useIdentifyInfoListHook();
//按手机号搜索
const searchPhone = debounce((val: string) => {
setParams({ phone: val.trim(), current: 1 }, true);
}, 500);
//按会员名称搜索
const searchMemberId = debounce((val: string) => {
setParams({ memberId: val.trim(), current: 1 }, true);
}, 500);
//按认证码搜索;
const searchCode = debounce((val: string) => {
setParams({ identifyCode: val, current: 1 }, true);
}, 0);
// 删除认证记录
const removeMemberReord = debounce((val: number) => {
removeMemberRecordApi(val)
.then((res) => {
message.success(res.result);
setLoading(true);
})
.catch((e) => {
message.error(e.message);
});
}, 500);
return (
<PageHeaderWrapper title="会员认证记录">
<Card>
<div
style={{
display: "flex",
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
marginBottom: 20,
}}
>
<div style={{ display: "flex" }}>
<FeeweeFilterOption title="手机号">
<Search
allowClear
placeholder="手机号"
onChange={(e) => searchPhone(e.target.value)}
style={{ maxWidth: 260, marginRight: 15 }}
/>
</FeeweeFilterOption>
<div style={{ width: 10 }} />
<FeeweeFilterOption title="会员ID">
<Search
allowClear
placeholder="会员ID"
onChange={(e) => searchMemberId(e.target.value)}
style={{ maxWidth: 260, marginRight: 15 }}
/>
</FeeweeFilterOption>
<div style={{ width: 10 }} />
<FeeweeFilterOption title="资料项">
<Select
allowClear
placeholder="请选择资料项"
showSearch
optionFilterProp="children"
onChange={(identifyCode: string) => searchCode(identifyCode)}
style={{
minWidth: 260,
marginRight: 10,
marginBottom: 10,
}}
getPopupContainer={(triggerNode) => triggerNode.parentNode}
>
{Databases.map((data) => (
<Select.Option key={data.code} value={data.code}>
{data.name}
</Select.Option>
))}
</Select>
</FeeweeFilterOption>
</div>
</div>
<Table
dataSource={list}
pagination={paginationConfig}
rowKey="id"
loading={loading}
>
<Column title="资料代码" dataIndex="identifyCode" align="center" />
<Column
title="资料名称"
dataIndex="identifyName"
align="center"
render={(text) => text || "-"}
/>
<Column title="会员号" dataIndex="memberId" align="center" />
<Column title="会员昵称" dataIndex="memberName" align="center" />
<Column
title="生效时间"
dataIndex="effectiveDate"
align="center"
render={(value) => (value && moment(value).format("YYYY-MM-DD")) || "-"}
/>
<Column
title="过期时间"
dataIndex="expireDate"
align="center"
render={(value) => (value && moment(value).format("YYYY-MM-DD")) || "-"}
/>
<Column
title="额外资料"
dataIndex="extraData"
align="center"
render={(value: string) => (
<Button
type="link"
onClick={() => {
setExtraData(value);
setExtraDataVisible(true);
}}
>
查看
</Button>
)}
/>
<Column
title="附件"
dataIndex="fileList"
align="center"
render={(value: string[]) => (
<Button
type="link"
onClick={() => {
setCurrentFile(value || []);
setFilesView(true);
}}
>
查看
</Button>
)}
/>
<Column
title="状态"
dataIndex="status"
align="center"
render={(status) => {
if (typeof status === "number") {
return (
<Badge
status={BadgeIcon[status + 1]}
text={StatusEnum[status]}
/>
);
}
return "-";
}}
/>
<Column
title="认证时间"
dataIndex="createTime"
align="center"
render={(value) => (value && moment(value).format("YYYY-MM-DD HH:mm:SS")) || "-"}
/>
<Column
title="操作"
align="center"
render={(text, record: Database.ListVO) => (
<Popconfirm
title="是否删除此项?"
onConfirm={() => removeMemberReord(record.id!)}
okText="确定"
cancelText="取消"
>
<a style={{ color: "red" }}>删除</a>
</Popconfirm>
)}
/>
</Table>
</Card>
<Modal
title="资料列表"
visible={filesView}
footer={null}
onCancel={() => {
setFilesView(false);
setCurrentFile([]);
}}
width="50%"
keyboard
destroyOnClose
>
<Card>
<Row gutter={16}>
{currentFile.map((item, index) => (
<Col key={`${item}+${index}`} span={8}>
<Card
hoverable
style={{ width: 220 }}
cover={
<Image
width={220}
placeholder
height={220}
fallback={placeholderImage}
src={`api/file/show?fid=${item}`}
/>
}
>
<Card.Meta title={`图片${index + 1}`} />
</Card>
</Col>
))}
</Row>
</Card>
</Modal>
<Modal
title="额外数据"
visible={extraDataVisible}
footer={null}
destroyOnClose
onCancel={() => {
setExtraDataVisible(false);
setExtraData(undefined);
}}
width={450}
keyboard
>
<ProDescriptions
title="额外数据:"
tooltip="点击旁边复制按钮可复制数据到剪切板"
extra={
<CopyOutlined
onClick={() => extraData && copy(extraData) && message.success("复制成功")}
/>
}
>
<ProDescriptions.Item valueType="jsonCode">
{extraData}
</ProDescriptions.Item>
</ProDescriptions>
</Modal>
</PageHeaderWrapper>
);
}