Selaa lähdekoodia

新增用户折线图

傅行帆 5 vuotta sitten
vanhempi
commit
92c1f79bbc

+ 1
- 1
src/pages/Welcome.jsx Näytä tiedosto

@@ -64,7 +64,7 @@ const welcome = (props) => {
64 64
             boxShadow: '0px  0.106rem 14px -15px rgba(107,130,230,1)',
65 65
             borderRadius: '12px', width: '32%',
66 66
           }}>
67
-            <span style={{ fontSize: '24px', color: '#fff', borderBottom: '1px solid #fff', margin: '30px 0', cursor: 'pointer' }}>最近7天新增 </span>
67
+            <span style={{ fontSize: '24px', color: '#fff', borderBottom: '1px solid #fff', margin: '30px 0', cursor: 'pointer' }}>今日新增用户 </span>
68 68
             <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy', lineHeight: '100px' }}>{data.selectRecentlyCount || '0'}</span>
69 69
           </div>
70 70
         }

+ 28
- 2
src/pages/indexEcharts/components/IntentionalCustomers.jsx Näytä tiedosto

@@ -88,12 +88,38 @@ const UserBehavior = (props) => {
88 88
     IntentionUsers({  pageNum: 1, pageSize: 5, buildingId: e })
89 89
     setBuildingId(e)
90 90
   }
91
+
92
+  //意向客户导出
93
+  function exportIntentionUsers () {
94
+    request({
95
+      ...apis.indexEcharts.exportIntentionUsers,
96
+      params: { buildingId }
97
+    }).then((data) => {
98
+      if (!data) {
99
+        return
100
+      }
101
+      const url = window.URL.createObjectURL(new Blob([data]))
102
+      const link = document.createElement('a')
103
+      link.style.display = 'none'
104
+      link.href = url
105
+      link.setAttribute('download', '意向客户.xlsx')
106
+      document.body.append(link)
107
+      link.click()
108
+    })
109
+  }
110
+
91 111
   return (
92 112
     <>
93 113
       <div>
94 114
       <p style={{fontSize:'0.12rem',fontWeight:'600'}}>意向客户</p>
95
-
96
-        <BuildSelect slot='action' onChange={(e => handleBuildingChange(e))} value={buildingId}></BuildSelect>
115
+        <Row>
116
+          <Col span={22}>
117
+            <BuildSelect slot='action' onChange={(e => handleBuildingChange(e))} value={buildingId}></BuildSelect>
118
+          </Col>
119
+          <Col span={2}>
120
+            <Button type="primary" onClick={exportIntentionUsers}>导出</Button>
121
+          </Col>
122
+        </Row>
97 123
 
98 124
         <Table rowKey="IntentionalCustomers" dataSource={data.records} columns={columns} style={{marginTop:'15px'}} pagination={{ total: data.total, defaultPageSize: 5, onChange: e => onChange(e) }} scroll={{ y: 500 }} />
99 125
 

+ 3
- 3
src/pages/indexEcharts/components/NewUsers.jsx Näytä tiedosto

@@ -24,7 +24,7 @@ const NewUsers = (props) => {
24 24
 
25 25
   function NewsUserCount (params) {
26 26
     request({
27
-      ...apis.indexEcharts.newUser,
27
+      ...apis.indexEcharts.changeNewUser,
28 28
       params,
29 29
     }).then((data) => {
30 30
       setData(data)
@@ -43,7 +43,7 @@ const NewUsers = (props) => {
43 43
       end: 100
44 44
     },
45 45
   ] : undefined 
46
-  const dataset = (data.selectNewsUserCount) || []
46
+  const dataset = data || []
47 47
   const options = {
48 48
 
49 49
    
@@ -74,7 +74,7 @@ const NewUsers = (props) => {
74 74
         }
75 75
       ],
76 76
       dataset: {
77
-        dimensions: ['date', 'userCount', 'authorizationCount'],
77
+        dimensions: ['createTime', 'fromNum', 'registeredNum'],
78 78
         source: dataset
79 79
       }
80 80
  

+ 62
- 9
src/pages/indexEcharts/newUsers.jsx Näytä tiedosto

@@ -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
   </>

+ 10
- 2
src/services/apis.js Näytä tiedosto

@@ -399,6 +399,11 @@ export default {
399 399
       url: `${prefix}/selectNewsUserCount`,
400 400
       action: 'selectNewsUserCount',
401 401
     },
402
+    changeNewUser: {
403
+      method: 'GET',
404
+      url: `${prefix}/changeNewsUserCount`,
405
+      action: 'selectNewsUserCount',
406
+    },
402 407
     userConversion: {
403 408
       method: 'GET',
404 409
       url: `${prefix}/selectConversion`,
@@ -419,8 +424,11 @@ export default {
419 424
       url: `${prefix}/listNoticeByCondition`,
420 425
       action: 'listNoticeByCondition',
421 426
     },
422
-
423
-
427
+    exportIntentionUsers: {
428
+      method: 'GET',
429
+      url: `${prefix}/exportIntentionUser`,
430
+      action: 'exportIntentionUser',
431
+    },
424 432
   },
425 433
   activity: {
426 434
     list: {