zlisen před 3 roky
rodič
revize
60e1565105

+ 6
- 4
src/pages/statistics/dataReport/components/Count.jsx Zobrazit soubor

@@ -67,12 +67,14 @@ const Count = props => {
67 67
         </Col>
68 68
         <Col span={4}>
69 69
           <Card>
70
-            {/* onClick={()=>router.push('/statistics/dataReport/newAdd')} style={{cursor:'pointer'}} */}
70
+            {/*  */}
71 71
             <Statistic
72
-              title="今日新增用户"
73
-              // title={<u></u>}
72
+              // title=""
73
+              title={<u  onClick={() => router.push('/statistics/dataReport/newAdd')}>今日新增用户</u>}
74
+             
75
+              style={{ cursor: 'pointer' }}
74 76
               value={data.todayAddPersonNum || 0}
75
-              //   valueStyle={{ color: '#cf1322' }}
77
+              valueStyle={{ color: '#cf1322' }}
76 78
             />
77 79
           </Card>
78 80
         </Col>

+ 2
- 4
src/pages/statistics/dataReport/components/NewUsers.jsx Zobrazit soubor

@@ -15,10 +15,8 @@ const formatDate = (start, end) => {
15 15
 };
16 16
 const NewUsers = props => {
17 17
   const {
18
-    startDate = moment()
19
-      .subtract(7, 'day')
20
-      .format('YYYY-MM-DD'),
21
-    endDate = moment().format('YYYY-MM-DD'),
18
+    startDate = moment().subtract(7, 'day').format('YYYY-MM-DDT00:00:00.000') + 'Z',
19
+    endDate = moment().format('YYYY-MM-DDT23:59:59.999') + 'Z',
22 20
     simple = false,
23 21
   } = props;
24 22
   const [data, setData] = useState({ records: [] });

+ 158
- 0
src/pages/statistics/dataReport/components/newUserTable.jsx Zobrazit soubor

@@ -0,0 +1,158 @@
1
+import React, { Component, useState, useEffect } from 'react';
2
+import {
3
+  Radio,
4
+  DatePicker,
5
+  Form,
6
+  Input,
7
+  Button,
8
+  Icon,
9
+  Select,
10
+  message,
11
+  Table,
12
+  Divider,
13
+  Tag,
14
+  Pagination,
15
+  Modal,
16
+  Breadcrumb,
17
+} from 'antd';
18
+import { Row, Col, Menu, Dropdown } from 'antd';
19
+
20
+// import XForm, { FieldTypes } from '../../components/XForm';
21
+import moment from 'moment';
22
+import router from 'umi/router';
23
+// import EChart from '../../components/EchartsTest/EChart';
24
+import request from '@/utils/request';
25
+import apis from '@/services/apis';
26
+
27
+const formatDate = (start, end) => {
28
+    const startDate = moment(start).format('YYYY-MM-DDT00:00:00.000') + 'Z';
29
+    const endDate = moment(end).format('YYYY-MM-DDT23:59:59.999') + 'Z';
30
+    return { startDate, endDate };
31
+  };
32
+
33
+let columns = [
34
+  {
35
+    title: '日期',
36
+    dataIndex: 'createTime',
37
+    key: 'createTime',
38
+  },
39
+];
40
+
41
+let daterange = [];
42
+
43
+const header = props => {
44
+  const {
45
+    startDate = moment().subtract(7, 'day').format('YYYY-MM-DDT00:00:00.000') + 'Z',
46
+    endDate = moment().format('YYYY-MM-DDT23:59:59.999') + 'Z',
47
+  } = props;
48
+  const [data, setData] = useState({ records: [] });
49
+
50
+  const [tableData, setTableData] = useState([]);
51
+//   const [endDate, setEndDate] = useState({});
52
+  const [userType, setUserType] = useState('all');
53
+//   const [startDate, setStartDate] = useState({});
54
+
55
+  useEffect(() => {
56
+    userResource({startDate, endDate,userType});
57
+  }, [startDate, endDate,userType]);
58
+
59
+  function userResource(params) {
60
+    request({
61
+      ...apis.indexEcharts.selectPersonFrom,
62
+      params,
63
+    }).then(data => {
64
+    //   setDate(data);
65
+      onTabledatas(data, 'all');
66
+    });
67
+  }
68
+
69
+  const onTabledatas = (e, changeType) => {
70
+    e.tdWxDicts.map(x => {
71
+      columns = columns
72
+        .filter(y => y.key != x.sceneType)
73
+        .concat({
74
+          title: x.sceneAlias,
75
+          dataIndex: x.sceneType,
76
+          key: x.sceneType,
77
+        });
78
+    });
79
+    const data = (e.list || []).reduce((acc, item) => {
80
+      const { sceneType, fromNum, registeredNum, createTime } = item;
81
+      const num = changeType === 'registered' ? registeredNum : fromNum;
82
+      acc[createTime] = { ...acc[createTime], ...item, [`${sceneType}`]: !num ? 0 : num };
83
+      return acc;
84
+    }, {});
85
+
86
+    const dictData = e.tdWxDicts.reduce((acc, item, index) => {
87
+      const { sceneType } = item;
88
+      acc[sceneType] = 0;
89
+      return acc;
90
+    }, {});
91
+
92
+    const tableData = Object.keys(data)
93
+      .map(k => data[k])
94
+      .reduce((acc, item, index) => {
95
+        acc[index] = { ...dictData, ...item };
96
+        return acc;
97
+      }, []);
98
+
99
+    setTableData(tableData);
100
+  };
101
+
102
+  function handleSelectChange(e) {
103
+    setUserType(e);
104
+  }
105
+
106
+  function exportUserStats() {
107
+    console.log(startDate, endDate, userType);
108
+    request({
109
+      ...apis.indexEcharts.exportUserStats,
110
+      params: { startDate, endDate, userType },
111
+    }).then(data => {
112
+      if (!data) {
113
+        return;
114
+      }
115
+      const url = window.URL.createObjectURL(new Blob([data]));
116
+      const link = document.createElement('a');
117
+      link.style.display = 'none';
118
+      link.href = url;
119
+      link.setAttribute('download', '新增用户.xlsx');
120
+      document.body.append(link);
121
+      link.click();
122
+    });
123
+  }
124
+
125
+  return (
126
+    <>
127
+      <div>
128
+        <Row>
129
+          <Col span={22}>
130
+            <Select
131
+              style={{ width: '180px' }}
132
+              placeholder="所有用户"
133
+              onChange={e => handleSelectChange(e)}
134
+            >
135
+              <Option value="all">所有用户</Option>
136
+              <Option value="registered">注册用户</Option>
137
+            </Select>
138
+          </Col>
139
+          <Col span={2}>
140
+            {/* <Button type="primary" onClick={exportUserStats}>
141
+              导出
142
+            </Button> */}
143
+          </Col>
144
+        </Row>
145
+
146
+        <Table
147
+          style={{ marginTop: '20px' }}
148
+          dataSource={tableData}
149
+          columns={columns}
150
+          pagination={false}
151
+          scroll={{ y: 500 }}
152
+        ></Table>
153
+      </div>
154
+    </>
155
+  );
156
+};
157
+
158
+export default header;

+ 13
- 8
src/pages/statistics/dataReport/newAdd.jsx Zobrazit soubor

@@ -18,19 +18,24 @@ import NewUsers from './components/NewUsers';
18 18
 import BuildingStatistic from './BuildingStatistic';
19 19
 import CityNums from './CityNums';
20 20
 import TimeSelect from '../compents/TimeSelect';
21
-import IntentionalCustomers from './components/IntentionalCustomers';
21
+import NewUserTable from './components/newUserTable';
22
+import moment  from 'moment';
22 23
 const newAdd = props => {
23 24
   const [data, setData] = useState([]);
24
-
25
-  const onTimeChange=()=>{
26
-
27
-  }
25
+  const [time, setTime] = useState({});
26
+  const onTimeChange = e => {
27
+    setTime({
28
+      startDate: moment(e[0]).format('YYYY-MM-DDT00:00:00.000') + 'Z',
29
+      endDate: moment(e[1]).format('YYYY-MM-DDT23:59:59.999') + 'Z',
30
+    });
31
+    // getData({ startDate: e[0], endDate: e[1] });
32
+  };
28 33
 
29 34
   return (
30 35
     <Card>
31
-      <TimeSelect onChange={onTimeChange}  ></TimeSelect>
32
-      <NewUsers simple={true}></NewUsers>
33
-      <IntentionalCustomers  simple={true}></IntentionalCustomers>
36
+      <TimeSelect onChange={onTimeChange}></TimeSelect>
37
+      <NewUsers startDate={time.startDate} endDate={time.endDate} simple={true}></NewUsers>
38
+      <NewUserTable startDate={time.startDate} endDate={time.endDate} simple={true}></NewUserTable>
34 39
     </Card>
35 40
   );
36 41
 };