diff --git a/anrui-system-ui/src/views/RoleAdminister/RoleAdminister.vue b/anrui-system-ui/src/views/RoleAdminister/RoleAdminister.vue index d227282def..13ed9eadfa 100644 --- a/anrui-system-ui/src/views/RoleAdminister/RoleAdminister.vue +++ b/anrui-system-ui/src/views/RoleAdminister/RoleAdminister.vue @@ -224,7 +224,7 @@ 岗位 - + @@ -244,10 +244,8 @@ 组织层级 - + - @@ -303,8 +301,8 @@ export default { type: '2', postSid: '', remarks: '', - roleType:'', - roleTypeValue:'' + roleType: '', + roleTypeValue: '' }, formBackup: {}, search: { @@ -341,7 +339,7 @@ export default { funDialog: false, // 移动端授权 mobileDialog: false - }; + } }, mounted() { this.formBackup = Object.assign({}, this.roleForm) @@ -357,16 +355,14 @@ export default { }, getPostList() { postList().then((res) => { - if (res.code === '200') { + if (res.success) { this.postSidData = res.data } }) }, getType() { - typeValues({ - type: 'roleType' - }).then((res) => { - if (res.code === '200') { + typeValues({ type: 'roleType' }).then((res) => { + if (res.success) { this.roleTypeValue_list = res.data console.log('下拉框请求组织层级', res.data) } @@ -394,7 +390,7 @@ export default { changeOrgName(value) { const choosetItem = this.roleTypeValue_list.filter((item) => item.dictValue === value) this.roleForm.roleType = choosetItem[0].dictKey - console.log('组织层级',this.roleForm.roleType,this.roleForm.roleTypeValue) + console.log('组织层级', this.roleForm.roleType, this.roleForm.roleTypeValue) }, changePost(value) { const choosetItem = this.postSidData.filter((item) => item.sid === value) @@ -419,38 +415,29 @@ export default { cancelButtonText: '取消', type: 'warning' }).then(() => { - delOrgroles({ - sid: row.sid - }).then(res => { - this.getroleOrgList() - this.$message({ - type: 'success', - message: '删除成功!' - }); + delOrgroles({ sid: row.sid }).then((res) => { + if (res.success) { + this.getroleOrgList() + this.$message({ showClose: true, type: 'success', message: '删除成功!' }) + } }) }) }, // 保存角色 save() { if (this.roleForm.sid) { - putOrgroles(this.roleForm).then(res => { - if (res.code == '200') { + putOrgroles(this.roleForm).then((res) => { + if (res.success) { this.getroleOrgList() this.editDialog = false - this.$message({ - message: res.msg, - type: 'success' - }) + this.$message({ showClose: true, message: res.msg, type: 'success' }) } }) } else { - saveOrgroles(this.roleForm).then(res => { - if (res.code == '200') { - this.$message({ - message: res.msg, - type: 'success' - }) - this.activeName = "roleList" + saveOrgroles(this.roleForm).then((res) => { + if (res.success) { + this.$message({ showClose: true, message: res.msg, type: 'success' }) + this.activeName = 'roleList' this.getroleOrgList() } }) @@ -461,11 +448,10 @@ export default { setRoleEnable({ sid: row.sid, isEnable: value - }).then(res => { - this.$message({ - type: 'success', - message: res.msg - }); + }).then((res) => { + if (res.success) { + this.$message({ showClose: true, type: 'success', message: res.msg }) + } }) }, sourceMenus(row) { @@ -499,23 +485,56 @@ export default { } funMenuTree(params).then(res => { let data1 = res.data + // 如果菜单有子级菜单,说明是父级菜单,父级菜单不可以直接赋值已选中状态 for (let i = 0; i < data1.length; i++) { - if (data1[i].checked == 0) { - this.checkedId.push(data1[i].sid) - } - for (let j = 0; j < data1[i].children.length; j++) { + if (data1[i].children) { + // data2各模块中的一级菜单 let data2 = data1[i].children - if (data2[j].checked == 0) { - this.checkedId.push(data2[j].sid) - } - for (let k = 0; k < data2[j].children.length; k++) { - let data3 = data2[j].children - if (data3[k].checked == 0) { - this.checkedId.push(data3[k].sid) + for (let j = 0; j < data2.length; j++) { + // 如果一级菜单有子级菜单(二级菜单),就循环查看二级菜单有无子级菜单 + if (data2[j].children) { + // data3各模块中的二级菜单 + const data3 = data2[j].children + for (let k = 0; k < data3.length; k++) { + // 如果二级菜单有子级菜单(三级菜单),就循环查看三级菜单有无子级菜单 + if (data3[k].children) { + const data4 = data3[k].children + for (let l = 0; l < data4.length; l++) { + if (data4[l].checked == 0) { + this.checkedId.push(data4[l].sid) + } + } + } + // 如果二级菜单没有子级菜单(三级菜单),查看是否是选中状态 + if (data3[k].children.length == 0 && data3[k].checked == 0) { + this.checkedId.push(data3[k].sid) + } + } + } + // 如果一级菜单没有子级菜单(二级菜单),查看是否是选中状态 + if (data2[j].children.length == 0 && data2[j].checked == 0) { + this.checkedId.push(data2[j].sid) } } } } + // for (let i = 0; i < data1.length; i++) { + // if (data1[i].checked == 0) { + // this.checkedId.push(data1[i].sid) + // } + // for (let j = 0; j < data1[i].children.length; j++) { + // let data2 = data1[i].children + // if (data2[j].checked == 0) { + // this.checkedId.push(data2[j].sid) + // } + // for (let k = 0; k < data2[j].children.length; k++) { + // let data3 = data2[j].children + // if (data3[k].checked == 0) { + // this.checkedId.push(data3[k].sid) + // } + // } + // } + // } this.treedata = res.data this.loading = false }) @@ -746,11 +765,10 @@ export default { }, // 资源授权保存 sourceSave() { - let _this = this let sourceMenus = this.$refs.sourceTree.getCheckedKeys() let params = { sorceSid: sourceMenus.toString(), - roleSid: _this.Thisrow.sid + roleSid: this.Thisrow.sid } saveSource(params).then(res => { this.sourceDialog = false @@ -762,11 +780,10 @@ export default { }, // 功能授权保存 funSave() { - let _this = this let funMenus = this.$refs.funTree.getCheckedKeys() let params = { functionSid: funMenus.toString(), - roleSid: _this.Thisrow.sid + roleSid: this.Thisrow.sid } savefunMenu(params).then(res => { this.funDialog = false @@ -778,7 +795,6 @@ export default { }, // 菜单授权 getCheckedKeys() { - let _this = this let roleMenus = [] roleMenus = this.$refs.Tree.getCheckedNodes(false, true) // roleMenus = this.$refs.Tree.getCheckedKeys() @@ -798,7 +814,7 @@ export default { // } let params = { menuSid: roleMenus_sid.toString(), - roleSid: _this.Thisrow.sid + roleSid: this.Thisrow.sid } saveorgrolemenus(params).then(res => { this.roleDialog = false @@ -809,7 +825,6 @@ export default { }) }, getCheckedMobile() { - let _this = this let roleMenus = [] roleMenus = this.$refs.mobileTree.getCheckedNodes(false, true) // roleMenus = this.$refs.Tree.getCheckedKeys() @@ -829,7 +844,7 @@ export default { // } let params = { menuSid: roleMenus_sid.toString(), - roleSid: _this.Thisrow.sid + roleSid: this.Thisrow.sid } saveRoleMenuList(params).then((res) => { if (res.success) { @@ -842,10 +857,10 @@ export default { } } -}; +} -