You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.9 KiB

6 years ago
<template>
<el-row :gutter="40" class="panel-group">
6 years ago
<el-col v-for="i in list" :key="i.id" :xs="12" :sm="12" :lg="6">
6 years ago
<panel-group-item v-bind="i" @click.native="jump(i)"/>
6 years ago
</el-col>
</el-row>
</template>
<script>
6 years ago
import PanelGroupItem from './PanelGroupItem'
import variables from '@/asset/style/variables.scss'
6 years ago
import {getFourBlock} from '@/api/statistic'
import {isEmpty} from "@/util"
import {auth} from "@/util/auth"
6 years ago
6 years ago
export default {
name: 'panelGroup',
6 years ago
components: {PanelGroupItem},
6 years ago
data() {
return {
loading: false,
list: [
{id: 'online', path: '/system/user', icon: 'user', color: variables.info, value: 0, text: '在线用户'},
{
id: 'purchase',
path: '/purchase/order',
icon: 'shopping',
color: variables.primary,
value: 0,
text: '今日采购额'
},
{id: 'sell', path: '/sell/order', icon: 'sell', color: variables.warning, value: 0, text: '今日销售额'},
{id: 'profit', icon: 'money', color: variables.success, value: 0, text: '今日毛利润'},
]
}
},
6 years ago
methods: {
init() {
if (this.loading) return
this.loading = true
getFourBlock()
.then(data => {
this.list.forEach(i => {
if (i.id in data) i.value = data[i.id]
6 years ago
})
6 years ago
})
.finally(() => this.loading = false)
6 years ago
},
6 years ago
jump({path}) {
if (!isEmpty(path) && auth(path)) this.$router.push(path)
6 years ago
}
6 years ago
},
mounted() {
this.init()
6 years ago
}
6 years ago
}
6 years ago
</script>
<style lang="scss">
6 years ago
.panel-group {
padding-top: 17px;
6 years ago
6 years ago
> .el-col {
margin-bottom: 32px;
6 years ago
}
6 years ago
}
6 years ago
</style>