Skip to content

Commit e7c6994

Browse files
committed
dd
1 parent baa114f commit e7c6994

File tree

11 files changed

+415
-11
lines changed

11 files changed

+415
-11
lines changed

package-lock.json

Lines changed: 13 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
@@ -11,6 +11,7 @@
1111
},
1212
"dependencies": {
1313
"babel-plugin-transform-remove-strict-mode": "0.0.2",
14+
"echarts": "^4.1.0",
1415
"less": "^3.8.0",
1516
"less-loader": "^4.1.0",
1617
"vue": "^2.5.2",

src/components/layout/LayoutMain.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,13 @@
7373
},
7474
logout:function () {
7575
network.post(api.logout).then(()=>{
76-
this.$router.push({path:config.login_path})
76+
77+
7778
authorize.clearToken()
7879
this.$store.commit('CLEAR_USER_INFO')
80+
//采取跳转目的是为了清空router,因为之前采取了addRouter,但是没法清除,只能刷新页面
81+
window.location.href=config.login_path
82+
// this.$router.push({path:config.login_path})
7983
})
8084
}
8185
}

src/components/mod/Echarts.vue

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<template>
2+
<div class="echarts" :style="{width:w,height:h}">
3+
<div :id="domCharts" class="echarts-canvas"></div>
4+
</div>
5+
</template>
6+
<script>
7+
import network from '../../utils/base/network'
8+
import echarts from 'echarts'
9+
import helper from '../../utils/base/helper'
10+
11+
export default {
12+
name:'Echarts',
13+
props:{
14+
option:Object,
15+
url:String,
16+
params:Object,
17+
parseData:Function,
18+
width:[String,Number],
19+
height:[String,Number],
20+
21+
},
22+
computed:{
23+
w:function () {
24+
if(!isNaN(this.width)){
25+
return this.width+'px';
26+
}else if(this.width.indexOf('%')!= -1) {
27+
return this.width
28+
}else {
29+
return this.width+'px';
30+
}
31+
},
32+
h:function () {
33+
if(!isNaN(this.height)){
34+
return this.height+'px';
35+
}else if(this.height.indexOf('%')!= -1) {
36+
return this.height
37+
}else {
38+
return this.height+'px';
39+
}
40+
}
41+
},
42+
data:function () {
43+
return{
44+
domCharts:'chart-'+ helper.randomString(20),
45+
myEcharts:''
46+
}
47+
},
48+
watch:{
49+
'params':function () {
50+
this.reload()
51+
}
52+
},
53+
mounted:function(){
54+
this.init()
55+
},
56+
methods:{
57+
init(){
58+
this.myEcharts=echarts.init(document.getElementById(this.domCharts));
59+
this.myEcharts.setOption(this.option)
60+
this.reload()
61+
},
62+
reload(){
63+
this.myEcharts.showLoading()
64+
network.get(this.url,this.params).then(res=>{
65+
this.myEcharts.hideLoading()
66+
this.parseData(res,this.myEcharts)
67+
})
68+
}
69+
70+
}
71+
72+
73+
}
74+
</script>
75+
76+
<style scoped lang="less">
77+
.echarts{
78+
.echarts-canvas{
79+
width: 100%;
80+
height: 100%;
81+
}
82+
}
83+
84+
</style>

