|
|
@@ -1,204 +1,291 @@
|
|
1
|
1
|
<template>
|
|
2
|
2
|
<div class="app-container role_setup">
|
|
3
|
3
|
<div class="filter-container">
|
|
4
|
|
- <el-input v-model="keyword" placeholder="请输入角色代码" class="filter-item" />
|
|
5
|
|
- <el-button type="primary" class="filter-item" icon="el-icon-search" @click="btn_search">搜索</el-button>
|
|
6
|
|
- <el-button type="primary" class="filter-item" icon="el-icon-plus" @click="btn_add">添加</el-button>
|
|
7
|
|
- <el-button type="primary" class="filter-item" icon="el-icon-edit" @click="btn_edit">编辑</el-button>
|
|
8
|
|
- <el-button type="primary" class="filter-item" icon="el-icon-delete" @click="btn_delete">删除</el-button>
|
|
9
|
|
- <el-button type="primary" class="filter-item" @click="btn_save"><svg-icon icon-class="baocun" />保存角色权限</el-button>
|
|
|
4
|
+ <el-input
|
|
|
5
|
+ v-model="keyword"
|
|
|
6
|
+ placeholder="请输入角色代码"
|
|
|
7
|
+ class="filter-item"
|
|
|
8
|
+ />
|
|
|
9
|
+ <el-button
|
|
|
10
|
+ type="primary"
|
|
|
11
|
+ class="filter-item"
|
|
|
12
|
+ icon="el-icon-search"
|
|
|
13
|
+ @click="btn_search"
|
|
|
14
|
+ >搜索</el-button
|
|
|
15
|
+ >
|
|
|
16
|
+ <el-button
|
|
|
17
|
+ type="primary"
|
|
|
18
|
+ class="filter-item"
|
|
|
19
|
+ icon="el-icon-plus"
|
|
|
20
|
+ @click="btn_add"
|
|
|
21
|
+ >添加</el-button
|
|
|
22
|
+ >
|
|
|
23
|
+ <el-button
|
|
|
24
|
+ type="primary"
|
|
|
25
|
+ class="filter-item"
|
|
|
26
|
+ icon="el-icon-edit"
|
|
|
27
|
+ @click="btn_edit"
|
|
|
28
|
+ >编辑</el-button
|
|
|
29
|
+ >
|
|
|
30
|
+ <el-button
|
|
|
31
|
+ type="primary"
|
|
|
32
|
+ class="filter-item"
|
|
|
33
|
+ icon="el-icon-delete"
|
|
|
34
|
+ @click="btn_delete"
|
|
|
35
|
+ >删除</el-button
|
|
|
36
|
+ >
|
|
|
37
|
+ <el-button type="primary" class="filter-item" @click="btn_save"
|
|
|
38
|
+ ><svg-icon icon-class="baocun" />保存角色权限</el-button
|
|
|
39
|
+ >
|
|
10
|
40
|
</div>
|
|
11
|
41
|
<el-row :gutter="20">
|
|
12
|
42
|
<el-col :span="12">
|
|
13
|
43
|
<el-alert :closable="false" title="角色列表" type="success" />
|
|
14
|
|
- <el-table v-loading="loading" :data="roleLists" border stripe highlight-current-row @row-click="handleTableClick">
|
|
15
|
|
- <el-table-column type="index" label="编号" align="center" fixed width="80" />
|
|
16
|
|
- <el-table-column prop="F_RoleName" label="用户角色" align="center" min-width="" />
|
|
17
|
|
- <el-table-column prop="F_RoleCode" label="角色代码" align="center" min-width="" />
|
|
18
|
|
- <el-table-column prop="F_CreateTime" label="创建时间" align="center" width="200" />
|
|
19
|
|
- <el-table-column prop="F_CreateUser" label="创建人" align="center" min-width="" />
|
|
20
|
|
- <el-table-column prop="F_Remark" label="备注" align="center" min-width="" />
|
|
|
44
|
+ <el-table
|
|
|
45
|
+ v-loading="loading"
|
|
|
46
|
+ :data="roleLists"
|
|
|
47
|
+ border
|
|
|
48
|
+ stripe
|
|
|
49
|
+ highlight-current-row
|
|
|
50
|
+ @row-click="handleTableClick"
|
|
|
51
|
+ >
|
|
|
52
|
+ <el-table-column
|
|
|
53
|
+ type="index"
|
|
|
54
|
+ label="编号"
|
|
|
55
|
+ align="center"
|
|
|
56
|
+ fixed
|
|
|
57
|
+ width="80"
|
|
|
58
|
+ />
|
|
|
59
|
+ <el-table-column
|
|
|
60
|
+ prop="F_RoleName"
|
|
|
61
|
+ label="用户角色"
|
|
|
62
|
+ align="center"
|
|
|
63
|
+ min-width=""
|
|
|
64
|
+ />
|
|
|
65
|
+ <el-table-column
|
|
|
66
|
+ prop="F_RoleCode"
|
|
|
67
|
+ label="角色代码"
|
|
|
68
|
+ align="center"
|
|
|
69
|
+ min-width=""
|
|
|
70
|
+ />
|
|
|
71
|
+ <el-table-column
|
|
|
72
|
+ prop="F_CreateTime"
|
|
|
73
|
+ label="创建时间"
|
|
|
74
|
+ align="center"
|
|
|
75
|
+ width="200"
|
|
|
76
|
+ />
|
|
|
77
|
+ <el-table-column
|
|
|
78
|
+ prop="F_CreateUser"
|
|
|
79
|
+ label="创建人"
|
|
|
80
|
+ align="center"
|
|
|
81
|
+ min-width=""
|
|
|
82
|
+ />
|
|
|
83
|
+ <el-table-column
|
|
|
84
|
+ prop="F_Remark"
|
|
|
85
|
+ label="备注"
|
|
|
86
|
+ align="center"
|
|
|
87
|
+ min-width=""
|
|
|
88
|
+ />
|
|
21
|
89
|
</el-table>
|
|
22
|
|
- <pagination v-show="pageParams.total > 0" :total="pageParams.total" :pageindex.sync="pageParams.pageindex" :pagesize.sync="pageParams.pagesize" class="pagination" @pagination="getList" />
|
|
|
90
|
+ <pagination
|
|
|
91
|
+ v-show="pageParams.total > 0"
|
|
|
92
|
+ :total="pageParams.total"
|
|
|
93
|
+ :pageindex.sync="pageParams.pageindex"
|
|
|
94
|
+ :pagesize.sync="pageParams.pagesize"
|
|
|
95
|
+ class="pagination"
|
|
|
96
|
+ @pagination="getList"
|
|
|
97
|
+ />
|
|
23
|
98
|
</el-col>
|
|
24
|
99
|
<el-col :span="12">
|
|
25
|
100
|
<el-alert :closable="false" title="权限树" type="success" />
|
|
26
|
|
- <el-tree ref="treeRef" :data="treelists" show-checkbox node-key="id" highlight-current />
|
|
|
101
|
+ <el-tree
|
|
|
102
|
+ ref="treeRef"
|
|
|
103
|
+ :check-strictly="treeCheckFlag"
|
|
|
104
|
+ :data="treelists"
|
|
|
105
|
+ show-checkbox
|
|
|
106
|
+ node-key="id"
|
|
|
107
|
+ highlight-current
|
|
|
108
|
+ />
|
|
27
|
109
|
</el-col>
|
|
28
|
110
|
</el-row>
|
|
29
|
111
|
</div>
|
|
30
|
112
|
</template>
|
|
31
|
113
|
|
|
32
|
114
|
<script>
|
|
33
|
|
-import { getRoleLists, deleteRole, saveRoleList, getRoleTree } from '@/api/systemSetup/roleSetting/roleSetup'
|
|
34
|
|
-import addOrEditRole from './addOrEditRole'
|
|
35
|
|
-import { pickerOptions,buildTree,filterTreeDatas } from '@/utils'
|
|
36
|
|
-import Pagination from '@/components/context/Pagination' // 对el-pagination 二次封装
|
|
|
115
|
+import {
|
|
|
116
|
+ getRoleLists,
|
|
|
117
|
+ deleteRole,
|
|
|
118
|
+ saveRoleList,
|
|
|
119
|
+ getRoleTree,
|
|
|
120
|
+} from "@/api/systemSetup/roleSetting/roleSetup";
|
|
|
121
|
+import addOrEditRole from "./addOrEditRole";
|
|
|
122
|
+import { pickerOptions, buildTree, filterTreeDatas } from "@/utils";
|
|
|
123
|
+import Pagination from "@/components/context/Pagination"; // 对el-pagination 二次封装
|
|
37
|
124
|
|
|
38
|
125
|
export default {
|
|
39
|
|
- name: 'RoleSetup',
|
|
|
126
|
+ name: "RoleSetup",
|
|
40
|
127
|
components: {
|
|
41
|
|
- Pagination
|
|
|
128
|
+ Pagination,
|
|
42
|
129
|
},
|
|
43
|
130
|
data() {
|
|
44
|
131
|
return {
|
|
45
|
132
|
loading: false,
|
|
46
|
|
- searchDate: '',
|
|
47
|
|
- keyword: '',
|
|
|
133
|
+ searchDate: "",
|
|
|
134
|
+ keyword: "",
|
|
|
135
|
+ treeCheckFlag: true,
|
|
48
|
136
|
pageParams: {
|
|
49
|
137
|
pageindex: 1, // 当前第几页
|
|
50
|
138
|
pagesize: Number(this.$store.getters.serverConfig.PAGESIZE), // 每页几条数据
|
|
51
|
|
- total: 0 // 总共多少数据
|
|
|
139
|
+ total: 0, // 总共多少数据
|
|
52
|
140
|
},
|
|
53
|
141
|
pickerOptions, // 日期选择器快捷选项
|
|
54
|
142
|
roleLists: [], // 角色列表数据
|
|
55
|
143
|
treelists: [], // 菜单树数据
|
|
56
|
|
- role_id: '' // 角色id
|
|
57
|
|
- }
|
|
|
144
|
+ role_id: "", // 角色id
|
|
|
145
|
+ };
|
|
58
|
146
|
},
|
|
59
|
147
|
created() {
|
|
60
|
148
|
this.getList().then(() => {
|
|
61
|
|
- this.getTreeList()
|
|
62
|
|
- })
|
|
|
149
|
+ this.getTreeList();
|
|
|
150
|
+ });
|
|
63
|
151
|
document.onkeyup = (e) => {
|
|
64
|
152
|
if (e.keyCode === 13) {
|
|
65
|
|
- this.getList()
|
|
|
153
|
+ this.getList();
|
|
66
|
154
|
}
|
|
67
|
|
- }
|
|
|
155
|
+ };
|
|
68
|
156
|
},
|
|
69
|
157
|
methods: {
|
|
70
|
158
|
getList() {
|
|
71
|
|
- this.loading = true
|
|
|
159
|
+ this.loading = true;
|
|
72
|
160
|
return new Promise((resolve) => {
|
|
73
|
161
|
const params = {
|
|
74
|
162
|
pageindex: this.pageParams.pageindex, // 第几页
|
|
75
|
163
|
pagesize: this.pageParams.pagesize, // 每页几条信息
|
|
76
|
|
- keyword: this.keyword.replace(/\s+/g, ''), // 项目名称,项目类型,项目负责人
|
|
|
164
|
+ keyword: this.keyword.replace(/\s+/g, ""), // 项目名称,项目类型,项目负责人
|
|
77
|
165
|
stime: this.searchDate && this.searchDate[0],
|
|
78
|
|
- etime: this.searchDate && this.searchDate[1]
|
|
79
|
|
- }
|
|
|
166
|
+ etime: this.searchDate && this.searchDate[1],
|
|
|
167
|
+ };
|
|
80
|
168
|
getRoleLists(params).then((response) => {
|
|
81
|
|
- this.loading = false
|
|
|
169
|
+ this.loading = false;
|
|
82
|
170
|
if (response.rows.length > 0) {
|
|
83
|
|
- this.pageParams.total = response.total
|
|
84
|
|
- this.roleLists = response.rows
|
|
85
|
|
- this.$refs.treeRef.setCheckedKeys([]) // 清空权限树的选中状态
|
|
86
|
|
- this.role_id = ''
|
|
|
171
|
+ this.pageParams.total = response.total;
|
|
|
172
|
+ this.roleLists = response.rows;
|
|
|
173
|
+ this.$refs.treeRef.setCheckedKeys([]); // 清空权限树的选中状态
|
|
|
174
|
+ this.role_id = "";
|
|
87
|
175
|
}
|
|
88
|
|
- })
|
|
89
|
|
- resolve()
|
|
90
|
|
- })
|
|
|
176
|
+ });
|
|
|
177
|
+ resolve();
|
|
|
178
|
+ });
|
|
91
|
179
|
},
|
|
92
|
180
|
// 点击某一行的table
|
|
93
|
181
|
handleTableClick(row, event, column) {
|
|
94
|
|
- this.role_id = row.F_RoleId
|
|
95
|
|
- this.getTreeList()
|
|
|
182
|
+ this.role_id = row.F_RoleId;
|
|
|
183
|
+ this.getTreeList();
|
|
96
|
184
|
},
|
|
97
|
185
|
btn_search() {
|
|
98
|
|
- this.pageParams.pageindex = 1
|
|
99
|
|
- this.getList()
|
|
|
186
|
+ this.pageParams.pageindex = 1;
|
|
|
187
|
+ this.getList();
|
|
100
|
188
|
},
|
|
101
|
189
|
btn_add() {
|
|
102
|
190
|
this.$layer.iframe({
|
|
103
|
191
|
content: {
|
|
104
|
192
|
content: addOrEditRole, // 传递的组件对象
|
|
105
|
193
|
parent: this, // 当前的vue对象
|
|
106
|
|
- data: { rowid: '' } // props//该方法会自动添加一个key为layerid的值, 该值为创建层的id, 可以直接使用
|
|
|
194
|
+ data: { rowid: "" }, // props//该方法会自动添加一个key为layerid的值, 该值为创建层的id, 可以直接使用
|
|
107
|
195
|
},
|
|
108
|
|
- area: ['40%', '400px'],
|
|
|
196
|
+ area: ["40%", "400px"],
|
|
109
|
197
|
shadeClose: false,
|
|
110
|
|
- title: '添加用户角色'
|
|
111
|
|
- })
|
|
|
198
|
+ title: "添加用户角色",
|
|
|
199
|
+ });
|
|
112
|
200
|
},
|
|
113
|
201
|
btn_edit() {
|
|
114
|
202
|
if (!this.role_id) {
|
|
115
|
|
- this.$message.warning('请先选择要编辑的用户角色!')
|
|
116
|
|
- return
|
|
|
203
|
+ this.$message.warning("请先选择要编辑的用户角色!");
|
|
|
204
|
+ return;
|
|
117
|
205
|
}
|
|
118
|
206
|
this.$layer.iframe({
|
|
119
|
207
|
content: {
|
|
120
|
208
|
content: addOrEditRole, // 传递的组件对象
|
|
121
|
209
|
parent: this, // 当前的vue对象
|
|
122
|
|
- data: { rowid: this.role_id } // props//该方法会自动添加一个key为layerid的值, 该值为创建层的id, 可以直接使用
|
|
|
210
|
+ data: { rowid: this.role_id }, // props//该方法会自动添加一个key为layerid的值, 该值为创建层的id, 可以直接使用
|
|
123
|
211
|
},
|
|
124
|
|
- area: ['40%', '400px'],
|
|
|
212
|
+ area: ["40%", "400px"],
|
|
125
|
213
|
shadeClose: false,
|
|
126
|
|
- title: '编辑用户角色'
|
|
127
|
|
- })
|
|
|
214
|
+ title: "编辑用户角色",
|
|
|
215
|
+ });
|
|
128
|
216
|
},
|
|
129
|
217
|
btn_delete() {
|
|
130
|
218
|
if (!this.role_id) {
|
|
131
|
|
- this.$message.warning('请先选择要删除的用户角色!')
|
|
132
|
|
- return
|
|
|
219
|
+ this.$message.warning("请先选择要删除的用户角色!");
|
|
|
220
|
+ return;
|
|
133
|
221
|
}
|
|
134
|
|
- if (this.role_id === '5aaa5a54b9c1893cb015df26') {
|
|
135
|
|
- this.$message.warning('系统维护不能删除!')
|
|
136
|
|
- return
|
|
|
222
|
+ if (this.role_id === "5aaa5a54b9c1893cb015df26") {
|
|
|
223
|
+ this.$message.warning("系统维护不能删除!");
|
|
|
224
|
+ return;
|
|
137
|
225
|
}
|
|
138
|
|
- this.$confirm('此操作将永久删除当前角色, 是否继续?', '提示', {
|
|
139
|
|
- confirmButtonText: '确定',
|
|
140
|
|
- cancelButtonText: '取消',
|
|
141
|
|
- type: 'warning'
|
|
|
226
|
+ this.$confirm("此操作将永久删除当前角色, 是否继续?", "提示", {
|
|
|
227
|
+ confirmButtonText: "确定",
|
|
|
228
|
+ cancelButtonText: "取消",
|
|
|
229
|
+ type: "warning",
|
|
142
|
230
|
})
|
|
143
|
231
|
.then(() => {
|
|
144
|
232
|
deleteRole(this.role_id).then((response) => {
|
|
145
|
|
- if (response.state.toLowerCase() === 'success') {
|
|
146
|
|
- this.getList()
|
|
147
|
|
- this.$message.success('删除成功!')
|
|
|
233
|
+ if (response.state.toLowerCase() === "success") {
|
|
|
234
|
+ this.getList();
|
|
|
235
|
+ this.$message.success("删除成功!");
|
|
148
|
236
|
}
|
|
149
|
|
- })
|
|
|
237
|
+ });
|
|
150
|
238
|
})
|
|
151
|
239
|
.catch(() => {
|
|
152
|
|
- this.$message.info('已取消删除')
|
|
153
|
|
- })
|
|
|
240
|
+ this.$message.info("已取消删除");
|
|
|
241
|
+ });
|
|
154
|
242
|
},
|
|
155
|
243
|
btn_save() {
|
|
156
|
244
|
if (!this.role_id) {
|
|
157
|
|
- this.$message.warning('请先选择用户角色!')
|
|
158
|
|
- return
|
|
|
245
|
+ this.$message.warning("请先选择用户角色!");
|
|
|
246
|
+ return;
|
|
159
|
247
|
}
|
|
160
|
248
|
if (this.$refs.treeRef.getCheckedKeys().length === 0) {
|
|
161
|
|
- this.$message.warning('请选择权限!')
|
|
162
|
|
- return
|
|
|
249
|
+ this.$message.warning("请选择权限!");
|
|
|
250
|
+ return;
|
|
163
|
251
|
}
|
|
164
|
252
|
saveRoleList({
|
|
165
|
253
|
roleid: this.role_id, // 角色id
|
|
166
|
|
- menuids: this.$refs.treeRef.getCheckedKeys() // 选中权限树的id值,
|
|
|
254
|
+ menuids: this.$refs.treeRef.getCheckedKeys(), // 选中权限树的id值,
|
|
167
|
255
|
}).then((response) => {
|
|
168
|
|
- if (response.state.toLowerCase() === 'success') {
|
|
169
|
|
- this.$message.success('恭喜你,角色权限保存成功!')
|
|
|
256
|
+ if (response.state.toLowerCase() === "success") {
|
|
|
257
|
+ this.$message.success("恭喜你,角色权限保存成功!");
|
|
170
|
258
|
}
|
|
171
|
|
- })
|
|
|
259
|
+ });
|
|
172
|
260
|
},
|
|
173
|
261
|
// 权限树
|
|
174
|
262
|
getTreeList() {
|
|
175
|
263
|
return new Promise((resolve) => {
|
|
176
|
264
|
getRoleTree(this.role_id).then((response) => {
|
|
177
|
|
- if (response.state.toLowerCase() === 'success') {
|
|
178
|
|
- this.treelists = filterTreeDatas(buildTree(response.data))
|
|
|
265
|
+ if (response.state.toLowerCase() === "success") {
|
|
|
266
|
+ this.treelists = filterTreeDatas(buildTree(response.data));
|
|
179
|
267
|
if (this.role_id) {
|
|
180
|
268
|
// 获取ischecked数组 设置选中
|
|
181
|
|
- const checkedKeys = this.getIsChecked(response.data)
|
|
182
|
|
- this.$refs.treeRef.setCheckedKeys(checkedKeys)
|
|
|
269
|
+ const checkedKeys = this.getIsChecked(response.data);
|
|
|
270
|
+ this.$refs.treeRef.setCheckedKeys(checkedKeys);
|
|
183
|
271
|
}
|
|
184
|
272
|
}
|
|
185
|
|
- })
|
|
186
|
|
- resolve()
|
|
187
|
|
- })
|
|
|
273
|
+ });
|
|
|
274
|
+ resolve();
|
|
|
275
|
+ });
|
|
188
|
276
|
},
|
|
189
|
277
|
// 获取ischecked数组 设置选中
|
|
190
|
278
|
getIsChecked(checkeds) {
|
|
191
|
|
- const checkedArr = []
|
|
|
279
|
+ const checkedArr = [];
|
|
192
|
280
|
for (let i = 0, len = checkeds.length; i < len; i++) {
|
|
193
|
281
|
if (checkeds[i].ischecked === true) {
|
|
194
|
|
- checkedArr.push(checkeds[i].id)
|
|
|
282
|
+ checkedArr.push(checkeds[i].id);
|
|
195
|
283
|
}
|
|
196
|
284
|
}
|
|
197
|
|
- return checkedArr
|
|
|
285
|
+ return checkedArr;
|
|
198
|
286
|
},
|
|
199
|
|
-
|
|
200
|
|
- }
|
|
201
|
|
-}
|
|
|
287
|
+ },
|
|
|
288
|
+};
|
|
202
|
289
|
</script>
|
|
203
|
290
|
|
|
204
|
291
|
<!-- 需要注意的是,修改elementUI的默认样式的css不能使用scoped. -->
|