|
@@ -0,0 +1,348 @@
|
|
1
|
+import React, { useState, useEffect } from 'react';
|
|
2
|
+import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, DatePicker } from 'antd';
|
|
3
|
+import { FormattedMessage } from 'umi-plugin-react/locale';
|
|
4
|
+import router from 'umi/router';
|
|
5
|
+import moment from 'moment';
|
|
6
|
+import styles from '../../style/GoodsList.less';
|
|
7
|
+import SelectCity from '../../../components/SelectButton/CitySelect'
|
|
8
|
+import BuildSelect from '../../../components/SelectButton/BuildSelect'
|
|
9
|
+import apis from '../../../services/apis';
|
|
10
|
+import request from '../../../utils/request';
|
|
11
|
+import AuthButton from '@/components/AuthButton';
|
|
12
|
+
|
|
13
|
+const { Option } = Select;
|
|
14
|
+const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
|
|
15
|
+
|
|
16
|
+const header = props => {
|
|
17
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
18
|
+ const [data, setData] = useState({ list: [], total: 0 })
|
|
19
|
+ // const [page, changePage] = useState({})
|
|
20
|
+ const [time, setTime] = useState('')
|
|
21
|
+
|
|
22
|
+ //==========看这里-- 新功能都用house为中间单词,我已经创建好了,你只要修改list的指向链接就行,看完删除=========
|
|
23
|
+ // 查询列表
|
|
24
|
+ const getList = params => {
|
|
25
|
+ request({ ...apis.house.list, params: { ...params } }).then(data => {
|
|
26
|
+ console.log(data)
|
|
27
|
+ setData(data)
|
|
28
|
+ })
|
|
29
|
+ }
|
|
30
|
+
|
|
31
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
32
|
+ useEffect(() => {
|
|
33
|
+ getList({ pageNum: 1, pageSize: 10 });
|
|
34
|
+ }, [])
|
|
35
|
+
|
|
36
|
+ // 跳转到编辑商品
|
|
37
|
+ const toAddHouse = id => () => {
|
|
38
|
+ if(id) {
|
|
39
|
+ router.push({
|
|
40
|
+ pathname: '/house/edit',
|
|
41
|
+ });
|
|
42
|
+ return
|
|
43
|
+ }
|
|
44
|
+ router.push({
|
|
45
|
+ pathname: '/house/add',
|
|
46
|
+ });
|
|
47
|
+ }
|
|
48
|
+
|
|
49
|
+ const newQrcode = row => {
|
|
50
|
+ const x = new XMLHttpRequest();
|
|
51
|
+ const resourceUrl = row.qrCode
|
|
52
|
+ x.open('GET', resourceUrl, true);
|
|
53
|
+ x.responseType = 'blob';
|
|
54
|
+ x.onload = function (e) {
|
|
55
|
+ const url = window.URL.createObjectURL(x.response)
|
|
56
|
+ const a = document.createElement('a');
|
|
57
|
+ a.href = url;
|
|
58
|
+ a.style.display = 'none'
|
|
59
|
+ a.download = '活动二维码.png';
|
|
60
|
+ a.click();
|
|
61
|
+ }
|
|
62
|
+ x.send();
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+ const getActivityDetail = (dynamicId) => () => {
|
|
66
|
+ router.push({
|
|
67
|
+ pathname: '/activity/detailActivity',
|
|
68
|
+ query: {
|
|
69
|
+ dynamicId,
|
|
70
|
+ },
|
|
71
|
+ });
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+ const getJoinPeople = (dynamicId) => () => {
|
|
75
|
+ router.push({
|
|
76
|
+ pathname: '/activity/SignList',
|
|
77
|
+ query: {
|
|
78
|
+ dynamicId,
|
|
79
|
+ },
|
|
80
|
+ });
|
|
81
|
+ }
|
|
82
|
+ /**
|
|
83
|
+ *
|
|
84
|
+ *
|
|
85
|
+ * @param {*} props
|
|
86
|
+ * @returns
|
|
87
|
+ */
|
|
88
|
+ const columns = [
|
|
89
|
+ {
|
|
90
|
+ title: '活动标题',
|
|
91
|
+ dataIndex: 'title',
|
|
92
|
+ key: 'title',
|
|
93
|
+ align: 'center',
|
|
94
|
+ // width: '15%',
|
|
95
|
+ render: (x, row) => <><div style={{overflow: 'hidden',textOverflow: 'ellipsis',whiteSpace: 'nowrap', width: '201px',title:'content'}}>
|
|
96
|
+ <span style={{color: 'blue',cursor: 'pointer'}} onClick={toAddHouse(1)}>{row.title}</span></div></>,
|
|
97
|
+ // width: '300px',
|
|
98
|
+ // ellipsis:'true'overflow: hidden; /*溢出隐藏*/
|
|
99
|
+// text-overflow: ellipsis; /*以省略号...显示*/
|
|
100
|
+// white-space: nowrap;
|
|
101
|
+ },
|
|
102
|
+ {
|
|
103
|
+ title: '活动时间',
|
|
104
|
+ dataIndex: 'startDate',
|
|
105
|
+ key: 'startDate',
|
|
106
|
+ align: 'center',
|
|
107
|
+ // width: '15%',
|
|
108
|
+ // width: '20%',
|
|
109
|
+ render: (x, row) => <><span>{`${moment(row.startDate).format('YYYY-MM-DD')} —— ${moment(row.endDate).format('YYYY-MM-DD')}`}</span></>,
|
|
110
|
+ },
|
|
111
|
+ {
|
|
112
|
+ title: '已参加人数',
|
|
113
|
+ dataIndex: 'count',
|
|
114
|
+ key: 'count',
|
|
115
|
+ align: 'center',
|
|
116
|
+ render: (x, row) => <><div style={{overflow: 'hidden',textOverflow: 'ellipsis',whiteSpace: 'nowrap', width: '201px',title:'content'}}>
|
|
117
|
+ <span style={{color: 'blue',cursor: 'pointer'}} onClick={getJoinPeople(row.dynamicId)}>{row.count}</span></div></>,
|
|
118
|
+ // width: '10%',
|
|
119
|
+ // width: '6%',
|
|
120
|
+ },
|
|
121
|
+ // {
|
|
122
|
+ // title: '阅读量',
|
|
123
|
+ // dataIndex: 'pvNum',
|
|
124
|
+ // key: 'pvNum',
|
|
125
|
+ // align: 'center',
|
|
126
|
+ // // width: '10%',
|
|
127
|
+ // },
|
|
128
|
+ // {
|
|
129
|
+ // title: '转发量',
|
|
130
|
+ // dataIndex: 'shareNum',
|
|
131
|
+ // key: 'shareNum',
|
|
132
|
+ // align: 'center',
|
|
133
|
+ // // width: '10%',
|
|
134
|
+ // },
|
|
135
|
+ // {
|
|
136
|
+ // title: '收藏数',
|
|
137
|
+ // dataIndex: 'saveNum',
|
|
138
|
+ // key: 'saveNum',
|
|
139
|
+ // align: 'center',
|
|
140
|
+ // // width: '10%',
|
|
141
|
+ // },
|
|
142
|
+ {
|
|
143
|
+ title: '报名状态',
|
|
144
|
+ dataIndex: 'activityStatus',
|
|
145
|
+ key: 'activityStatus',
|
|
146
|
+ align: 'center',
|
|
147
|
+ // width: '10%',
|
|
148
|
+ render: activityStatus => <><span>{activityStatus == 0 ? '进行中' : activityStatus == 1 ? '未开始' : '已结束'}</span></>,
|
|
149
|
+ },
|
|
150
|
+ {
|
|
151
|
+ title: '权重',
|
|
152
|
+ dataIndex: 'heavy',
|
|
153
|
+ key: 'heavy',
|
|
154
|
+ align: 'center',
|
|
155
|
+ },
|
|
156
|
+ ];
|
|
157
|
+ const getSignList = dynamicId => {
|
|
158
|
+ router.push({
|
|
159
|
+ pathname: '/activity/SignList',
|
|
160
|
+ query: {
|
|
161
|
+ dynamicId,
|
|
162
|
+ },
|
|
163
|
+ });
|
|
164
|
+ }
|
|
165
|
+
|
|
166
|
+ const finishDynamic = row => {
|
|
167
|
+ Modal.confirm({
|
|
168
|
+ title: '活动会被强制结束,小程序端无法再发起或参与此活动,如果不想让客户看到活动,请再点击取消发布按钮',
|
|
169
|
+ okText: '确定',
|
|
170
|
+ cancelText: '取消',
|
|
171
|
+ onOk () {
|
|
172
|
+ request({ ...apis.activity.finish, data: { dynamicId: row.dynamicId, top: '' } }).then(data => {
|
|
173
|
+ console.log(data)
|
|
174
|
+ message.info('操作成功!')
|
|
175
|
+ getList({ pageNum: 1, pageSize: 10, ...props.form.getFieldsValue() })
|
|
176
|
+ }).catch(err => {
|
|
177
|
+ console.log(err)
|
|
178
|
+ message.info(err.msg || err.message)
|
|
179
|
+ })
|
|
180
|
+ },
|
|
181
|
+ });
|
|
182
|
+ }
|
|
183
|
+
|
|
184
|
+ // 置顶
|
|
185
|
+ const topDynamic = row => () => {
|
|
186
|
+ const weight = Math.abs(row.weight - 1)
|
|
187
|
+ request({ ...apis.activity.weight, params: { dynamicId: row.dynamicId, weight } }).then(data => {
|
|
188
|
+ console.log(data)
|
|
189
|
+ message.info('操作成功!')
|
|
190
|
+ getList({ pageNum: 1, pageSize: 10, ...props.form.getFieldsValue() })
|
|
191
|
+ }).catch(err => {
|
|
192
|
+ console.log(err)
|
|
193
|
+ message.info(err.msg || err.message)
|
|
194
|
+ })
|
|
195
|
+ }
|
|
196
|
+
|
|
197
|
+ // 推首页
|
|
198
|
+ const homeDynamic = row => () => {
|
|
199
|
+ const home = Math.abs(row.home - 1)
|
|
200
|
+ request({ ...apis.activity.home, params: { dynamicId: row.dynamicId, home } }).then(data => {
|
|
201
|
+ console.log(data)
|
|
202
|
+ message.info('操作成功!')
|
|
203
|
+ getList({ pageNum: 1, pageSize: 10, ...props.form.getFieldsValue() })
|
|
204
|
+ }).catch(err => {
|
|
205
|
+ console.log(err)
|
|
206
|
+ message.info(err.msg || err.message)
|
|
207
|
+ })
|
|
208
|
+ }
|
|
209
|
+
|
|
210
|
+ const sendOrPublicDynamic = row => {
|
|
211
|
+ if (row.status === 1) {
|
|
212
|
+ cancelDynamic(row)
|
|
213
|
+ } else {
|
|
214
|
+ sendDynamic(row)
|
|
215
|
+ }
|
|
216
|
+ }
|
|
217
|
+
|
|
218
|
+ // 取消活动
|
|
219
|
+ const cancelDynamic = row => {
|
|
220
|
+ Modal.confirm({
|
|
221
|
+ title: '活动会在小程序端隐藏,后台可以继续编辑重新发布',
|
|
222
|
+ okText: '确认',
|
|
223
|
+ cancelText: '取消',
|
|
224
|
+ onOk() {
|
|
225
|
+ request({ ...apis.activity.cancel, urlData: { id: row.dynamicId } }).then(data => {
|
|
226
|
+ message.info('操作成功!')
|
|
227
|
+ getList({ pageNum: 1, pageSize: 10, ...props.form.getFieldsValue() })
|
|
228
|
+ }).catch(err => {
|
|
229
|
+ console.log(err)
|
|
230
|
+ message.info(err.msg || err.message)
|
|
231
|
+ })
|
|
232
|
+ }
|
|
233
|
+ });
|
|
234
|
+ }
|
|
235
|
+
|
|
236
|
+ // 发布活动
|
|
237
|
+ const sendDynamic = row => {
|
|
238
|
+ Modal.confirm({
|
|
239
|
+ title: '确定发布吗?',
|
|
240
|
+ okText: '确认',
|
|
241
|
+ cancelText: '取消',
|
|
242
|
+ onOk() {
|
|
243
|
+ request({ ...apis.activity.send, urlData: { id: row.dynamicId } }).then(data => {
|
|
244
|
+ message.info('操作成功!')
|
|
245
|
+ getList({ pageNum: 1, pageSize: 10, ...props.form.getFieldsValue() });
|
|
246
|
+ }).catch(err => {
|
|
247
|
+ console.log(err)
|
|
248
|
+ message.info(err.msg || err.message)
|
|
249
|
+ })
|
|
250
|
+ }
|
|
251
|
+ });
|
|
252
|
+ }
|
|
253
|
+
|
|
254
|
+ const changePageNum = pageNumber => {
|
|
255
|
+ getList({ pageNum: pageNumber, pageSize: 10, ...props.form.getFieldsValue() })
|
|
256
|
+ }
|
|
257
|
+
|
|
258
|
+ // 提交事件
|
|
259
|
+ const handleSubmit = e => {
|
|
260
|
+ e.preventDefault();
|
|
261
|
+ props.form.validateFields((err, values) => {
|
|
262
|
+ if (!err) {
|
|
263
|
+ console.log('提交数据: ', values)
|
|
264
|
+ if (time) {
|
|
265
|
+ values.time = `${moment(time).format('YYYY-MM-DDT00:00:00.000')}Z`
|
|
266
|
+ } else {
|
|
267
|
+ values.time = null
|
|
268
|
+ }
|
|
269
|
+
|
|
270
|
+ getList({ pageNum: 1, pageSize: 10, ...values })
|
|
271
|
+ }
|
|
272
|
+ });
|
|
273
|
+ }
|
|
274
|
+
|
|
275
|
+ // 重置搜索
|
|
276
|
+ function handleReset () {
|
|
277
|
+ props.form.resetFields();
|
|
278
|
+ setTime('')
|
|
279
|
+ getList({ pageNum: 1, pageSize: 10 })
|
|
280
|
+ }
|
|
281
|
+
|
|
282
|
+ // 时间回调
|
|
283
|
+ function timeOnChange(date, dateString) {
|
|
284
|
+ console.log(date, dateString)
|
|
285
|
+ setTime(date)
|
|
286
|
+ }
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+ const { getFieldDecorator } = props.form
|
|
290
|
+ return (
|
|
291
|
+
|
|
292
|
+ <>
|
|
293
|
+ {/* style={{ display: 'none' }} */}
|
|
294
|
+ <div id="qrcode"></div>
|
|
295
|
+ <Form layout="inline" onSubmit={e => handleSubmit(e)}>
|
|
296
|
+ <Form.Item>
|
|
297
|
+ {getFieldDecorator('cityId')(
|
|
298
|
+ <SelectCity />,
|
|
299
|
+ )}
|
|
300
|
+ </Form.Item>
|
|
301
|
+ <Form.Item>
|
|
302
|
+ {getFieldDecorator('buildingId')(
|
|
303
|
+ <BuildSelect />,
|
|
304
|
+ )}
|
|
305
|
+ </Form.Item>
|
|
306
|
+ <Form.Item>
|
|
307
|
+ {getFieldDecorator('title')(
|
|
308
|
+ <Input
|
|
309
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
310
|
+ placeholder="请输入标题"
|
|
311
|
+ />,
|
|
312
|
+ )}
|
|
313
|
+ </Form.Item>
|
|
314
|
+ <Form.Item>
|
|
315
|
+ {getFieldDecorator('time')(
|
|
316
|
+ <DatePicker onChange={timeOnChange}/>,
|
|
317
|
+ )}
|
|
318
|
+ </Form.Item>
|
|
319
|
+ <Form.Item>
|
|
320
|
+ <AuthButton name="admin.buildingDynamic.search" noRight={null}>
|
|
321
|
+ <Button type="primary" htmlType="submit" className={styles.searchBtn}>
|
|
322
|
+ 搜索
|
|
323
|
+ </Button>
|
|
324
|
+ </AuthButton>
|
|
325
|
+ <Button style={{ marginLeft: 8 }} onClick={handleReset}>
|
|
326
|
+ 重置
|
|
327
|
+ </Button>
|
|
328
|
+ </Form.Item>
|
|
329
|
+ </Form>
|
|
330
|
+ <AuthButton name="admin.buildingDynamic.add.post" noRight={null}>
|
|
331
|
+ <Button type="danger" className={styles.addBtn} onClick={toAddHouse()}>新增</Button>
|
|
332
|
+ </AuthButton>
|
|
333
|
+ <Table
|
|
334
|
+ // onRow={record => {
|
|
335
|
+ // return {
|
|
336
|
+ // onClick: getActivityDetail(record.dynamicId),
|
|
337
|
+ // };
|
|
338
|
+ // }}
|
|
339
|
+ dataSource={data.list} columns={columns} pagination={false} rowKey="activityList" />
|
|
340
|
+ <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
|
341
|
+ <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={e => changePageNum(e)} current={data.current}/>
|
|
342
|
+ </div>
|
|
343
|
+ </>
|
|
344
|
+ )
|
|
345
|
+}
|
|
346
|
+const WrappedHeader = Form.create({ name: 'header' })(header);
|
|
347
|
+
|
|
348
|
+export default WrappedHeader
|