src/components/mod/TabTable.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@
9191
li{
9292
display: inline-block;
9393
list-style: none;
94-
padding: 0 20px;
95-
line-height: 30px;
96-
height: 30px;
94+
padding: 0 25px;
95+
line-height: 36px;
96+
height: 36px;
9797
border-radius: 2px;
9898
background-color: #fff;
9999
box-shadow: 0 2px 2px 0 rgba(225,225,225,.5);

src/components/mod/TableBox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
if(this.autoLoad){
126126
this.requestData(this.page)
127127
}
128+
128129
},
129130
methods:{
130131
rowIndex:function (index) {
@@ -147,7 +148,6 @@
147148
requestData:function(page){
148149
//请求数据
149150
150-
console.log(this.url)
151151
152152
if(this.url){
153153
this.loading=true

src/components/proj/LabelRadio.vue

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<template>
2+
<div class="label-radio">
3+
<label v-for="option in options" @click="change(option.value)" class="btn btn-default" :class="{active:option.value==value}">{{option.title}}</label>
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
name:'LableRadio',
10+
props:{
11+
value:[String,Number],
12+
options:Array
13+
},
14+
methods:{
15+
change(val){
16+
if(this.value!=val){
17+
this.$emit('input',val)
18+
this.$emit('change',val)
19+
}
20+
21+
}
22+
}
23+
}
24+
25+
</script>
26+
27+
<style scoped lang="less">
28+
.label-radio{
29+
label{
30+
border-radius: 0;
31+
margin-right: -1px;
32+
33+
&:first-child{
34+
border-top-left-radius: 5px;
35+
border-bottom-left-radius: 5px;
36+
}
37+
&:last-child{
38+
border-top-right-radius: 5px;
39+
border-bottom-right-radius: 5px;
40+
}
41+
&.active{
42+
background-color: #e6e6e6;
43+
border-color: #adadad;
44+
}
45+
}
46+
}
47+
</style>

src/pages/site/Index.vue

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,103 @@
11
<template>
22
<div>
3-
<p>首页内容</p>
3+
<p id="test2">首页内容</p>
4+
<div id="test">{{message}}</div>
5+
<table-box ref="tableBox" :url="table.url" :columns="table.columns" :key-name="table.keyName" :parse-data="table.parseData" :data="table.data" :multi-select="table.multiSelect">
6+
7+
<tr slot="row" slot-scope="props">
8+
<td class="tc">{{props.index}}</td>
9+
<td><img :src="props.item.avatar" width="50" height="50"/></td>
10+
<td>{{props.item.nickname}}</td>
11+
<td>{{props.item.province}}-{{props.item.city}}</td>
12+
<td class="tc">{{props.item.sex}}</td>
13+
<td>{{props.item.created_at}}</td>
14+
</tr>
15+
16+
17+
</table-box>
418
</div>
519
</template>
620

721
<script>
822
23+
import TableBox from '../../components/mod/TableBox'
24+
925
import authorize from '../../utils/base/authorize'
1026
import api from '../../utils/config/api'
1127
import network from '../../utils/base/network'
1228
import {SET_BREADCRUMB} from "../../store/mutation-types";
1329
1430
export default {
1531
name: 'Index',
16-
components: {},
32+
components: {TableBox},
1733
1834
data:function () {
1935
return {
36+
message:'ceshi',
37+
table:{
38+
url:api.member_index,
39+
multiSelect:false,
40+
keyName:'id',
41+
columns:[
42+
{
43+
title:"头像",
44+
field:"avatar",
45+
width:'80'
46+
},
47+
{
48+
title:"昵称",
49+
field:"nickname",
50+
width:''
51+
},
52+
{
53+
title:"所在地区",
54+
field:"province",
55+
width:''
56+
},
57+
{
58+
title:"性别",
59+
field:"sex",
60+
width:'80'
61+
},
62+
{
63+
title:"注册时间",
64+
field:"created_at",
65+
width:'160'
66+
},
2067
21-
68+
],
69+
parseData:function (data) {
70+
data.forEach(function(row){
71+
row.sex=row.sex==1?'':''
72+
})
73+
}
74+
}
2275
}
2376
},
77+
beforeCreate:function(){
78+
console.log('====父组件:beforeCreate=====')
79+
},
80+
created:function(){
81+
console.log('====父组件:created=====')
82+
},
83+
beforeMount:function(){
84+
console.log('====父组件:beforeMount=====')
85+
},
86+
beforeUpdate:function(){
87+
console.log('====父组件: beforeUpdate=====')
88+
},
89+
90+
91+
methods:{
92+
test:function () {
93+
console.log("methods-test")
94+
}
95+
},
2496
mounted:function () {
97+
console.log('====父组件:mounted=====')
98+
99+
100+
25101
let breadcrumb=[
26102
{
27103
link: '/index',

0 commit comments

Comments
 (0)