Bladeren bron

新需求

傅行帆 5 jaren geleden
bovenliggende
commit
2938794103

+ 6
- 0
config/routes.js Bestand weergeven

@@ -557,6 +557,12 @@ export default [
557 557
                 name: '项目统计',
558 558
                 component: './statistical/building/index',
559 559
               },
560
+              {
561
+                path: '/statistical/building/detail',
562
+                name: '项目统计详情',
563
+                component: './statistical/building/detail',
564
+                hideInMenu: true,
565
+              },
560 566
               {
561 567
                 path: '/statistical/consultant/index',
562 568
                 name: '置业顾问KPI',

+ 84
- 0
src/pages/statistical/building/component/StatsChartLine.jsx Bestand weergeven

@@ -0,0 +1,84 @@
1
+import React, { Component, useState, useEffect } from 'react';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions } from 'antd';
3
+import moment from 'moment';
4
+import echarts from 'echarts/lib/echarts';
5
+import EChart from '../../../../components/EchartsTest/EChart';
6
+import router from 'umi/router';
7
+
8
+class StatsChart extends React.Component {
9
+
10
+  constructor(props) {
11
+    super(props)
12
+    this.state = {}
13
+  }
14
+
15
+  render() {
16
+    const { data = {}} = this.props
17
+    const options = {
18
+      title: {
19
+          text: this.props.title,
20
+      },
21
+      tooltip: {
22
+          trigger: 'axis'
23
+      },
24
+      legend: {
25
+          data: ['公客数', '私客数', '新增客户数', '访问人数']
26
+      },
27
+      grid: {
28
+          left: '3%',
29
+          right: '4%',
30
+          bottom: '3%',
31
+          containLabel: true
32
+      },
33
+      toolbox: {
34
+          feature: {
35
+              saveAsImage: {}
36
+          }
37
+      },
38
+      xAxis: {
39
+          type: 'category',
40
+          boundaryGap: false,
41
+          axisLabel: {rotate: 45},
42
+          data: data.timeList || []
43
+      },
44
+      yAxis: {
45
+          type: 'value'
46
+      },
47
+      series: [
48
+          {
49
+              name: '公客数',
50
+              type: 'line',
51
+              stack: '总量',
52
+              data: data.gkList || []
53
+          },
54
+          {
55
+              name: '私客数',
56
+              type: 'line',
57
+              stack: '总量',
58
+              data: data.skList || []
59
+          },
60
+          {
61
+              name: '新增客户数',
62
+              type: 'line',
63
+              stack: '总量',
64
+              data: data.khList || []
65
+          },
66
+          {
67
+              name: '访问人数',
68
+              type: 'line',
69
+              stack: '总量',
70
+              data: data.uvList || []
71
+          }
72
+      ]
73
+  };
74
+  
75
+
76
+    return (
77
+    <>
78
+      <EChart options={options} style={{ width: '100%', height: '400px', }} />
79
+    </>
80
+    )
81
+  }
82
+}
83
+
84
+export default StatsChart

+ 180
- 0
src/pages/statistical/building/detail.jsx Bestand weergeven

