李志伟 3 anni fa
parent
commit
860df150ba

+ 9
- 11
src/components/ECharts/index.vue Vedi File

@@ -1,13 +1,13 @@
1 1
 <template>
2
-  <div class="echart"></div>
2
+  <div class="echart" />
3 3
 </template>
4 4
 
5 5
 <script>
6 6
 // 按需导入模块
7 7
 // 引入 echarts 核心模块,核心模块提供了 echarts 使用必须要的接口。
8
-import * as echarts from 'echarts/core';
8
+import * as echarts from 'echarts/core'
9 9
 // 引入图表,图表后缀都为 Chart
10
-import { LineChart } from 'echarts/charts';
10
+import { LineChart } from 'echarts/charts'
11 11
 // 引入提示框,标题,直角坐标系,数据集,内置数据转换器组件,组件后缀都为 Component
12 12
 import {
13 13
   TitleComponent,
@@ -15,11 +15,11 @@ import {
15 15
   GridComponent,
16 16
   DatasetComponent,
17 17
   TransformComponent
18
-} from 'echarts/components';
18
+} from 'echarts/components'
19 19
 // 标签自动布局,全局过渡动画等特性
20
-import { LabelLayout, UniversalTransition } from 'echarts/features';
20
+import { LabelLayout, UniversalTransition } from 'echarts/features'
21 21
 // 引入 Canvas 渲染器,注意引入 CanvasRenderer 或者 SVGRenderer 是必须的一步
22
-import { CanvasRenderer } from 'echarts/renderers';
22
+import { CanvasRenderer } from 'echarts/renderers'
23 23
 
24 24
 // 注册必须的组件
25 25
 echarts.use([
@@ -32,8 +32,7 @@ echarts.use([
32 32
   LabelLayout,
33 33
   UniversalTransition,
34 34
   CanvasRenderer
35
-]);
36
-
35
+])
37 36
 
38 37
 export default {
39 38
   name: 'ECharts',
@@ -46,7 +45,7 @@ export default {
46 45
   },
47 46
   data() {
48 47
     return {
49
-      echartsRef: undefined,
48
+      echartsRef: undefined
50 49
     }
51 50
   },
52 51
   watch: {
@@ -54,13 +53,12 @@ export default {
54 53
       handler(v) {
55 54
         if (this.echartsRef) {
56 55
           this.echartsRef.setOption(v)
57
-          console.log('-------------', v)
58 56
         }
59 57
       },
60 58
       immediate: true
61 59
     },
62 60
     loading(nw) {
63
-      if (!this.echartsRef) return;
61
+      if (!this.echartsRef) return
64 62
 
65 63
       if (nw) {
66 64
         this.echartsRef.showLoading()

+ 3
- 3
src/views/dashboard/components/Statistic.vue Vedi File

@@ -1,7 +1,7 @@
1 1
 <template>
2 2
   <el-card class="stat-card">
3
-    <div class="stat-card_title">{{title}}</div>
4
-    <div class="stat-card_content">{{value}}</div>
3
+    <div class="stat-card_title">{{ title }}</div>
4
+    <div class="stat-card_content">{{ value }}</div>
5 5
   </el-card>
6 6
 </template>
7 7
 
@@ -10,7 +10,7 @@ export default {
10 10
   name: 'Statistic',
11 11
   props: {
12 12
     title: [String, Number],
13
-    value: String,
13
+    value: [String, Number]
14 14
   }
15 15
 }
16 16
 </script>

+ 16
- 16
src/views/dashboard/index.vue Vedi File

@@ -14,7 +14,7 @@
14 14
       </el-col>
15 15
     </el-row>
16 16
 
17
-    <el-row class="sec" type="flex" justify="space-between" gutter="24">
17
+    <el-row class="sec" type="flex" justify="space-between" :gutter="20">
18 18
       <el-col :span="12">
19 19
         <el-card>
20 20
           <div slot="header">
@@ -46,7 +46,20 @@ export default {
46 46
   name: 'Dashboard',
47 47
   components: {
48 48
     Statistic: () => import('./components/Statistic.vue'),
49
-    LineChart: () => import('@/components/ECharts/Line.vue'),
49
+    LineChart: () => import('@/components/ECharts/Line.vue')
50
+  },
51
+  data() {
52
+    return {
53
+      total: {},
54
+      today: new Date(),
55
+      days: 15, // 默认统计 15 天的
56
+      pv: [],
57
+      uv: [],
58
+      loading: {
59
+        pv: false,
60
+        uv: false
61
+      }
62
+    }
50 63
   },
51 64
   computed: {
52 65
     ...mapGetters(['name']),
@@ -60,20 +73,7 @@ export default {
60 73
 
61 74
       return {
62 75
         startDate: `${year}-${formateNum(mon)}-${formateNum(dt)}`,
63
-        days: this.days,
64
-      }
65
-    }
66
-  },
67
-  data() {
68
-    return {
69
-      total: {},
70
-      today: new Date(),
71
-      days: 15, // 默认统计 15 天的
72
-      pv: [],
73
-      uv: [],
74
-      loading: {
75
-        pv: false,
76
-        uv: false,
76
+        days: this.days
77 77
       }
78 78
     }
79 79
   },