| | |
| | | |
| | | <el-table v-loading="loading" :data="roleList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="角色编号" prop="roleId" width="120" /> |
| | | <el-table-column label="角色编号" prop="roleId" width="120" v-if="false" /> |
| | | <el-table-column label="角色名称" prop="roleName" :show-overflow-tooltip="true" width="150" /> |
| | | <el-table-column label="权限字符" prop="roleKey" :show-overflow-tooltip="true" width="150" /> |
| | | <el-table-column label="显示顺序" prop="roleSort" width="100" /> |
| | |
| | | v-hasPermi="['system:role:remove']" |
| | | >删除</el-button> |
| | | <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['system:role:edit']"> |
| | | <span class="el-dropdown-link"> |
| | | <i class="el-icon-d-arrow-right el-icon--right"></i>更多 |
| | | </span> |
| | | <el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button> |
| | | <el-dropdown-menu slot="dropdown"> |
| | | <el-dropdown-item command="handleDataScope" icon="el-icon-circle-check" |
| | | v-hasPermi="['system:role:edit']">数据权限</el-dropdown-item> |
| | |
| | | <el-form-item label="菜单权限"> |
| | | <el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">展开/折叠</el-checkbox> |
| | | <el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">全选/全不选</el-checkbox> |
| | | <el-checkbox v-model="form.menuCheckStrictly == 1" @change="handleCheckedTreeConnect($event, 'menu')">父子联动</el-checkbox> |
| | | <el-checkbox v-model="form.menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')">父子联动</el-checkbox> |
| | | <el-tree |
| | | class="tree-border" |
| | | :data="menuOptions" |
| | | show-checkbox |
| | | ref="menu" |
| | | node-key="id" |
| | | :check-strictly="!form.menuCheckStrictly == 1" |
| | | :check-strictly="!form.menuCheckStrictly" |
| | | empty-text="加载中,请稍候" |
| | | :props="defaultProps" |
| | | ></el-tree> |
| | |
| | | <el-form-item label="数据权限" v-show="form.dataScope == 2"> |
| | | <el-checkbox v-model="deptExpand" @change="handleCheckedTreeExpand($event, 'dept')">展开/折叠</el-checkbox> |
| | | <el-checkbox v-model="deptNodeAll" @change="handleCheckedTreeNodeAll($event, 'dept')">全选/全不选</el-checkbox> |
| | | <el-checkbox v-model="form.deptCheckStrictly == 1" @change="handleCheckedTreeConnect($event, 'dept')">父子联动</el-checkbox> |
| | | <el-checkbox v-model="form.deptCheckStrictly" @change="handleCheckedTreeConnect($event, 'dept')">父子联动</el-checkbox> |
| | | <el-tree |
| | | class="tree-border" |
| | | :data="deptOptions" |
| | |
| | | default-expand-all |
| | | ref="dept" |
| | | node-key="id" |
| | | :check-strictly="!form.deptCheckStrictly == 1" |
| | | :check-strictly="!form.deptCheckStrictly" |
| | | empty-text="加载中,请稍候" |
| | | :props="defaultProps" |
| | | ></el-tree> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus } from "@/api/system/role"; |
| | | import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus, deptTreeSelect } from "@/api/system/role"; |
| | | import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu"; |
| | | import { treeselect as deptTreeselect, roleDeptTreeselect } from "@/api/system/dept"; |
| | | |
| | | export default { |
| | | name: "Role", |
| | |
| | | this.menuOptions = response.data; |
| | | }); |
| | | }, |
| | | /** 查询部门树结构 */ |
| | | getDeptTreeselect() { |
| | | deptTreeselect().then(response => { |
| | | this.deptOptions = response.data; |
| | | }); |
| | | }, |
| | | // 所有菜单节点数据 |
| | | getMenuAllCheckedKeys() { |
| | | // 目前被选中的菜单节点 |
| | |
| | | }); |
| | | }, |
| | | /** 根据角色ID查询部门树结构 */ |
| | | getRoleDeptTreeselect(roleId) { |
| | | return roleDeptTreeselect(roleId).then(response => { |
| | | getDeptTree(roleId) { |
| | | return deptTreeSelect(roleId).then(response => { |
| | | this.deptOptions = response.data.depts; |
| | | return response; |
| | | }); |
| | |
| | | status: "0", |
| | | menuIds: [], |
| | | deptIds: [], |
| | | menuCheckStrictly: 1, |
| | | deptCheckStrictly: 1, |
| | | menuCheckStrictly: true, |
| | | deptCheckStrictly: true, |
| | | remark: undefined |
| | | }; |
| | | this.resetForm("form"); |
| | |
| | | // 树权限(父子联动) |
| | | handleCheckedTreeConnect(value, type) { |
| | | if (type == 'menu') { |
| | | this.form.menuCheckStrictly = value ? 1: 0; |
| | | this.form.menuCheckStrictly = value ? true: false; |
| | | } else if (type == 'dept') { |
| | | this.form.deptCheckStrictly = value ? 1: 0; |
| | | this.form.deptCheckStrictly = value ? true: false; |
| | | } |
| | | }, |
| | | /** 新增按钮操作 */ |
| | |
| | | /** 分配数据权限操作 */ |
| | | handleDataScope(row) { |
| | | this.reset(); |
| | | const roleDeptTreeselect = this.getRoleDeptTreeselect(row.roleId); |
| | | const deptTreeSelect = this.getDeptTree(row.roleId); |
| | | getRole(row.roleId).then(response => { |
| | | this.form = response.data; |
| | | this.openDataScope = true; |
| | | this.$nextTick(() => { |
| | | roleDeptTreeselect.then(res => { |
| | | deptTreeSelect.then(res => { |
| | | this.$refs.dept.setCheckedKeys(res.data.checkedKeys); |
| | | }); |
| | | }); |
| | |
| | | } |
| | | }; |
| | | </script> |
| | | |