许成详 6 年之前
父節點
當前提交
b21677fc93

+ 593
- 75
package-lock.json
文件差異過大導致無法顯示
查看文件


+ 3
- 0
package.json 查看文件

@@ -14,14 +14,17 @@
14 14
     "build": "node build/build.js"
15 15
   },
16 16
   "dependencies": {
17
+    "@antv/g2": "^3.2.7",
17 18
     "axios": "^0.18.0",
18 19
     "element-ui": "^2.4.5",
20
+    "g2-vue": "^1.0.1",
19 21
     "js-base64": "^2.4.8",
20 22
     "js-md5": "^0.7.3",
21 23
     "vue": "^2.5.2",
22 24
     "vue-amap": "^0.5.8",
23 25
     "vue-cookie": "^1.1.4",
24 26
     "vue-fullcalendar": "^1.0.9",
27
+    "vue-morris": "0.0.13",
25 28
     "vue-router": "^3.0.1",
26 29
     "vuex": "^3.0.1"
27 30
   },

+ 36
- 0
src/components/dashboardList/index.vue 查看文件

@@ -0,0 +1,36 @@
1
+<template>
2
+  <div class="dashboardList">
3
+    <ul class="flex-h">
4
+      <li class="flex-item" v-for="(item,index) in data" :key="index">
5
+        <div>
6
+          <div class="centerLabel">
7
+            <span>{{item.name}}</span>
8
+            <span>{{item.value}}</span>
9
+          </div>
10
+        </div>
11
+      </li>
12
+    </ul>
13
+  </div>
14
+</template>
15
+
16
+<script>
17
+export default {
18
+  name: '',
19
+  props: ['data'],
20
+  data () {
21
+    return {
22
+
23
+    }
24
+  },
25
+  mounted () {
26
+    this.$nextTick(function () {})
27
+  },
28
+  methods: {
29
+  }
30
+}
31
+</script>
32
+
33
+<!-- Add "scoped" attribute to limit CSS to this component only -->
34
+<style lang="scss" scoped>
35
+@import "page.scss";
36
+</style>

+ 57
- 0
src/components/dashboardList/page.scss 查看文件

@@ -0,0 +1,57 @@
1
+
2
+.dashboardList{
3
+  >ul{
4
+    >li{
5
+      margin-left: 20px;
6
+      position: relative;
7
+      overflow: hidden;
8
+      &:first-child{
9
+        margin-left: 0;
10
+      }
11
+      >div{
12
+        width: 100%;
13
+        position: relative;
14
+        overflow: hidden;
15
+        padding-bottom: 30%;
16
+        border-radius: 10px;
17
+        background: #ccc;
18
+        >div{
19
+          width: 100%;
20
+          >*{
21
+            width: 100%;
22
+            display: block;
23
+            text-align: center;
24
+            font-size: 18px;
25
+            color: #fff;
26
+            font-weight: bolder;
27
+            line-height: 1.6;
28
+          }
29
+        }
30
+      }
31
+    }
32
+  }
33
+}
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+

+ 49
- 0
src/components/histogram/index.vue 查看文件

@@ -0,0 +1,49 @@
1
+<template>
2
+  <div class="component">
3
+    <h6 class="title">{{data.title}}</h6>
4
+    <div id="histogram" ref="box"></div>
5
+  </div>
6
+</template>
7
+
8
+<script>
9
+import G2 from '@antv/g2'
10
+
11
+export default {
12
+  name: '',
13
+  props: ['data'],
14
+  data () {
15
+    return {
16
+    }
17
+  },
18
+  components: {
19
+    G2,
20
+  },
21
+  mounted () {
22
+    this.$nextTick(function () {
23
+      this.init()
24
+    })
25
+  },
26
+  methods: {
27
+    init () {
28
+      var _that = this
29
+      var chart = new G2.Chart({
30
+        container: 'histogram',
31
+        forceFit: true,
32
+        width: _that.$refs.box.clientWidth,
33
+        height: 400
34
+      })
35
+      chart.source(_that.data.list)
36
+      chart.scale('y', {
37
+        tickInterval: 20
38
+      })
39
+      chart.interval().position('x*y')
40
+      chart.render()
41
+    },
42
+  }
43
+}
44
+</script>
45
+
46
+<!-- Add "scoped" attribute to limit CSS to this component only -->
47
+<style lang="scss" scoped>
48
+@import "page.scss";
49
+</style>

+ 28
- 0
src/components/histogram/page.scss 查看文件

@@ -0,0 +1,28 @@
1
+
2
+.component{
3
+  
4
+}
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+

+ 73
- 0
src/components/pieDiagram/index.vue 查看文件

