角色管理模块角色权限处理
Showing
5 changed files
with
162 additions
and
143 deletions
... | @@ -10,22 +10,27 @@ import { | ... | @@ -10,22 +10,27 @@ import { |
10 | } from './manageApi' | 10 | } from './manageApi' |
11 | 11 | ||
12 | /** 角色管理开始 */ | 12 | /** 角色管理开始 */ |
13 | // 获取角色列表 by categoryId | 13 | // 获取角色列表 categoryId |
14 | export const getRolesById = categoryId => { | 14 | export const getRolesById = categoryId => { |
15 | const conditionGroup = { | 15 | const conditionGroup = { |
16 | conditions: [ | 16 | conditions: [ |
17 | { | 17 | { |
18 | property: 'category', | 18 | property: 'category', |
19 | value: categoryId, | 19 | value:categoryId, |
20 | operator: 'EQ' | 20 | operator: 'EQ' |
21 | } | 21 | } |
22 | ], | 22 | ], |
23 | queryRelation: 'AND' | 23 | queryRelation: 'AND' |
24 | } | 24 | } |
25 | const params = getParams(conditionGroup) | 25 | const params = getParams(conditionGroup); |
26 | console.log(api.roles,params); | ||
26 | return getAction(api.roles, params) | 27 | return getAction(api.roles, params) |
27 | } | 28 | } |
28 | // 人员列表 | 29 | // 人员列表 |
29 | export const getUserRoles = (id) => { | 30 | export const getUserRoles = (id) => { |
30 | return getAction(`${api.userRoles}/${id}/users`) | 31 | return getAction(`${api.userRoles}/${id}/users`) |
31 | } | 32 | } |
33 | // 更新人员 | ||
34 | export const updateUser = (id, data) => { | ||
35 | return putAction(`${api.userRoles}/${id}/users`, data) | ||
36 | } | ... | ... |
... | @@ -20,14 +20,6 @@ | ... | @@ -20,14 +20,6 @@ |
20 | </el-col> | 20 | </el-col> |
21 | <el-col :span="12"> | 21 | <el-col :span="12"> |
22 | <el-form-item label="角色类型:" prop="roleType"> | 22 | <el-form-item label="角色类型:" prop="roleType"> |
23 | <!-- <el-select v-model="dialogForm.roleType.value" placeholder="角色类型"> | ||
24 | <el-option | ||
25 | v-for="item in roleTypeOptions" | ||
26 | :key="item.value" | ||
27 | :label="item.name" | ||
28 | :value="item.value"> | ||
29 | </el-option> | ||
30 | </el-select> --> | ||
31 | <el-input | 23 | <el-input |
32 | v-model="dialogForm.roleType" | 24 | v-model="dialogForm.roleType" |
33 | clearable | 25 | clearable |
... | @@ -66,7 +58,7 @@ | ... | @@ -66,7 +58,7 @@ |
66 | 58 | ||
67 | <script> | 59 | <script> |
68 | import Dialog from "@/components/Dialog/"; | 60 | import Dialog from "@/components/Dialog/"; |
69 | 61 | import { api, httpAction } from '@/api/manageApi' | |
70 | export default { | 62 | export default { |
71 | components: { | 63 | components: { |
72 | Dialog | 64 | Dialog |
... | @@ -104,55 +96,57 @@ export default { | ... | @@ -104,55 +96,57 @@ export default { |
104 | if (valid) { | 96 | if (valid) { |
105 | try { | 97 | try { |
106 | const params = { | 98 | const params = { |
107 | category: this.menuType, | 99 | category: 2, |
108 | description: this.dialogForm.roleTextArea, | 100 | description: this.dialogForm.roleTextArea, |
109 | name: this.dialogForm.roleName, | 101 | name: this.dialogForm.roleName, |
110 | sort: this.sort, | 102 | sort: this.sort, |
111 | type: this.dialogForm.roleType | 103 | type: this.dialogForm.roleType |
112 | } | 104 | } |
105 | console.log("this.roleId",this.roleId); | ||
113 | if (this.roleId) { | 106 | if (this.roleId) { |
114 | // params.id = this.roleId | 107 | params.id = this.roleId |
115 | // httpAction(`${api.roles}/${params.id}`, params, 'post').then( | 108 | console.log("修改",params.id,params); |
116 | // (res) => { | 109 | httpAction(`${api.roles}/${params.id}`, params, 'post').then( |
117 | // if (res.status === 1) { | 110 | (res) => { |
118 | // this.$message.success({ | 111 | if (res.status === 1) { |
119 | // message: '修改成功', | 112 | this.$message.success({ |
120 | // showClose: true | 113 | message: '修改成功', |
121 | // }) | 114 | showClose: true |
122 | // this.dialogForm = { | 115 | }) |
123 | // roleName: '', | 116 | this.dialogForm = { |
124 | // roleType: '' | 117 | roleName: '', |
125 | // } | 118 | roleType: '' |
126 | // this.showAddEditDialog = val | 119 | } |
127 | // this.$emit('ok', this.menuType) | 120 | this.showAddEditDialog = val |
128 | // } else { | 121 | this.$emit('ok', this.menuType) |
129 | // this.$message.error({ | 122 | } else { |
130 | // message: res.message, | 123 | this.$message.error({ |
131 | // showClose: true | 124 | message: res.message, |
132 | // }) | 125 | showClose: true |
133 | // } | 126 | }) |
134 | // } | 127 | } |
135 | // ) | 128 | } |
129 | ) | ||
136 | } else { | 130 | } else { |
137 | // httpAction(api.roles, params, 'post').then((res) => { | 131 | httpAction(api.roles, params, 'post').then((res) => { |
138 | // if (res.status === 1) { | 132 | if (res.status === 1) { |
139 | // this.$message.success({ | 133 | this.$message.success({ |
140 | // message: '新增成功', | 134 | message: '新增成功', |
141 | // showClose: true | 135 | showClose: true |
142 | // }) | 136 | }) |
143 | // this.dialogForm = { | 137 | this.dialogForm = { |
144 | // roleName: '', | 138 | roleName: '', |
145 | // roleType: '' | 139 | roleType: '' |
146 | // } | 140 | } |
147 | // this.showAddEditDialog = val | 141 | this.showAddEditDialog = val |
148 | // this.$emit('ok', this.menuType) | 142 | this.$emit('ok', this.menuType) |
149 | // } else { | 143 | } else { |
150 | // this.$message.error({ | 144 | this.$message.error({ |
151 | // message: res.message, | 145 | message: res.message, |
152 | // showClose: true | 146 | showClose: true |
153 | // }) | 147 | }) |
154 | // } | 148 | } |
155 | // }) | 149 | }) |
156 | } | 150 | } |
157 | } catch (e) { | 151 | } catch (e) { |
158 | console.error(e) | 152 | console.error(e) |
... | @@ -162,6 +156,7 @@ export default { | ... | @@ -162,6 +156,7 @@ export default { |
162 | }, | 156 | }, |
163 | // 取消事件 | 157 | // 取消事件 |
164 | handleCloseDialog() { | 158 | handleCloseDialog() { |
159 | this.$refs.form.resetFields() | ||
165 | this.dialogForm = { | 160 | this.dialogForm = { |
166 | roleName: '', | 161 | roleName: '', |
167 | roleType: '' | 162 | roleType: '' | ... | ... |
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | </el-form-item> | 7 | </el-form-item> |
8 | <el-row class="mb-5"> | 8 | <el-row class="mb-5"> |
9 | <el-col :span="2" class="btnColRight"> | 9 | <el-col :span="2" class="btnColRight"> |
10 | <btn nativeType="cx" @click="handleAdd">增加角色</btn> | 10 | <btn nativeType="cx" @click="handleAddEdit">增加角色</btn> |
11 | </el-col> | 11 | </el-col> |
12 | </el-row> | 12 | </el-row> |
13 | </el-form> | 13 | </el-form> |
... | @@ -41,7 +41,7 @@ import { | ... | @@ -41,7 +41,7 @@ import { |
41 | import { getRolesById, getUserRoles } from "@/api/Rolemanagement"; | 41 | import { getRolesById, getUserRoles } from "@/api/Rolemanagement"; |
42 | import data from "./data"; | 42 | import data from "./data"; |
43 | import sjsbTask from "@/api/sjsbTask.js"; | 43 | import sjsbTask from "@/api/sjsbTask.js"; |
44 | import { api, getAction } from "@/api/manageApi"; | 44 | import { api, getAction,deleteAction } from "@/api/manageApi"; |
45 | import tableMixin from "@/mixins/tableMixin.js"; | 45 | import tableMixin from "@/mixins/tableMixin.js"; |
46 | import EditDialog from "./edit-dialog.vue"; | 46 | import EditDialog from "./edit-dialog.vue"; |
47 | import Roleslistdiglog from "./roleslistdiglog.vue"; | 47 | import Roleslistdiglog from "./roleslistdiglog.vue"; |
... | @@ -58,6 +58,7 @@ export default { | ... | @@ -58,6 +58,7 @@ export default { |
58 | waitMemberList: [], | 58 | waitMemberList: [], |
59 | keyList: [], | 59 | keyList: [], |
60 | listdata: [], | 60 | listdata: [], |
61 | tableUrl: api.roles, | ||
61 | form: { | 62 | form: { |
62 | job_name: "", | 63 | job_name: "", |
63 | currentPage: 1, | 64 | currentPage: 1, |
... | @@ -140,7 +141,10 @@ export default { | ... | @@ -140,7 +141,10 @@ export default { |
140 | render: (h, scope) => { | 141 | render: (h, scope) => { |
141 | return ( | 142 | return ( |
142 | <div> | 143 | <div> |
144 | <el-tooltip class="item" effect="dark" disabled={scope.row.type !== 'Everyone'} content="没有点击的权限" placement="top"> | ||
145 | <span> | ||
143 | <el-button | 146 | <el-button |
147 | disabled={scope.row.type === 'Everyone'} | ||
144 | type="text" | 148 | type="text" |
145 | size="mini" | 149 | size="mini" |
146 | icon="el-icon-video-pause" | 150 | icon="el-icon-video-pause" |
... | @@ -150,27 +154,39 @@ export default { | ... | @@ -150,27 +154,39 @@ export default { |
150 | > | 154 | > |
151 | 人员 | 155 | 人员 |
152 | </el-button> | 156 | </el-button> |
157 | </span> | ||
158 | </el-tooltip> | ||
159 | <el-tooltip class="item" effect="dark" disabled={scope.row.category !== 1} content="系统内置角色 不允许修改" placement="top"> | ||
160 | <span> | ||
153 | <el-button | 161 | <el-button |
162 | disabled={scope.row.category === 1} | ||
154 | type="text" | 163 | type="text" |
155 | size="mini" | 164 | size="mini" |
156 | icon="el-icon-edit" | 165 | icon="el-icon-edit" |
157 | onClick={() => { | 166 | onClick={() => { |
158 | this.handleEdit(scope.row); | 167 | this.handleAddEdit(scope.row); |
159 | }} | 168 | }} |
160 | > | 169 | > |
161 | 修改 | 170 | 修改 |
162 | </el-button> | 171 | </el-button> |
172 | </span> | ||
173 | </el-tooltip> | ||
174 | <el-tooltip class="item" effect="dark" disabled={scope.row.category !== 1} content="系统内置角色 不允许删除" placement="top"> | ||
175 | <span> | ||
163 | <el-button | 176 | <el-button |
164 | type="text" | 177 | type="text" |
178 | disabled={scope.row.category === 1} | ||
165 | size="mini" | 179 | size="mini" |
166 | icon="el-icon-delete" | 180 | icon="el-icon-delete" |
167 | style="color:#F56C6C" | 181 | // style="color:#F56C6C" |
168 | onClick={() => { | 182 | onClick={() => { |
169 | this.handleDel(scope.row); | 183 | this.handleDelete(scope.row.id, scope.row.name); |
170 | }} | 184 | }} |
171 | > | 185 | > |
172 | 删除 | 186 | 删除 |
173 | </el-button> | 187 | </el-button> |
188 | </span> | ||
189 | </el-tooltip> | ||
174 | </div> | 190 | </div> |
175 | ); | 191 | ); |
176 | }, | 192 | }, |
... | @@ -192,15 +208,29 @@ export default { | ... | @@ -192,15 +208,29 @@ export default { |
192 | methods: { | 208 | methods: { |
193 | // 获取角色列表 | 209 | // 获取角色列表 |
194 | getTableData() { | 210 | getTableData() { |
195 | getRolesById() | 211 | let Builtinrole=[] |
212 | let Publicrole=[] | ||
213 | |||
214 | getRolesById(1) | ||
215 | .then((res) => { | ||
216 | console.log("res.content", res.content); | ||
217 | Builtinrole = res.content; | ||
218 | getRolesById(2) | ||
196 | .then((res) => { | 219 | .then((res) => { |
197 | this.listdata = res.content; | 220 | console.log("res.content", res.content); |
221 | Publicrole = res.content; | ||
222 | |||
223 | this.listdata = Builtinrole.concat(Publicrole); | ||
198 | 224 | ||
199 | this.listdata = judgeSort(this.listdata); | 225 | this.listdata = judgeSort(this.listdata); |
200 | }) | 226 | }) |
201 | .catch((e) => console.error(e)); | 227 | .catch((e) => console.error(e)); |
202 | }, | 228 | }) |
229 | .catch((e) => console.error(e)); | ||
230 | |||
203 | 231 | ||
232 | }, | ||
233 | // 人员配置 | ||
204 | getUserList(row) { | 234 | getUserList(row) { |
205 | const params = {}; | 235 | const params = {}; |
206 | const queryOptions = { | 236 | const queryOptions = { |
... | @@ -238,7 +268,7 @@ export default { | ... | @@ -238,7 +268,7 @@ export default { |
238 | }); | 268 | }); |
239 | } | 269 | } |
240 | 270 | ||
241 | this.$refs.rolesForm.adds(this.waitMemberList,row.id); | 271 | this.$refs.rolesForm.adds(this.waitMemberList, row.id); |
242 | } else { | 272 | } else { |
243 | this.$message.error({ message: res.message, showClose: true }); | 273 | this.$message.error({ message: res.message, showClose: true }); |
244 | } | 274 | } |
... | @@ -246,28 +276,19 @@ export default { | ... | @@ -246,28 +276,19 @@ export default { |
246 | this.$refs.rolesForm.title = "人员配置"; | 276 | this.$refs.rolesForm.title = "人员配置"; |
247 | } else this.$message.error({ message: res.message, showClose: true }); | 277 | } else this.$message.error({ message: res.message, showClose: true }); |
248 | }); | 278 | }); |
249 | |||
250 | |||
251 | }, | 279 | }, |
252 | // 新增角色 | 280 | // 新增、修改角色 |
253 | handleAdd() { | 281 | handleAddEdit(value) { |
254 | // this.$refs.addEditDialog.roleId = value.id | 282 | this.$refs.addEditDialog.menuType = this.menuType; |
255 | // this.roleSort = value.sort ? value.sort : 0 | 283 | this.$refs.addEditDialog.roleId = value.id; |
256 | 284 | this.roleSort = value.sort ? value.sort : 0; | |
257 | this.$refs.addEditDialog.showAddEditDialog = true; | 285 | if (value.id) { |
258 | this.$refs.addEditDialog.dialogTitle = "新增"; | 286 | this.$refs.addEditDialog.dialogForm.roleName = value.name; |
259 | }, | 287 | this.$refs.addEditDialog.dialogForm.roleType = value.type; |
260 | // 修改角色 | 288 | this.$refs.addEditDialog.dialogForm.roleTextArea = value.description; |
261 | handleEdit(row) { | ||
262 | this.$refs.addEditDialog.roleId = row.id; | ||
263 | this.roleSort = row.sort ? row.sort : 0; | ||
264 | if (row.id) { | ||
265 | this.$refs.addEditDialog.dialogForm.roleName = row.name; | ||
266 | this.$refs.addEditDialog.dialogForm.roleType = row.type; | ||
267 | this.$refs.addEditDialog.dialogForm.roleTextArea = row.description; | ||
268 | } | 289 | } |
269 | this.$refs.addEditDialog.showAddEditDialog = true; | 290 | this.$refs.addEditDialog.showAddEditDialog = true; |
270 | this.$refs.addEditDialog.dialogTitle = "修改"; | 291 | this.$refs.addEditDialog.dialogTitle = value.id ? "修改" : "新增"; |
271 | }, | 292 | }, |
272 | // 上移下移 | 293 | // 上移下移 |
273 | moveUpward(index, row) { | 294 | moveUpward(index, row) { |
... | @@ -284,39 +305,45 @@ export default { | ... | @@ -284,39 +305,45 @@ export default { |
284 | }, | 305 | }, |
285 | 306 | ||
286 | // 删除 | 307 | // 删除 |
287 | handleDel(row) { | 308 | handleDelete: function(id, content = '') { |
288 | this.$confirm("此操将进行删除操作, 是否继续?", "提示", { | 309 | this.$confirm( |
289 | confirmButtonText: "确定", | 310 | `<div class="customer-message-wrapper"> |
290 | cancelButtonText: "取消", | 311 | <h5 class="title">您确认要执行该操作用于以下信息:</h5> |
291 | type: "warning", | 312 | <p class="content" aria-controls="${content}">${content} |
292 | }) | 313 | </p> |
314 | <p class="result">执行后,数据将 | ||
315 | <span >无法恢复</span> | ||
316 | </p> | ||
317 | </div>`, | ||
318 | '执行确认', | ||
319 | { | ||
320 | dangerouslyUseHTMLString: true, | ||
321 | customClass: 'customer-delete', | ||
322 | confirmButtonText: '确定', | ||
323 | cancelButtonText: '取消', | ||
324 | type: 'warning' | ||
325 | } | ||
326 | ) | ||
293 | .then(() => { | 327 | .then(() => { |
294 | sjsbTask | 328 | if (!this.tableUrl) { |
295 | .sjsbTaskRemove(row.id) | 329 | this.$message.error({ |
296 | .then((res) => { | 330 | message: '请设置tableUrl属性为接口地址!', |
297 | if ((res.code = 200)) { | 331 | showClose: true |
298 | this.$message({ | 332 | }) |
299 | type: "success", | 333 | return |
300 | message: res.message, | 334 | } |
301 | }); | 335 | const url = this.tableUrl + '/' + id |
302 | // this.featchData(); | 336 | deleteAction(url).then(res => { |
337 | if (res.status === 1) { | ||
338 | this.$message.success({ message: res.message, showClose: true }) | ||
339 | this.loadDataS(this.subcode) | ||
340 | } else { | ||
341 | this.$message.error({ message: res.message, showClose: true }) | ||
303 | } | 342 | } |
304 | }) | 343 | }) |
305 | .catch((error) => { | ||
306 | this.$alert(error, "提示", { | ||
307 | confirmButtonText: "确定", | ||
308 | type: "error", | ||
309 | }); | ||
310 | }); | ||
311 | }) | 344 | }) |
312 | .catch(() => { | 345 | .catch(() => {}) |
313 | this.$message({ | ||
314 | type: "info", | ||
315 | message: "已取消", | ||
316 | }); | ||
317 | }); | ||
318 | }, | 346 | }, |
319 | |||
320 | }, | 347 | }, |
321 | }; | 348 | }; |
322 | </script> | 349 | </script> | ... | ... |
... | @@ -27,6 +27,7 @@ | ... | @@ -27,6 +27,7 @@ |
27 | 27 | ||
28 | <script> | 28 | <script> |
29 | import Dialog from "@/components/Dialog/"; | 29 | import Dialog from "@/components/Dialog/"; |
30 | import { updateUser } from "@/api/Rolemanagement"; | ||
30 | export default { | 31 | export default { |
31 | name: "", | 32 | name: "", |
32 | components: { Dialog }, | 33 | components: { Dialog }, |
... | @@ -72,7 +73,7 @@ export default { | ... | @@ -72,7 +73,7 @@ export default { |
72 | ], | 73 | ], |
73 | data: [], | 74 | data: [], |
74 | // 角色id | 75 | // 角色id |
75 | roleId:"" | 76 | roleId: "", |
76 | }, | 77 | }, |
77 | multipleSelection: [], | 78 | multipleSelection: [], |
78 | }; | 79 | }; |
... | @@ -82,11 +83,12 @@ export default { | ... | @@ -82,11 +83,12 @@ export default { |
82 | created() {}, | 83 | created() {}, |
83 | mounted() {}, | 84 | mounted() {}, |
84 | methods: { | 85 | methods: { |
85 | adds(a,roleId) { | 86 | // 人员配置根据selectStatus字段确定已选人员 |
86 | this.roleId=roleId | 87 | adds(a, rid) { |
88 | this.roleId = rid; | ||
87 | this.visible = true; | 89 | this.visible = true; |
88 | console.log("a",a); | 90 | console.log("a", a); |
89 | this.tableData.data=a | 91 | this.tableData.data = a; |
90 | this.tableData.data.forEach((item, index) => { | 92 | this.tableData.data.forEach((item, index) => { |
91 | if (item.selectStatus === 0) { | 93 | if (item.selectStatus === 0) { |
92 | this.$nextTick(() => { | 94 | this.$nextTick(() => { |
... | @@ -103,14 +105,22 @@ export default { | ... | @@ -103,14 +105,22 @@ export default { |
103 | }, | 105 | }, |
104 | // 保存 | 106 | // 保存 |
105 | handleSaveMember() { | 107 | handleSaveMember() { |
106 | let arrlist= this.tableData.data.filter((item) => { | 108 | const idList = this.multipleSelection.map((item) => { |
107 | return item.selectStatus==0 | 109 | return item.id; |
108 | }) | 110 | }); |
109 | const idList = arrlist.map((item) => { | 111 | console.log("this.roleId",this.roleId,idList); |
110 | return item.id | 112 | updateUser(this.roleId, idList).then((res) => { |
111 | }) | 113 | console.log("res",res); |
114 | if (res.status === 1) { | ||
115 | this.$message.success({ message: "保存成功", showClose: true }); | ||
116 | this.visible = false; | ||
117 | // this.$emit("setUsers", this.roleId); | ||
118 | // this.resetMemberConfig(); | ||
119 | } else this.$message.error({ message: res.message, showClose: true }); | ||
120 | }); | ||
112 | }, | 121 | }, |
113 | handleSelectionChange(val) { | 122 | handleSelectionChange(val) { |
123 | console.log("val", val); | ||
114 | this.multipleSelection = val; | 124 | this.multipleSelection = val; |
115 | }, | 125 | }, |
116 | }, | 126 | }, | ... | ... |
... | @@ -186,29 +186,11 @@ export default { | ... | @@ -186,29 +186,11 @@ export default { |
186 | }, | 186 | }, |
187 | }; | 187 | }; |
188 | }, | 188 | }, |
189 | created() { | ||
190 | this.featchData(); | ||
191 | }, | ||
189 | methods: { | 192 | methods: { |
190 | // 添加索引 | 193 | |
191 | // addIndexes (data = this.tableData.data, isAdd = true) { | ||
192 | // data.forEach((item, index) => { | ||
193 | // if (index == 0) { | ||
194 | // item.codeShow = true; | ||
195 | // item.nameShow = false; | ||
196 | // item.normcodeShow = false; | ||
197 | // item.normnameShow = false; | ||
198 | // } else { | ||
199 | // item.codeShow = false; | ||
200 | // item.nameShow = false; | ||
201 | // item.normcodeShow = false; | ||
202 | // item.normnameShow = false; | ||
203 | // } | ||
204 | // if (isAdd) { | ||
205 | // item.index = index + 1; | ||
206 | // } | ||
207 | // if (item.children) { | ||
208 | // this.addIndexes(item.children, false); | ||
209 | // } | ||
210 | // }); | ||
211 | // }, | ||
212 | handleAdd() { | 194 | handleAdd() { |
213 | this.taskData = null; | 195 | this.taskData = null; |
214 | this.$refs.dialogForm.add(); | 196 | this.$refs.dialogForm.add(); | ... | ... |
-
Please register or sign in to post a comment