|
@@ -1,11 +1,10 @@
|
1
|
1
|
import React, { useState, useEffect } from 'react';
|
2
|
|
-import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, DatePicker, notification } from 'antd';
|
|
2
|
+import { Form, Input, Button, Icon, message, Table, Pagination, Modal } from 'antd';
|
3
|
3
|
import router from 'umi/router';
|
4
|
4
|
import moment from 'moment';
|
5
|
5
|
import AuthButton from '@/components/AuthButton';
|
6
|
6
|
import withActions from '@/components/ActionList';
|
7
|
7
|
import EditIcon from '@/components/EditIcon';
|
8
|
|
-import Navigate from '@/components/Navigate';
|
9
|
8
|
import QrcodeType from '@/components/SelectButton/QrcodeType'
|
10
|
9
|
import { ConfirmButton } from '@/components/ModalButton';
|
11
|
10
|
import BuildSelect from '@/components/SelectButton/BuildSelect'
|
|
@@ -14,6 +13,7 @@ import apis from '../../../services/apis';
|
14
|
13
|
import request from '../../../utils/request';
|
15
|
14
|
|
16
|
15
|
// import RaiseHelpDoc from '../edit/components/RaiseHelpDoc';
|
|
16
|
+// eslint-disable-next-line consistent-return
|
17
|
17
|
const typeName = targetType => {
|
18
|
18
|
// eslint-disable-next-line default-case
|
19
|
19
|
switch (targetType) {
|
|
@@ -36,6 +36,8 @@ const qrcodelist = props => {
|
36
|
36
|
|
37
|
37
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
38
|
38
|
useEffect(() => {
|
|
39
|
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
40
|
+ // eslint-disable-next-line no-use-before-define
|
39
|
41
|
getList({ pageNum: 1, pageSize: 10 });
|
40
|
42
|
}, [])
|
41
|
43
|
|
|
@@ -48,11 +50,11 @@ const qrcodelist = props => {
|
48
|
50
|
}
|
49
|
51
|
|
50
|
52
|
const batchDelete = () => {
|
51
|
|
- request({ ...apis.qrcode.batchDelete, data: qrcodeList }).then(data => {
|
|
53
|
+ request({ ...apis.qrcode.batchDelete, data: qrcodeList }).then(() => {
|
52
|
54
|
message.info('操作成功')
|
53
|
55
|
setBeforeCheck('请至少选择一条数据')
|
54
|
56
|
getList({ pageNum: 1, pageSize: 10 });
|
55
|
|
- }).catch((err) => {
|
|
57
|
+ }).catch(() => {
|
56
|
58
|
// message.info(err.msg)
|
57
|
59
|
})
|
58
|
60
|
}
|
|
@@ -64,14 +66,33 @@ const qrcodelist = props => {
|
64
|
66
|
});
|
65
|
67
|
}
|
66
|
68
|
|
67
|
|
- const toDataRecord = (id) => {
|
|
69
|
+ const toDataRecord = id => {
|
|
70
|
+ // eslint-disable-next-line no-console
|
68
|
71
|
console.log(id)
|
69
|
72
|
router.push({
|
70
|
73
|
pathname: '/qrcode/qrcodelist/dataRecord',
|
71
|
|
- query: { id, }
|
|
74
|
+ query: { id },
|
72
|
75
|
});
|
73
|
76
|
}
|
74
|
77
|
|
|
78
|
+ const downloadQrcode = row => {
|
|
79
|
+ const x = new XMLHttpRequest();
|
|
80
|
+ const resourceUrl = row.qrCodeUrl
|
|
81
|
+ // const name = `${row.targetName}二维码.png`
|
|
82
|
+ console.log(resourceUrl);
|
|
83
|
+ x.open('GET', resourceUrl, true);
|
|
84
|
+ x.responseType = 'blob';
|
|
85
|
+ x.onload = function (e) {
|
|
86
|
+ const url = window.URL.createObjectURL(x.response)
|
|
87
|
+ const a = document.createElement('a');
|
|
88
|
+ a.href = url;
|
|
89
|
+ a.style.display = 'none'
|
|
90
|
+ a.download = `${row.targetName}二维码.png`
|
|
91
|
+ a.click();
|
|
92
|
+ }
|
|
93
|
+ x.send();
|
|
94
|
+ }
|
|
95
|
+
|
75
|
96
|
/**
|
76
|
97
|
*
|
77
|
98
|
*
|
|
@@ -126,10 +147,14 @@ const qrcodelist = props => {
|
126
|
147
|
dataIndex: '',
|
127
|
148
|
key: '',
|
128
|
149
|
align: 'center',
|
129
|
|
- render: withActions((text, record) => [
|
130
|
|
- <EditIcon type="download" text="下载二维码" ></EditIcon>,
|
131
|
|
-
|
132
|
|
- <EditIcon type="data" text="数据" onClick={() => toDataRecord(record.qrCodeId)} ></EditIcon>,
|
|
150
|
+ render: withActions((text, row) => [
|
|
151
|
+ <AuthButton name="admin.qrcode.download" noRight={null}>
|
|
152
|
+ <EditIcon type="download" text="下载二维码" onClick={() => downloadQrcode(row)}> </EditIcon>
|
|
153
|
+ </AuthButton>,
|
|
154
|
+ <AuthButton name="admin.qrcode.dataRecord" noRight={null}>
|
|
155
|
+ <EditIcon type="data" text="数据" onClick={() => toDataRecord(row.qrCodeId)} ></EditIcon>
|
|
156
|
+ </AuthButton>,
|
|
157
|
+
|
133
|
158
|
|
134
|
159
|
]),
|
135
|
160
|
},
|
|
@@ -141,7 +166,6 @@ const qrcodelist = props => {
|
141
|
166
|
}
|
142
|
167
|
|
143
|
168
|
|
144
|
|
-
|
145
|
169
|
const rowSelection = {
|
146
|
170
|
onChange: (selectedRowKeys, selectedRows) => {
|
147
|
171
|
console.log('selectedRowKeys:', selectedRowKeys, 'selectedRows: ', selectedRows);
|
|
@@ -205,10 +229,15 @@ const qrcodelist = props => {
|
205
|
229
|
</Form.Item>
|
206
|
230
|
</Form>
|
207
|
231
|
{/* title="确认删除?" */}
|
208
|
|
- <Button type="danger" onClick={() => toAdd()}>新增</Button>
|
209
|
|
- <ConfirmButton type="link" title="确认删除选中数据?" beforeCheck={beforeCheck} onClick={() => batchDelete()}>
|
210
|
|
- <Button type="primary" style={{ marginLeft: '30px' }}>删除</Button>
|
211
|
|
- </ConfirmButton>
|
|
232
|
+
|
|
233
|
+ <AuthButton name="admin.qrcode.add" noRight={null}>
|
|
234
|
+ <Button type="danger" onClick={() => toAdd()}>新增</Button>
|
|
235
|
+ </AuthButton>
|
|
236
|
+ <AuthButton name="admin.qrcode.delete" noRight={null}>
|
|
237
|
+ <ConfirmButton type="link" title="确认删除选中数据?" beforeCheck={beforeCheck} onClick={() => batchDelete()}>
|
|
238
|
+ <Button type="primary" style={{ marginLeft: '30px' }}>删除</Button>
|
|
239
|
+ </ConfirmButton>
|
|
240
|
+ </AuthButton>
|
212
|
241
|
<Icon type="question-circle" theme="filled" style={{ fontSize: '25px', color: '#F00', marginLeft: '30px' }} onClick={() => setShowHelp(true)} />
|
213
|
242
|
<Modal
|
214
|
243
|
title="相关说明"
|
|
@@ -228,7 +257,10 @@ const qrcodelist = props => {
|
228
|
257
|
<Table rowSelection={rowSelection}
|
229
|
258
|
dataSource={data.records} columns={columns} pagination={false} rowKey={r => r.qrCodeId} style={{ marginTop: '20px' }} />
|
230
|
259
|
<div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
231
|
|
- <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={e => changePageNum(e)} current={data.current} />
|
|
260
|
+ <Pagination
|
|
261
|
+ showQuickJumper
|
|
262
|
+ defaultCurrent={1}
|
|
263
|
+ total={data.total} onChange={e => changePageNum(e)} current={data.current} />
|
232
|
264
|
</div>
|
233
|
265
|
</>
|
234
|
266
|
)
|