Browse Source

角色管理改造

master
尹作梅 6 years ago
parent
commit
74b05868db
  1. 1
      src/i18n/zh-CN.js
  2. 36
      src/views/modules/sys/role-add-or-update.vue

1
src/i18n/zh-CN.js

@ -359,6 +359,7 @@ t.role.remark = '备注'
t.role.createDate = '创建时间'
t.role.menuList = '菜单授权'
t.role.deptList = '数据授权'
t.role.appMenuList = 'App菜单授权'
t.user = {}
t.user.username = '用户名'

36
src/views/modules/sys/role-add-or-update.vue

@ -29,7 +29,7 @@
:placeholder="$t('role.remark')"></el-input>
</el-form-item>
<el-row>
<el-col :span="12">
<el-col :span="8">
<el-form-item size="mini"
:label="$t('role.menuList')">
<el-tree :data="menuList"
@ -41,7 +41,7 @@
</el-tree>
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="8">
<el-form-item size="mini"
:label="$t('role.deptList')">
<el-tree :data="deptList"
@ -53,6 +53,18 @@
</el-tree>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item size="mini"
:label="$t('role.appMenuList')">
<el-tree :data="appMenuList"
:props="{ label: 'name', children: 'children' }"
node-key="id"
ref="appMenuListTree"
accordion
show-checkbox>
</el-tree>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template slot="footer">
@ -71,12 +83,14 @@ export default {
visible: false,
menuList: [],
deptList: [],
appMenuList: [],
roleTypeList: [],
dataForm: {
id: '',
name: '',
menuIdList: [],
deptIdList: [],
appMenuIdList: [],
remark: '',
typeKey: ''
}
@ -101,9 +115,11 @@ export default {
this.$refs['dataForm'].resetFields()
this.$refs.menuListTree.setCheckedKeys([])
this.$refs.deptListTree.setCheckedKeys([])
this.$refs.appMenuListTree.setCheckedKeys([])
Promise.all([
this.getMenuList(),
this.getDeptList()
this.getDeptList(),
this.getAppMenuList()
]).then(() => {
if (this.dataForm.id) {
this.getInfo()
@ -129,6 +145,15 @@ export default {
this.deptList = res.data
}).catch(() => { })
},
// App
getAppMenuList () {
return this.$http.get('/sys/appmenu/select').then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.appMenuList = res.data
}).catch(() => { })
},
//
getInfo () {
this.$http.get(`/sys/role/${this.dataForm.id}`).then(({ data: res }) => {
@ -141,6 +166,7 @@ export default {
}
this.dataForm.menuIdList.forEach(item => this.$refs.menuListTree.setChecked(item, true))
this.$refs.deptListTree.setCheckedKeys(this.dataForm.deptIdList)
this.dataForm.appMenuIdList.forEach(item => this.$refs.appMenuListTree.setChecked(item, true))
}).catch(() => { })
},
//
@ -154,6 +180,10 @@ export default {
...this.$refs.menuListTree.getHalfCheckedKeys()
]
this.dataForm.deptIdList = this.$refs.deptListTree.getCheckedKeys()
this.dataForm.appMenuIdList = [
...this.$refs.appMenuListTree.getCheckedKeys(),
...this.$refs.appMenuListTree.getHalfCheckedKeys()
]
this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/role', this.dataForm).then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)

Loading…
Cancel
Save