|
@@ -1,246 +1,131 @@
|
1
|
|
-import React from 'react';
|
2
|
|
-import { Form, Input, Button, Icon, Select, DatePicker, Table } from 'antd';
|
|
1
|
+import React, { useState, useEffect } from 'react';
|
|
2
|
+import { Form, Input, Button, Icon, Select, DatePicker, Table, Pagination } from 'antd';
|
3
|
3
|
import { FormattedMessage } from 'umi-plugin-react/locale';
|
4
|
4
|
import styles from '../style/GoodsList.less';
|
|
5
|
+import router from 'umi/router';
|
|
6
|
+import moment from 'moment';
|
|
7
|
+import BuildSelect from '../../components/SelectButton/BuildSelect'
|
|
8
|
+
|
|
9
|
+import request from '../../utils/request'
|
5
|
10
|
|
6
|
11
|
/**
|
7
|
12
|
@param {*} props
|
8
|
13
|
@returns
|
9
|
14
|
*/
|
10
|
15
|
const { Option } = Select;
|
11
|
|
-// 提交事件
|
12
|
|
-function handleSubmit(e, props) {
|
13
|
|
- e.preventDefault();
|
14
|
|
- props.form.validateFields((err, values) => {
|
15
|
|
- if (!err) {
|
16
|
|
- console.log('提交数据: ', values)
|
17
|
|
- }
|
18
|
|
- });
|
19
|
|
-}
|
20
|
|
-// Change 事件
|
21
|
|
-function handleSelectChange(props) {
|
22
|
|
- console.log(props)
|
23
|
|
-}
|
24
|
|
-// 兑换时间 组件
|
25
|
|
-class DateRange extends React.Component {
|
26
|
|
- state = {
|
27
|
|
- startValue: null,
|
28
|
|
- endValue: null,
|
29
|
|
- endOpen: false,
|
30
|
|
- };
|
31
|
|
-
|
32
|
|
- disabledStartDate = startValue => {
|
33
|
|
- const { endValue } = this.state;
|
34
|
|
- if (!startValue || !endValue) {
|
35
|
|
- return false;
|
36
|
|
- }
|
37
|
|
- return startValue.valueOf() > endValue.valueOf();
|
38
|
|
- };
|
39
|
|
-
|
40
|
|
- disabledEndDate = endValue => {
|
41
|
|
- const { startValue } = this.state;
|
42
|
|
- if (!endValue || !startValue) {
|
43
|
|
- return false;
|
44
|
|
- }
|
45
|
|
- return endValue.valueOf() <= startValue.valueOf();
|
46
|
|
- };
|
47
|
|
-
|
48
|
|
- onChange = (field, value) => {
|
49
|
|
- this.setState({
|
50
|
|
- [field]: value,
|
51
|
|
- });
|
52
|
|
-
|
53
|
|
- };
|
54
|
|
- onStartChange = value => {
|
55
|
|
- this.onChange('startValue', value);
|
56
|
|
- console.log(value, "startValue")
|
57
|
|
- };
|
|
16
|
+const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
|
58
|
17
|
|
59
|
|
- onEndChange = value => {
|
60
|
|
- this.onChange('endValue', value);
|
61
|
|
- console.log(value, "endValue")
|
62
|
|
- };
|
|
18
|
+function record(props) {
|
|
19
|
+ const { getFieldDecorator } = props.form
|
63
|
20
|
|
64
|
|
- handleStartOpenChange = open => {
|
65
|
|
- if (!open) {
|
66
|
|
- this.setState({ endOpen: true });
|
67
|
|
- }
|
68
|
|
- };
|
69
|
|
- handleEndOpenChange = open => {
|
70
|
|
- this.setState({ endOpen: open });
|
71
|
|
- };
|
72
|
|
- render() {
|
73
|
|
- const { startValue, endValue, endOpen } = this.state;
|
74
|
|
- return (
|
75
|
|
- <div>
|
76
|
|
- <span style={{ marginRight: '14px' }}>兑换时间</span>
|
77
|
|
- <DatePicker
|
78
|
|
- disabledDate={this.disabledStartDate}
|
79
|
|
- format="YYYY-MM-DD"
|
80
|
|
- value={startValue}
|
81
|
|
- placeholder="开始时间"
|
82
|
|
- onChange={this.onStartChange}
|
83
|
|
- onOpenChange={this.handleStartOpenChange}
|
84
|
|
- style={{ marginRight: '14px' }}
|
85
|
|
- />
|
86
|
|
- <DatePicker
|
87
|
|
- disabledDate={this.disabledEndDate}
|
88
|
|
- format="YYYY-MM-DD"
|
89
|
|
- value={endValue}
|
90
|
|
- placeholder="结束时间"
|
91
|
|
- onChange={this.onEndChange}
|
92
|
|
- open={endOpen}
|
93
|
|
- onOpenChange={this.handleEndOpenChange}
|
94
|
|
- />
|
95
|
|
- </div>
|
96
|
|
- );
|
|
21
|
+ // 获取初始化数据
|
|
22
|
+ const [ data, setData ] = useState({})
|
|
23
|
+
|
|
24
|
+ useEffect(() => {
|
|
25
|
+ getList({ pageNum: 1, pageSize: 10 });
|
|
26
|
+ },[])
|
|
27
|
+
|
|
28
|
+ // 查询列表
|
|
29
|
+ const getList = (params) => {
|
|
30
|
+ request({
|
|
31
|
+ url: '/api/admin/taPointsExchange',
|
|
32
|
+ method: 'GET',
|
|
33
|
+ params: { ...params },
|
|
34
|
+ }).then((data) => {
|
|
35
|
+ setData(data)
|
|
36
|
+ })
|
97
|
37
|
}
|
98
|
|
-}
|
99
|
|
-// 兑换时间 组件 end
|
100
|
|
-// 领取时间 组件
|
101
|
|
-class DateRange2 extends React.Component {
|
102
|
|
- state = {
|
103
|
|
- startValue2: null,
|
104
|
|
- endValue2: null,
|
105
|
|
- endOpen2: false,
|
106
|
|
- };
|
107
|
|
-
|
108
|
|
- disabledStartDate2 = startValue2 => {
|
109
|
|
- const { endValue2 } = this.state;
|
110
|
|
- if (!startValue2 || !endValue2) {
|
111
|
|
- return false;
|
112
|
|
- }
|
113
|
|
- return startValue2.valueOf() > endValue2.valueOf();
|
114
|
|
- };
|
115
|
|
-
|
116
|
|
- disabledEndDate2 = endValue2 => {
|
117
|
|
- const { startValue2 } = this.state;
|
118
|
|
- if (!endValue2 || !startValue2) {
|
119
|
|
- return false;
|
120
|
|
- }
|
121
|
|
- return endValue2.valueOf() <= startValue2.valueOf();
|
122
|
|
- };
|
123
|
|
-
|
124
|
|
- onChange = (field, value) => {
|
125
|
|
- this.setState({
|
126
|
|
- [field]: value,
|
|
38
|
+
|
|
39
|
+ // 提交事件
|
|
40
|
+ const handleSubmit = (e, props) => {
|
|
41
|
+ e.preventDefault();
|
|
42
|
+ props.form.validateFields((err, values) => {
|
|
43
|
+ if (!err) {
|
|
44
|
+ let {exchangeTime,receiveTime, ...submitValue} = values
|
|
45
|
+ if(null != exchangeTime && exchangeTime.length > 0){
|
|
46
|
+ const [startCreateDate, endCreateDate] = exchangeTime
|
|
47
|
+ submitValue.startCreateDate = moment(startCreateDate).format('YYYY-MM-DD');
|
|
48
|
+ submitValue.endCreateDate = moment(endCreateDate).format('YYYY-MM-DD');
|
|
49
|
+ }else{
|
|
50
|
+ submitValue.startCreateDate = null
|
|
51
|
+ submitValue.endCreateDate = null
|
|
52
|
+ }
|
|
53
|
+
|
|
54
|
+ if(null != receiveTime && receiveTime.length > 0){
|
|
55
|
+ const [startVerifyDate, endVerifyDate] = receiveTime
|
|
56
|
+ submitValue.startVerifyDate = moment(startVerifyDate).format('YYYY-MM-DD');
|
|
57
|
+ submitValue.endVerifyDate = moment(endVerifyDate).format('YYYY-MM-DD');
|
|
58
|
+ }else{
|
|
59
|
+ submitValue.startVerifyDate = null
|
|
60
|
+ submitValue.endVerifyDate = null
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ console.log(submitValue)
|
|
64
|
+ getList({ pageNum: 1, pageSize: 10, ...submitValue })
|
|
65
|
+ }
|
127
|
66
|
});
|
128
|
|
- };
|
129
|
|
- onStartChange2 = value => {
|
130
|
|
- this.onChange('startValue2', value);
|
131
|
|
- console.log(value, "startValue2")
|
132
|
|
- };
|
133
|
|
-
|
134
|
|
- onEndChange2 = value => {
|
135
|
|
- this.onChange('endValue2', value);
|
136
|
|
- console.log(value, "endValue2")
|
137
|
|
- };
|
138
|
|
-
|
139
|
|
- handleStartOpenChange2 = open => {
|
140
|
|
- if (!open) {
|
141
|
|
- this.setState({ endOpen2: true });
|
142
|
|
- }
|
143
|
|
- };
|
144
|
|
- handleEndOpenChange2 = open => {
|
145
|
|
- this.setState({ endOpen2: open });
|
146
|
|
- };
|
147
|
|
- render() {
|
148
|
|
- const { startValue2, endValue2, endOpen2 } = this.state;
|
149
|
|
- return (
|
150
|
|
- <div>
|
151
|
|
- <span style={{ marginRight: '14px' }}>领取时间</span>
|
152
|
|
- <DatePicker
|
153
|
|
- disabledDate={this.disabledStartDate2}
|
154
|
|
- format="YYYY-MM-DD"
|
155
|
|
- value={startValue2}
|
156
|
|
- placeholder="开始时间"
|
157
|
|
- onChange={this.onStartChange2}
|
158
|
|
- onOpenChange={this.handleStartOpenChange2}
|
159
|
|
- style={{ marginRight: '14px' }}
|
160
|
|
- />
|
161
|
|
- <DatePicker
|
162
|
|
- disabledDate={this.disabledEndDate2}
|
163
|
|
- format="YYYY-MM-DD"
|
164
|
|
- value={endValue2}
|
165
|
|
- placeholder="结束时间"
|
166
|
|
- onChange={this.onEndChange2}
|
167
|
|
- open={endOpen2}
|
168
|
|
- onOpenChange={this.handleEndOpenChange2}
|
169
|
|
- />
|
170
|
|
- </div>
|
171
|
|
- );
|
172
|
67
|
}
|
173
|
|
-}
|
174
|
|
-// 领取时间 组件 end
|
175
|
|
-const dataSource = [
|
176
|
|
- {
|
177
|
|
- key: '1',
|
178
|
|
- img: 'http://img0.imgtn.bdimg.com/it/u=4246326797,2657995307&fm=26&gp=0.jpg',
|
179
|
|
- name: '华为P30 Pro',
|
180
|
|
- },
|
181
|
|
- {
|
182
|
|
- key: '2',
|
183
|
|
- img: '',
|
184
|
|
- name: '大米',
|
185
|
|
- },
|
186
|
|
-];
|
187
|
|
-
|
188
|
|
-const columns = [
|
189
|
68
|
|
190
|
|
- {
|
191
|
|
- title: '用户姓名',
|
192
|
|
- dataIndex: 'name',
|
193
|
|
- key: 'name',
|
194
|
|
- align: 'center',
|
195
|
|
-
|
196
|
|
- },
|
197
|
|
- {
|
198
|
|
- title: '用户类型',
|
199
|
|
- dataIndex: 'type',
|
200
|
|
- key: 'type',
|
201
|
|
- align: 'center',
|
202
|
|
- },
|
203
|
|
- {
|
204
|
|
- title: '手机号',
|
205
|
|
- dataIndex: 'phone',
|
206
|
|
- key: 'phone',
|
207
|
|
- align: 'center',
|
208
|
|
- },
|
209
|
|
- {
|
210
|
|
- title: '商品图片',
|
211
|
|
- dataIndex: 'img',
|
212
|
|
- key: 'img',
|
213
|
|
- align: 'center',
|
214
|
|
- render: (text, record) => <img src={record.img} className={styles.touxiang} />,
|
215
|
|
- },
|
216
|
|
- {
|
217
|
|
- title: '商品名称',
|
218
|
|
- dataIndex: 'goodName',
|
219
|
|
- key: 'goodName',
|
220
|
|
- align: 'center',
|
221
|
|
- },
|
222
|
|
- {
|
223
|
|
- title: '兑换时间',
|
224
|
|
- dataIndex: 'time',
|
225
|
|
- key: 'time',
|
226
|
|
- align: 'center',
|
227
|
|
- },
|
228
|
|
- {
|
229
|
|
- title: '领取时间',
|
230
|
|
- dataIndex: 'time2',
|
231
|
|
- key: 'time2',
|
232
|
|
- align: 'center',
|
233
|
|
- },
|
234
|
|
- {
|
235
|
|
- title: '状态',
|
236
|
|
- dataIndex: 'state',
|
237
|
|
- key: 'state',
|
238
|
|
- align: 'center',
|
239
|
|
- },
|
240
|
|
-];
|
|
69
|
+ const changePageNum = (pageNumber) => {
|
|
70
|
+ getList({ pageNum: pageNumber, pageSize: 10 })
|
|
71
|
+ }
|
241
|
72
|
|
242
|
|
-function record(props) {
|
243
|
|
- const { getFieldDecorator } = props.form
|
|
73
|
+ const columns = [
|
|
74
|
+
|
|
75
|
+ {
|
|
76
|
+ title: '用户姓名',
|
|
77
|
+ dataIndex: 'personName',
|
|
78
|
+ key: 'personName',
|
|
79
|
+ align: 'center',
|
|
80
|
+ },
|
|
81
|
+ {
|
|
82
|
+ title: '用户类型',
|
|
83
|
+ dataIndex: 'personType',
|
|
84
|
+ key: 'personType',
|
|
85
|
+ align: 'center',
|
|
86
|
+ render: (personType)=> <><span>{personType === 'Realty Consultant' ? '置业顾问' : personType === 'Sales Executive' ? '销售主管' : personType === 'estate agent' ? '经纪人' : ''}</span></>
|
|
87
|
+ },
|
|
88
|
+ {
|
|
89
|
+ title: '手机号',
|
|
90
|
+ dataIndex: 'phone',
|
|
91
|
+ key: 'phone',
|
|
92
|
+ align: 'center',
|
|
93
|
+ },
|
|
94
|
+ {
|
|
95
|
+ title: '商品图片',
|
|
96
|
+ dataIndex: 'image',
|
|
97
|
+ key: 'image',
|
|
98
|
+ align: 'center',
|
|
99
|
+ render: (text, record) => <img src={record.image} className={styles.touxiang} />,
|
|
100
|
+ },
|
|
101
|
+ {
|
|
102
|
+ title: '商品名称',
|
|
103
|
+ dataIndex: 'targetName',
|
|
104
|
+ key: 'targetName',
|
|
105
|
+ align: 'center',
|
|
106
|
+ },
|
|
107
|
+ {
|
|
108
|
+ title: '兑换时间',
|
|
109
|
+ dataIndex: 'createDate',
|
|
110
|
+ key: 'createDate',
|
|
111
|
+ align: 'center',
|
|
112
|
+ render: (createDate) => <><span>{moment(createDate).format('YYYY-MM-DD HH:mm')}</span></>
|
|
113
|
+ },
|
|
114
|
+ {
|
|
115
|
+ title: '领取时间',
|
|
116
|
+ dataIndex: 'verifyDate',
|
|
117
|
+ key: 'verifyDate',
|
|
118
|
+ align: 'center',
|
|
119
|
+ render: (verifyDate) => <><span>{verifyDate != null ? moment(verifyDate).format('YYYY-MM-DD HH:mm') : ''}</span></>
|
|
120
|
+ },
|
|
121
|
+ {
|
|
122
|
+ title: '状态',
|
|
123
|
+ dataIndex: 'status',
|
|
124
|
+ key: 'status',
|
|
125
|
+ align: 'center',
|
|
126
|
+ render: (status)=> <><span>{status == 1 ? '已领取' : '未领取'}</span></>
|
|
127
|
+ },
|
|
128
|
+ ];
|
244
|
129
|
|
245
|
130
|
return (
|
246
|
131
|
|
|
@@ -248,7 +133,7 @@ function record(props) {
|
248
|
133
|
<Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
|
249
|
134
|
<div style={{ display: 'flex' }}>
|
250
|
135
|
<Form.Item>
|
251
|
|
- {getFieldDecorator('name')(
|
|
136
|
+ {getFieldDecorator('personName')(
|
252
|
137
|
<Input
|
253
|
138
|
prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
254
|
139
|
placeholder="用户姓名"
|
|
@@ -264,7 +149,7 @@ function record(props) {
|
264
|
149
|
)}
|
265
|
150
|
</Form.Item>
|
266
|
151
|
<Form.Item>
|
267
|
|
- {getFieldDecorator('goodName')(
|
|
152
|
+ {getFieldDecorator('targetName')(
|
268
|
153
|
<Input
|
269
|
154
|
prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
270
|
155
|
placeholder="商品名称"
|
|
@@ -272,36 +157,43 @@ function record(props) {
|
272
|
157
|
)}
|
273
|
158
|
</Form.Item>
|
274
|
159
|
<Form.Item>
|
275
|
|
- {getFieldDecorator('type')(
|
276
|
|
- <Select style={{ width: '220px' }} placeholder="用户类型" onChange={handleSelectChange}>
|
277
|
|
- <Option value="2">置业顾问</Option>
|
278
|
|
- <Option value="1">销售主管</Option>
|
279
|
|
- <Option value="0">经纪人</Option>
|
|
160
|
+ {getFieldDecorator('personType')(
|
|
161
|
+ <Select style={{ width: '220px' }} placeholder="用户类型">
|
|
162
|
+ <Option value="Realty Consultant">置业顾问</Option>
|
|
163
|
+ <Option value="Sales Executive">销售主管</Option>
|
|
164
|
+ <Option value="estate agent">经纪人</Option>
|
280
|
165
|
</Select>,
|
281
|
166
|
)}
|
282
|
167
|
</Form.Item>
|
283
|
168
|
<Form.Item>
|
284
|
|
- {getFieldDecorator('state')(
|
285
|
|
- <Select style={{ width: '220px' }} placeholder="状态" onChange={handleSelectChange}>
|
|
169
|
+ {getFieldDecorator('status')(
|
|
170
|
+ <Select style={{ width: '220px' }} placeholder="状态">
|
286
|
171
|
<Option value="1">已领取</Option>
|
287
|
172
|
<Option value="0">未领取</Option>
|
288
|
173
|
</Select>,
|
289
|
174
|
)}
|
290
|
175
|
</Form.Item>
|
|
176
|
+ <Form.Item>
|
|
177
|
+ {getFieldDecorator('exchangeTime')(
|
|
178
|
+ <RangePicker placeholder={['兑换开始时间','兑换结束时间']}/>
|
|
179
|
+ )}
|
|
180
|
+ </Form.Item>
|
|
181
|
+ <Form.Item>
|
|
182
|
+ {getFieldDecorator('receiveTime')(
|
|
183
|
+ <RangePicker placeholder={['领取开始时间','领取结束时间']}/>
|
|
184
|
+ )}
|
|
185
|
+ </Form.Item>
|
291
|
186
|
<Form.Item>
|
292
|
187
|
<Button type="primary" htmlType="submit" className={styles.searchBtn}>
|
293
|
188
|
搜索
|
294
|
189
|
</Button>
|
295
|
190
|
</Form.Item>
|
296
|
191
|
</div>
|
297
|
|
- <Form.Item>
|
298
|
|
- <DateRange />
|
299
|
|
- </Form.Item>
|
300
|
|
- <Form.Item>
|
301
|
|
- <DateRange2 />
|
302
|
|
- </Form.Item>
|
303
|
192
|
</Form>
|
304
|
|
- <Table style={{ marginTop: '40px' }} dataSource={dataSource} columns={columns} />
|
|
193
|
+ <Table dataSource={data.records} columns={columns} pagination={false} />
|
|
194
|
+ <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
|
195
|
+ <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} />
|
|
196
|
+ </div>
|
305
|
197
|
</>
|
306
|
198
|
)
|
307
|
199
|
}
|