home.vue
4.63 KB
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
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<template>
<div class="dashboard-container">
<div class="dashboard-editor-container">
<github-corner class="github-corner" />
<panel-group />
<div class="active-open-card">
<el-card>
<div slot="header" class="clearfix">
<span>开卡地区</span>
</div>
<el-row>
<el-col :xs="24" :sm="24" :lg="24">
<div class="chart-wrapper">
<bar-chart :option-data="regionStatistics[0]" :option="{title: { show: true, text: '开卡地区:地区分布' }}" />
</div>
</el-col>
<el-col :xs="24" :sm="24" :lg="24">
<div class="chart-wrapper">
<bar-chart :option-data="batchStatistics[0]" :option="{title: { show: true, text: '开卡地区:批次分布' }}" />
</div>
</el-col>
<el-col :xs="24" :sm="24" :lg="24">
<div class="chart-wrapper">
<bar-chart :option-data="channelStatistics[0]" :option="{title: { show: true, text: '开卡地区:渠道分布' }}" />
</div>
</el-col>
</el-row>
</el-card>
<el-card>
<div slot="header" class="clearfix">
<span>激活地区</span>
</div>
<el-row>
<el-col :xs="24" :sm="24" :lg="24">
<div class="chart-wrapper">
<bar-chart :option-data="regionStatistics[1]" :option="{title: { show: true, text: '激活地区:地区分布' }}" />
</div>
</el-col>
<el-col :xs="24" :sm="24" :lg="24">
<div class="chart-wrapper">
<bar-chart :option-data="batchStatistics[1]" :option="{title: { show: true, text: '激活地区:批次分布' }}" />
</div>
</el-col>
<el-col :xs="24" :sm="24" :lg="24">
<div class="chart-wrapper">
<bar-chart :option-data="channelStatistics[1]" :option="{title: { show: true, text: '激活地区:渠道分布' }}" />
</div>
</el-col>
</el-row>
</el-card>
</div>
</div>
</div>
</template>
<script>
import GithubCorner from '@/components/GithubCorner'
import PanelGroup from './dashboard/PanelGroup'
import BarChart from './dashboard/BarChart'
import homeData from '@/api/home/homeData'
export default {
name: 'Dashboard',
components: {
GithubCorner,
PanelGroup,
BarChart
},
data() {
return {
regionStatistics: [{}, {}],
batchStatistics: [{}, {}],
channelStatistics: [{}, {}]
}
},
mounted() {
this.getRegionStatistics(0)
this.getBatchStatistics(0)
this.getChannelStatistics(0)
this.getRegionStatistics(1)
this.getBatchStatistics(1)
this.getChannelStatistics(1)
},
methods: {
getRegionStatistics(status) {
homeData.getRegionStatistics({
userId: this.$store.state.user.user.id,
status: status
}).then(res => {
console.log(res)
this.$set(this.regionStatistics, status, res)
}).catch(err => {
this.$message.error(err.message)
this.$set(this.regionStatistics, status, [])
console.log(err)
})
},
getBatchStatistics(status) {
homeData.getBatchStatistics({
userId: this.$store.state.user.user.id,
status: status
}).then(res => {
console.log(res)
this.$set(this.batchStatistics, status, res)
}).catch(err => {
this.$message.error(err.message)
this.$set(this.batchStatistics, status, [])
console.log(err)
})
},
getChannelStatistics(status) {
homeData.getChannelStatistics({
userId: this.$store.state.user.user.id,
status: status
}).then(res => {
console.log(res)
this.$set(this.channelStatistics, status, res)
}).catch(err => {
this.$message.error(err.message)
this.$set(this.channelStatistics, status, [])
console.log(err)
})
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.dashboard-editor-container {
padding: 32px;
background-color: rgb(240, 242, 245);
position: relative;
.github-corner {
position: absolute;
top: 0;
border: 0;
right: 0;
}
.chart-wrapper {
background: #fff;
padding: 16px;
border-top: 1px solid #ccc;
}
.el-col:nth-of-type(1) {
.chart-wrapper {
border-top: 0;
}
}
}
@media (max-width:1024px) {
.chart-wrapper {
padding: 8px;
}
}
.active-open-card {
display: flex;
justify-content: space-between;
}
.el-card {
width: 48%;
flex-shrink: 0;
flex-grow: 0;
}
</style>