Skip to content

Commit 6be720b

Browse files
committed
6/2
1 parent a3e57ff commit 6be720b

File tree

2 files changed

+103
-40
lines changed

2 files changed

+103
-40
lines changed

src/views/Layout.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@
6969
<el-menu-item index="/addBorrow">借书添加</el-menu-item>
7070
<el-menu-item index="/borrowList">借书列表</el-menu-item>
7171
</el-submenu>
72+
<el-submenu index="borrow">
73+
<template slot="title">
74+
<i class="el-icon-suitcase"></i>
75+
<span>借书管理</span>
76+
</template>
77+
<el-menu-item index="/addBorrow">借书添加</el-menu-item>
78+
<el-menu-item index="/borrowList">借书列表</el-menu-item>
79+
<el-menu-item index="/borrowList">借书列表</el-menu-item>
80+
</el-submenu>
7281
</el-menu>
7382

7483
</div>

src/views/home/HomeView.vue

Lines changed: 94 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,54 @@
11
<template>
22
<div>
33
<div>主页</div>
4+
<div>
5+
<el-select class="input" v-model="timeRange" placeholder="请选择" @change="load()">
6+
<el-option
7+
v-for="item in options"
8+
:key="item.value"
9+
:label="item.label"
10+
:value="item.value">
11+
</el-option>
12+
</el-select>
13+
</div>
414
<el-card>
515
<div id="line" style="width:100%;height: 400px;"></div>
616
</el-card>
17+
18+
<el-table
19+
:data="tableData"
20+
style="width: 100%">
21+
<el-table-column
22+
prop="date"
23+
label="日期"
24+
width="180">
25+
</el-table-column>
26+
<el-table-column
27+
prop="name"
28+
label="姓名"
29+
width="180">
30+
</el-table-column>
31+
<el-table-column
32+
prop="address"
33+
label="地址">
34+
</el-table-column>
35+
</el-table>
736
</div>
837
</template>
938

1039
<script>
1140
import * as echarts from 'echarts';
1241
import request from '@/utils/request';
13-
export default {
14-
name: "HomeView",
15-
components: {
16-
},
17-
data(){
18-
return{
19-
lineBox:null,
20-
timeRange:'week',
21-
options:[
22-
{label:'最近一周',value:'week'},
23-
{label:'最近一个月',value:'month'},
24-
{label:'最近两个月',value:'month2'},
25-
{label:'最近三个月',value:'month3'},
26-
]
27-
}
28-
},
29-
// 初始化完后执行
30-
mounted(){
31-
this.load()
32-
},
33-
methods:{
34-
load(){
35-
if(!this.lineBox0){
36-
this.lineBox = echarts.init(document.getElementById('line'))//初始化容器
37-
}
38-
//从后台获取数据
39-
request.get('/borrow.lineCharts/'+this,timeRange).then(res =>{
40-
option.xAxis[0].data = res.data.borrow
41-
option.series[1].data = res.data.return
42-
this.lineBox.setOption(option)//设置容器属性值
43-
})
44-
45-
}
46-
}
47-
};
48-
49-
option = {
42+
import Cookies from 'js-cookie'
43+
const option = {
5044
title: {
5145
text: '借还书'
5246
},
5347
tooltip: {
5448
trigger: 'axis'
5549
},
5650
legend: {
57-
data: ['借书', '还书']
51+
data: ['借书数量', '还书数量']
5852
},
5953
grid: {
6054
left: '3%',
@@ -68,7 +62,7 @@ option = {
6862
}
6963
},
7064
xAxis: {
71-
type: '日期',
65+
type: 'category',
7266
boundaryGap: false,
7367
data: []
7468
},
@@ -84,7 +78,7 @@ option = {
8478
data: []
8579
},
8680
{
87-
name: '还数数量',
81+
name: '还书数量',
8882
type: 'line',
8983
stack: 'Total',
9084
smooth:true,
@@ -93,5 +87,65 @@ option = {
9387
]
9488
};
9589
90+
export default {
91+
name: "HomeView",
92+
data(){
93+
return{
94+
admin: Cookies.get('admin') ? JSON.parse(Cookies.get('admin')) : {},
95+
lineBox:null,
96+
timeRange:'week',//时间范围
97+
options:[
98+
{label:'最近一周',value:'week'},
99+
{label:'最近一个月',value:'month'},
100+
{label:'最近两个月',value:'month2'},
101+
{label:'最近三个月',value:'month3'},
102+
],
103+
tableData: [{
104+
date: '2016-05-02',
105+
name: '王小虎',
106+
address: '上海市普陀区金沙江路 1518 弄'
107+
}, {
108+
date: '2016-05-04',
109+
name: '王小虎',
110+
address: '上海市普陀区金沙江路 1517 弄'
111+
}, {
112+
date: '2016-05-01',
113+
name: '王小虎',
114+
address: '上海市普陀区金沙江路 1519 弄'
115+
}, {
116+
date: '2016-05-03',
117+
name: '王小虎',
118+
address: '上海市普陀区金沙江路 1516 弄'
119+
}]
120+
}
121+
},
122+
// 初始化完后执行
123+
mounted(){
124+
this.load()
125+
},
126+
methods:{
127+
load(){
128+
if(!this.lineBox){
129+
this.lineBox = echarts.init(document.getElementById('line'))//初始化容器
130+
}
131+
//从后台获取数据
132+
request.get('/borrow/lineCharts/'+ this.timeRange).then(res =>{
133+
option.xAxis.data = res.data.date
134+
option.series[0].data = res.data.borrow
135+
option.series[1].data = res.data.retur
136+
this.lineBox.setOption(option)//设置容器属性值
137+
})
138+
139+
}
140+
}
141+
};
142+
143+
144+
96145
97146
</script>
147+
<style>
148+
.input {
149+
width: 300px;
150+
}
151+
</style>

0 commit comments

Comments
 (0)