|
@@ -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,28 @@ const toEditGoods = dynamicId => () => {
|
41
|
42
|
});
|
42
|
43
|
}
|
43
|
44
|
|
|
45
|
+ const newQrcode = row => {
|
|
46
|
+ const qr = new QRCode('qrcode', {
|
|
47
|
+ text: row.dynamicId,
|
|
48
|
+ width: 128,
|
|
49
|
+ height: 128,
|
|
50
|
+ });
|
|
51
|
+ }
|
|
52
|
+
|
|
53
|
+ function download () {
|
|
54
|
+ const qrcode = document.getElementById('qrcode');
|
|
55
|
+ const imgs = qrcode.getElementsByTagName('img')
|
|
56
|
+ const img = imgs[imgs.length - 1]
|
|
57
|
+ console.log(img)
|
|
58
|
+ const link = document.createElement('a');
|
|
59
|
+ link.style.display = 'none'
|
|
60
|
+ const url = img.getAttribute('src');
|
|
61
|
+ console.log(img.getAttribute('src'))
|
|
62
|
+ link.setAttribute('href', url);
|
|
63
|
+ link.setAttribute('download', '活动二维码.png');
|
|
64
|
+ link.click();
|
|
65
|
+ }
|
|
66
|
+
|
44
|
67
|
/**
|
45
|
68
|
*
|
46
|
69
|
*
|
|
@@ -59,7 +82,7 @@ const toEditGoods = dynamicId => () => {
|
59
|
82
|
dataIndex: 'startDate',
|
60
|
83
|
key: 'startDate',
|
61
|
84
|
align: 'center',
|
62
|
|
- render: (x, row) => <><span>{`${moment(row.startDate).format('YYYY-MM-DD')} —— ${moment(row.endDate).format('YYYY-MM-DD')}`}</span></>
|
|
85
|
+ render: (x, row) => <><span>{`${moment(row.startDate).format('YYYY-MM-DD')} —— ${moment(row.endDate).format('YYYY-MM-DD')}`}</span></>,
|
63
|
86
|
},
|
64
|
87
|
{
|
65
|
88
|
title: '已参加人数',
|
|
@@ -90,7 +113,7 @@ const toEditGoods = dynamicId => () => {
|
90
|
113
|
dataIndex: 'activityStatus',
|
91
|
114
|
key: 'activityStatus',
|
92
|
115
|
align: 'center',
|
93
|
|
- render: activityStatus => <><span>{activityStatus == 0 ? "进行中" : activityStatus == 1 ? '未开始' : '已结束'}</span></>,
|
|
116
|
+ render: activityStatus => <><span>{activityStatus == 0 ? '进行中' : activityStatus == 1 ? '未开始' : '已结束'}</span></>,
|
94
|
117
|
},
|
95
|
118
|
{
|
96
|
119
|
title: '操作',
|
|
@@ -100,20 +123,21 @@ const toEditGoods = dynamicId => () => {
|
100
|
123
|
render: (x, row) => (
|
101
|
124
|
<>
|
102
|
125
|
<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>
|
|
126
|
+ <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
|
127
|
</AuthButton>
|
105
|
128
|
<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>
|
|
129
|
+ <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={sendOrPublicDynamic.bind(this, row)}>{ row.status === 1 ? '取消发布' : '发布' }<Icon type="close-circle" className={styles.edit} /></span>
|
107
|
130
|
</AuthButton>
|
108
|
131
|
<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>}
|
|
132
|
+ {row.isEnlist == 1 && <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={finishDynamic.bind(this, row)}>结束活动<Icon type="poweroff" className={styles.edit} /></span>}
|
110
|
133
|
</AuthButton>
|
111
|
134
|
<AuthButton name="admin.buildingDynamic.update.put" noRight={null}>
|
112
|
135
|
<span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={topDynamic(row)}>{ row.weight === 1 ? '取消置顶' : '置顶' }<Icon type="vertical-align-top" className={styles.edit} /></span>
|
113
|
136
|
{row.isEnlist != 2 && <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={toEditGoods(row.dynamicId)}>编辑<Icon type="form" className={styles.edit} /></span>}
|
114
|
137
|
</AuthButton>
|
|
138
|
+ <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={newQrcode.bind(this, row)}>下载二维码<Icon type="qrcode" className={styles.shoppingCart} /></span>
|
115
|
139
|
</>
|
116
|
|
- )
|
|
140
|
+ ),
|
117
|
141
|
},
|
118
|
142
|
];
|
119
|
143
|
|
|
@@ -132,7 +156,7 @@ const toEditGoods = dynamicId => () => {
|
132
|
156
|
okText: '确定',
|
133
|
157
|
cancelText: '取消',
|
134
|
158
|
onOk() {
|
135
|
|
- request({ ...apis.activity.finish, data: {dynamicId: row.dynamicId, top: "" } }).then(data => {
|
|
159
|
+ request({ ...apis.activity.finish, data: { dynamicId: row.dynamicId, top: '' } }).then(data => {
|
136
|
160
|
console.log(data)
|
137
|
161
|
message.info('操作成功!')
|
138
|
162
|
getList({ pageNum: 1, pageSize: 10 })
|
|
@@ -147,7 +171,7 @@ const toEditGoods = dynamicId => () => {
|
147
|
171
|
// 置顶
|
148
|
172
|
const topDynamic = row => () => {
|
149
|
173
|
const weight = Math.abs(row.weight - 1)
|
150
|
|
- request({ ...apis.activity.weight, params: {dynamicId: row.dynamicId, weight} }).then(data => {
|
|
174
|
+ request({ ...apis.activity.weight, params: { dynamicId: row.dynamicId, weight } }).then(data => {
|
151
|
175
|
console.log(data)
|
152
|
176
|
message.info('操作成功!')
|
153
|
177
|
getList({ pageNum: 1, pageSize: 10 })
|
|
@@ -156,7 +180,7 @@ const toEditGoods = dynamicId => () => {
|
156
|
180
|
message.info(err.msg || err.message)
|
157
|
181
|
})
|
158
|
182
|
}
|
159
|
|
-
|
|
183
|
+
|
160
|
184
|
const sendOrPublicDynamic = row => {
|
161
|
185
|
if (row.status === 1) {
|
162
|
186
|
cancelDynamic(row)
|
|
@@ -164,29 +188,29 @@ const toEditGoods = dynamicId => () => {
|
164
|
188
|
sendDynamic(row)
|
165
|
189
|
}
|
166
|
190
|
}
|
167
|
|
-
|
|
191
|
+
|
168
|
192
|
// 取消活动
|
169
|
193
|
const cancelDynamic = row => {
|
170
|
|
- request({ ...apis.activity.cancel, urlData: {id: row.dynamicId}}).then((data) => {
|
|
194
|
+ request({ ...apis.activity.cancel, urlData: { id: row.dynamicId } }).then(data => {
|
171
|
195
|
message.info('操作成功!')
|
172
|
196
|
getList({ pageNum: 1, pageSize: 10 })
|
173
|
|
- }).catch((err) => {
|
|
197
|
+ }).catch(err => {
|
174
|
198
|
console.log(err)
|
175
|
199
|
message.info(err.msg || err.message)
|
176
|
200
|
})
|
177
|
201
|
}
|
178
|
|
-
|
179
|
|
- //发布活动
|
|
202
|
+
|
|
203
|
+ // 发布活动
|
180
|
204
|
const sendDynamic = row => {
|
181
|
|
- request({ ...apis.activity.send, urlData: {id: row.dynamicId}}).then((data) => {
|
|
205
|
+ request({ ...apis.activity.send, urlData: { id: row.dynamicId } }).then(data => {
|
182
|
206
|
message.info('操作成功!')
|
183
|
207
|
getList({ pageNum: 1, pageSize: 10 });
|
184
|
|
- }).catch((err) => {
|
|
208
|
+ }).catch(err => {
|
185
|
209
|
console.log(err)
|
186
|
210
|
message.info(err.msg || err.message)
|
187
|
211
|
})
|
188
|
212
|
}
|
189
|
|
-
|
|
213
|
+
|
190
|
214
|
const changePageNum = pageNumber => {
|
191
|
215
|
getList({ pageNum: pageNumber, pageSize: 10 })
|
192
|
216
|
}
|
|
@@ -202,7 +226,7 @@ const handleSubmit = (e, props) => {
|
202
|
226
|
});
|
203
|
227
|
}
|
204
|
228
|
|
205
|
|
- //重置搜索
|
|
229
|
+ // 重置搜索
|
206
|
230
|
function handleReset() {
|
207
|
231
|
props.form.resetFields();
|
208
|
232
|
}
|
|
@@ -212,6 +236,8 @@ const handleSubmit = (e, props) => {
|
212
|
236
|
return (
|
213
|
237
|
|
214
|
238
|
<>
|
|
239
|
+ {/* style={{ display: 'none' }} */}
|
|
240
|
+ <div id="qrcode"></div>
|
215
|
241
|
<Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
|
216
|
242
|
<Form.Item>
|
217
|
243
|
{getFieldDecorator('cityId')(
|
|
@@ -233,7 +259,7 @@ const handleSubmit = (e, props) => {
|
233
|
259
|
</Form.Item>
|
234
|
260
|
<Form.Item>
|
235
|
261
|
{getFieldDecorator('time')(
|
236
|
|
- <DatePicker />
|
|
262
|
+ <DatePicker />,
|
237
|
263
|
)}
|
238
|
264
|
</Form.Item>
|
239
|
265
|
<Form.Item>
|
|
@@ -258,7 +284,7 @@ const handleSubmit = (e, props) => {
|
258
|
284
|
</AuthButton>
|
259
|
285
|
<Table dataSource={data.list} columns={columns} pagination={false} rowKey="activityList"/>
|
260
|
286
|
<div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
261
|
|
- <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={(e) => changePageNum(e)} />
|
|
287
|
+ <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={e => changePageNum(e)} />
|
262
|
288
|
</div>
|
263
|
289
|
</>
|
264
|
290
|
)
|