@@ -0,0 +1,180 @@
1
+import React, { Component, useState, useEffect } from 'react';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions } from 'antd';
3
+import moment from 'moment';
4
+import EChart from '../../../components/EchartsTest/EChart';
5
+import request from '../../../utils/request';
6
+import apis from '../../../services/apis';
7
+import StatsChartLine from './component/StatsChartLine';
8
+import BuildSelect from '../../../components/SelectButton/BuildSelect'
9
+import router from 'umi/router';
10
+
11
+
12
+const { RangePicker } = DatePicker;
13
+const { Option } = Select
14
+
15
+let daterange = []
16
+let tableTitle = ['类型']
17
+
18
+class buildingDetailStats extends React.Component {
19
+
20
+  constructor(props) {
21
+    super(props)
22
+    this.state = {
23
+      barData: {},
24
+      tableData: [],
25
+      total: 0,
26
+      userType: 'all',
27
+      endDate: {},
28
+      startDate: {},
29
+      buildingId: props.location.query.buildingId,
30
+      buildingName: props.location.query.buildingName,
31
+    }
32
+  }
33
+
34
+  componentDidMount() {
35
+    this.getTimeBarDate(moment().subtract(7, 'day').toDate(),new Date())
36
+    this.getTimeTableData(moment().subtract(7, 'day').toDate(),new Date())
37
+    this.setState({...this.state, endDate: new Date(), startDate: moment().subtract(7, 'day').toDate() })
38
+    
39
+  }
40
+
41
+  // 获取图表数据
42
+  getTimeBarDate = (startDate, endDate) => {
43
+    request({ ...apis.stats.timeBarList, params: { startDate, endDate, buildingId: this.state.buildingId } }).then((data) => {
44
+        this.setState({...this.state, barData: data})
45
+      })
46
+  }
47
+
48
+  //获取表格数据
49
+  getTimeTableData = (startDate, endDate,pageNum,pageSize,sortField,sortOrder) => {
50
+    request({ ...apis.stats.timeTableList, params: { startDate, endDate, buildingId: this.state.buildingId,pageNum,pageSize,sortField,sortOrder } }).then((data) => {
51
+        this.setState({...this.state, tableData: data.records, total: data.total})
52
+      })
53
+  }
54
+
55
+  formatDate = (start, end) => {
56
+    const tempStartDate = `${moment(start).format('YYYY-MM-DDT00:00:00.000')}Z`
57
+    const tempEndDate = `${moment(end).format('YYYY-MM-DDT23:59:59.999')}Z`
58
+    return { startDate: tempStartDate, endDate: tempEndDate }
59
+  }
60
+
61
+  //时间选择器改变的时候
62
+  onChangetime = (_dates, dateStrings) => {
63
+    daterange[0] = `${moment(dateStrings[0]).format('YYYY-MM-DDT00:00:00.000')}Z`
64
+    daterange[1] = `${moment(dateStrings[1]).format('YYYY-MM-DDT23:59:59.999')}Z`
65
+  }
66
+
67
+  //切换三个标签页
68
+  getDataOf = (days) => {
69
+    this.getTimeBarDate(moment().subtract(days, 'day').toDate(),new Date())
70
+    this.getTimeTableData(moment().subtract(days, 'day').toDate(),new Date())
71
+    this.setState({ ...this.state, endDate: new Date(), startDate: moment().subtract(days, 'day').toDate() })
72
+  }
73
+
74
+  //点击查询
75
+  datalist = () => {
76
+    this.getTimeBarDate(daterange[0] === undefined ? moment().subtract(7, 'day').toDate() : daterange[0],daterange[1] === undefined ? new Date() : daterange[1])
77
+    this.getTimeTableData(daterange[0] === undefined ? moment().subtract(7, 'day').toDate() : daterange[0],daterange[1] === undefined ? new Date() : daterange[1])
78
+    this.setState({ 
79
+      ...this.state,
80
+      endDate: daterange[1] === undefined ? new Date() : daterange[1],
81
+      startDate: daterange[0] === undefined ? moment().subtract(7, 'day').toDate() : daterange[0],
82
+    })
83
+    
84
+  }
85
+
86
+  //排序
87
+  handleTableChange = (pagination, filters, sorter) => {
88
+    console.log(pagination, filters, sorter)
89
+    this.getTimeTableData(this.state.startDate,this.state.endDate,pagination.current,10,sorter.columnKey,sorter.order)
90
+  };
91
+
92
+  //导出
93
+  exportBuildingStats = () => {
94
+    request({ ...apis.stats.buildingExport, params: { startDate: this.state.startDate, endDate: this.state.endDate, buildingId: this.state.buildingId } })
95
+      .then(data => {
96
+        if (!data) {
97
+          return
98
+        }
99
+        const url = window.URL.createObjectURL(new Blob([data]))
100
+        const link = document.createElement('a')
101
+        link.style.display = 'none'
102
+        link.href = url
103
+        link.setAttribute('download', '项目统计.xlsx')
104
+        document.body.append(link)
105
+        link.click()
106
+      }).catch(() => {
107
+
108
+      })
109
+  }
110
+
111
+  render() {
112
+    const columns = [
113
+        {
114
+          title: '日期',
115
+          dataIndex: 'createDate',
116
+          key: 'createDate',
117
+        },
118
+        {
119
+          title: '新增客户',
120
+          dataIndex: 'khNum',
121
+          key: 'kh_num',
122
+          sorter: true,
123
+        },
124
+        {
125
+          title: '公客',
126
+          dataIndex: 'gkNum',
127
+          key: 'gk_num',
128
+          sorter: true,
129
+        },
130
+        {
131
+          title: '私客',
132
+          dataIndex: 'skNum',
133
+          key: 'sk_num',
134
+          sorter: true,
135
+        },
136
+        {
137
+            title: '访问人数',
138
+            dataIndex: 'uvNum',
139
+            key: 'uv_num',
140
+            sorter: true,
141
+        },
142
+      ];
143
+
144
+    return (
145
+    <div>
146
+      <Radio.Group buttonStyle="solid" defaultValue="a">
147
+          <Radio.Button value="c" onClick={() => this.getDataOf(0)}>今日</Radio.Button>
148
+          <Radio.Button value="a" onClick={() => this.getDataOf(7)}>最近7天</Radio.Button>
149
+          <Radio.Button value="b" onClick={() => this.getDataOf(30)}>最近1月</Radio.Button>
150
+        </Radio.Group>
151
+        <RangePicker
152
+          style={{ paddingLeft: '30px' }}
153
+          ranges={{
154
+            Today: [moment(), moment()],
155
+            'This Month': [moment().startOf('month'), moment().endOf('month')],
156
+          }}
157
+          onChange={(_dates, dateStrings) => this.onChangetime(_dates, dateStrings)}
158
+        />
159
+        <Button type="primary" htmlType="submit" style={{ marginLeft: '30px' }} onClick={() => this.datalist()}>
160
+          查询
161
+        </Button>
162
+        <Button type="danger" onClick={() => router.go(-1)} style={{ marginBottom: '18px', marginLeft: '30px' }}>重置</Button>
163
+
164
+        <StatsChartLine title={this.state.buildingName} data={this.state.barData} />
165
+        <Row>
166
+            <Col span={22}>
167
+              <span>详细数据</span>
168
+            </Col>
169
+            <Col span={2}>
170
+              <Button type="primary" onClick={this.exportBuildingStats}>导出</Button>
171
+            </Col>
172
+        </Row>
173
+        
174
+        <Table style={{marginTop:'20px'}} dataSource={this.state.tableData} columns={columns} pagination={{ total: this.state.total}} onChange={this.handleTableChange} scroll={{ y: 500 }}></Table>
175
+    </div>
176
+    )
177
+  }
178
+}
179
+
180
+export default buildingDetailStats

