|
@@ -16,20 +16,28 @@ import apis from '../../services/apis';
|
16
|
16
|
// return { startDate, endDate }
|
17
|
17
|
// }
|
18
|
18
|
|
|
19
|
+let columns = [
|
|
20
|
+ {
|
|
21
|
+ title: '日期',
|
|
22
|
+ dataIndex: 'createTime',
|
|
23
|
+ key: 'createTime',
|
|
24
|
+ },
|
|
25
|
+]
|
19
|
26
|
|
20
|
27
|
const header = props => {
|
21
|
28
|
|
22
|
|
- const [tableData, setTableData] = useState({ records: [] })
|
23
|
|
-
|
|
29
|
+ const [tableData, setTableData] = useState([])
|
24
|
30
|
const [endDate, setEndDate] = useState({})
|
|
31
|
+ const [data, setDate] = useState({})
|
25
|
32
|
const [startDate, setStartDate] = useState({})
|
26
|
33
|
let daterange= []
|
27
|
34
|
|
28
|
35
|
useEffect(() => {
|
29
|
36
|
|
30
|
37
|
setEndDate(new Date())
|
31
|
|
- setStartDate(moment().subtract(7, 'day').toDate())
|
32
|
|
-
|
|
38
|
+ setStartDate(new Date())
|
|
39
|
+ // setStartDate(moment().subtract(7, 'day').toDate())
|
|
40
|
+ userResource({startDate: new Date(), endDate: new Date()})
|
33
|
41
|
}, [])
|
34
|
42
|
|
35
|
43
|
const { RangePicker } = DatePicker;
|
|
@@ -52,7 +60,7 @@ const header = props => {
|
52
|
60
|
|
53
|
61
|
setEndDate(new Date())
|
54
|
62
|
setStartDate(moment().subtract(days, 'day').toDate())
|
55
|
|
-
|
|
63
|
+ userResource({startDate: moment().subtract(days, 'day').toDate(), endDate: new Date()})
|
56
|
64
|
}
|
57
|
65
|
|
58
|
66
|
function onChange (e) {
|
|
@@ -64,15 +72,53 @@ const header = props => {
|
64
|
72
|
|
65
|
73
|
setEndDate(daterange[1])
|
66
|
74
|
setStartDate(daterange[0])
|
|
75
|
+ userResource({startDate: daterange[0], endDate: daterange[1]})
|
67
|
76
|
|
68
|
77
|
}
|
69
|
78
|
|
70
|
|
-
|
71
|
|
- function handleSelectChange (e) {
|
|
79
|
+ function userResource(params) {
|
|
80
|
+ request({
|
|
81
|
+ ...apis.indexEcharts.selectPersonFrom,
|
|
82
|
+ params,
|
|
83
|
+ }).then((data) => {
|
|
84
|
+ setDate(data);
|
|
85
|
+ onTabledatas(data,"all")
|
|
86
|
+ })
|
|
87
|
+ }
|
72
|
88
|
|
73
|
|
- console.log(e)
|
|
89
|
+ const onTabledatas = (e,changeType) => {
|
|
90
|
+ e.tdWxDicts.map(x => {
|
|
91
|
+ columns = columns.filter(y => y.key != x.sceneType).concat({
|
|
92
|
+ title: x.sceneAlias,
|
|
93
|
+ dataIndex: x.sceneType,
|
|
94
|
+ key: x.sceneType,
|
|
95
|
+ })
|
|
96
|
+ })
|
|
97
|
+ const data = (e.list || []).reduce((acc, item) => {
|
|
98
|
+ const { sceneType, fromNum, registeredNum, createTime } = item
|
|
99
|
+ const num = changeType === 'registered' ? registeredNum : fromNum
|
|
100
|
+ acc[createTime] = { ...acc[createTime], ...item, [`${sceneType}`]: !num ? 0 : num }
|
|
101
|
+ return acc
|
|
102
|
+ }, {})
|
|
103
|
+
|
|
104
|
+ const dictData = e.tdWxDicts.reduce((acc,item,index) => {
|
|
105
|
+ const { sceneType } = item
|
|
106
|
+ acc[sceneType] = 0
|
|
107
|
+ return acc
|
|
108
|
+ },{})
|
|
109
|
+
|
|
110
|
+ const tableData = Object.keys(data).map(k => data[k]).reduce((acc,item,index) => {
|
|
111
|
+ acc[index] = { ...dictData, ...item }
|
|
112
|
+ return acc
|
|
113
|
+ },[])
|
|
114
|
+
|
|
115
|
+ setTableData(tableData)
|
74
|
116
|
|
75
|
117
|
}
|
|
118
|
+
|
|
119
|
+ function handleSelectChange (e) {
|
|
120
|
+ onTabledatas(data,e)
|
|
121
|
+ }
|
76
|
122
|
|
77
|
123
|
const { Column, ColumnGroup } = Table;
|
78
|
124
|
|
|
@@ -84,7 +130,8 @@ const header = props => {
|
84
|
130
|
borderRadius: '12px',
|
85
|
131
|
minHeight: '60vh'
|
86
|
132
|
}}>
|
87
|
|
- <Radio.Group onChange={onChange} buttonStyle="solid" defaultValue="a" style={{marginBottom:'20px'}}>
|
|
133
|
+ <Radio.Group onChange={onChange} buttonStyle="solid" defaultValue="c" style={{marginBottom:'20px'}}>
|
|
134
|
+ <Radio.Button value="c" onClick={getDataOf(0)}>今日</Radio.Button>
|
88
|
135
|
<Radio.Button value="a" onClick={getDataOf(7)}>最近7天</Radio.Button>
|
89
|
136
|
<Radio.Button value="b" onClick={getDataOf(30)}>最近1月</Radio.Button>
|
90
|
137
|
</Radio.Group>
|
|
@@ -105,6 +152,12 @@ const header = props => {
|
105
|
152
|
<div>
|
106
|
153
|
<NewUsers BuildSelectHide={true} endDate={endDate} startDate={startDate} dataZoom={true} ></NewUsers>
|
107
|
154
|
{/* */}
|
|
155
|
+ <Select style={{ width: '180px' }} placeholder="所有用户" onChange={(e) => handleSelectChange(e)}>
|
|
156
|
+ <Option value='all'>所有用户</Option>
|
|
157
|
+ <Option value='registered'>注册用户</Option>
|
|
158
|
+ </Select>
|
|
159
|
+
|
|
160
|
+ <Table style={{marginTop:'20px'}} dataSource={tableData} columns={columns} pagination={false} scroll={{ y: 500 }}></Table>
|
108
|
161
|
</div>
|
109
|
162
|
</div>
|
110
|
163
|
</>
|