|
@@ -1,86 +1,132 @@
|
|
|
<template>
|
|
|
<div class="sy-content">
|
|
|
- <div class="statistics">
|
|
|
- <div v-for="(item, index) in statData" :key="index" class="stat-item">
|
|
|
- <span class="stat-top">{{ item.title }}</span>
|
|
|
- <span class="stat-bottom">{{ item.num }}</span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+<!-- <div class="statistics">-->
|
|
|
+<!-- <div v-for="(item, index) in statData" :key="index" class="stat-item">-->
|
|
|
+<!-- <span class="stat-top">{{ item.title }}</span>-->
|
|
|
+<!-- <span class="stat-bottom">{{ item.num }}</span>-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- </div>-->
|
|
|
+ <el-row :gutter="40" class="panel-group">
|
|
|
+ <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
|
|
|
+ <div class="card-panel">
|
|
|
+ <div class="card-panel-icon-wrapper icon-people">
|
|
|
+ <svg-icon icon-class="user-manger" class-name="card-panel-icon" />
|
|
|
+ </div>
|
|
|
+ <div class="card-panel-description">
|
|
|
+ <div class="card-panel-text">管理端用户数量</div>
|
|
|
+ <count-to :start-val="startVal" :end-val="statistics.managerUserNum" :duration="countDuration" class="card-panel-num" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
|
|
|
+ <div class="card-panel">
|
|
|
+ <div class="card-panel-icon-wrapper icon-message">
|
|
|
+ <svg-icon icon-class="user-t" class-name="card-panel-icon" />
|
|
|
+ </div>
|
|
|
+ <div class="card-panel-description">
|
|
|
+ <div class="card-panel-text">客户端用户数量</div>
|
|
|
+ <count-to :start-val="startVal" :end-val="statistics.clientUserNum" :duration="countDuration" class="card-panel-num" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
|
|
|
+ <div class="card-panel">
|
|
|
+ <div class="card-panel-icon-wrapper icon-money">
|
|
|
+ <svg-icon icon-class="user-role" class-name="card-panel-icon" />
|
|
|
+ </div>
|
|
|
+ <div class="card-panel-description">
|
|
|
+ <div class="card-panel-text">角色数量</div>
|
|
|
+ <count-to :start-val="startVal" :end-val="statistics.roleNum" :duration="countDuration" class="card-panel-num" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
|
|
|
+ <div class="card-panel">
|
|
|
+ <div class="card-panel-icon-wrapper icon-shopping">
|
|
|
+ <svg-icon icon-class="user-table" class-name="card-panel-icon" />
|
|
|
+ </div>
|
|
|
+ <div class="card-panel-description">
|
|
|
+ <div class="card-panel-text">报表数量</div>
|
|
|
+ <count-to :start-val="startVal" :end-val="statistics.reportNum" :duration="countDuration" class="card-panel-num" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
|
|
|
+ <div class="card-panel">
|
|
|
+ <div class="card-panel-icon-wrapper icon-money">
|
|
|
+ <svg-icon icon-class="user-online" class-name="card-panel-icon" />
|
|
|
+ </div>
|
|
|
+ <div class="card-panel-description">
|
|
|
+ <div class="card-panel-text">客户端在线用户数</div>
|
|
|
+ <count-to :start-val="startVal" :end-val="statistics.onlineClientUserNum" :duration="countDuration" class="card-panel-num" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { mapGetters } from 'vuex'
|
|
|
+import CountTo from 'vue-count-to'
|
|
|
import {
|
|
|
getManagerUserNum,
|
|
|
getCustomerUserNum,
|
|
|
getRoleNum,
|
|
|
- getReportFormrNum
|
|
|
+ getReportFormrNum, getOnlineUser
|
|
|
} from '@/api/dashboard'
|
|
|
|
|
|
export default {
|
|
|
name: 'Dashboard',
|
|
|
+ components: {
|
|
|
+ CountTo
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
- statData: []
|
|
|
+ statData: [],
|
|
|
+ countDuration: 1000,
|
|
|
+ startVal: 0,
|
|
|
+ statistics: {
|
|
|
+ roleNum: 0,
|
|
|
+ managerUserNum: 0,
|
|
|
+ clientUserNum: 0,
|
|
|
+ onlineClientUserNum: 0,
|
|
|
+ reportNum: 0
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
...mapGetters(['roles'])
|
|
|
},
|
|
|
created() {
|
|
|
- this.statistics()
|
|
|
+ this.statisticsNum()
|
|
|
},
|
|
|
methods: {
|
|
|
- statistics() {
|
|
|
- const p1 = new Promise((resolve, reject) => {
|
|
|
- getManagerUserNum().then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- resolve(res.data)
|
|
|
- }
|
|
|
- })
|
|
|
+ statisticsNum() {
|
|
|
+ getManagerUserNum().then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.statistics.managerUserNum = res.data
|
|
|
+ }
|
|
|
})
|
|
|
- const p2 = new Promise((resolve, reject) => {
|
|
|
- getCustomerUserNum().then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- resolve(res.data)
|
|
|
- }
|
|
|
- })
|
|
|
+ getCustomerUserNum().then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.statistics.clientUserNum = res.data
|
|
|
+ }
|
|
|
})
|
|
|
- const p3 = new Promise((resolve, reject) => {
|
|
|
- getRoleNum().then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- resolve(res.data)
|
|
|
- }
|
|
|
- })
|
|
|
+ getRoleNum().then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.statistics.roleNum = res.data
|
|
|
+ }
|
|
|
})
|
|
|
- const p4 = new Promise((resolve, reject) => {
|
|
|
- getReportFormrNum().then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- resolve(res.data)
|
|
|
- }
|
|
|
- })
|
|
|
+ getReportFormrNum().then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.statistics.reportNum = res.data
|
|
|
+ }
|
|
|
})
|
|
|
- Promise.all([p1, p2, p3, p4]).then((res) => {
|
|
|
- const [a, b, c, d] = res
|
|
|
- this.statData = [
|
|
|
- {
|
|
|
- title: '管理端用户数量',
|
|
|
- num: a
|
|
|
- },
|
|
|
- {
|
|
|
- title: '客户端用户数量',
|
|
|
- num: b
|
|
|
- },
|
|
|
- {
|
|
|
- title: '角色数量',
|
|
|
- num: c
|
|
|
- },
|
|
|
- {
|
|
|
- title: '报表数量',
|
|
|
- num: d
|
|
|
- }
|
|
|
- ]
|
|
|
+ getOnlineUser('front').then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.statistics.onlineClientUserNum = res.data
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -93,6 +139,7 @@ export default {
|
|
|
justify-content: space-between;
|
|
|
margin: 30px auto;
|
|
|
width: 50%;
|
|
|
+ flex-wrap: wrap;
|
|
|
.stat-item {
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
@@ -107,4 +154,90 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+.panel-group {
|
|
|
+ margin-top: 18px;
|
|
|
+
|
|
|
+ .card-panel-col {
|
|
|
+ margin-bottom: 32px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card-panel {
|
|
|
+ height: 108px;
|
|
|
+ //cursor: pointer;
|
|
|
+ font-size: 12px;
|
|
|
+ position: relative;
|
|
|
+ overflow: hidden;
|
|
|
+ color: #666;
|
|
|
+ background: #fff;
|
|
|
+ box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
|
|
|
+ border-color: rgba(0, 0, 0, .05);
|
|
|
+
|
|
|
+ .icon-people {
|
|
|
+ color: #40c9c6;
|
|
|
+ }
|
|
|
+
|
|
|
+ .icon-message {
|
|
|
+ color: #36a3f7;
|
|
|
+ }
|
|
|
+
|
|
|
+ .icon-money {
|
|
|
+ color: #f4516c;
|
|
|
+ }
|
|
|
+
|
|
|
+ .icon-shopping {
|
|
|
+ color: #34bfa3
|
|
|
+ }
|
|
|
+
|
|
|
+ .card-panel-icon-wrapper {
|
|
|
+ float: left;
|
|
|
+ margin: 14px 0 0 14px;
|
|
|
+ padding: 16px;
|
|
|
+ transition: all 0.38s ease-out;
|
|
|
+ border-radius: 6px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card-panel-icon {
|
|
|
+ float: left;
|
|
|
+ font-size: 48px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card-panel-description {
|
|
|
+ float: right;
|
|
|
+ font-weight: bold;
|
|
|
+ margin: 26px;
|
|
|
+ margin-left: 0px;
|
|
|
+
|
|
|
+ .card-panel-text {
|
|
|
+ line-height: 18px;
|
|
|
+ color: rgba(0, 0, 0, 0.45);
|
|
|
+ font-size: 16px;
|
|
|
+ margin-bottom: 12px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card-panel-num {
|
|
|
+ font-size: 20px;
|
|
|
+ float: right;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+@media (max-width:550px) {
|
|
|
+ .card-panel-description {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card-panel-icon-wrapper {
|
|
|
+ float: none !important;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ margin: 0 !important;
|
|
|
+
|
|
|
+ .svg-icon {
|
|
|
+ display: block;
|
|
|
+ margin: 14px auto !important;
|
|
|
+ float: none !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|