Yansen 2 år sedan
förälder
incheckning
a792dc82da
5 ändrade filer med 59 tillägg och 51 borttagningar
  1. 1
    0
      .env.production
  2. 50
    49
      src/pages/home/components/SpotCharts.jsx
  3. 6
    1
      src/service/stat.js
  4. 1
    1
      src/utils/request.js
  5. 1
    0
      vite.config.js

+ 1
- 0
.env.production Visa fil

@@ -0,0 +1 @@
1
+VITE_SERVER_BASE=https://t.njyz.tech

+ 50
- 49
src/pages/home/components/SpotCharts.jsx Visa fil

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

+ 6
- 1
src/service/stat.js Visa fil

@@ -20,4 +20,9 @@ export const getStatBanner = (params) => request('/api/stat/admin/index-banner',
20 20
 /*
21 21
  * 查询上报统计
22 22
  */
23
-export const getStatIssue = (params) => request('/api/stat/issue', { params });
23
+export const getStatIssue = (params) => request('/api/stat/issue', { params });
24
+
25
+/*
26
+ * 查询点位统计
27
+ */
28
+export const getStatIssueLoc = (params) => request('/api/stat/issue/loc', { params });

+ 1
- 1
src/utils/request.js Visa fil

@@ -5,7 +5,7 @@ import { message } from 'antd';
5 5
 const instance = axios.create({
6 6
   baseURL: import.meta.env.VITE_SERVER_BASE || '',
7 7
   timeout: 10000,
8
-  withCredentials: true, // 跨域
8
+  withCredentials: false, // 跨域
9 9
 });
10 10
 
11 11
 

+ 1
- 0
vite.config.js Visa fil

@@ -4,6 +4,7 @@ import react from '@vitejs/plugin-react'
4 4
 
5 5
 // https://vitejs.dev/config/
6 6
 export default defineConfig({
7
+  base: '',
7 8
   server: {
8 9
     port: 3001,
9 10
     host: '0.0.0.0',