fangmingyue 2 年之前
父節點
當前提交
2eec6f4320

+ 101
- 62
src/pages/home/components/AssignedCharts.jsx 查看文件

@@ -1,74 +1,113 @@
1
-import React from 'react';
1
+import React, { useState } from 'react';
2 2
 import { Card } from 'antd';
3 3
 import * as echarts from 'echarts/core';
4
+import RangeDate from './RangeDate';
5
+import * as dayjs from 'dayjs';
4 6
 import Chart from '@/components/chart';
7
+import { getStatIssue } from "@/service/stat";
5 8
 
6
-export default (props) => {
7
-  const option = {
8
-    title: {
9
-      text: '上报统计'
10
-    },
11
-    tooltip: {
12
-      trigger: 'axis',
13
-      axisPointer: {
14
-        type: 'cross',
15
-        label: {
16
-          backgroundColor: '#0A9071'
17
-        }
18
-      }
19
-    },
20
-    grid: {
21
-      left: '3%',
22
-      bottom: '3%',
23
-      width: '90%',
24
-      containLabel: true
25
-    },
26
-    xAxis: [
27
-      {
28
-        type: 'category',
29
-        boundaryGap: false,
30
-        data: ['12/01', '12/02', '12/03', '12/04', '12/05', '12/06', '12/07']
31
-      }
32
-    ],
33
-    yAxis: [
34
-      {
35
-        type: 'value',
36
-        minInterval: 1
37
-      }
38
-    ],
39
-    series: [
40
-      {
41
-        type: 'line',
42
-        stack: 'Total',
43
-        smooth: true,
44
-        lineStyle: {
45
-          width: 0
46
-        },
47
-        showSymbol: false,
48
-        areaStyle: {
49
-          opacity: 1,
50
-          color: new echarts.graphic.LinearGradient(0, 0, 0, 1.1, [
51
-            {
52
-              offset: 0,
53
-              color: '#0A9071'
54
-            },
55
-            {
56
-              offset: 1,
57
-              color: '#FFF'
9
+export default React.forwardRef((props, ref) => {
10
+  const [option, setOption] = useState({});
11
+
12
+  const [condition, setCondition] = useState();
13
+
14
+  React.useEffect(() => {
15
+    if (!condition) return;
16
+
17
+    getStatIssue(condition).then((res) => {
18
+      setOption({
19
+        tooltip: {
20
+          trigger: 'axis',
21
+          axisPointer: {
22
+            type: 'cross',
23
+            label: {
24
+              backgroundColor: '#0A9071'
58 25
             }
59
-          ])
26
+          }
60 27
         },
61
-        emphasis: {
62
-          focus: 'series'
28
+        grid: {
29
+          left: '3%',
30
+          bottom: '3%',
31
+          width: '92%',
32
+          height: '90%',
33
+          containLabel: true
63 34
         },
64
-        data: [1.8, 3.3, 1.9, 2.9, 2.1, 1.5, 2.3]
65
-      }
66
-    ]
67
-  };
35
+        xAxis: [
36
+          {
37
+            type: 'category',
38
+            boundaryGap: false,
39
+            data: res.map(x => x.name)
40
+          }
41
+        ],
42
+        yAxis: [
43
+          {
44
+            type: 'value',
45
+            minInterval: 1
46
+          }
47
+        ],
48
+        series: [
49
+          {
50
+            type: 'line',
51
+            stack: 'Total',
52
+            smooth: true,
53
+            lineStyle: {
54
+              width: 0
55
+            },
56
+            showSymbol: false,
57
+            areaStyle: {
58
+              opacity: 1,
59
+              color: new echarts.graphic.LinearGradient(0, 0, 0, 1.1, [
60
+                {
61
+                  offset: 0,
62
+                  color: '#0A9071'
63
+                },
64
+                {
65
+                  offset: 1,
66
+                  color: '#FFF'
67
+                }
68
+              ])
69
+            },
70
+            emphasis: {
71
+              focus: 'series'
72
+            },
73
+            data: res.map(x => x.name)
74
+          }
75
+        ]
76
+      })
77
+    })
78
+  }, [condition]);
79
+
80
+  const onChange = (dt, typ) => {
81
+    if (typ == 1) {
82
+      setCondition({
83
+        num: 7,
84
+        statType: 'issue_daily',
85
+        startDate: dt[0].format('YY-MM-DD'),
86
+        endDate: dt[1].format('YY-MM-DD'),
87
+      })
88
+    } else if (typ == 2) {
89
+      setCondition({
90
+        num: dt[0].daysInMonth(),
91
+        statType: 'issue_daily',
92
+        startDate: dt[0].format('YY-MM-DD'),
93
+        endDate: dt[1].format('YY-MM-DD'),
94
+      })
95
+    } else if (typ == 3) {
96
+      setCondition({
97
+        num: 365,
98
+        statType: 'issue_daily',
99
+        startDate: dt[0].format('YY-MM-DD'),
100
+        endDate: dt[1].format('YY-MM-DD'),
101
+      })
102
+    }
103
+
104
+    console.log('dt天数', dt[0].format('MM-DD'));
105
+    // console.log('dt,typ', dt, typ);
106
+  }
68 107
 
69 108
   return (
70
-    <Card title="上报统计">
109
+    <Card title="上报统计" extra={<RangeDate onChange={onChange} />}>
71 110
       <Chart option={option} style={props.style}></Chart>
72 111
     </Card>
73 112
   )
74
-}
113
+});

+ 16
- 7
src/pages/home/components/Banner.jsx 查看文件

@@ -1,28 +1,37 @@
1
-import React from 'react';
2
-import { UserOutlined } from '@ant-design/icons';
3
-import { Row, Col, Card, Statistic, Space } from 'antd';
1
+import React, { useState } from 'react';
2
+import { UserOutlined, ShrinkOutlined, DoubleRightOutlined, CarryOutOutlined } from '@ant-design/icons';
3
+import { Row, Col, Card, Statistic } from 'antd';
4
+import { getStatBanner } from "@/service/stat";
4 5
 
5 6
 export default (props) => {
7
+  const [sum, setSum] = useState({});
8
+  React.useEffect(() => {
9
+    getStatBanner().then((res) => {
10
+      // console.log('user', res)
11
+      setSum(res)
12
+    });
13
+  }, [0]);
14
+
6 15
   return (
7 16
     <Row gutter={24}>
8 17
       <Col span={6}>
9 18
         <Card>
10
-          <Statistic prefix={<UserOutlined />} title="注册用户" value={580239} />
19
+          <Statistic prefix={<UserOutlined />} title="注册用户" value={sum.user_num} />
11 20
         </Card>
12 21
       </Col>
13 22
       <Col span={6}>
14 23
         <Card>
15
-          <Statistic prefix={<UserOutlined />} title="待处理问题单数" value={580239} />
24
+          <Statistic prefix={<ShrinkOutlined />} title="待处理问题单数" value={sum.published_num} />
16 25
         </Card>
17 26
       </Col>
18 27
       <Col span={6}>
19 28
         <Card>
20
-          <Statistic prefix={<UserOutlined />} title="待处理中问题单数" value={580239} />
29
+          <Statistic prefix={<DoubleRightOutlined />} title="处理中问题单数" value={sum.assigned_num} />
21 30
         </Card>
22 31
       </Col>
23 32
       <Col span={6}>
24 33
         <Card>
25
-          <Statistic prefix={<UserOutlined />} title="已办结问题单数" value={580239} />
34
+          <Statistic prefix={<CarryOutOutlined />} title="已办结问题单数" value={sum.unassigned_num} />
26 35
         </Card>
27 36
       </Col>
28 37
     </Row>

+ 83
- 55
src/pages/home/components/EscalationCharts.jsx 查看文件

@@ -1,66 +1,94 @@
1
-import React from 'react';
2
-import { Card } from 'antd';
1
+import React, { useState } from 'react';
2
+import { Card, Select } from 'antd';
3 3
 import * as echarts from 'echarts/core';
4 4
 import Chart from '@/components/chart';
5
+import { getStatEscalation } from "@/service/stat";
6
+import { getSysOrg } from "@/service/sysorg";
5 7
 
6 8
 export default (props) => {
9
+  const [option, setOption] = useState({});
10
+  // const [id, setId] = useState({});
11
+  const [orgList, setOrgList] = useState([]);
12
+  const [orgId, setOrgId] = useState();
13
+  console.log('orgId', orgId);
7 14
 
8
-  const option = {
9
-    title: {
10
-      text: '交办统计'
11
-    },
12
-    tooltip: {
13
-      trigger: 'axis',
14
-      axisPointer: {
15
-        type: 'cross',
16
-        label: {
17
-          backgroundColor: '#F772D1'
18
-        }
19
-      }
20
-    },
21
-    grid: {
22
-      left: '3%',
23
-      bottom: '3%',
24
-      width: '90%',
25
-      containLabel: true
26
-    },
27
-    xAxis: [
28
-      {
29
-        type: 'category',
30
-        boundaryGap: false,
31
-        data: ['已处理', '未处理', '逾期'],
32
-        boundaryGap: true,
33
-        name: '状态',
34
-        axisTick: {
35
-          alignWithLabel: true,
36
-        }
37
-      }
38
-    ],
39
-    yAxis: [
40
-      {
41
-        type: 'value',
42
-        minInterval: 1,
43
-        name: '交办次数'
44
-      }
45
-    ],
46
-    series: [
47
-      {
48
-        type: 'bar',
49
-        barWidth: '15%',
50
-        itemStyle: {
51
-          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
52
-            { offset: 0, color: '#F772D1' },
53
-            { offset: 0.5, color: '#C872F2' },
54
-            { offset: 1, color: '#E5BEF8' }
55
-          ])
15
+  React.useEffect(() => {
16
+    getSysOrg({ pageSize: 500 }).then((res) => {
17
+      setOrgList(res.records || [])
18
+    })
19
+  }, []);
20
+
21
+  React.useEffect(() => {
22
+    getStatEscalation({ orgId: orgId }).then((res) => {
23
+      setOption({
24
+        tooltip: {
25
+          trigger: 'axis',
26
+          axisPointer: {
27
+            type: 'cross',
28
+            label: {
29
+              backgroundColor: '#F772D1'
30
+            }
31
+          }
56 32
         },
57
-        data: [2, 3, 1]
58
-      }
59
-    ]
60
-  };
33
+        grid: {
34
+          left: '3%',
35
+          bottom: '3%',
36
+          width: '90%',
37
+          height: '90%',
38
+          containLabel: true
39
+        },
40
+        xAxis: [
41
+          {
42
+            type: 'category',
43
+            data: res.map(x => x.name),
44
+            boundaryGap: true,
45
+            name: '状态',
46
+            axisTick: {
47
+              alignWithLabel: true,
48
+            }
49
+          }
50
+        ],
51
+        yAxis: [
52
+          {
53
+            type: 'value',
54
+            minInterval: 1,
55
+            name: '交办次数'
56
+          }
57
+        ],
58
+        series: [
59
+          {
60
+            type: 'bar',
61
+            barWidth: '15%',
62
+            itemStyle: {
63
+              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
64
+                { offset: 0, color: '#F772D1' },
65
+                { offset: 0.5, color: '#C872F2' },
66
+                { offset: 1, color: '#E5BEF8' }
67
+              ])
68
+            },
69
+            data: res.map(x => x.value),
70
+          }
71
+        ]
72
+      })
73
+    })
74
+  }, [orgId]);
61 75
 
62 76
   return (
63
-    <Card title="时间维度">
77
+    <Card
78
+      title="交办统计"
79
+      extra={
80
+        <Select style={{ width: "200px" }} placeholder="请选择单位" value={orgId} onChange={e => setOrgId(e)}>
81
+          {
82
+            orgList.map((item) => (
83
+              <Select.Option key={item.orgId} value={item.orgId}>
84
+                {item.name}
85
+              </Select.Option>
86
+            )
87
+            )
88
+          }
89
+        </Select>
90
+      }
91
+    >
64 92
       <Chart option={option} style={props.style}></Chart>
65 93
     </Card>
66 94
   )

+ 60
- 52
src/pages/home/components/ProblemCharts.jsx 查看文件

@@ -1,65 +1,73 @@
1
-import React from 'react';
1
+import React, { useState } from 'react';
2 2
 import { Card } from 'antd';
3 3
 import * as echarts from 'echarts/core';
4 4
 import Chart from '@/components/chart';
5
+import { getStatProblem } from "@/service/stat";
5 6
 
6 7
 export default (props) => {
7 8
 
8
-  const option = {
9
-    title: {
10
-      text: '问题分类'
11
-    },
12
-    tooltip: {
13
-      trigger: 'axis',
14
-      axisPointer: {
15
-        type: 'cross',
16
-        label: {
17
-          backgroundColor: '#FB9900'
18
-        }
19
-      }
20
-    },
21
-    grid: {
22
-      left: '3%',
23
-      bottom: '3%',
24
-      width: '90%',
25
-      containLabel: true
26
-    },
27
-    xAxis: [
28
-      {
29
-        type: 'category',
30
-        data: ['公益宣传', '环境卫生', '基础设施', '文明素养', '公共秩序', '其他'],
31
-        // boundaryGap: true,
32
-        axisTick: {
33
-          alignWithLabel: true,
9
+  const [option, setOption] = useState({});
10
+  console.log('---------->', option)
11
+
12
+  React.useEffect(() => {
13
+    getStatProblem().then((res) => {
14
+      console.log('====================>', res.map(x => x.name))
15
+      setOption({
16
+        tooltip: {
17
+          trigger: 'axis',
18
+          axisPointer: {
19
+            type: 'cross',
20
+            label: {
21
+              backgroundColor: '#FB9900'
22
+            }
23
+          }
34 24
         },
35
-        axisLabel: {
36
-          interval: 0,
37
-        }
38
-      }
39
-    ],
40
-    yAxis: [
41
-      {
42
-        type: 'value',
43
-        minInterval: 1
44
-      }
45
-    ],
46
-    series: [
47
-      {
48
-        type: 'bar',
49
-        barWidth: '20%',
50
-        itemStyle: {
51
-          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
52
-            { offset: 0, color: '#FB9900' },
53
-            { offset: 1, color: '#FFD38F' }
54
-          ])
25
+        grid: {
26
+          left: '3%',
27
+          bottom: '3%',
28
+          height: '90%',
29
+          width: '90%',
30
+          containLabel: true
55 31
         },
56
-        data: [2, 1, 2, 3, 2, 1]
57
-      }
58
-    ]
59
-  };
32
+        xAxis: [
33
+          {
34
+            type: 'category',
35
+            data: res.map(x => x.name),
36
+            // boundaryGap: true,
37
+            axisTick: {
38
+              alignWithLabel: true,
39
+            },
40
+            axisLabel: {
41
+              interval: 0,
42
+            }
43
+          }
44
+        ],
45
+        yAxis: [
46
+          {
47
+            type: 'value',
48
+            minInterval: 1
49
+          }
50
+        ],
51
+        series: [
52
+          {
53
+            type: 'bar',
54
+            barWidth: '20%',
55
+            itemStyle: {
56
+              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
57
+                { offset: 0, color: '#FB9900' },
58
+                { offset: 1, color: '#FFD38F' }
59
+              ])
60
+            },
61
+            data: res.map(x => x.value),
62
+          }
63
+        ]
64
+      });
65
+    });
66
+  }, [0]);
67
+
60 68
 
61 69
   return (
62
-    <Card>
70
+    <Card title="问题分类">
63 71
       <Chart option={option} style={props.style}></Chart>
64 72
     </Card>
65 73
   )

+ 61
- 0
src/pages/home/components/RangeDate.jsx 查看文件

@@ -0,0 +1,61 @@
1
+import React, { useState } from 'react';
2
+import { Card, DatePicker, Button } from 'antd';
3
+import * as dayjs from 'dayjs';
4
+// import * as isLeapYear from 'dayjs/plugin/isLeapYear' // 导入插件
5
+// import 'dayjs/locale/zh-cn' // 导入本地化语言
6
+
7
+export default (props) => {
8
+
9
+  const { onChange } = props;
10
+
11
+  const { RangePicker } = DatePicker;
12
+  const [date, setDate] = useState([]);
13
+
14
+  const updateDate = (dt, typ) => {
15
+    if (onChange) {
16
+      onChange(dt, typ);
17
+    }
18
+
19
+    setDate(dt);
20
+  }
21
+
22
+  const onWeek = () => {
23
+    updateDate(
24
+      [
25
+        dayjs().startOf('week').add(1, 'day'),
26
+        dayjs().endOf('week').add(1, 'day')
27
+      ],
28
+      1
29
+    );
30
+  }
31
+
32
+  const onMonth = () => {
33
+    updateDate([
34
+      dayjs().startOf('month'),
35
+      dayjs().endOf('month')
36
+    ], 2)
37
+    // console.log('fangfang', dayjs().endOf('month'));
38
+  }
39
+
40
+  const onYear = () => {
41
+    updateDate([
42
+      dayjs().startOf('year'),
43
+      dayjs().endOf('year')
44
+    ], 3)
45
+    // console.log('fangfang', dayjs().endOf('year'));
46
+  }
47
+
48
+  const onRange = (e) => {
49
+    updateDate(e, 0);
50
+  }
51
+
52
+  // console.log('data', data)
53
+  return (
54
+    <div>
55
+      <Button onClick={onWeek} type="text">本周</Button>
56
+      <Button onClick={onMonth} type="text">本月</Button>
57
+      <Button onClick={onYear} type="text">本年</Button>
58
+      <RangePicker onChange={onRange} value={date} />
59
+    </div>
60
+  )
61
+}

+ 3
- 5
src/pages/home/components/SpotCharts.jsx 查看文件

@@ -6,9 +6,6 @@ import Chart from '@/components/chart';
6 6
 export default (props) => {
7 7
 
8 8
   const option = {
9
-    title: {
10
-      text: '点位分类'
11
-    },
12 9
     tooltip: {
13 10
       trigger: 'axis',
14 11
       axisPointer: {
@@ -21,7 +18,8 @@ export default (props) => {
21 18
     grid: {
22 19
       left: '3%',
23 20
       bottom: '3%',
24
-      width: '90%',
21
+      width: '92%',
22
+      height: '90%',
25 23
       containLabel: true
26 24
     },
27 25
     xAxis: [
@@ -59,7 +57,7 @@ export default (props) => {
59 57
   };
60 58
 
61 59
   return (
62
-    <Card>
60
+    <Card title="点位分类" extra={'只显示本年度问题数前10的点位'}>
63 61
       <Chart option={option} style={props.style}></Chart>
64 62
     </Card>
65 63
   )

+ 14
- 6
src/pages/home/index.jsx 查看文件

@@ -10,7 +10,12 @@ import Page from '@/components/Page';
10 10
 export default (props) => {
11 11
 
12 12
   const chartStyle = {
13
-    height: '215px',
13
+    height: '260px',
14
+    width: '100%',
15
+  }
16
+
17
+  const chartStyle2 = {
18
+    height: '200px',
14 19
     width: '100%',
15 20
   }
16 21
 
@@ -19,19 +24,22 @@ export default (props) => {
19 24
       <Banner />
20 25
 
21 26
       <Row gutter={24} style={{ marginTop: '24px' }}>
22
-        <Col span={12}>
27
+        <Col span={24}>
23 28
           <AssignedCharts style={chartStyle} />
24 29
         </Col>
25
-        <Col span={12}>
26
-          <EscalationCharts style={chartStyle} />
27
-        </Col>
28 30
       </Row>
29 31
 
30 32
       <Row gutter={24} style={{ marginTop: '24px' }}>
31 33
         <Col span={12}>
32
-          <ProblemCharts style={chartStyle} />
34
+          <ProblemCharts style={chartStyle2} />
33 35
         </Col>
34 36
         <Col span={12}>
37
+          <EscalationCharts style={chartStyle2} />
38
+        </Col>
39
+
40
+      </Row>
41
+      <Row gutter={24} style={{ marginTop: '24px' }}>
42
+        <Col span={24}>
35 43
           <SpotCharts style={chartStyle} />
36 44
         </Col>
37 45
       </Row>

+ 23
- 0
src/service/stat.js 查看文件

@@ -0,0 +1,23 @@
1
+import request from '@/utils/request';
2
+
3
+export const getStat = (duty) => request('/api/ma/index-stat', { duty });
4
+
5
+/*
6
+ * 查询问题(图表)
7
+ */
8
+export const getStatProblem = (params) => request('/api/stat/issue/type', { params });
9
+
10
+/*
11
+ * 查询交办(图表)
12
+ */
13
+export const getStatEscalation = (params) => request('/api/stat/issue/org', { params });
14
+
15
+/*
16
+ * 查询首页统计
17
+ */
18
+export const getStatBanner = (params) => request('/api/stat/admin/index-banner', { params });
19
+
20
+/*
21
+ * 查询上报统计
22
+ */
23
+export const getStatIssue = (params) => request('/api/stat/issue', { params });