Skip to content

Commit a111a79

Browse files
committed
数据报表完成
1 parent 5e3d61c commit a111a79

File tree

4 files changed

+129
-0
lines changed

4 files changed

+129
-0
lines changed

package-lock.json

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"dependencies": {
1111
"axios": "^0.21.4",
1212
"core-js": "^3.6.5",
13+
"echarts": "^5.2.1",
1314
"element-ui": "^2.15.6",
1415
"less": "^4.1.1",
1516
"less-loader": "^10.0.1",

src/components/reports/Reports.vue

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<template>
2+
<div>
3+
<!-- 面包屑区域 -->
4+
<el-breadcrumb separator-class="el-icon-arrow-right">
5+
<el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
6+
<el-breadcrumb-item>数据统计</el-breadcrumb-item>
7+
<el-breadcrumb-item>数据报表</el-breadcrumb-item>
8+
</el-breadcrumb>
9+
<el-card>
10+
<div id="main" style="width: 700px;height:400px;"></div>
11+
</el-card>
12+
</div>
13+
</template>
14+
15+
<script>
16+
import * as echarts from 'echarts'
17+
import _ from 'lodash'
18+
19+
export default {
20+
name: '',
21+
data() {
22+
return {
23+
options: {
24+
title: {
25+
text: '用户来源'
26+
},
27+
tooltip: {
28+
trigger: 'axis',
29+
axisPointer: {
30+
type: 'cross',
31+
label: {
32+
backgroundColor: '#E9EEF3'
33+
}
34+
}
35+
},
36+
grid: {
37+
left: '3%',
38+
right: '4%',
39+
bottom: '3%',
40+
containLabel: true
41+
},
42+
xAxis: [
43+
{
44+
boundaryGap: false
45+
}
46+
],
47+
yAxis: [
48+
{
49+
type: 'value'
50+
}
51+
]
52+
}
53+
}
54+
},
55+
async mounted() {
56+
// 基于准备好的dom,初始化echarts实例
57+
var myChart = echarts.init(document.getElementById('main'));
58+
59+
const { data: res } = await this.$axios.get('reports/type/1');
60+
if (res.meta.status !== 200) return this.$message.error('获取数据折线图失败');
61+
62+
const result = _.merge(this.options, res.data);
63+
// 指定图表的配置项和数据
64+
/* var option = {
65+
title: {
66+
text: 'ECharts 入门示例'
67+
},
68+
tooltip: {},
69+
legend: {
70+
data: ['销量']
71+
},
72+
xAxis: {
73+
data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
74+
},
75+
yAxis: {},
76+
series: [
77+
{
78+
name: '销量',
79+
type: 'bar',
80+
data: [5, 20, 36, 10, 10, 20]
81+
}
82+
]
83+
}; */
84+
// 使用刚指定的配置项和数据显示图表。
85+
myChart.setOption(result);
86+
}
87+
88+
};
89+
</script>
90+
91+
<style scoped>
92+
</style>

src/router/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Params from '@/components/goods/Params.vue'
1111
import GoodsList from '@/components/goods/GoodsList.vue'
1212
import AddGood from '@/components/goods/AddGood.vue'
1313
import Order from '@/components/orders/Order.vue'
14+
import Reports from '@/components/reports/Reports.vue'
1415

1516
Vue.use(Router)
1617

@@ -64,6 +65,10 @@ const router = new Router({
6465
{
6566
path: '/orders',
6667
component: Order,
68+
},
69+
{
70+
path: '/reports',
71+
component: Reports,
6772
}
6873
]
6974
}]

0 commit comments

Comments
 (0)