+ 18
- 6
src/pages/statistical/building/index.jsx Bestand weergeven

@@ -72,12 +72,12 @@ class buildingStats extends React.Component {
72 72
 
73 73
   //点击查询
74 74
   datalist = () => {
75
-    this.getBarData(daterange[0] === '' ? moment().subtract(7, 'day').toDate() : daterange[0],daterange[1] === '' ? new Date() : daterange[1])
76
-    this.getTableData(daterange[0] === '' ? moment().subtract(7, 'day').toDate() : daterange[0],daterange[1] === '' ? new Date() : daterange[1],this.state.buildingId)
75
+    this.getBarData(daterange[0] === undefined ? moment().subtract(7, 'day').toDate() : daterange[0],daterange[1] === undefined ? new Date() : daterange[1])
76
+    this.getTableData(daterange[0] === undefined ? moment().subtract(7, 'day').toDate() : daterange[0],daterange[1] === undefined ? new Date() : daterange[1],this.state.buildingId)
77 77
     this.setState({ 
78 78
       ...this.state,
79
-      endDate: daterange[1] === '' ? new Date() : daterange[1],
80
-      startDate: daterange[0] === '' ? moment().subtract(7, 'day').toDate() : daterange[0],
79
+      endDate: daterange[1] === undefined ? new Date() : daterange[1],
80
+      startDate: daterange[0] === undefined ? moment().subtract(7, 'day').toDate() : daterange[0],
81 81
     })
82 82
     
83 83
   }
@@ -113,6 +113,17 @@ class buildingStats extends React.Component {
113 113
       })
114 114
   }
115 115
 
116
+  //去详情页面
117
+  toDetailPage = (record) => {
118
+    router.push({
119
+      pathname: '/statistical/building/detail',
120
+      query: {
121
+        buildingId: record.buildingId,
122
+        buildingName: record.buildingName
123
+      },
124
+    });
125
+  }
126
+
116 127
   render() {
117 128
     const columns = [
118 129
         {
@@ -153,7 +164,7 @@ class buildingStats extends React.Component {
153 164
         {
154 165
             title: '详情',
155 166
             render: (_, record) => (
156
-                    <Button type="link" style={{ color: 'red' }} >查看详情</Button>
167
+                    <Button type="link" style={{ color: 'red' }} onClick={() => this.toDetailPage(record)}>查看详情</Button>
157 168
                 ),
158 169
         },
159 170
       ];
@@ -191,11 +202,12 @@ class buildingStats extends React.Component {
191 202
                 <StatsChart title="项目访问人数排行" subtext="项目详情访问情况" data={this.state.barData.wgBarMap} />
192 203
             </Col>
193 204
             <Col span={12}>
194
-                <StatsChart title="项目访问次数排行" subtext="项目详情访问情况" data={this.state.barData.fwBarMap} />
205
+                <StatsChart title="项目访问次数排行" subtext="项目详情访问情况,与上方时间筛选无关" data={this.state.barData.fwBarMap} />
195 206
             </Col>
196 207
         </Row>
197 208
         <Row>
198 209
             <Col span={22}>
210
+              <span style={{marginRight: '10px'}} >详细数据</span>
199 211
               <BuildSelect slot='action' onChange={(e => this.handleBuildingChange(e))} value={this.state.buildingId}></BuildSelect>
200 212
             </Col>
201 213
             <Col span={2}>

+ 11
- 1
src/services/apis.js Bestand weergeven

@@ -1596,6 +1596,16 @@ export default {
1596 1596
       method: 'GET',
1597 1597
       url: `${prefix}/stats/buildingExport`,
1598 1598
       action: 'admin.contract.list.get',
1599
-    }
1599
+    },
1600
+    timeBarList: {
1601
+      method: 'GET',
1602
+      url: `${prefix}/stats/timeBarList`,
1603
+      action: 'admin.contract.list.get',
1604
+    },
1605
+    timeTableList: {
1606
+      method: 'GET',
1607
+      url: `${prefix}/stats/timeTableList`,
1608
+      action: 'admin.contract.list.get',
1609
+    },
1600 1610
   }
1601 1611
 }