@@ -0,0 +1,73 @@
1
+<template>
2
+  <div class="component">
3
+    <h6 class="title">{{data.title}}</h6>
4
+    <div id="pieDiagram" ref="box"></div>
5
+  </div>
6
+</template>
7
+
8
+<script>
9
+import G2 from '@antv/g2'
10
+
11
+export default {
12
+  name: '',
13
+  props: ['data'],
14
+  data () {
15
+    return {
16
+    }
17
+  },
18
+  components: {
19
+    G2,
20
+  },
21
+  mounted () {
22
+    this.$nextTick(function () {
23
+      this.init()
24
+    })
25
+  },
26
+  methods: {
27
+    init () {
28
+      var _that = this
29
+      var chart = new G2.Chart({
30
+        container: 'pieDiagram',
31
+        forceFit: true,
32
+        width: _that.$refs.box.clientWidth,
33
+        height: 400
34
+      })
35
+      chart.source(_that.data.list, {
36
+        percent: {
37
+          formatter: function formatter (val) {
38
+            val = val * 100 + '%'
39
+            return val
40
+          }
41
+        }
42
+      })
43
+      chart.coord('theta', {
44
+        radius: 0.75
45
+      })
46
+      chart.tooltip({
47
+        showTitle: false,
48
+        itemTpl: '<li><span style="background-color:{color}" class="g2-tooltip-marker"></span>{name}: {value}</li>'
49
+      })
50
+      chart.intervalStack().position('percent').color('item').label('percent', {
51
+        formatter: (val, item) => {
52
+          return item.point.item + ': ' + val
53
+        }
54
+      }).tooltip('item*percent', function (item, percent) {
55
+        percent = percent * 100 + '%'
56
+        return {
57
+          name: item,
58
+          value: percent
59
+        }
60
+      }).style({
61
+        lineWidth: 1,
62
+        stroke: '#fff'
63
+      })
64
+      chart.render()
65
+    },
66
+  }
67
+}
68
+</script>
69
+
70
+<!-- Add "scoped" attribute to limit CSS to this component only -->
71
+<style lang="scss" scoped>
72
+@import "page.scss";
73
+</style>

+ 26
- 0
src/components/pieDiagram/page.scss 查看文件

@@ -0,0 +1,26 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+

+ 1
- 1
src/components/siderBar/index.vue 查看文件

@@ -31,7 +31,7 @@
31 31
               </el-menu-item-group>
32 32
             </el-submenu>
33 33
             <el-menu-item v-else :index="String(index)" :key="index">
34
-              <span slot="title">{{item.MenuName}}</span>
34
+              <router-link :to="{name:item.Url,query:{}}" active-class="active">{{item.MenuName}}</router-link>
35 35
             </el-menu-item>
36 36
           </template>
37 37
         </el-menu>

+ 1
- 1
src/pages/login/index.vue 查看文件

@@ -71,7 +71,7 @@ export default {
71 71
           duration: 1000
72 72
         })
73 73
         setTimeout(() => {
74
-          this.$router.push({ name: 'userManager' })
74
+          this.$router.push({ name: 'dashboard' })
75 75
         }, 1000)
