|
@ -18,8 +18,10 @@ |
|
|
</CustomTable> |
|
|
</CustomTable> |
|
|
<pagination /> |
|
|
<pagination /> |
|
|
<!--弹出框内容--> |
|
|
<!--弹出框内容--> |
|
|
<el-dialog |
|
|
<el-drawer |
|
|
width="80%" |
|
|
ref="roleDrawer" |
|
|
|
|
|
direction="rtl" |
|
|
|
|
|
size="90%" |
|
|
:before-close="crud.cancelCU" |
|
|
:before-close="crud.cancelCU" |
|
|
:visible="crud.status.editor > 0" |
|
|
:visible="crud.status.editor > 0" |
|
|
:title="crud.status.title" |
|
|
:title="crud.status.title" |
|
@ -33,14 +35,15 @@ |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item label="功能权限:"> |
|
|
<el-form-item label="功能权限:"> |
|
|
<el-table |
|
|
<el-table |
|
|
ref="menuList" |
|
|
ref="permissions" |
|
|
:data="menuList" |
|
|
:data="permissions" |
|
|
border |
|
|
border |
|
|
fit |
|
|
fit |
|
|
|
|
|
height="680" |
|
|
highlight-current-row |
|
|
highlight-current-row |
|
|
row-key="permission.id" |
|
|
row-key="permission.id" |
|
|
:default-expand-all="true" |
|
|
|
|
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}" |
|
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}" |
|
|
|
|
|
style="width: 99%;" |
|
|
> |
|
|
> |
|
|
<el-table-column label="菜单名称" width="400"> |
|
|
<el-table-column label="菜单名称" width="400"> |
|
|
<template slot-scope="scope"> |
|
|
<template slot-scope="scope"> |
|
@ -63,15 +66,27 @@ |
|
|
</el-table> |
|
|
</el-table> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-form> |
|
|
</el-form> |
|
|
<div slot="footer" class="dialog-footer"> |
|
|
<el-row :gutter="20"> |
|
|
<el-button @click="crud.cancelCU"> |
|
|
<el-col :span="4" :offset="2"> |
|
|
取 消 |
|
|
<el-select v-model="showMode" @change="changeShowMode"> |
|
|
</el-button> |
|
|
<el-option |
|
|
<el-button type="primary" @click="crud.submitCU"> |
|
|
v-for="(item, index) in showModes" |
|
|
确 认 |
|
|
:key="index" |
|
|
</el-button> |
|
|
:label="item" |
|
|
</div> |
|
|
:value="index" |
|
|
</el-dialog> |
|
|
/> |
|
|
|
|
|
</el-select> |
|
|
|
|
|
</el-col> |
|
|
|
|
|
<el-col :span="4" :offset="14"> |
|
|
|
|
|
<el-button type="primary" @click="crud.submitCU"> |
|
|
|
|
|
确 认 |
|
|
|
|
|
</el-button> |
|
|
|
|
|
<el-button @click="crud.cancelCU"> |
|
|
|
|
|
取 消 |
|
|
|
|
|
</el-button> |
|
|
|
|
|
</el-col> |
|
|
|
|
|
</el-row> |
|
|
|
|
|
</el-drawer> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
@ -98,7 +113,7 @@ const defaultForm = form({ |
|
|
id: null, |
|
|
id: null, |
|
|
roleName: '', |
|
|
roleName: '', |
|
|
roleCode: '', |
|
|
roleCode: '', |
|
|
menuOptionIds: {} |
|
|
resourcePermissionIds: {} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
@ -107,7 +122,7 @@ export default { |
|
|
mixins: [defaultCrud, defaultForm, header()], |
|
|
mixins: [defaultCrud, defaultForm, header()], |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
menuList: [], |
|
|
permissions: [], |
|
|
colConfigs: [ |
|
|
colConfigs: [ |
|
|
{ prop: 'roleName', label: '角色名称', align: 'center' }, |
|
|
{ prop: 'roleName', label: '角色名称', align: 'center' }, |
|
|
{ prop: 'roleCode', label: '角色代码', align: 'center' }, |
|
|
{ prop: 'roleCode', label: '角色代码', align: 'center' }, |
|
@ -126,7 +141,9 @@ export default { |
|
|
{ required: true, message: '请输入角色代码', trigger: 'blur' } |
|
|
{ required: true, message: '请输入角色代码', trigger: 'blur' } |
|
|
] |
|
|
] |
|
|
}, |
|
|
}, |
|
|
checkedIds: new Set() |
|
|
checkedIds: new Set(), |
|
|
|
|
|
showMode: 0, |
|
|
|
|
|
showModes: ['合并所有', '展开所有', '全部勾选', '取消勾选'] |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
mounted() { |
|
|
mounted() { |
|
@ -135,7 +152,7 @@ export default { |
|
|
methods: { |
|
|
methods: { |
|
|
// 新增与编辑前做的操作 |
|
|
// 新增与编辑前做的操作 |
|
|
[CRUD.HOOK.afterToCU]() { |
|
|
[CRUD.HOOK.afterToCU]() { |
|
|
this.clearChecked(this.menuList) |
|
|
this.clearChecked(this.permissions) |
|
|
this.checkedIds.clear() |
|
|
this.checkedIds.clear() |
|
|
}, |
|
|
}, |
|
|
// 编辑框打开后做的操作 |
|
|
// 编辑框打开后做的操作 |
|
@ -144,18 +161,55 @@ export default { |
|
|
}, |
|
|
}, |
|
|
// 提交前的验证 |
|
|
// 提交前的验证 |
|
|
[CRUD.HOOK.afterValidateCU]() { |
|
|
[CRUD.HOOK.afterValidateCU]() { |
|
|
this.form.menuOptionIds = Array.from(this.checkedIds) |
|
|
this.form.resourcePermissionIds = Array.from(this.checkedIds) |
|
|
|
|
|
}, |
|
|
|
|
|
/** |
|
|
|
|
|
* 改变展示方式 |
|
|
|
|
|
*/ |
|
|
|
|
|
changeShowMode(val) { |
|
|
|
|
|
switch (val) { |
|
|
|
|
|
case 0: |
|
|
|
|
|
this.permissions.forEach(row => { |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
this.$refs.permissions.toggleRowExpansion(row, false) |
|
|
|
|
|
}, 1000) |
|
|
|
|
|
}) |
|
|
|
|
|
break |
|
|
|
|
|
case 1: |
|
|
|
|
|
this.permissions.forEach(row => { |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
this.$refs.permissions.toggleRowExpansion(row, true) |
|
|
|
|
|
}, 1000) |
|
|
|
|
|
}) |
|
|
|
|
|
break |
|
|
|
|
|
case 2: |
|
|
|
|
|
this.permissions.forEach(row => { |
|
|
|
|
|
row.checked = true |
|
|
|
|
|
row.indeterminate = false |
|
|
|
|
|
this.handleCheckAllChange(row, true) |
|
|
|
|
|
}) |
|
|
|
|
|
break |
|
|
|
|
|
case 3: |
|
|
|
|
|
this.permissions.forEach(row => { |
|
|
|
|
|
row.checked = false |
|
|
|
|
|
row.indeterminate = false |
|
|
|
|
|
this.handleCheckAllChange(row, false) |
|
|
|
|
|
}) |
|
|
|
|
|
break |
|
|
|
|
|
default: |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
// 获取菜单树 |
|
|
// 获取菜单树 |
|
|
getAllMenu() { |
|
|
getAllMenu() { |
|
|
getTree().then(data => { |
|
|
getTree().then(data => { |
|
|
this.menuList = data |
|
|
this.permissions = data |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
getRoleMenuList(roleId) { |
|
|
getRoleMenuList(roleId) { |
|
|
getPermissionsByRoleId(roleId).then(data => { |
|
|
getPermissionsByRoleId(roleId).then(data => { |
|
|
data = data.map(row => row.resourcePermissionId) |
|
|
data = data.map(row => row.resourcePermissionId) |
|
|
this.menuList.forEach(permission => { |
|
|
this.permissions.forEach(permission => { |
|
|
if (permission.children.length > 0) { |
|
|
if (permission.children.length > 0) { |
|
|
this.echoChildren(permission.children, data) |
|
|
this.echoChildren(permission.children, data) |
|
|
} else { |
|
|
} else { |
|
@ -167,10 +221,12 @@ export default { |
|
|
handleCheckAllChange(val, checked) { |
|
|
handleCheckAllChange(val, checked) { |
|
|
// 有下级去处理下级 |
|
|
// 有下级去处理下级 |
|
|
if (val.children.length > 0) { |
|
|
if (val.children.length > 0) { |
|
|
if (checked) { |
|
|
if (val.resourcePermissions.length) { |
|
|
this.checkedIds.add(val.resourcePermissions[0].id) |
|
|
if (checked) { |
|
|
} else { |
|
|
this.checkedIds.add(val.resourcePermissions[0].id) |
|
|
this.checkedIds.delete(val.resourcePermissions[0].id) |
|
|
} else { |
|
|
|
|
|
this.checkedIds.delete(val.resourcePermissions[0].id) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
this.findChildren(val.children, checked) |
|
|
this.findChildren(val.children, checked) |
|
|
} else { |
|
|
} else { |
|
@ -186,7 +242,7 @@ export default { |
|
|
} |
|
|
} |
|
|
// 处理上级 |
|
|
// 处理上级 |
|
|
if (val.permission.pid !== 0) { |
|
|
if (val.permission.pid !== 0) { |
|
|
this.findParent(this.menuList, val.permission.pid) |
|
|
this.findParent(this.permissions, val.permission.pid) |
|
|
} |
|
|
} |
|
|
val.indeterminate = false |
|
|
val.indeterminate = false |
|
|
}, |
|
|
}, |
|
@ -205,7 +261,7 @@ export default { |
|
|
val.indeterminate = checkedLength > 0 && checkedLength < length |
|
|
val.indeterminate = checkedLength > 0 && checkedLength < length |
|
|
// 处理上级 |
|
|
// 处理上级 |
|
|
if (val.permission.pid !== 0) { |
|
|
if (val.permission.pid !== 0) { |
|
|
this.findParent(this.menuList, val.permission.pid) |
|
|
this.findParent(this.permissions, val.permission.pid) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
findChildren(list, checked) { |
|
|
findChildren(list, checked) { |
|
@ -250,7 +306,7 @@ export default { |
|
|
} |
|
|
} |
|
|
// 如果还有上级,继续操作 |
|
|
// 如果还有上级,继续操作 |
|
|
if (result.permission.pid !== 0) { |
|
|
if (result.permission.pid !== 0) { |
|
|
this.findParent(this.menuList, result.permission.pid) |
|
|
this.findParent(this.permissions, result.permission.pid) |
|
|
} |
|
|
} |
|
|
} else if (result.children.length > 0) { |
|
|
} else if (result.children.length > 0) { |
|
|
this.findParent(result.children, pid) |
|
|
this.findParent(result.children, pid) |
|
@ -281,8 +337,8 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
// 递归清空菜单和选项 |
|
|
// 递归清空菜单和选项 |
|
|
clearChecked(menuList) { |
|
|
clearChecked(permissions) { |
|
|
menuList.forEach(permission => { |
|
|
permissions.forEach(permission => { |
|
|
permission.checked = false |
|
|
permission.checked = false |
|
|
permission.indeterminate = false |
|
|
permission.indeterminate = false |
|
|
permission.resourcePermissions.forEach(options => { |
|
|
permission.resourcePermissions.forEach(options => { |
|
|