|
@@ -5,6 +5,7 @@ import EChart from '../../../components/EchartsTest/EChart';
|
5
|
5
|
import request from '../../../utils/request';
|
6
|
6
|
import apis from '../../../services/apis';
|
7
|
7
|
import StatsChart from './component/StatsChart';
|
|
8
|
+import BuildSelect from '../../../components/SelectButton/BuildSelect'
|
8
|
9
|
import router from 'umi/router';
|
9
|
10
|
|
10
|
11
|
|
|
@@ -23,28 +24,28 @@ class buildingStats extends React.Component {
|
23
|
24
|
tableData: [],
|
24
|
25
|
userType: 'all',
|
25
|
26
|
endDate: {},
|
26
|
|
- startDate: {}
|
|
27
|
+ startDate: {},
|
|
28
|
+ buildingId: ''
|
27
|
29
|
}
|
28
|
30
|
}
|
29
|
31
|
|
30
|
32
|
componentDidMount() {
|
31
|
33
|
this.getBarData(moment().subtract(7, 'day').toDate(),new Date())
|
32
|
|
- this.getTableData(moment().subtract(7, 'day').toDate(),new Date())
|
33
|
|
- // this.setState({ endDate: new Date(), startDate: moment().subtract(7, 'day').toDate() })
|
|
34
|
+ this.getTableData(moment().subtract(7, 'day').toDate(),new Date(),this.state.buildingId)
|
|
35
|
+ this.setState({...this.state, endDate: new Date(), startDate: moment().subtract(7, 'day').toDate() })
|
34
|
36
|
|
35
|
37
|
}
|
36
|
38
|
|
37
|
39
|
// 获取图表数据
|
38
|
40
|
getBarData = (startDate, endDate) => {
|
39
|
41
|
request({ ...apis.stats.barList, params: { startDate, endDate } }).then((data) => {
|
40
|
|
- console.log(data)
|
41
|
|
- this.setState({barData: data})
|
|
42
|
+ this.setState({...this.state, barData: data})
|
42
|
43
|
})
|
43
|
44
|
}
|
44
|
45
|
|
45
|
46
|
//获取表格数据
|
46
|
|
- getTableData = (startDate, endDate) => {
|
47
|
|
- console.log(startDate,endDate,"时间2")
|
|
47
|
+ getTableData = (startDate, endDate, buildingId) => {
|
|
48
|
+ console.log(startDate,endDate,buildingId,"时间2")
|
48
|
49
|
}
|
49
|
50
|
|
50
|
51
|
formatDate = (start, end) => {
|
|
@@ -53,72 +54,35 @@ class buildingStats extends React.Component {
|
53
|
54
|
return { startDate: tempStartDate, endDate: tempEndDate }
|
54
|
55
|
}
|
55
|
56
|
|
|
57
|
+ //时间选择器改变的时候
|
56
|
58
|
onChangetime = (_dates, dateStrings) => {
|
57
|
59
|
daterange[0] = `${moment(dateStrings[0]).format('YYYY-MM-DDT00:00:00.000')}Z`
|
58
|
60
|
daterange[1] = `${moment(dateStrings[1]).format('YYYY-MM-DDT23:59:59.999')}Z`
|
59
|
61
|
}
|
60
|
62
|
|
61
|
|
- handleSubmit = (e, props) => {
|
62
|
|
-
|
63
|
|
- e.preventDefault();
|
64
|
|
-
|
65
|
|
- }
|
66
|
|
-
|
|
63
|
+ //切换三个标签页
|
67
|
64
|
getDataOf = (days) => {
|
68
|
65
|
this.getBarData(moment().subtract(days, 'day').toDate(),new Date())
|
69
|
|
- // this.setState({ endDate: new Date(), startDate: moment().subtract(days, 'day').toDate() })
|
|
66
|
+ this.getTableData(moment().subtract(days, 'day').toDate(),new Date(),this.state.buildingId)
|
|
67
|
+ this.setState({ ...this.state, endDate: new Date(), startDate: moment().subtract(days, 'day').toDate() })
|
70
|
68
|
}
|
71
|
69
|
|
|
70
|
+ //点击查询
|
72
|
71
|
datalist = () => {
|
73
|
72
|
this.getBarData(daterange[0] === '' ? moment().subtract(7, 'day').toDate() : daterange[0],daterange[1] === '' ? new Date() : daterange[1])
|
74
|
|
- // this.setState({
|
75
|
|
- // endDate: daterange[1] === '' ? new Date() : daterange[1],
|
76
|
|
- // startDate: daterange[0] === '' ? moment().subtract(7, 'day').toDate() : daterange[0],
|
77
|
|
- // })
|
78
|
|
-
|
79
|
|
- }
|
80
|
|
-
|
81
|
|
- onSuccess = e => {
|
82
|
|
- this.setState({ dataSoures: e }, () => {
|
83
|
|
- this.onTabledatas(e)
|
84
|
|
- })
|
85
|
|
- }
|
86
|
|
-
|
87
|
|
- onTabledatas = (e) => {
|
88
|
|
- console.log('this.state.userType: ', this.state.userType)
|
89
|
|
- e.tdWxDicts.map(x => {
|
90
|
|
- columns = columns.filter(y => y.key != x.sceneType).concat({
|
91
|
|
- title: x.sceneAlias,
|
92
|
|
- dataIndex: x.sceneType,
|
93
|
|
- key: x.sceneType,
|
94
|
|
- })
|
|
73
|
+ this.getTableData(daterange[0] === '' ? moment().subtract(7, 'day').toDate() : daterange[0],daterange[1] === '' ? new Date() : daterange[1],this.state.buildingId)
|
|
74
|
+ this.setState({
|
|
75
|
+ ...this.state,
|
|
76
|
+ endDate: daterange[1] === '' ? new Date() : daterange[1],
|
|
77
|
+ startDate: daterange[0] === '' ? moment().subtract(7, 'day').toDate() : daterange[0],
|
95
|
78
|
})
|
96
|
|
- const data = (e.list || []).reduce((acc, item) => {
|
97
|
|
- const { sceneType, fromNum, registeredNum, createTime } = item
|
98
|
|
- const num = this.state.userType === 'registered' ? registeredNum : fromNum
|
99
|
|
- acc[createTime] = { ...acc[createTime], ...item, [`${sceneType}`]: !num ? 0 : num }
|
100
|
|
- return acc
|
101
|
|
- }, {})
|
102
|
|
-
|
103
|
|
- const dictData = e.tdWxDicts.reduce((acc,item,index) => {
|
104
|
|
- const { sceneType } = item
|
105
|
|
- acc[sceneType] = 0
|
106
|
|
- return acc
|
107
|
|
- },{})
|
108
|
|
-
|
109
|
|
- const tableData = Object.keys(data).map(k => data[k]).reduce((acc,item,index) => {
|
110
|
|
- acc[index] = { ...dictData, ...item }
|
111
|
|
- return acc
|
112
|
|
- },[])
|
113
|
|
-
|
114
|
|
- this.setState({ tableData })
|
115
|
|
-
|
|
79
|
+
|
116
|
80
|
}
|
117
|
|
-
|
118
|
|
- handleSelectChange = (e) => {
|
119
|
|
- this.setState({ userType: e }, () => {
|
120
|
|
- this.onTabledatas(this.state.dataSoures)
|
121
|
|
- })
|
|
81
|
+
|
|
82
|
+ //切换楼盘信息
|
|
83
|
+ handleBuildingChange = (e) => {
|
|
84
|
+ this.getTableData(this.state.startDate,this.state.endDate,e)
|
|
85
|
+ this.setState({...this.state, buildingId: e})
|
122
|
86
|
}
|
123
|
87
|
|
124
|
88
|
render() {
|
|
@@ -159,10 +123,7 @@ class buildingStats extends React.Component {
|
159
|
123
|
</Col>
|
160
|
124
|
</Row>
|
161
|
125
|
|
162
|
|
- <Select style={{ width: '180px' }} placeholder="所有用户" onChange={(e) => this.handleSelectChange(e)}>
|
163
|
|
- <Option value='all'>所有用户</Option>
|
164
|
|
- <Option value='registered'>注册用户</Option>
|
165
|
|
- </Select>
|
|
126
|
+ <BuildSelect slot='action' onChange={(e => this.handleBuildingChange(e))} value={this.state.buildingId}></BuildSelect>
|
166
|
127
|
|
167
|
128
|
{/* <Table style={{marginTop:'20px'}} dataSource={this.state.tableData} columns={columns} pagination={false} scroll={{ y: 500 }}></Table> */}
|
168
|
129
|
</div>
|