Skip to content

Commit 611ebe5

Browse files
committed
加入mutliselect插件,替换原有element ui select ,解决select v-model绑定obj数据回显问题
1 parent 4971cc3 commit 611ebe5

File tree

9 files changed

+44
-12
lines changed

9 files changed

+44
-12
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"normalize.css": "7.0.0",
2020
"nprogress": "0.2.0",
2121
"vue": "2.5.2",
22+
"vue-multiselect": "^2.0.8",
2223
"vue-router": "2.7.0",
2324
"vuex": "2.3.1"
2425
},

src/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Vue from 'vue'
22
import ElementUI from 'element-ui'
33
import 'element-ui/lib/theme-chalk/index.css'
4+
import 'vue-multiselect/dist/vue-multiselect.min.css'
45
import locale from 'element-ui/lib/locale/lang/en'
56
import App from './App'
67
import router from './router'

src/store/getters.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const getters = {
66
name: state => state.user.name,
77
roles: state => state.user.roles,
88
permission_routers: state => state.permission.routers,
9-
addRouters: state => state.permission.addRouters
9+
addRouters: state => state.permission.addRouters,
10+
AllRouters:state=>state.permission.AllRouters
1011
}
1112
export default getters

src/store/modules/permission.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,17 @@ function filterAsyncRouter(asyncRouterMap, roles) {
3434
const permission = {
3535
state: {
3636
routers: constantRouterMap,
37-
addRouters: []
37+
addRouters: [],
38+
AllRouters:[]
3839
},
3940
mutations: {
4041
SET_ROUTERS: (state, routers) => {
4142
state.addRouters = routers
4243
state.routers = constantRouterMap.concat(routers)
44+
},
45+
46+
SET_ALLROUTERS: (state) => {
47+
state.AllRouters = constantRouterMap.concat(asyncRouterMap)
4348
}
4449
},
4550
actions: {
@@ -53,6 +58,9 @@ const permission = {
5358
accessedRouters = filterAsyncRouter(asyncRouterMap, roles)
5459
}
5560
commit('SET_ROUTERS', accessedRouters)
61+
62+
commit('SET_ALLROUTERS')
63+
5664
resolve()
5765
})
5866
}

src/views/dashboard/index.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="dashboard-container">
33
<el-row>
4-
<el-col :span="8">
4+
<el-col :span="6">
55
<el-card :body-style="{ padding: '15px 0px',height:'250px'}">
66
<i class="el-icon-edit" style="font-size:30px"></i>
77

@@ -16,12 +16,13 @@
1616

1717
</el-card>
1818
</el-col>
19-
<el-col :span="8" :offset="2">
19+
<el-col :span="6" :offset="2">
2020
<el-card :body-style="{ padding: '15px 0px',height:'250px'}">
2121
<i class="el-icon-location" style="font-size:30px"></i>
2222

2323
<div class="dashboard-text" style="padding-top:0px">{{weather.city}}天气</div>
24-
<div class="dashboard-text">空气质量:{{weather.data.quality}},气温:{{weather.data.wendu}}℃,湿度:{{weather.data.shidu}}</div>
24+
<div class="dashboard-text">空气质量:{{weather.data.quality}}。</div>
25+
<div class="dashboard-text">气温:{{weather.data.wendu}}℃,湿度:{{weather.data.shidu}}。</div>
2526

2627
</el-card>
2728
</el-col>

src/views/layout/Levelbar.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,11 @@ export default {
4646
cursor: text;
4747
}
4848
}
49+
.app-levelbar.el-breadcrumb :focus{
50+
outline:none;
51+
}
52+
53+
54+
55+
4956
</style>

src/views/layout/Sidebar.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ export default {
1111
components: { SidebarItem },
1212
computed: {
1313
...mapGetters([
14-
'permission_routers'
14+
'permission_routers',
15+
'AllRouters'
1516
])
17+
},
18+
created(){
19+
console.log(this.AllRouters)
20+
1621
}
1722
}
1823
</script>

src/views/login/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="login-container">
33
<el-form autoComplete="on" :model="loginForm" ref="loginForm" label-position="left" label-width="0px"
44
class="card-box login-form">
5-
<h3 class="title"> <img style="width:7%" src='/favicon.ico'> Anshare</h3>
5+
<h3 class="title"> <img style="width:7%" src='/logo.ico'> Anshare</h3>
66

77

88
<el-form-item prop="username">

src/views/system/users.vue

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,13 @@
8181
</el-form-item>
8282

8383
<el-form-item label="角色">
84-
<el-select v-model="RoleID" placeholder="请选择">
84+
<!-- <el-select v-model="RoleID" placeholder="请选择">
8585
<el-option v-for="item in options" :key="item.ID" :label="item.RoleName" :value="item.ID">
8686
</el-option>
87-
</el-select>
87+
</el-select> -->
88+
<multiselect :value="RoleID" :options="options" :searchable="false" :close-on-select="true" :allow-empty="false" label="RoleName"
89+
placeholder="请选择角色" track-by="RoleName">
90+
</multiselect>
8891
</el-form-item>
8992
</el-form>
9093
<div slot="footer" class="dialog-footer">
@@ -111,10 +114,12 @@
111114
import {
112115
GetRoles
113116
} from "@/api/system/role";
117+
import Multiselect from 'vue-multiselect'
114118
115119
export default {
116120
data() {
117121
return {
122+
RoleID:"",
118123
depttree: [],
119124
textMap: {
120125
update: "编辑",
@@ -139,9 +144,14 @@
139144
defaultProps: {
140145
children: "children",
141146
label: "text"
142-
}
147+
},
148+
selected: null
149+
143150
};
144151
},
152+
components: {
153+
Multiselect
154+
},
145155
146156
created() {
147157
this.fetchData();
@@ -199,11 +209,9 @@
199209
200210
GetUsersDetail(ID).then(response => {
201211
202-
this.dialogStatus = "update";
203212
this.temp = response.data;
204213
this.$refs.tree.setCheckedKeys([this.temp.DeptID]);
205214
this.RoleID = this.temp.RoleID;
206-
this.fetchData();
207215
});
208216
},
209217

0 commit comments

Comments
 (0)