76 76
       }).catch(msg => {
77 77
 

+ 143
- 0
src/pages/system/dashboard/index.vue 查看文件

@@ -0,0 +1,143 @@
1
+<template>
2
+  <div class="subPage">
3
+    <div class="selectCase">
4
+      <el-select v-model="CaseId" placeholder="请选择">
5
+        <el-option
6
+          v-for="item in cases"
7
+          :key="item.CaseId"
8
+          :label="item.CaseName"
9
+          :value="item.CaseId">
10
+        </el-option>
11
+      </el-select>
12
+    </div>
13
+    <div class="top flex-h">
14
+      <div class="flex-item" v-for="(item,index) in topData" :key="index">
15
+        <div v-if="item.type === 'dashboardList'">
16
+          <dashboardList :data="item.data"></dashboardList>
17
+        </div>
18
+      </div>
19
+    </div>
20
+    <div class="body flex-h">
21
+      <div class="flex-item" v-for="(item,index) in bodyData" :key="index">
22
+        <div v-if="item.type === 'histogram'">
23
+          <histogram :data="item.data"></histogram>
24
+        </div>
25
+        <template v-if="item.type === 'pieDiagram'">
26
+          <pieDiagram :data="item.data"></pieDiagram>
27
+        </template>
28
+      </div>
29
+    </div>
30
+    <div class="bottom flex-h">
31
+      3
32
+    </div>
33
+  </div>
34
+</template>
35
+
36
+<script>
37
+import { mapState } from 'vuex'
38
+import dashboardList from '../../../components/dashboardList/index'
39
+import histogram from '../../../components/histogram/index'
40
+import pieDiagram from '../../../components/pieDiagram/index'
41
+
42
+export default {
43
+  name: '',
44
+  data () {
45
+    return {
46
+      postData: {
47
+        caseid: ''
48
+      },
49
+      topData: [{
50
+        type: 'dashboardList', // 列表面板
51
+        data: [{
52
+          name: '会员总数',
53
+          value: '1000',
54
+        }, {
55
+          name: '课程预约总量',
56
+          value: '1000',
57
+        }, {
58
+          name: '饮品下单总量',
59
+          value: '1000',
60
+        }]
61
+      }],
62
+      bodyData: [{
63
+        type: 'histogram', // 柱状图
64
+        data: {
65
+          title: '今日数据',
66
+          list: [{
67
+            x: '推荐会员新增',
68
+            y: 38
69
+          }, {
70
+            x: '课程数',
71
+            y: 52
72
+          }, {
73
+            x: '预约数',
74
+            y: 61
75
+          }, {
76
+            x: '到场人次',
77
+            y: 145
78
+          }]
79
+        },
80
+      }, {
81
+        type: 'pieDiagram', // 扇形图
82
+        data: {
83
+          title: '明日课程预约数据',
84
+          list: [{
85
+            item: '小小体验官',
86
+            count: 40,
87
+            percent: 0.4
88
+          }, {
89
+            item: '哈他瑜伽',
90
+            count: 52,
91
+            percent: 0.52
92
+          }, {
93
+            item: '小小飞行家',
94
+            count: 8,
95
+            percent: 0.08
96
+          }]
97
+        },
98
+      }],
99
+      bottomData: [{
100
+        type: 'brokenLineGraph', // 折线图
101
+        data: [],
102
+      }, {
103
+        type: 'ringChart', // 环形图
104
+        data: [],
105
+      }],
106
+    }
107
+  },
108
+  components: {
109
+    dashboardList,
110
+    histogram,
111
+    pieDiagram,
112
+  },
113
+  computed: {
114
+    ...mapState({
115
+      cases: x => x.app.cases.list,
116
+      defaultCaseId: x => x.app.cases.default
117
+    }),
118
+    CaseId: {
119
+      get () {
120
+        return this.postData.caseid || this.defaultCaseId
121
+      },
122
+      set (val) {
123
+        this.postData.caseid = val
124
+      }
125
+    }
126
+  },
127
+  mounted () {
128
+    this.$nextTick(function () {
129
+      this.drawHistogram()
130
+    })
131
+  },
132
+  methods: {
133
+    drawHistogram () { // 绘制柱状图
134
+      // this.histogramInit.source(this.histogramParams)
135
+    },
136
+  }
137
+}
138
+</script>
139
+
140
+<!-- Add "scoped" attribute to limit CSS to this component only -->
141
+<style lang="scss" scoped>
142
+@import "page.scss";
143
+</style>

+ 54
- 0
src/pages/system/dashboard/page.scss 查看文件

@@ -0,0 +1,54 @@
1
+
2
+.subPage{
3
+  >*{
4
+    width: calc(100% - 40px);
5
+    position: relative;
6
+    overflow: hidden;
7
+    margin: 20px auto 0;
8
+    >div{
9
+      >div{
10
+        >div{
11
+          
12
+        }
13
+      }
14
+    }
15
+  }
16
+  >*:last-child{
17
+    margin-bottom: 20px;
18
+  }
19
+  .selectCase{
20
+    text-align: right;
21
+  }
22
+  .top{
23
+    
24
+  }
25
+}
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+

+ 8
- 1
src/pages/system/page.js 查看文件

@@ -1,6 +1,8 @@
1 1
 
2 2
 import system from './index' // 系统首页
3 3
 
4
+import dashboard from './dashboard/index' // 控制板
5
+
4 6
 import systemSet from './systemSet/index' // 系统设置
5 7
 import userManager from './systemSet/userManager/index' // 用户管理
6 8
 import addUser from './systemSet/userManager/add' // 添加用户
@@ -82,7 +84,12 @@ export default {
82 84
       path: '/system',
83 85
       name: 'system',
84 86
       component: system,
85
-      children: [{ // 系统设置
87
+      children: [{ // 首页控制板
88
+        path: 'dashboard',
89
+        name: 'dashboard',
90
+        component: dashboard,
91
+        children: []
92
+      }, { // 系统设置
86 93
         path: 'systemSet',
87 94
         name: 'systemSet',
88 95
         component: systemSet,

+ 9
- 0
src/style/main.css 查看文件

@@ -388,6 +388,15 @@ select:focus {
388 388
   display: inline-block;
389 389
 }
390 390
 
391
+.component,
392
+.component>div,
393
+#mountNode>div{
394
+  width: 100%;
395
+  height: 100%;
396
+}
397
+
398
+
399
+
391 400
 
392 401
 
393 402