|
@@ -1,9 +1,10 @@
|
1
|
1
|
import React, { useState, useEffect } from 'react';
|
2
|
2
|
import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, DatePicker } from 'antd';
|
3
|
3
|
import { FormattedMessage } from 'umi-plugin-react/locale';
|
4
|
|
-import styles from '../style/GoodsList.less';
|
5
|
4
|
import router from 'umi/router';
|
6
|
5
|
import moment from 'moment';
|
|
6
|
+import QRCode from 'qrcodejs2'
|
|
7
|
+import styles from '../style/GoodsList.less';
|
7
|
8
|
import SelectCity from '../../components/SelectButton/CitySelect'
|
8
|
9
|
import BuildSelect from '../../components/SelectButton/BuildSelect'
|
9
|
10
|
import apis from '../../services/apis';
|
|
@@ -41,6 +42,38 @@ const toEditGoods = dynamicId => () => {
|
41
|
42
|
});
|
42
|
43
|
}
|
43
|
44
|
|
|
45
|
+ const newQrcode = row => {
|
|
46
|
+ const x = new XMLHttpRequest();
|
|
47
|
+ const resourceUrl = row.qrCode
|
|
48
|
+ x.open('GET', resourceUrl, true);
|
|
49
|
+ x.responseType = 'blob';
|
|
50
|
+ x.onload = function(e) {
|
|
51
|
+ const url = window.URL.createObjectURL(x.response)
|
|
52
|
+ const a = document.createElement('a');
|
|
53
|
+ a.href = url;
|
|
54
|
+ a.style.display = 'none'
|
|
55
|
+ a.download = '活动二维码.png';
|
|
56
|
+ a.click();
|
|
57
|
+ }
|
|
58
|
+ x.send();
|
|
59
|
+ }
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+ function download(data) {
|
|
63
|
+ if (!data) {
|
|
64
|
+ return
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ const url = URL.createObjectURL(data)
|
|
68
|
+ const link = document.createElement('a')
|
|
69
|
+ link.style.display = 'none'
|
|
70
|
+ link.href = url
|
|
71
|
+ link.setAttribute('download', '活动二维码.png')
|
|
72
|
+ document.body.append(link)
|
|
73
|
+ link.click()
|
|
74
|
+ }
|
|
75
|
+
|
|
76
|
+
|
44
|
77
|
/**
|
45
|
78
|
*
|
46
|
79
|
*
|
|
@@ -59,7 +92,7 @@ const toEditGoods = dynamicId => () => {
|
59
|
92
|
dataIndex: 'startDate',
|
60
|
93
|
key: 'startDate',
|
61
|
94
|
align: 'center',
|
62
|
|
- render: (x, row) => <><span>{`${moment(row.startDate).format('YYYY-MM-DD')} —— ${moment(row.endDate).format('YYYY-MM-DD')}`}</span></>
|
|
95
|
+ render: (x, row) => <><span>{`${moment(row.startDate).format('YYYY-MM-DD')} —— ${moment(row.endDate).format('YYYY-MM-DD')}`}</span></>,
|
63
|
96
|
},
|
64
|
97
|
{
|
65
|
98
|
title: '已参加人数',
|
|
@@ -90,7 +123,7 @@ const toEditGoods = dynamicId => () => {
|
90
|
123
|
dataIndex: 'activityStatus',
|
91
|
124
|
key: 'activityStatus',
|
92
|
125
|
align: 'center',
|
93
|
|
- render: activityStatus => <><span>{activityStatus == 0 ? "进行中" : activityStatus == 1 ? '未开始' : '已结束'}</span></>,
|
|
126
|
+ render: activityStatus => <><span>{activityStatus == 0 ? '进行中' : activityStatus == 1 ? '未开始' : '已结束'}</span></>,
|
94
|
127
|
},
|
95
|
128
|
{
|
96
|
129
|
title: '操作',
|
|
@@ -100,20 +133,21 @@ const toEditGoods = dynamicId => () => {
|
100
|
133
|
render: (x, row) => (
|
101
|
134
|
<>
|
102
|
135
|
<AuthButton name="admin.SignList.get" noRight={null}>
|
103
|
|
- <span style={{ color: '#1990FF', cursor: 'pointer'}} onClick={getSignList.bind(this, row.dynamicId)}>{row.isEnlist == '1' || row.isEnlist == '2' ? "报名记录" : ""}<Icon type="snippets" className={styles.shoppingCart} /></span>
|
|
136
|
+ <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={getSignList.bind(this, row.dynamicId)}>{row.isEnlist == '1' || row.isEnlist == '2' ? '报名记录' : ''}<Icon type="snippets" className={styles.shoppingCart} /></span>
|
104
|
137
|
</AuthButton>
|
105
|
138
|
<AuthButton name="admin.buildingDynamic.send.dynamicId.put" noRight={null}>
|
106
|
|
- <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={sendOrPublicDynamic.bind(this,row)}>{ row.status === 1 ? '取消发布' : '发布' }<Icon type="close-circle" className={styles.edit} /></span>
|
|
139
|
+ <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={sendOrPublicDynamic.bind(this, row)}>{ row.status === 1 ? '取消发布' : '发布' }<Icon type="close-circle" className={styles.edit} /></span>
|
107
|
140
|
</AuthButton>
|
108
|
141
|
<AuthButton name="admin.buildingDynamic.finish.put" noRight={null}>
|
109
|
|
- {row.isEnlist == 1 && <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={finishDynamic.bind(this,row)}>结束活动<Icon type="poweroff" className={styles.edit} /></span>}
|
|
142
|
+ {row.isEnlist == 1 && <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={finishDynamic.bind(this, row)}>结束活动<Icon type="poweroff" className={styles.edit} /></span>}
|
110
|
143
|
</AuthButton>
|
111
|
144
|
<AuthButton name="admin.buildingDynamic.update.put" noRight={null}>
|
112
|
145
|
<span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={topDynamic(row)}>{ row.weight === 1 ? '取消置顶' : '置顶' }<Icon type="vertical-align-top" className={styles.edit} /></span>
|
113
|
146
|
{row.isEnlist != 2 && <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={toEditGoods(row.dynamicId)}>编辑<Icon type="form" className={styles.edit} /></span>}
|
114
|
147
|
</AuthButton>
|
|
148
|
+ <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={newQrcode.bind(this, row)}>下载二维码<Icon type="qrcode" className={styles.shoppingCart} /></span>
|
115
|
149
|
</>
|
116
|
|
- )
|
|
150
|
+ ),
|
117
|
151
|
},
|
118
|
152
|
];
|
119
|
153
|
|
|
@@ -132,7 +166,7 @@ const toEditGoods = dynamicId => () => {
|
132
|
166
|
okText: '确定',
|
133
|
167
|
cancelText: '取消',
|
134
|
168
|
onOk() {
|
135
|
|
- request({ ...apis.activity.finish, data: {dynamicId: row.dynamicId, top: "" } }).then(data => {
|
|
169
|
+ request({ ...apis.activity.finish, data: { dynamicId: row.dynamicId, top: '' } }).then(data => {
|
136
|
170
|
console.log(data)
|
137
|
171
|
message.info('操作成功!')
|
138
|
172
|
getList({ pageNum: 1, pageSize: 10 })
|
|
@@ -147,7 +181,7 @@ const toEditGoods = dynamicId => () => {
|
147
|
181
|
// 置顶
|
148
|
182
|
const topDynamic = row => () => {
|
149
|
183
|
const weight = Math.abs(row.weight - 1)
|
150
|
|
- request({ ...apis.activity.weight, params: {dynamicId: row.dynamicId, weight} }).then(data => {
|
|
184
|
+ request({ ...apis.activity.weight, params: { dynamicId: row.dynamicId, weight } }).then(data => {
|
151
|
185
|
console.log(data)
|
152
|
186
|
message.info('操作成功!')
|
153
|
187
|
getList({ pageNum: 1, pageSize: 10 })
|
|
@@ -156,7 +190,7 @@ const toEditGoods = dynamicId => () => {
|
156
|
190
|
message.info(err.msg || err.message)
|
157
|
191
|
})
|
158
|
192
|
}
|
159
|
|
-
|
|
193
|
+
|
160
|
194
|
const sendOrPublicDynamic = row => {
|
161
|
195
|
if (row.status === 1) {
|
162
|
196
|
cancelDynamic(row)
|
|
@@ -164,29 +198,29 @@ const toEditGoods = dynamicId => () => {
|
164
|
198
|
sendDynamic(row)
|
165
|
199
|
}
|
166
|
200
|
}
|
167
|
|
-
|
|
201
|
+
|
168
|
202
|
// 取消活动
|
169
|
203
|
const cancelDynamic = row => {
|
170
|
|
- request({ ...apis.activity.cancel, urlData: {id: row.dynamicId}}).then((data) => {
|
|
204
|
+ request({ ...apis.activity.cancel, urlData: { id: row.dynamicId } }).then(data => {
|
171
|
205
|
message.info('操作成功!')
|
172
|
206
|
getList({ pageNum: 1, pageSize: 10 })
|
173
|
|
- }).catch((err) => {
|
|
207
|
+ }).catch(err => {
|
174
|
208
|
console.log(err)
|
175
|
209
|
message.info(err.msg || err.message)
|
176
|
210
|
})
|
177
|
211
|
}
|
178
|
|
-
|
179
|
|
- //发布活动
|
|
212
|
+
|
|
213
|
+ // 发布活动
|
180
|
214
|
const sendDynamic = row => {
|
181
|
|
- request({ ...apis.activity.send, urlData: {id: row.dynamicId}}).then((data) => {
|
|
215
|
+ request({ ...apis.activity.send, urlData: { id: row.dynamicId } }).then(data => {
|
182
|
216
|
message.info('操作成功!')
|
183
|
217
|
getList({ pageNum: 1, pageSize: 10 });
|
184
|
|
- }).catch((err) => {
|
|
218
|
+ }).catch(err => {
|
185
|
219
|
console.log(err)
|
186
|
220
|
message.info(err.msg || err.message)
|
187
|
221
|
})
|
188
|
222
|
}
|
189
|
|
-
|
|
223
|
+
|
190
|
224
|
const changePageNum = pageNumber => {
|
191
|
225
|
getList({ pageNum: pageNumber, pageSize: 10 })
|
192
|
226
|
}
|
|
@@ -202,7 +236,7 @@ const handleSubmit = (e, props) => {
|
202
|
236
|
});
|
203
|
237
|
}
|
204
|
238
|
|
205
|
|
- //重置搜索
|
|
239
|
+ // 重置搜索
|
206
|
240
|
function handleReset() {
|
207
|
241
|
props.form.resetFields();
|
208
|
242
|
}
|
|
@@ -212,6 +246,8 @@ const handleSubmit = (e, props) => {
|
212
|
246
|
return (
|
213
|
247
|
|
214
|
248
|
<>
|
|
249
|
+ {/* style={{ display: 'none' }} */}
|
|
250
|
+ <div id="qrcode"></div>
|
215
|
251
|
<Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
|
216
|
252
|
<Form.Item>
|
217
|
253
|
{getFieldDecorator('cityId')(
|
|
@@ -233,7 +269,7 @@ const handleSubmit = (e, props) => {
|
233
|
269
|
</Form.Item>
|
234
|
270
|
<Form.Item>
|
235
|
271
|
{getFieldDecorator('time')(
|
236
|
|
- <DatePicker />
|
|
272
|
+ <DatePicker />,
|
237
|
273
|
)}
|
238
|
274
|
</Form.Item>
|
239
|
275
|
<Form.Item>
|
|
@@ -258,7 +294,7 @@ const handleSubmit = (e, props) => {
|
258
|
294
|
</AuthButton>
|
259
|
295
|
<Table dataSource={data.list} columns={columns} pagination={false} rowKey="activityList"/>
|
260
|
296
|
<div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
261
|
|
- <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={(e) => changePageNum(e)} />
|
|
297
|
+ <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={e => changePageNum(e)} />
|
262
|
298
|
</div>
|
263
|
299
|
</>
|
264
|
300
|
)
|