许静 hace 5 años
padre
commit
a0449f4864

+ 96
- 18
src/pages/indexEcharts/components/UserBehavior.jsx Ver fichero

@@ -18,7 +18,7 @@ const formatDate = (start, end) => {
18 18
 const UserBehavior = (props) => {
19 19
 
20 20
   const [data, setData] = useState({ records: [] })
21
-  const [datas, setDatas] = useState({ records: [] })
21
+
22 22
 
23 23
 
24 24
   //柱图
@@ -31,10 +31,10 @@ const UserBehavior = (props) => {
31 31
       event: props.event,
32 32
       eventType: props.eventType
33 33
     })
34
-    getUserBehaviorProfile(formatDate(props.startDate, props.endDate))
34
+    // getUserBehaviorProfile(formatDate(props.startDate, props.endDate))
35 35
 
36 36
   }, [props.startDate, props.endDate, props.activity, props.event, props.eventType])
37
-
37
+  const [recordList, setList] = useState([])
38 38
   function getUserBehaviorSummary(params) {
39 39
 
40 40
 
@@ -42,24 +42,13 @@ const UserBehavior = (props) => {
42 42
       ...apis.indexEcharts.userBehavior.summary,
43 43
       params
44 44
     }).then((data) => {
45
+
45 46
       setData(data || {})
47
+      setList(data.data.records || [])
46 48
 
47 49
     })
48 50
   }
49 51
 
50
-  function getUserBehaviorProfile(row) {
51
-
52
-    setData([])
53
-    request({
54
-      ...apis.indexEcharts.userBehavior.profile,
55
-      params: { event: row.event, personId: row.personId }
56
-    }).then((data) => {
57
-
58
-      setData(data)
59
-
60
-    })
61
-
62
-  }
63 52
 
