|
@@ -3,7 +3,7 @@
|
3
|
3
|
<div class="system-table-search">
|
4
|
4
|
<div class="flex-h">
|
5
|
5
|
<div class="flex-item flex-h">
|
6
|
|
- <el-button size="mini" type="success" @click='editRole'>新增角色</el-button>
|
|
6
|
+ <el-button size="mini" type="success" @click='addRole'>新增角色</el-button>
|
7
|
7
|
</div>
|
8
|
8
|
<tableSearch value='角色名称' @exportSearchKey="searchList"></tableSearch>
|
9
|
9
|
</div>
|
|
@@ -35,24 +35,26 @@
|
35
|
35
|
layout="prev, pager, next, jumper"
|
36
|
36
|
:total="roles.pagenum">
|
37
|
37
|
</el-pagination>
|
38
|
|
- <!-- <el-dialog title="请选择机构" :visible.sync="dialogTableVisible">
|
|
38
|
+ <el-dialog title="请选择菜单" :visible.sync="dialogTableVisible">
|
39
|
39
|
<el-tree
|
|
40
|
+ v-if="dialogTableVisible"
|
40
|
41
|
class="flxe-h"
|
41
|
|
- :data="treeData"
|
|
42
|
+ :data="menus"
|
42
|
43
|
:default-expand-all="true"
|
43
|
44
|
:expand-on-click-node="false"
|
|
45
|
+ :default-checked-keys="defaultChecked"
|
44
|
46
|
ref="tree"
|
45
|
47
|
show-checkbox
|
46
|
48
|
@node-click="handleNodeClick"></el-tree>
|
47
|
49
|
<div class="flex-h" style="justify-content: flex-end;margin-top: 1rem">
|
48
|
50
|
<el-button type='success' @click="getCheckedNodes">确定</el-button>
|
49
|
51
|
</div>
|
50
|
|
- </el-dialog> -->
|
|
52
|
+ </el-dialog>
|
51
|
53
|
</div>
|
52
|
54
|
</template>
|
53
|
55
|
|
54
|
56
|
<script>
|
55
|
|
-import { createNamespacedHelpers } from 'vuex'
|
|
57
|
+import { createNamespacedHelpers, mapState } from 'vuex'
|
56
|
58
|
import tableSearch from '@/components/tableSearch/index'
|
57
|
59
|
|
58
|
60
|
const { mapState: mapRoleState, mapActions: mapRoleActions } = createNamespacedHelpers('role')
|
|
@@ -62,17 +64,26 @@ export default {
|
62
|
64
|
data () {
|
63
|
65
|
return {
|
64
|
66
|
currentPage: 0, // 当前页码
|
65
|
|
- tableSearch: {
|
66
|
|
- // 表格搜索条件
|
67
|
|
- key: '111' // 搜索关键字
|
68
|
|
- },
|
|
67
|
+ key: '',
|
|
68
|
+ selid: '',
|
69
|
69
|
dialogTableVisible: false,
|
70
|
70
|
}
|
71
|
71
|
},
|
72
|
72
|
computed: {
|
73
|
73
|
...mapRoleState({
|
74
|
74
|
roles: x => x.roleList,
|
|
75
|
+ selmenus: x => x.roleMenus,
|
|
76
|
+ }),
|
|
77
|
+ ...mapState({
|
|
78
|
+ menus: x => x.app.menus
|
75
|
79
|
}),
|
|
80
|
+ defaultChecked: {
|
|
81
|
+ get () {
|
|
82
|
+ console.log(this.selmenus)
|
|
83
|
+ // const sels = (this.selmenus || []).map(x => x.MenuId)
|
|
84
|
+ return []
|
|
85
|
+ },
|
|
86
|
+ },
|
76
|
87
|
},
|
77
|
88
|
components: {
|
78
|
89
|
tableSearch
|
|
@@ -80,6 +91,9 @@ export default {
|
80
|
91
|
methods: {
|
81
|
92
|
...mapRoleActions([
|
82
|
93
|
'GetRolesList',
|
|
94
|
+ 'DelRole',
|
|
95
|
+ 'SaveRoleMenus',
|
|
96
|
+ 'GetRoleMenu',
|
83
|
97
|
]),
|
84
|
98
|
FormatDate (date) {
|
85
|
99
|
console.log()
|
|
@@ -98,16 +112,13 @@ export default {
|
98
|
112
|
handleDelete (index, row) {
|
99
|
113
|
// 删除
|
100
|
114
|
console.log(index, row)
|
101
|
|
- this.$confirm('确认删除此用户?', '提示', {
|
|
115
|
+ this.$confirm('确认删除此角色?', '提示', {
|
102
|
116
|
confirmButtonText: '确定',
|
103
|
117
|
cancelButtonText: '取消',
|
104
|
118
|
type: 'warning'
|
105
|
119
|
})
|
106
|
120
|
.then(() => {
|
107
|
|
- this.$message({
|
108
|
|
- type: 'success',
|
109
|
|
- message: '删除成功!'
|
110
|
|
- })
|
|
121
|
+ this.DelRole({id: row.RoleId, callback: this.delCallBack})
|
111
|
122
|
})
|
112
|
123
|
.catch(() => {
|
113
|
124
|
this.$message({
|
|
@@ -116,7 +127,16 @@ export default {
|
116
|
127
|
})
|
117
|
128
|
})
|
118
|
129
|
},
|
|
130
|
+ delCallBack () {
|
|
131
|
+ this.$message({
|
|
132
|
+ type: 'success',
|
|
133
|
+ message: '删除成功!'
|
|
134
|
+ })
|
|
135
|
+ this.GetRolesList({name: this.key})
|
|
136
|
+ },
|
119
|
137
|
handlePermission (index, row) {
|
|
138
|
+ this.selid = row.RoleId
|
|
139
|
+ this.GetRoleMenu(this.selid)
|
120
|
140
|
this.dialogTableVisible = true
|
121
|
141
|
console.log(index)
|
122
|
142
|
},
|
|
@@ -124,14 +144,27 @@ export default {
|
124
|
144
|
console.log(node)
|
125
|
145
|
},
|
126
|
146
|
searchList (key) {
|
127
|
|
- this.GetRolesList({name: key})
|
|
147
|
+ this.key = key
|
|
148
|
+ this.GetRolesList({name: this.key})
|
128
|
149
|
},
|
129
|
150
|
addRole () {
|
130
|
|
- this.$router.push({ name: 'addRole' })
|
|
151
|
+ this.$router.push({ name: 'editRole' })
|
131
|
152
|
},
|
132
|
153
|
getCheckedNodes () { // 获取选中的节点
|
133
|
|
- console.log(this.$refs.tree.getCheckedNodes())
|
134
|
|
- }
|
|
154
|
+ const menuids = this.$refs.tree.getCheckedNodes().map(x => x.id).join(',')
|
|
155
|
+ this.SaveRoleMenus({
|
|
156
|
+ id: this.selid,
|
|
157
|
+ menuids: menuids,
|
|
158
|
+ callback: this.hideDialog,
|
|
159
|
+ })
|
|
160
|
+ },
|
|
161
|
+ hideDialog () {
|
|
162
|
+ this.$message({
|
|
163
|
+ type: 'success',
|
|
164
|
+ message: '操作成功!'
|
|
165
|
+ })
|
|
166
|
+ this.dialogTableVisible = false
|
|
167
|
+ },
|
135
|
168
|
},
|
136
|
169
|
beforeMount () {
|
137
|
170
|
this.GetRolesList()
|