|
@@ -25,45 +25,75 @@ let tableTitle = ['类型']
|
25
|
25
|
let columns = [
|
26
|
26
|
{
|
27
|
27
|
title: '日期',
|
28
|
|
- dataIndex: 'createTime',
|
29
|
|
- key: 'createTime',
|
|
28
|
+ dataIndex: 'date',
|
|
29
|
+ key: 'date',
|
30
|
30
|
},
|
31
|
31
|
{
|
32
|
32
|
title: '分享人数',
|
33
|
33
|
dataIndex: 'sharePersonNum',
|
34
|
34
|
key: 'sharePersonNum',
|
|
35
|
+ sorter: true,
|
35
|
36
|
},
|
36
|
37
|
{
|
37
|
38
|
title: '分享次数',
|
38
|
39
|
dataIndex: 'shareNum',
|
39
|
40
|
key: 'shareNum',
|
|
41
|
+ sorter: true,
|
40
|
42
|
},
|
41
|
43
|
{
|
42
|
44
|
title: '访问人数',
|
43
|
45
|
dataIndex: 'visitPersonNum',
|
44
|
46
|
key: 'visitPersonNum',
|
|
47
|
+ sorter: true,
|
45
|
48
|
},
|
46
|
49
|
{
|
47
|
50
|
title: '访问次数',
|
48
|
51
|
dataIndex: 'visitNum',
|
49
|
52
|
key: 'visitNum',
|
|
53
|
+ sorter: true,
|
50
|
54
|
},
|
51
|
55
|
{
|
52
|
56
|
title: '新增注册用户',
|
53
|
57
|
dataIndex: 'addRegistNum',
|
54
|
58
|
key: 'addRegistNum',
|
|
59
|
+ sorter: true,
|
55
|
60
|
},
|
56
|
61
|
]
|
57
|
62
|
|
58
|
63
|
|
|
64
|
+function getDayBegin(dt) {
|
|
65
|
+ return moment(dt, 'day').hours(0).minutes(0).seconds(0).milliseconds(0).toDate();
|
|
66
|
+}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+function getDayEnd(dt) {
|
|
70
|
+ return moment(dt, 'day').hours(23).minutes(59).seconds(59).milliseconds(999).toDate();
|
|
71
|
+}
|
|
72
|
+
|
|
73
|
+
|
59
|
74
|
class OverView extends React.Component {
|
60
|
75
|
|
61
|
76
|
constructor(props) {
|
62
|
77
|
super(props)
|
|
78
|
+
|
|
79
|
+ const defaultDays = 7
|
|
80
|
+
|
63
|
81
|
this.state = {
|
|
82
|
+ radioVal: defaultDays,
|
|
83
|
+ formData: {
|
|
84
|
+ startDate: moment().subtract(7, 'day').toDate(),
|
|
85
|
+ endDate: new Date,
|
|
86
|
+ buildingId: '',
|
|
87
|
+ targetType: '',
|
|
88
|
+ pageNum:'',
|
|
89
|
+ pageSize:'',
|
|
90
|
+ sort:null,
|
|
91
|
+ colKey:null
|
|
92
|
+ },
|
64
|
93
|
personData: [],
|
65
|
94
|
dataSoures: [],
|
66
|
95
|
tableData: [],
|
|
96
|
+ barData: {},
|
67
|
97
|
userType: 'all',
|
68
|
98
|
endDate: '',
|
69
|
99
|
startDate: '',
|
|
@@ -74,11 +104,13 @@ class OverView extends React.Component {
|
74
|
104
|
|
75
|
105
|
componentDidMount() {
|
76
|
106
|
this.getList()
|
|
107
|
+ this.getTableList()
|
77
|
108
|
}
|
78
|
109
|
|
79
|
|
- getList (params) {
|
80
|
|
- console.log("params",params);
|
81
|
|
- request({ ...apis.activityDataStatis.total, params: { ...params } }).then(res => {
|
|
110
|
+ getList () {
|
|
111
|
+ console.log('getlist')
|
|
112
|
+ const { formData } = this.state
|
|
113
|
+ request({ ...apis.activityDataStatis.total, params: formData }).then(res => {
|
82
|
114
|
this.setState({ personData: res })
|
83
|
115
|
}).catch(err => {
|
84
|
116
|
<Alert
|
|
@@ -92,6 +124,25 @@ class OverView extends React.Component {
|
92
|
124
|
})
|
93
|
125
|
}
|
94
|
126
|
|
|
127
|
+ getTableList () {
|
|
128
|
+ const { formData } = this.state
|
|
129
|
+ request({ ...apis.activityDataStatis.tableData, params: formData }).then(data => {
|
|
130
|
+ console.log(data)
|
|
131
|
+ this.setState({ tableData: data.records, total: data.total})
|
|
132
|
+ }).catch()
|
|
133
|
+ }
|
|
134
|
+
|
|
135
|
+ getBarData = (startDate, endDate) => {
|
|
136
|
+ console.log(startDate, 'startDate')
|
|
137
|
+ console.log(endDate, 'endDate')
|
|
138
|
+ request({
|
|
139
|
+ ...apis.activityDataStatis.selectAllActivityUser,
|
|
140
|
+ params: { startDate, endDate }
|
|
141
|
+ }).then((data) => {
|
|
142
|
+ this.setState({barData: data})
|
|
143
|
+ })
|
|
144
|
+ }
|
|
145
|
+
|
95
|
146
|
formatDate = (start, end) => {
|
96
|
147
|
const tempStartDate = `${moment(start).format('YYYY-MM-DDT00:00:00.000')}Z`
|
97
|
148
|
const tempEndDate = `${moment(end).format('YYYY-MM-DDT23:59:59.999')}Z`
|
|
@@ -104,7 +155,6 @@ class OverView extends React.Component {
|
104
|
155
|
}
|
105
|
156
|
|
106
|
157
|
handleSubmit = (e, props) => {
|
107
|
|
- console.log(this.props.form.getFieldValue("startDate"), 'eeeeeee')
|
108
|
158
|
let startDate = null
|
109
|
159
|
let endDate = null
|
110
|
160
|
const buildingId = this.props.form.getFieldValue("buildingId");
|
|
@@ -115,12 +165,16 @@ class OverView extends React.Component {
|
115
|
165
|
if (this.props.form.getFieldValue("endDate") != undefined){
|
116
|
166
|
endDate = this.props.form.getFieldValue("endDate").toDate()
|
117
|
167
|
}
|
118
|
|
- e.preventDefault();
|
119
|
|
- props.form.validateFields((err, values) => {
|
120
|
|
- if (!err) {
|
121
|
|
- this.getList({buildingId: buildingId, targetType: targetType, startDate: startDate, endDate: endDate})
|
122
|
|
- }
|
123
|
|
- });
|
|
168
|
+ const { formData } = this.state
|
|
169
|
+ this.setState({
|
|
170
|
+ formData: {
|
|
171
|
+ ...formData,
|
|
172
|
+ startDate: startDate,
|
|
173
|
+ endDate: endDate,
|
|
174
|
+ buildingId: buildingId,
|
|
175
|
+ targetType: targetType
|
|
176
|
+ }
|
|
177
|
+ }, this.getAllList)
|
124
|
178
|
this.setState({ startDate: startDate, endDate: endDate, buildingId: this.props.form.getFieldValue("buildingId"), targetType: this.props.form.getFieldValue("targetType") })
|
125
|
179
|
}
|
126
|
180
|
|
|
@@ -129,8 +183,23 @@ class OverView extends React.Component {
|
129
|
183
|
this.props.form.resetFields()
|
130
|
184
|
}
|
131
|
185
|
|
|
186
|
+ exportActivityStats = () => {
|
|
187
|
+ const { formData } = this.state
|
|
188
|
+ request({ ...apis.activityDataStatis.tableDataExport, params: formData }).then(data => {
|
|
189
|
+ if (!data) {
|
|
190
|
+ return
|
|
191
|
+ }
|
|
192
|
+ const url = window.URL.createObjectURL(new Blob([data]))
|
|
193
|
+ const link = document.createElement('a')
|
|
194
|
+ link.style.display = 'none'
|
|
195
|
+ link.href = url
|
|
196
|
+ link.setAttribute('download', '活动统计.xlsx')
|
|
197
|
+ document.body.append(link)
|
|
198
|
+ link.click()
|
|
199
|
+ }).catch()
|
|
200
|
+ }
|
|
201
|
+
|
132
|
202
|
getDataOf = (days) => {
|
133
|
|
- console.log(77777777)
|
134
|
203
|
this.setState({ endDate: new Date(), startDate: moment().subtract(days, 'day').toDate() })
|
135
|
204
|
this.getList({ endDate: new Date(), startDate: moment().subtract(days, 'day').toDate() })
|
136
|
205
|
}
|
|
@@ -179,15 +248,49 @@ class OverView extends React.Component {
|
179
|
248
|
|
180
|
249
|
}
|
181
|
250
|
|
182
|
|
- handleSelectChange = (e) => {
|
183
|
|
- this.setState({ userType: e }, () => {
|
184
|
|
- this.onTabledatas(this.state.dataSoures)
|
185
|
|
- })
|
|
251
|
+ //排序
|
|
252
|
+ handleTableChange = (pagination, filters, sorter) => {
|
|
253
|
+ console.log(pagination, filters, sorter)
|
|
254
|
+ const { formData } = this.state
|
|
255
|
+ this.setState({
|
|
256
|
+ formData: {
|
|
257
|
+ ...formData,
|
|
258
|
+ startDate: formData.startDate,
|
|
259
|
+ endDate: formData.endDate,
|
|
260
|
+ buildingId: formData.buildingId,
|
|
261
|
+ targetType: formData.targetType,
|
|
262
|
+ pageNum: pagination.current,
|
|
263
|
+ pageSize: pagination.pageSize,
|
|
264
|
+ sort: sorter.order,
|
|
265
|
+ colKey: sorter.columnKey
|
|
266
|
+ }
|
|
267
|
+ }, this.getAllList)
|
|
268
|
+ };
|
|
269
|
+
|
|
270
|
+ getAllList(){
|
|
271
|
+ this.getList()
|
|
272
|
+ this.getTableList()
|
|
273
|
+ }
|
|
274
|
+
|
|
275
|
+ handleRadioChange = (e) => {
|
|
276
|
+ const { formData } = this.state
|
|
277
|
+ const val = e.target.value;
|
|
278
|
+ this.setState({
|
|
279
|
+ radioVal: val - 0,
|
|
280
|
+ formData: {
|
|
281
|
+ ...formData,
|
|
282
|
+ startDate: moment().subtract(val, 'day').toDate(),
|
|
283
|
+ endDate: new Date,
|
|
284
|
+ }
|
|
285
|
+ }, this.getAllList)
|
186
|
286
|
}
|
187
|
287
|
|
188
|
288
|
|
189
|
289
|
render() {
|
|
290
|
+ const { radioVal } = this.state
|
190
|
291
|
const { getFieldDecorator } = this.props.form;
|
|
292
|
+ const startDate = this.state.formData.startDate
|
|
293
|
+ const endDate = this.state.formData.endDate
|
191
|
294
|
|
192
|
295
|
return (
|
193
|
296
|
<>
|
|
@@ -198,19 +301,23 @@ class OverView extends React.Component {
|
198
|
301
|
borderRadius: '12px',
|
199
|
302
|
minHeight: '60vh'
|
200
|
303
|
}}>
|
201
|
|
- <Radio.Group buttonStyle="solid" defaultValue="a">
|
202
|
|
- <Radio.Button value="c" onClick={() => this.getDataOf(1)}>今日</Radio.Button>
|
203
|
|
- <Radio.Button value="a" onClick={() => this.getDataOf(7)}>最近7天</Radio.Button>
|
204
|
|
- <Radio.Button value="b" onClick={() => this.getDataOf(30)}>最近1月</Radio.Button>
|
|
304
|
+ <Radio.Group buttonStyle="solid" value={radioVal} onChange={this.handleRadioChange}>
|
|
305
|
+ <Radio.Button value={0}>今日</Radio.Button>
|
|
306
|
+ <Radio.Button value={7}>最近7天</Radio.Button>
|
|
307
|
+ <Radio.Button value={30}>最近1月</Radio.Button>
|
205
|
308
|
</Radio.Group>
|
206
|
309
|
<Form layout="inline" onSubmit={e => this.handleSubmit(e, this.props)}>
|
207
|
310
|
<Form.Item style={{marginTop:'20px', marginBottom:'20px'}}>
|
208
|
|
- {getFieldDecorator('startDate')(
|
|
311
|
+ {getFieldDecorator('startDate', {initialValue: moment(startDate)
|
|
312
|
+
|
|
313
|
+ })(
|
209
|
314
|
<DatePicker placeholder="开始日期"/>,
|
210
|
315
|
)}
|
211
|
316
|
</Form.Item>
|
212
|
317
|
<Form.Item style={{marginTop:'20px', marginBottom:'20px'}}>
|
213
|
|
- {getFieldDecorator('endDate')(
|
|
318
|
+ {getFieldDecorator('endDate', {initialValue: moment(endDate)
|
|
319
|
+
|
|
320
|
+ })(
|
214
|
321
|
<DatePicker placeholder="结束日期"/>,
|
215
|
322
|
)}
|
216
|
323
|
</Form.Item>
|
|
@@ -274,15 +381,15 @@ class OverView extends React.Component {
|
274
|
381
|
|
275
|
382
|
<div style={{ display: 'flex' }}>
|
276
|
383
|
<div className={style.bar}>
|
277
|
|
- <NewUsers startDate={this.state.startDate} endDate={this.state.endDate} buildingId={this.state.buildingId} targetType={this.state.targetType} dataZoom={false}></NewUsers>
|
|
384
|
+ <NewUsers startDate={this.state.formData.startDate} endDate={this.state.formData.endDate} buildingId={this.state.buildingId} targetType={this.state.targetType} dataZoom={false}></NewUsers>
|
278
|
385
|
</div>
|
279
|
386
|
</div >
|
280
|
387
|
<AuthButton name="admin.customer.import" noRight={null}>
|
281
|
|
- <Button type="primary" style={{ float: 'right', margin: '20px 0', zIndex: 1 }}>
|
|
388
|
+ <Button type="primary" style={{ float: 'right', margin: '20px 0', zIndex: 1 }} onClick={this.exportActivityStats}>
|
282
|
389
|
导出
|
283
|
390
|
</Button>
|
284
|
391
|
</AuthButton>
|
285
|
|
- <Table style={{marginTop:'20px'}} dataSource={this.state.tableData} columns={columns} pagination={false} scroll={{ y: 500 }}></Table>
|
|
392
|
+ <Table style={{marginTop:'20px'}} dataSource={this.state.tableData} columns={columns} pagination={{ total: this.state.total}} onChange={this.handleTableChange} scroll={{ y: 500 }}></Table>
|
286
|
393
|
</div>
|
287
|
394
|
</div>
|
288
|
395
|
</>
|