64 53
   const seriesMaker = (data.selectUserBehavior || []).reduce((series, item) => {
65 54
     let { date, activityCount, activity } = item
@@ -120,11 +109,95 @@ const UserBehavior = (props) => {
120 109
     height: '400px',
121 110
 
122 111
   }
112
+  const eventcolumns = [
113
+    {
114
+      title: '编号',
115
+      dataIndex: 'recordId',
116
+      key: 'recordId',
117
+      align: 'center',
118
+      width: '16%'
119
+
120
+    },
121
+    {
122
+      title: '访问时间',
123
+      dataIndex: 'visitTime',
124
+      key: 'visitTime',
125
+      align: 'center',
126
+      width: '18%'
127
+
128
+    },
129
+    {
130
+      title: '离开时间',
131
+      dataIndex: 'userName',
132
+      key: 'userName',
133
+      align: 'center',
134
+      width: '18%'
135
+
136
+    },
137
+  ]
138
+
139
+  const columns = [
140
+    {
141
+      title: '访问事件',
142
+      dataIndex: 'eventName',
143
+      key: 'eventName',
144
+      align: 'center',
145
+      width: '16%'
146
+
147
+    },
148
+    {
149
+      title: '访问用户',
150
+      dataIndex: 'userName',
151
+      key: 'userName',
152
+      align: 'center',
153
+      width: '15%'
154
+
155
+    },
156
+    {
157
+      title: '访问次数',
158
+      dataIndex: 'accessCount',
159
+      key: 'accessCount',
160
+      align: 'center',
161
+      width: '17%',
162
+
163
+      render: (x, row) => (
164
+        <>
165
+          <span style={{ color: '#EF273A', cursor: 'pointer' }} onClick={() => showDetails(row)}> {row.accessCount}</span>
166
+        </>
167
+      ),
168
+    },
169
+    {
170
+      title: '首次访问时间',
171
+      dataIndex: 'visitTime',
172
+      key: 'visitTime',
173
+      align: 'center',
174
+      width: '18%'
175
+    },
176
+    {
177
+      title: '离开时间',
178
+      dataIndex: 'leaveTime',
179
+      key: 'leaveTime',
180
+      width: '18%',
181
+      align: 'center',
182
+    },
183
+  ];
184
+  // 点击访问次数查看详情
185
+  const [eventList, seEventtList] = useState([])
186
+  
187
+  function showDetails(row) {
188
+    seEventtList([])
189
+    request({
190
+      ...apis.indexEcharts.userBehavior.profile,
191
+      params: { event: row.event, personId: row.personId }
192
+    }).then((data) => {
193
+      seEventtList(data)
194
+    })
195
+  }
196
+
123 197
 
124 198
   return (
125 199
     <>
126 200
       <div>
127
-        {/* onSuccess={(e) => onTabledatas(e)} */}
128 201
         <p onClick={() => router.push('/indexEcharts/userBehavior')}>
129 202
           <span style={{ borderBottom: '1px solid #f02d40', color: '#333', fontSize: '0.12rem', fontWeight: '600' }}>用户行为</span>
130 203
           {!props.BuildSelectHide && <span style={{ fontSize: '0.09rem', color: '#888', marginLeft: '0.06rem' }}>最近七天</span>}
@@ -133,7 +206,12 @@ const UserBehavior = (props) => {
133 206
           {!props.BuildSelectHide && <BuildSelect slot='action' onChange={(e => handleBuildingChange(e))}></BuildSelect>}
134 207
         </div>
135 208
         <EChart onClick={() => router.push('/indexEcharts/userBehavior')} options={options} style={style} />
136
-
209
+        {props.tableShow &&
210
+          <Table dataSource={recordList} columns={columns} pagination={false} rowKey="userbehavior" scroll={{ y: 500 }} />
211
+        }
212
+        {props.tableShow &&
213
+          <Table dataSource={eventList} columns={eventcolumns} pagination={false} rowKey="eventall" scroll={{ y: 400 }} />
214
+        }
137 215
       </div>
138 216
 
139 217
     </>

+ 1
- 1
src/pages/indexEcharts/index.jsx Ver fichero

@@ -41,7 +41,7 @@ const indexEcharts = (props) => {
41 41
       <CityNums></CityNums>
42 42
       </div>
43 43
       <div className={styles.behavior}>
44
-        <UserBehavior endDate={endDate} startDate={startDate} dataZoom={false}></UserBehavior>
44
+        <UserBehavior tableShow={false} endDate={endDate} startDate={startDate} dataZoom={false}></UserBehavior>
45 45
       </div>
46 46
       <div style={{ display: 'flex' }}>
47 47
         <div className={styles.bar}>

+ 17
- 3
src/pages/indexEcharts/userBehavior.jsx Ver fichero

@@ -30,8 +30,22 @@ const header = props => {
30 30
     getBizEventType()
31 31
     getBizEventList()
32 32
     getProperties()
33
-
33
+  
34
+    
34 35
   }, [])
36
+ 
37
+
38
+function getUserBehaviorSummary(params) {
39
+
40
+
41
+  request({
42
+    ...apis.indexEcharts.userBehavior.summary,
43
+    params
44
+  }).then((data) => {
45
+    setData(data || {})
46
+
47
+  })
48
+}
35 49
   const [eventypes, setEventTypes] = useState([])
36 50
   function getBizEventType(row) {
37 51
 
@@ -192,10 +206,10 @@ const header = props => {
192 206
 
193 207
 
194 208
       <div style={{ margin: '24px 0' }}>
195
-        <UserBehavior BuildSelectHide={true} endDate={endDate} startDate={startDate}  eventType={eventType} activity={activity}  event={event} dataZoom={true} onReData={(e) => redata(e)}></UserBehavior>
209
+        <UserBehavior tableShow={true} BuildSelectHide={true} endDate={endDate} startDate={startDate}  eventType={eventType} activity={activity}  event={event} dataZoom={true} onReData={(e) => redata(e)}></UserBehavior>
196 210
       </div>
197 211
 
198
-      <Table dataSource={dataSource} columns={columns} pagination={false} scroll={{ y: 500 }} />
212
+      {/* <Table dataSource={dataSource} columns={columns} pagination={false} scroll={{ y: 500 }} /> */}
199 213
     </div>
200 214
   </>
201 215
   )