|
@@ -0,0 +1,278 @@
|
|
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 styles from '../../style/GoodsList.less';
|
|
5
|
+import router from 'umi/router';
|
|
6
|
+import moment from 'moment';
|
|
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
|
+ const [ data, setData ] = useState({})
|
|
18
|
+// const [page, changePage] = useState({})
|
|
19
|
+
|
|
20
|
+ useEffect(() => {
|
|
21
|
+ getList({ pageNum: 1, pageSize: 10 });
|
|
22
|
+ },[])
|
|
23
|
+
|
|
24
|
+ // 查询列表
|
|
25
|
+ const getList = (params) => {
|
|
26
|
+ console.log(params);
|
|
27
|
+ request({ ...apis.groupActivity.list, params: { ...params } }).then((data) => {
|
|
28
|
+ console.log(data)
|
|
29
|
+ setData(data)
|
|
30
|
+ })
|
|
31
|
+ }
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+// 跳转到助力新增
|
|
35
|
+const toEditActivity = (recordId) => () => {
|
|
36
|
+ router.push({
|
|
37
|
+ pathname: '/activity/groupActivity/editGroupActivity',
|
|
38
|
+ query: {
|
|
39
|
+ recordId
|
|
40
|
+ },
|
|
41
|
+ });
|
|
42
|
+ }
|
|
43
|
+
|
|
44
|
+ /**
|
|
45
|
+ *
|
|
46
|
+ *
|
|
47
|
+ * @param {*} props
|
|
48
|
+ * @returns
|
|
49
|
+ */
|
|
50
|
+
|
|
51
|
+ const columns = [
|
|
52
|
+ {
|
|
53
|
+ title: '活动标题',
|
|
54
|
+ dataIndex: 'activityName',
|
|
55
|
+ key: 'activityName',
|
|
56
|
+ align: 'center',
|
|
57
|
+ },
|
|
58
|
+ {
|
|
59
|
+ title: '活动时间',
|
|
60
|
+ dataIndex: 'startTime',
|
|
61
|
+ key: 'startTime',
|
|
62
|
+ align: 'center',
|
|
63
|
+ render: (x, row) => <><span>{`${moment(row.startTime).format('YYYY-MM-DD')} —— ${moment(row.endTime).format('YYYY-MM-DD')}`}</span></>
|
|
64
|
+ },
|
|
65
|
+ {
|
|
66
|
+ title: '所需积分',
|
|
67
|
+ dataIndex: 'integral',
|
|
68
|
+ key: 'integral',
|
|
69
|
+ align: 'center',
|
|
70
|
+ },
|
|
71
|
+ {
|
|
72
|
+ title: '已参与人数',
|
|
73
|
+ dataIndex: 'joinPeople',
|
|
74
|
+ key: 'joinPeople',
|
|
75
|
+ align: 'center',
|
|
76
|
+ },
|
|
77
|
+ {
|
|
78
|
+ title: '成团数',
|
|
79
|
+ dataIndex: 'groupBuyPeople',
|
|
80
|
+ key: 'groupBuyPeople',
|
|
81
|
+ align: 'center',
|
|
82
|
+ },
|
|
83
|
+ {
|
|
84
|
+ title: '状态',
|
|
85
|
+ dataIndex: 'status',
|
|
86
|
+ key: 'status',
|
|
87
|
+ align: 'center',
|
|
88
|
+ render: (text, records) => {
|
|
89
|
+ if (records.status === 0) { return '进行中' }
|
|
90
|
+ if (records.status === 1) { return '未开始' }
|
|
91
|
+ if (records.status === 2) { return '已结束' }
|
|
92
|
+ },
|
|
93
|
+ },
|
|
94
|
+ {
|
|
95
|
+ title: '操作',
|
|
96
|
+ dataIndex: 'handle',
|
|
97
|
+ key: 'handle',
|
|
98
|
+ align: 'center',
|
|
99
|
+ render: (x, row) => (
|
|
100
|
+ <>
|
|
101
|
+ {row.status === 0 &&
|
|
102
|
+ <AuthButton name="admin.SignList.get" noRight={null}>
|
|
103
|
+
|
|
104
|
+ <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={ getSignList.bind(this, row.recordId)}>拼团记录<Icon type="snippets" className={styles.shoppingCart} /></span>
|
|
105
|
+ <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={endGroupActivity(row)}>结束活动<Icon type="poweroff" className={styles.edit} /></span>
|
|
106
|
+ <span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={recommendGroupActivity(row)}>{ row.sort === true ? '取消首页推荐' : '推荐至首页' }<Icon type="vertical-align-top" className={styles.edit} /></span>
|
|
107
|
+ <span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={topGroupActivity(row)}>{ row.weight === 1 ? '取消置顶' : '置顶' }<Icon type="vertical-align-top" className={styles.edit} /></span>
|
|
108
|
+ </AuthButton> }
|
|
109
|
+
|
|
110
|
+ {row.status === 1 &&
|
|
111
|
+ <AuthButton name="admin.buildingDynamic.finish.put" noRight={null}>
|
|
112
|
+ <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={toEditActivity(row.recordId)}>编辑<Icon type="form" className={styles.edit} /></span>
|
|
113
|
+ <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={endGroupActivity(row)}>结束活动<Icon type="poweroff" className={styles.edit} /></span>
|
|
114
|
+ <span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={recommendGroupActivity(row)}>{ row.sort === true ? '取消首页推荐' : '推荐至首页' }<Icon type="vertical-align-top" className={styles.edit} /></span>
|
|
115
|
+ <span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={topGroupActivity(row)}>{ row.weight === 1 ? '取消置顶' : '置顶' }<Icon type="vertical-align-top" className={styles.edit} /></span>
|
|
116
|
+ </AuthButton>
|
|
117
|
+ }
|
|
118
|
+
|
|
119
|
+ {row.status === 2 &&
|
|
120
|
+ <AuthButton name="admin.buildingDynamic.finish.put" noRight={null}>
|
|
121
|
+ <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={ getSignList.bind(this, row.recordId)}>拼团记录<Icon type="snippets" className={styles.shoppingCart} /></span>
|
|
122
|
+ <span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={topGroupActivity(row)}>{ row.weight === 1 ? '取消置顶' : '置顶' }<Icon type="vertical-align-top" className={styles.edit} /></span>
|
|
123
|
+ <span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={recommendGroupActivity(row)}>{ row.sort === true ? '取消推荐首页' : '推荐首页' }<Icon type="vertical-align-top" className={styles.edit} /></span>
|
|
124
|
+ </AuthButton>
|
|
125
|
+ }
|
|
126
|
+ </>
|
|
127
|
+ ),
|
|
128
|
+ },
|
|
129
|
+ ];
|
|
130
|
+ const getSignList = recordId => {
|
|
131
|
+ router.push({
|
|
132
|
+ pathname: '/activity/groupActivity/helpRecord',
|
|
133
|
+ query: {
|
|
134
|
+ recordId,
|
|
135
|
+ },
|
|
136
|
+ });
|
|
137
|
+ }
|
|
138
|
+
|
|
139
|
+ const finishDynamic = (row) => {
|
|
140
|
+ Modal.confirm({
|
|
141
|
+ title: '结束以后将无法编辑, 是否继续?',
|
|
142
|
+ okText: '确定',
|
|
143
|
+ cancelText: '取消',
|
|
144
|
+ onOk() {
|
|
145
|
+ request({ ...apis.activity.finish, data: {dynamicId: row.dynamicId, top: ""} }).then((data) => {
|
|
146
|
+ console.log(data)
|
|
147
|
+ message.info('操作成功!')
|
|
148
|
+ getList({ pageNum: 1, pageSize: 10 })
|
|
149
|
+ }).catch((err) => {
|
|
150
|
+ console.log(err)
|
|
151
|
+ message.info(err.msg || err.message)
|
|
152
|
+ })
|
|
153
|
+ },
|
|
154
|
+ });
|
|
155
|
+ }
|
|
156
|
+
|
|
157
|
+ //结束活动
|
|
158
|
+ const endGroupActivity = (row) => () => {
|
|
159
|
+ request({ ...apis.groupActivity.finish, data: { groupActicityId: row.groupActicityId} }).then((data) => {
|
|
160
|
+ console.log(data)
|
|
161
|
+ message.info('操作成功!')
|
|
162
|
+ getList({ pageNum: 1, pageSize: 10 })
|
|
163
|
+ }).catch((err) => {
|
|
164
|
+ console.log(err)
|
|
165
|
+ message.info(err.msg || err.message)
|
|
166
|
+ })
|
|
167
|
+ }
|
|
168
|
+
|
|
169
|
+ //置顶
|
|
170
|
+ const topGroupActivity = (row, code) => () => {
|
|
171
|
+ request({ ...apis.groupActivity.top, data: { groupActicityId: row.groupActicityId, weight: row.weight } }).then((data) => {
|
|
172
|
+ console.log(data)
|
|
173
|
+ message.info('操作成功!')
|
|
174
|
+ getList({ pageNum: 1, pageSize: 10 })
|
|
175
|
+ }).catch((err) => {
|
|
176
|
+ console.log(err)
|
|
177
|
+ message.info(err.msg || err.message)
|
|
178
|
+ })
|
|
179
|
+ }
|
|
180
|
+
|
|
181
|
+ //首页推荐
|
|
182
|
+ const recommendGroupActivity = (row, code) => () => {
|
|
183
|
+ request({ ...apis.groupActivity.top, data: { groupActicityId: row.groupActicityId, sort: row.sort } }).then((data) => {
|
|
184
|
+ console.log(data)
|
|
185
|
+ message.info('操作成功!')
|
|
186
|
+ getList({ pageNum: 1, pageSize: 10 })
|
|
187
|
+ }).catch((err) => {
|
|
188
|
+ console.log(err)
|
|
189
|
+ message.info(err.msg || err.message)
|
|
190
|
+ })
|
|
191
|
+ }
|
|
192
|
+
|
|
193
|
+ //发布活动
|
|
194
|
+ const sendDynamic = (row) => {
|
|
195
|
+ request({ ...apis.activity.send, urlData: {id: row.dynamicId}}).then((data) => {
|
|
196
|
+ message.info('操作成功!')
|
|
197
|
+ getList({ pageNum: 1, pageSize: 10 });
|
|
198
|
+ }).catch(err => {
|
|
199
|
+ console.log(err)
|
|
200
|
+ message.info(err.msg || err.message)
|
|
201
|
+ })
|
|
202
|
+ }
|
|
203
|
+
|
|
204
|
+ const changePageNum = pageNumber => {
|
|
205
|
+ getList({ pageNum: pageNumber, pageSize: 10 })
|
|
206
|
+ }
|
|
207
|
+
|
|
208
|
+ // 提交事件
|
|
209
|
+const handleSubmit = (e, props) => {
|
|
210
|
+ e.preventDefault();
|
|
211
|
+ props.form.validateFields((err, values) => {
|
|
212
|
+ if (!err) {
|
|
213
|
+ console.log('提交数据: ', values)
|
|
214
|
+ getList({ pageNum: 1, pageSize: 10, ...values })
|
|
215
|
+ }
|
|
216
|
+ });
|
|
217
|
+ }
|
|
218
|
+
|
|
219
|
+ //重置搜索
|
|
220
|
+ function handleReset() {
|
|
221
|
+ props.form.resetFields();
|
|
222
|
+ }
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+ const { getFieldDecorator } = props.form
|
|
226
|
+ return (
|
|
227
|
+
|
|
228
|
+ <>
|
|
229
|
+ <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
|
|
230
|
+ <Form.Item>
|
|
231
|
+ {getFieldDecorator('cityId')(
|
|
232
|
+ <SelectCity />,
|
|
233
|
+ )}
|
|
234
|
+ </Form.Item>
|
|
235
|
+ <Form.Item>
|
|
236
|
+ {getFieldDecorator('buildingId')(
|
|
237
|
+ <BuildSelect />,
|
|
238
|
+ )}
|
|
239
|
+ </Form.Item>
|
|
240
|
+ <Form.Item>
|
|
241
|
+ {getFieldDecorator('activityName')(
|
|
242
|
+ <Input
|
|
243
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
244
|
+ placeholder="请输入标题"
|
|
245
|
+ />,
|
|
246
|
+ )}
|
|
247
|
+ </Form.Item>
|
|
248
|
+ <Form.Item>
|
|
249
|
+ {getFieldDecorator('status')(
|
|
250
|
+ <Select style={{ width: '180px' }} placeholder="活动状态">
|
|
251
|
+ <Option value="0">进行中</Option>
|
|
252
|
+ <Option value="1">未开始</Option>
|
|
253
|
+ <Option value="2">已结束</Option>
|
|
254
|
+ </Select>,
|
|
255
|
+ )}
|
|
256
|
+ </Form.Item>
|
|
257
|
+ <Form.Item>
|
|
258
|
+ <Button type="primary" htmlType="submit" className={styles.searchBtn}>
|
|
259
|
+ 搜索
|
|
260
|
+ </Button>
|
|
261
|
+ <Button style={{ marginLeft: 8 }} onClick={handleReset}>
|
|
262
|
+ 重置
|
|
263
|
+ </Button>
|
|
264
|
+ </Form.Item>
|
|
265
|
+ </Form>
|
|
266
|
+ <AuthButton name="admin.buildingDynamic.add.post" noRight={null}>
|
|
267
|
+ <Button type="danger" className={styles.addBtn} onClick={toEditActivity()}>新增</Button>
|
|
268
|
+ </AuthButton>
|
|
269
|
+ <Table dataSource={data.records} columns={columns} pagination={false} rowKey="activityList"/>
|
|
270
|
+ <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
|
271
|
+ <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} />
|
|
272
|
+ </div>
|
|
273
|
+ </>
|
|
274
|
+ )
|
|
275
|
+}
|
|
276
|
+const WrappedHeader = Form.create({ name: 'header' })(header);
|
|
277
|
+
|
|
278
|
+export default WrappedHeader
|