| | |
| | | package com.ruoyi.system.api.domain;
|
| | |
|
| | | import java.util.Set;
|
| | | import javax.validation.constraints.NotBlank;
|
| | | import javax.validation.constraints.Size;
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | |
| | |
|
| | | /** 部门组(数据权限) */
|
| | | private Long[] deptIds;
|
| | |
|
| | | /** 角色菜单权限 */
|
| | | private Set<String> permissions;
|
| | |
|
| | | public SysRole()
|
| | | {
|
| | |
| | | this.deptIds = deptIds;
|
| | | }
|
| | |
|
| | | public Set<String> getPermissions()
|
| | | {
|
| | | return permissions;
|
| | | }
|
| | |
|
| | | public void setPermissions(Set<String> permissions)
|
| | | {
|
| | | this.permissions = permissions;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
| | |
| | | * 登录用户
|
| | | */
|
| | | public static final String LOGIN_USER = "login_user";
|
| | |
|
| | | /**
|
| | | * 角色权限
|
| | | */
|
| | | public static final String ROLE_PERMISSION = "role_permission";
|
| | | }
|
| | |
| | | set(SecurityConstants.USER_KEY, userKey);
|
| | | }
|
| | |
|
| | | public static String getPermission()
|
| | | {
|
| | | return get(SecurityConstants.ROLE_PERMISSION);
|
| | | }
|
| | |
|
| | | public static void setPermission(String permissions)
|
| | | {
|
| | | set(SecurityConstants.ROLE_PERMISSION, permissions);
|
| | | }
|
| | |
|
| | | public static void remove()
|
| | | {
|
| | | THREAD_LOCAL.remove();
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 判断给定的set列表中是否包含数组array 判断给定的数组array中是否包含给定的元素value
|
| | | *
|
| | | * @param set 给定的集合
|
| | | * @param array 给定的数组
|
| | | * @return boolean 结果
|
| | | */
|
| | | public static boolean containsAny(Collection<String> collection, String... array)
|
| | | {
|
| | | if (isEmpty(collection) || isEmpty(array))
|
| | | {
|
| | | return false;
|
| | | }
|
| | | else
|
| | | {
|
| | | for (String str : array)
|
| | | {
|
| | | if (collection.contains(str))
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 驼峰转下划线命名
|
| | | */
|
| | | public static String toUnderScoreCase(String str)
|
| | |
| | | * 用户表的别名
|
| | | */
|
| | | public String userAlias() default "";
|
| | |
|
| | | /**
|
| | | * 权限字符(用于多个角色匹配符合要求的权限)默认根据权限注解@ss获取,多个权限用逗号分隔开来
|
| | | */
|
| | | public String permission() default "";
|
| | | }
|
| | |
| | | import org.aspectj.lang.annotation.Aspect;
|
| | | import org.aspectj.lang.annotation.Before;
|
| | | import org.springframework.stereotype.Component;
|
| | | import com.ruoyi.common.core.context.SecurityContextHolder;
|
| | | import com.ruoyi.common.core.text.Convert;
|
| | | import com.ruoyi.common.core.utils.StringUtils;
|
| | | import com.ruoyi.common.core.web.domain.BaseEntity;
|
| | | import com.ruoyi.common.datascope.annotation.DataScope;
|
| | |
| | | // 如果是超级管理员,则不过滤数据
|
| | | if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin())
|
| | | {
|
| | | String permission = StringUtils.defaultIfEmpty(controllerDataScope.permission(), SecurityContextHolder.getPermission());
|
| | | dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
|
| | | controllerDataScope.userAlias());
|
| | | controllerDataScope.userAlias(), permission);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | * @param user 用户
|
| | | * @param deptAlias 部门别名
|
| | | * @param userAlias 用户别名
|
| | | * @param permission 权限字符
|
| | | */
|
| | | public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias)
|
| | | public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias, String permission)
|
| | | {
|
| | | StringBuilder sqlString = new StringBuilder();
|
| | | List<String> conditions = new ArrayList<String>();
|
| | |
| | | {
|
| | | continue;
|
| | | }
|
| | | if (StringUtils.isNotEmpty(permission) && StringUtils.isNotEmpty(role.getPermissions())
|
| | | && !StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission)))
|
| | | {
|
| | | continue;
|
| | | }
|
| | | if (DATA_SCOPE_ALL.equals(dataScope))
|
| | | {
|
| | | sqlString = new StringBuilder();
|
| | |
| | | * @param collection 多个对象
|
| | | * @return
|
| | | */
|
| | | public long deleteObject(final Collection collection)
|
| | | public boolean deleteObject(final Collection collection)
|
| | | {
|
| | | return redisTemplate.delete(collection);
|
| | | return redisTemplate.delete(collection) > 0;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | import java.util.HashSet;
|
| | | import java.util.Set;
|
| | | import org.springframework.util.PatternMatchUtils;
|
| | | import com.ruoyi.common.core.context.SecurityContextHolder;
|
| | | import com.ruoyi.common.core.exception.auth.NotLoginException;
|
| | | import com.ruoyi.common.core.exception.auth.NotPermissionException;
|
| | | import com.ruoyi.common.core.exception.auth.NotRoleException;
|
| | |
| | | */
|
| | | public void checkPermi(RequiresPermissions requiresPermissions)
|
| | | {
|
| | | SecurityContextHolder.setPermission(StringUtils.join(requiresPermissions.value(), ","));
|
| | | if (requiresPermissions.logical() == Logical.AND)
|
| | | {
|
| | | checkPermiAnd(requiresPermissions.value());
|
| | |
| | | package com.ruoyi.system.controller;
|
| | |
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import org.apache.commons.lang3.ArrayUtils;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
|
| | | {
|
| | | List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
| | | depts.removeIf(d -> d.getDeptId().intValue() == deptId
|
| | | || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
|
| | | depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
|
| | | return AjaxResult.success(depts);
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | deptService.checkDeptDataScope(deptId);
|
| | | return AjaxResult.success(deptService.selectDeptById(deptId));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取部门下拉树列表
|
| | | */
|
| | | @GetMapping("/treeselect")
|
| | | public AjaxResult treeselect(SysDept dept)
|
| | | {
|
| | | List<SysDept> depts = deptService.selectDeptList(dept);
|
| | | return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 加载对应角色部门列表树
|
| | | */
|
| | | @GetMapping(value = "/roleDeptTreeselect/{roleId}")
|
| | | public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId)
|
| | | {
|
| | | List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
| | | AjaxResult ajax = AjaxResult.success();
|
| | | ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
| | | ajax.put("depts", deptService.buildDeptTreeSelect(depts));
|
| | | return ajax;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.RequiresPermissions;
|
| | | import com.ruoyi.common.security.utils.SecurityUtils;
|
| | | import com.ruoyi.system.api.domain.SysDept;
|
| | | import com.ruoyi.system.api.domain.SysRole;
|
| | | import com.ruoyi.system.api.domain.SysUser;
|
| | | import com.ruoyi.system.domain.SysUserRole;
|
| | | import com.ruoyi.system.service.ISysDeptService;
|
| | | import com.ruoyi.system.service.ISysRoleService;
|
| | | import com.ruoyi.system.service.ISysUserService;
|
| | |
|
| | |
| | |
|
| | | @Autowired
|
| | | private ISysUserService userService;
|
| | |
|
| | | @Autowired
|
| | | private ISysDeptService deptService;
|
| | |
|
| | | @RequiresPermissions("system:role:list")
|
| | | @GetMapping("/list")
|
| | |
| | | roleService.checkRoleDataScope(roleId);
|
| | | return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
| | | }
|
| | | } |
| | |
|
| | | /**
|
| | | * 获取对应角色部门树列表
|
| | | */
|
| | | @RequiresPermissions("system:role:query")
|
| | | @GetMapping(value = "/deptTree/{roleId}")
|
| | | public AjaxResult deptTree(@PathVariable("roleId") Long roleId)
|
| | | {
|
| | | AjaxResult ajax = AjaxResult.success();
|
| | | ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
| | | ajax.put("depts", deptService.selectDeptTreeList(new SysDept()));
|
| | | return ajax;
|
| | | }
|
| | | }
|
| | |
| | | import com.ruoyi.common.security.annotation.InnerAuth;
|
| | | import com.ruoyi.common.security.annotation.RequiresPermissions;
|
| | | import com.ruoyi.common.security.utils.SecurityUtils;
|
| | | import com.ruoyi.system.api.domain.SysDept;
|
| | | import com.ruoyi.system.api.domain.SysRole;
|
| | | import com.ruoyi.system.api.domain.SysUser;
|
| | | import com.ruoyi.system.api.model.LoginUser;
|
| | | import com.ruoyi.system.service.ISysConfigService;
|
| | | import com.ruoyi.system.service.ISysDeptService;
|
| | | import com.ruoyi.system.service.ISysPermissionService;
|
| | | import com.ruoyi.system.service.ISysPostService;
|
| | | import com.ruoyi.system.service.ISysRoleService;
|
| | |
| | |
|
| | | @Autowired
|
| | | private ISysRoleService roleService;
|
| | |
|
| | | @Autowired
|
| | | private ISysDeptService deptService;
|
| | |
|
| | | @Autowired
|
| | | private ISysPostService postService;
|
| | |
| | | return R.fail("用户名或密码错误");
|
| | | }
|
| | | // 角色集合
|
| | | Set<String> roles = permissionService.getRolePermission(sysUser.getUserId());
|
| | | Set<String> roles = permissionService.getRolePermission(sysUser);
|
| | | // 权限集合
|
| | | Set<String> permissions = permissionService.getMenuPermission(sysUser.getUserId());
|
| | | Set<String> permissions = permissionService.getMenuPermission(sysUser);
|
| | | LoginUser sysUserVo = new LoginUser();
|
| | | sysUserVo.setSysUser(sysUser);
|
| | | sysUserVo.setRoles(roles);
|
| | |
| | | @GetMapping("getInfo")
|
| | | public AjaxResult getInfo()
|
| | | {
|
| | | Long userId = SecurityUtils.getUserId();
|
| | | SysUser user = userService.selectUserById(SecurityUtils.getUserId());
|
| | | // 角色集合
|
| | | Set<String> roles = permissionService.getRolePermission(userId);
|
| | | Set<String> roles = permissionService.getRolePermission(user);
|
| | | // 权限集合
|
| | | Set<String> permissions = permissionService.getMenuPermission(userId);
|
| | | Set<String> permissions = permissionService.getMenuPermission(user);
|
| | | AjaxResult ajax = AjaxResult.success();
|
| | | ajax.put("user", userService.selectUserById(userId));
|
| | | ajax.put("user", user);
|
| | | ajax.put("roles", roles);
|
| | | ajax.put("permissions", permissions);
|
| | | return ajax;
|
| | |
| | | userService.insertUserAuth(userId, roleIds);
|
| | | return success();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取部门树列表
|
| | | */
|
| | | @RequiresPermissions("system:user:list")
|
| | | @GetMapping("/deptTree")
|
| | | public AjaxResult deptTree(SysDept dept)
|
| | | {
|
| | | return AjaxResult.success(deptService.selectDeptTreeList(dept));
|
| | | }
|
| | | }
|
| | |
| | | public List<SysMenu> selectMenuListByUserId(SysMenu menu);
|
| | |
|
| | | /**
|
| | | * 根据角色ID查询权限
|
| | | * |
| | | * @param roleId 角色ID
|
| | | * @return 权限列表
|
| | | */
|
| | | public List<String> selectMenuPermsByRoleId(Long roleId);
|
| | |
|
| | | /**
|
| | | * 根据用户ID查询权限
|
| | | *
|
| | | * @param userId 用户ID
|
| | |
| | | public List<SysDept> selectDeptList(SysDept dept);
|
| | |
|
| | | /**
|
| | | * 查询部门树结构信息
|
| | | * |
| | | * @param dept 部门信息
|
| | | * @return 部门树信息集合
|
| | | */
|
| | | public List<TreeSelect> selectDeptTreeList(SysDept dept);
|
| | |
|
| | | /**
|
| | | * 构建前端所需要树结构
|
| | | *
|
| | | * @param depts 部门列表
|
| | |
| | | public Set<String> selectMenuPermsByUserId(Long userId);
|
| | |
|
| | | /**
|
| | | * 根据角色ID查询权限
|
| | | * |
| | | * @param roleId 角色ID
|
| | | * @return 权限列表
|
| | | */
|
| | | public Set<String> selectMenuPermsByRoleId(Long roleId);
|
| | |
|
| | | /**
|
| | | * 根据用户ID查询菜单树信息
|
| | | *
|
| | | * @param userId 用户ID
|
| | |
| | |
|
| | | import java.util.Set;
|
| | |
|
| | | import com.ruoyi.system.api.domain.SysUser;
|
| | |
|
| | | /**
|
| | | * 权限信息 服务层
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public interface ISysPermissionService
|
| | | {
|
| | | /**
|
| | |
| | | * @param userId 用户Id
|
| | | * @return 角色权限信息
|
| | | */
|
| | | public Set<String> getRolePermission(Long userId);
|
| | | public Set<String> getRolePermission(SysUser user);
|
| | |
|
| | | /**
|
| | | * 获取菜单数据权限
|
| | |
| | | * @param userId 用户Id
|
| | | * @return 菜单权限信息
|
| | | */
|
| | | public Set<String> getMenuPermission(Long userId);
|
| | | public Set<String> getMenuPermission(SysUser user);
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 查询部门树结构信息
|
| | | * |
| | | * @param dept 部门信息
|
| | | * @return 部门树信息集合
|
| | | */
|
| | | @Override
|
| | | public List<TreeSelect> selectDeptTreeList(SysDept dept)
|
| | | {
|
| | | List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
| | | return buildDeptTreeSelect(depts);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 构建前端所需要树结构
|
| | | *
|
| | | * @param depts 部门列表
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 根据角色ID查询权限
|
| | | * |
| | | * @param roleId 角色ID
|
| | | * @return 权限列表
|
| | | */
|
| | | @Override
|
| | | public Set<String> selectMenuPermsByRoleId(Long roleId)
|
| | | {
|
| | | List<String> perms = menuMapper.selectMenuPermsByRoleId(roleId);
|
| | | Set<String> permsSet = new HashSet<>();
|
| | | for (String perm : perms)
|
| | | {
|
| | | if (StringUtils.isNotEmpty(perm))
|
| | | {
|
| | | permsSet.addAll(Arrays.asList(perm.trim().split(",")));
|
| | | }
|
| | | }
|
| | | return permsSet;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 根据用户ID查询菜单
|
| | | *
|
| | | * @param userId 用户名称
|
| | |
| | | package com.ruoyi.system.service.impl;
|
| | |
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.system.api.domain.SysRole;
|
| | | import com.ruoyi.system.api.domain.SysUser;
|
| | | import com.ruoyi.system.service.ISysMenuService;
|
| | | import com.ruoyi.system.service.ISysPermissionService;
|
| | | import com.ruoyi.system.service.ISysRoleService;
|
| | |
|
| | | /**
|
| | | * 用户权限处理
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @Service
|
| | | public class SysPermissionServiceImpl implements ISysPermissionService
|
| | | {
|
| | |
| | | * @return 角色权限信息
|
| | | */
|
| | | @Override
|
| | | public Set<String> getRolePermission(Long userId)
|
| | | public Set<String> getRolePermission(SysUser user)
|
| | | {
|
| | | Set<String> roles = new HashSet<String>();
|
| | | // 管理员拥有所有权限
|
| | | if (SysUser.isAdmin(userId))
|
| | | if (user.isAdmin())
|
| | | {
|
| | | roles.add("admin");
|
| | | }
|
| | | else
|
| | | {
|
| | | roles.addAll(roleService.selectRolePermissionByUserId(userId));
|
| | | roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId()));
|
| | | }
|
| | | return roles;
|
| | | }
|
| | |
| | | * @return 菜单权限信息
|
| | | */
|
| | | @Override
|
| | | public Set<String> getMenuPermission(Long userId)
|
| | | public Set<String> getMenuPermission(SysUser user)
|
| | | {
|
| | | Set<String> perms = new HashSet<String>();
|
| | | // 管理员拥有所有权限
|
| | | if (SysUser.isAdmin(userId))
|
| | | if (user.isAdmin())
|
| | | {
|
| | | perms.add("*:*:*");
|
| | | }
|
| | | else
|
| | | {
|
| | | perms.addAll(menuService.selectMenuPermsByUserId(userId));
|
| | | List<SysRole> roles = user.getRoles();
|
| | | if (!roles.isEmpty() && roles.size() > 1)
|
| | | {
|
| | | // 多角色设置permissions属性,以便数据权限匹配权限
|
| | | for (SysRole role : roles)
|
| | | {
|
| | | Set<String> rolePerms = menuService.selectMenuPermsByRoleId(role.getRoleId());
|
| | | role.setPermissions(rolePerms);
|
| | | perms.addAll(rolePerms);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
|
| | | }
|
| | | }
|
| | | return perms;
|
| | | }
|
| | |
| | | where m.status = '0' and r.status = '0' and ur.user_id = #{userId}
|
| | | </select>
|
| | |
|
| | | <select id="selectMenuPermsByRoleId" parameterType="Long" resultType="String">
|
| | | select distinct m.perms
|
| | | from sys_menu m
|
| | | left join sys_role_menu rm on m.menu_id = rm.menu_id
|
| | | where m.status = '0' and rm.role_id = #{roleId}
|
| | | </select>
|
| | | |
| | | <select id="selectMenuById" parameterType="Long" resultMap="SysMenuResult">
|
| | | <include refid="selectMenuVo"/>
|
| | | where menu_id = #{menuId}
|
| | |
| | | })
|
| | | }
|
| | |
|
| | | // 查询部门下拉树结构
|
| | | export function treeselect() {
|
| | | return request({
|
| | | url: '/system/dept/treeselect',
|
| | | method: 'get'
|
| | | })
|
| | | }
|
| | |
|
| | | // 根据角色ID查询部门树结构
|
| | | export function roleDeptTreeselect(roleId) {
|
| | | return request({
|
| | | url: '/system/dept/roleDeptTreeselect/' + roleId,
|
| | | method: 'get'
|
| | | })
|
| | | }
|
| | |
|
| | | // 新增部门
|
| | | export function addDept(data) {
|
| | | return request({
|
| | |
| | | method: 'put',
|
| | | params: data
|
| | | })
|
| | | } |
| | | }
|
| | |
|
| | | // 根据角色ID查询部门树结构
|
| | | export function deptTreeSelect(roleId) {
|
| | | return request({
|
| | | url: '/system/role/deptTree/' + roleId,
|
| | | method: 'get'
|
| | | })
|
| | | }
|
| | |
| | | params: data |
| | | }) |
| | | } |
| | | |
| | | // 查询部门下拉树结构 |
| | | export function deptTreeSelect() { |
| | | return request({ |
| | | url: '/system/user/deptTree', |
| | | method: 'get' |
| | | }) |
| | | } |
| | |
| | | </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.depts;
|
| | | return response;
|
| | | });
|
| | |
| | | /** 分配数据权限操作 */
|
| | | 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.checkedKeys);
|
| | | });
|
| | | });
|
| | |
| | | </template>
|
| | |
|
| | | <script>
|
| | | import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus } from "@/api/system/user";
|
| | | import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, deptTreeSelect } from "@/api/system/user";
|
| | | import { getToken } from "@/utils/auth";
|
| | | import { treeselect } from "@/api/system/dept";
|
| | | import Treeselect from "@riophae/vue-treeselect";
|
| | | import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
| | |
|
| | |
| | | },
|
| | | created() {
|
| | | this.getList();
|
| | | this.getTreeselect();
|
| | | this.getDeptTree();
|
| | | this.getConfigKey("sys.user.initPassword").then(response => {
|
| | | this.initPassword = response.msg;
|
| | | });
|
| | |
| | | );
|
| | | },
|
| | | /** 查询部门下拉树结构 */
|
| | | getTreeselect() {
|
| | | treeselect().then(response => {
|
| | | getDeptTree() {
|
| | | deptTreeSelect().then(response => {
|
| | | this.deptOptions = response.data;
|
| | | });
|
| | | },
|
| | |
| | | /** 新增按钮操作 */
|
| | | handleAdd() {
|
| | | this.reset();
|
| | | this.getTreeselect();
|
| | | getUser().then(response => {
|
| | | this.postOptions = response.posts;
|
| | | this.roleOptions = response.roles;
|
| | |
| | | /** 修改按钮操作 */
|
| | | handleUpdate(row) {
|
| | | this.reset();
|
| | | this.getTreeselect();
|
| | | const userId = row.userId || this.ids;
|
| | | getUser(userId).then(response => {
|
| | | this.form = response.data;
|