feat: 添加用户、角色功能
This commit is contained in:
@@ -84,14 +84,15 @@ where TEntityDto : IEntityDto<TKey>
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual async Task<PagedResultDto<TGetListOutputDto>> GetListAsync(TGetListInput input)
|
public virtual async Task<PagedResultDto<TGetListOutputDto>> GetListAsync(TGetListInput input)
|
||||||
{
|
{
|
||||||
|
var totalCount = -1;
|
||||||
var totalCount = await _repository.CountAsync(_ => true);
|
|
||||||
|
|
||||||
var entities = new List<TEntity>();
|
var entities = new List<TEntity>();
|
||||||
var entityDtos = new List<TGetListOutputDto>();
|
var entityDtos = new List<TGetListOutputDto>();
|
||||||
|
|
||||||
if (totalCount > 0)
|
bool isPageList = true;
|
||||||
{
|
|
||||||
|
//if (totalCount > 0)
|
||||||
|
//{
|
||||||
|
|
||||||
//这里还可以追加如果是审计日志,继续拼接条件即可
|
//这里还可以追加如果是审计日志,继续拼接条件即可
|
||||||
if (input is IPageTimeResultRequestDto timeInput)
|
if (input is IPageTimeResultRequestDto timeInput)
|
||||||
@@ -103,6 +104,8 @@ where TEntityDto : IEntityDto<TKey>
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (input is IPagedAndSortedResultRequestDto sortInput)
|
if (input is IPagedAndSortedResultRequestDto sortInput)
|
||||||
{
|
{
|
||||||
entities = await _repository.GetPageListAsync(_ => true, sortInput,sortInput.SortBy, sortInput.SortType);
|
entities = await _repository.GetPageListAsync(_ => true, sortInput,sortInput.SortBy, sortInput.SortType);
|
||||||
@@ -111,11 +114,17 @@ where TEntityDto : IEntityDto<TKey>
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
isPageList = false;
|
||||||
entities = await _repository.GetListAsync();
|
entities = await _repository.GetListAsync();
|
||||||
}
|
}
|
||||||
entityDtos = await MapToGetListOutputDtosAsync(entities);
|
entityDtos = await MapToGetListOutputDtosAsync(entities);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
//如果是分页查询,还需要统计数量
|
||||||
|
if (isPageList)
|
||||||
|
{
|
||||||
|
totalCount = await _repository.CountAsync(_ => true);
|
||||||
|
}
|
||||||
return new PagedResultDto<TGetListOutputDto>(
|
return new PagedResultDto<TGetListOutputDto>(
|
||||||
totalCount,
|
totalCount,
|
||||||
entityDtos
|
entityDtos
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.RBAC.Application.Contracts.Identity.Dtos.Account
|
||||||
|
{
|
||||||
|
public class RestPasswordDto
|
||||||
|
{
|
||||||
|
public string Password = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.RBAC.Application.Contracts.Identity.Dtos.Account
|
||||||
|
{
|
||||||
|
public class UpdatePasswordDto
|
||||||
|
{
|
||||||
|
public string NewPassword { get; set; } = string.Empty;
|
||||||
|
public string OldPassword { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,13 +12,16 @@ namespace Yi.RBAC.Application.Contracts.Identity.Dtos
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class RoleCreateInputVo
|
public class RoleCreateInputVo
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
|
||||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
|
||||||
public long? CreatorId { get; set; }
|
|
||||||
public string? RoleName { get; set; }
|
public string? RoleName { get; set; }
|
||||||
public string? RoleCode { get; set; }
|
public string? RoleCode { get; set; }
|
||||||
public string? Remark { get; set; }
|
public string? Remark { get; set; }
|
||||||
public DataScopeEnum DataScope { get; set; } = DataScopeEnum.ALL;
|
public DataScopeEnum DataScope { get; set; } = DataScopeEnum.ALL;
|
||||||
public bool State { get; set; }
|
public bool State { get; set; } = true;
|
||||||
|
|
||||||
|
public int OrderNum { get; set; }
|
||||||
|
|
||||||
|
public List<long> DeptIds { get; set; }
|
||||||
|
|
||||||
|
public List<long> MenuIds { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,5 +18,7 @@ namespace Yi.RBAC.Application.Contracts.Identity.Dtos
|
|||||||
public string? Remark { get; set; }
|
public string? Remark { get; set; }
|
||||||
public DataScopeEnum DataScope { get; set; } = DataScopeEnum.ALL;
|
public DataScopeEnum DataScope { get; set; } = DataScopeEnum.ALL;
|
||||||
public bool State { get; set; }
|
public bool State { get; set; }
|
||||||
|
|
||||||
|
public int OrderNum { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,5 +18,7 @@ namespace Yi.RBAC.Application.Contracts.Identity.Dtos
|
|||||||
public string? Remark { get; set; }
|
public string? Remark { get; set; }
|
||||||
public DataScopeEnum DataScope { get; set; } = DataScopeEnum.ALL;
|
public DataScopeEnum DataScope { get; set; } = DataScopeEnum.ALL;
|
||||||
public bool State { get; set; }
|
public bool State { get; set; }
|
||||||
|
|
||||||
|
public int OrderNum { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,16 @@ namespace Yi.RBAC.Application.Contracts.Identity.Dtos
|
|||||||
{
|
{
|
||||||
public class RoleUpdateInputVo
|
public class RoleUpdateInputVo
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
|
||||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
|
||||||
public long? CreatorId { get; set; }
|
|
||||||
public string? RoleName { get; set; }
|
public string? RoleName { get; set; }
|
||||||
public string? RoleCode { get; set; }
|
public string? RoleCode { get; set; }
|
||||||
public string? Remark { get; set; }
|
public string? Remark { get; set; }
|
||||||
public DataScopeEnum DataScope { get; set; } = DataScopeEnum.ALL;
|
public DataScopeEnum DataScope { get; set; } = DataScopeEnum.ALL;
|
||||||
public bool State { get; set; }
|
public bool State { get; set; }
|
||||||
|
|
||||||
|
public int OrderNum { get; set; }
|
||||||
|
|
||||||
|
public List<long> DeptIds { get; set; }
|
||||||
|
|
||||||
|
public List<long> MenuIds { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,5 +27,6 @@ namespace Yi.RBAC.Application.Contracts.Identity.Dtos
|
|||||||
public List<long>? RoleIds { get; set; }
|
public List<long>? RoleIds { get; set; }
|
||||||
public List<long>? PostIds { get; set; }
|
public List<long>? PostIds { get; set; }
|
||||||
public long? DeptId { get; set; }
|
public long? DeptId { get; set; }
|
||||||
|
public bool State { get; set; } = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ namespace Yi.RBAC.Application.Contracts.Identity.Dtos
|
|||||||
public bool State { get; set; }
|
public bool State { get; set; }
|
||||||
public DateTime CreationTime { get; set; }
|
public DateTime CreationTime { get; set; }
|
||||||
|
|
||||||
|
public long DeptId { get; set; }
|
||||||
|
|
||||||
public DeptGetOutputDto Dept { get; set; }
|
public DeptGetOutputDto Dept { get; set; }
|
||||||
|
|
||||||
public List<PostGetListOutputDto> Posts { get; set; }
|
public List<PostGetListOutputDto> Posts { get; set; }
|
||||||
|
|||||||
@@ -58,6 +58,21 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Yi.RBAC.Application.Identity.AccountService.UpdatePasswordAsync(Yi.RBAC.Application.Contracts.Identity.Dtos.Account.UpdatePasswordDto)">
|
||||||
|
<summary>
|
||||||
|
更新密码
|
||||||
|
</summary>
|
||||||
|
<param name="input"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.RBAC.Application.Identity.AccountService.RestPasswordAsync(System.Int64,Yi.RBAC.Application.Contracts.Identity.Dtos.Account.RestPasswordDto)">
|
||||||
|
<summary>
|
||||||
|
重置密码
|
||||||
|
</summary>
|
||||||
|
<param name="userId"></param>
|
||||||
|
<param name="input"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="T:Yi.RBAC.Application.Identity.DeptService">
|
<member name="T:Yi.RBAC.Application.Identity.DeptService">
|
||||||
<summary>
|
<summary>
|
||||||
Dept服务实现
|
Dept服务实现
|
||||||
@@ -81,6 +96,13 @@
|
|||||||
Menu服务实现
|
Menu服务实现
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Yi.RBAC.Application.Identity.MenuService.GetListRoleIdAsync(System.Int64)">
|
||||||
|
<summary>
|
||||||
|
查询当前角色的菜单
|
||||||
|
</summary>
|
||||||
|
<param name="roleId"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="T:Yi.RBAC.Application.Identity.PostService">
|
<member name="T:Yi.RBAC.Application.Identity.PostService">
|
||||||
<summary>
|
<summary>
|
||||||
Post服务实现
|
Post服务实现
|
||||||
@@ -91,6 +113,13 @@
|
|||||||
Role服务实现
|
Role服务实现
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Yi.RBAC.Application.Identity.RoleService.CreateAsync(Yi.RBAC.Application.Contracts.Identity.Dtos.RoleCreateInputVo)">
|
||||||
|
<summary>
|
||||||
|
添加角色
|
||||||
|
</summary>
|
||||||
|
<param name="input"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="T:Yi.RBAC.Application.Identity.UserService">
|
<member name="T:Yi.RBAC.Application.Identity.UserService">
|
||||||
<summary>
|
<summary>
|
||||||
User服务实现
|
User服务实现
|
||||||
|
|||||||
@@ -140,5 +140,37 @@ namespace Yi.RBAC.Application.Identity
|
|||||||
var imgbyte = _securityCode.GetEnDigitalCodeByte(code);
|
var imgbyte = _securityCode.GetEnDigitalCodeByte(code);
|
||||||
return new CaptchaImageDto { Img = imgbyte, Uuid = code };
|
return new CaptchaImageDto { Img = imgbyte, Uuid = code };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新密码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<bool> UpdatePasswordAsync(UpdatePasswordDto input)
|
||||||
|
{
|
||||||
|
if (input.OldPassword.Equals(input.NewPassword))
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException("无效更新!输入的数据,新密码不能与老密码相同");
|
||||||
|
}
|
||||||
|
await _accountManager.UpdatePasswordAsync(_currentUser.Id, input.NewPassword, input.OldPassword);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重置密码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPut]
|
||||||
|
public async Task<bool> RestPasswordAsync(long userId, RestPasswordDto input)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(input.Password))
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException("重置密码不能为空!");
|
||||||
|
}
|
||||||
|
await _accountManager.RestPasswordAsync(userId, input.Password);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using NET.AutoWebApi.Setting;
|
|||||||
using Yi.RBAC.Application.Contracts.Identity.Dtos;
|
using Yi.RBAC.Application.Contracts.Identity.Dtos;
|
||||||
using Yi.RBAC.Domain.Identity.Entities;
|
using Yi.RBAC.Domain.Identity.Entities;
|
||||||
using Yi.Framework.Ddd.Services;
|
using Yi.Framework.Ddd.Services;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
namespace Yi.RBAC.Application.Identity
|
namespace Yi.RBAC.Application.Identity
|
||||||
{
|
{
|
||||||
@@ -13,5 +14,16 @@ namespace Yi.RBAC.Application.Identity
|
|||||||
public class MenuService : CrudAppService<MenuEntity, MenuGetOutputDto, MenuGetListOutputDto, long, MenuGetListInputVo, MenuCreateInputVo, MenuUpdateInputVo>,
|
public class MenuService : CrudAppService<MenuEntity, MenuGetOutputDto, MenuGetListOutputDto, long, MenuGetListInputVo, MenuCreateInputVo, MenuUpdateInputVo>,
|
||||||
IMenuService, IAutoApiService
|
IMenuService, IAutoApiService
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 查询当前角色的菜单
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="roleId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<List<MenuGetListOutputDto>> GetListRoleIdAsync(long roleId)
|
||||||
|
{
|
||||||
|
var entities= await _DbQueryable.Where(m => SqlFunc.Subqueryable<RoleMenuEntity>().Where(rm => rm.RoleId == roleId && rm.MenuId == m.Id).Any()).ToListAsync();
|
||||||
|
|
||||||
|
return await MapToGetListOutputDtosAsync(entities);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ using NET.AutoWebApi.Setting;
|
|||||||
using Yi.RBAC.Application.Contracts.Identity.Dtos;
|
using Yi.RBAC.Application.Contracts.Identity.Dtos;
|
||||||
using Yi.RBAC.Domain.Identity.Entities;
|
using Yi.RBAC.Domain.Identity.Entities;
|
||||||
using Yi.Framework.Ddd.Services;
|
using Yi.Framework.Ddd.Services;
|
||||||
|
using Yi.RBAC.Domain.Identity;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using Yi.Framework.Uow;
|
||||||
|
|
||||||
namespace Yi.RBAC.Application.Identity
|
namespace Yi.RBAC.Application.Identity
|
||||||
{
|
{
|
||||||
@@ -13,5 +16,30 @@ namespace Yi.RBAC.Application.Identity
|
|||||||
public class RoleService : CrudAppService<RoleEntity, RoleGetOutputDto, RoleGetListOutputDto, long, RoleGetListInputVo, RoleCreateInputVo, RoleUpdateInputVo>,
|
public class RoleService : CrudAppService<RoleEntity, RoleGetOutputDto, RoleGetListOutputDto, long, RoleGetListInputVo, RoleCreateInputVo, RoleUpdateInputVo>,
|
||||||
IRoleService, IAutoApiService
|
IRoleService, IAutoApiService
|
||||||
{
|
{
|
||||||
|
[Autowired]
|
||||||
|
private RoleManager _roleManager { get; set; }
|
||||||
|
|
||||||
|
[Autowired]
|
||||||
|
private IUnitOfWorkManager _unitOfWorkManager { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加角色
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<RoleGetOutputDto> CreateAsync(RoleCreateInputVo input)
|
||||||
|
{
|
||||||
|
RoleGetOutputDto outputDto;
|
||||||
|
using (var uow = _unitOfWorkManager.CreateContext())
|
||||||
|
{
|
||||||
|
var entity = await MapToEntityAsync(input);
|
||||||
|
await _repository.InsertAsync(entity);
|
||||||
|
outputDto = await MapToGetOutputDtoAsync(entity);
|
||||||
|
await _roleManager.GiveRoleSetMenuAsync(new List<long> { entity.Id }, input.MenuIds);
|
||||||
|
uow.Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputDto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -669,6 +669,14 @@
|
|||||||
<param name="userId"></param>
|
<param name="userId"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Yi.RBAC.Domain.Identity.RoleManager.GiveRoleSetMenuAsync(System.Collections.Generic.List{System.Int64},System.Collections.Generic.List{System.Int64})">
|
||||||
|
<summary>
|
||||||
|
给角色设置菜单
|
||||||
|
</summary>
|
||||||
|
<param name="roleIds"></param>
|
||||||
|
<param name="menuIds"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:Yi.RBAC.Domain.Identity.UserManager.GiveUserSetRoleAsync(System.Collections.Generic.List{System.Int64},System.Collections.Generic.List{System.Int64})">
|
<member name="M:Yi.RBAC.Domain.Identity.UserManager.GiveUserSetRoleAsync(System.Collections.Generic.List{System.Int64},System.Collections.Generic.List{System.Int64})">
|
||||||
<summary>
|
<summary>
|
||||||
给用户设置角色
|
给用户设置角色
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Mapster;
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -103,6 +104,30 @@ namespace Yi.RBAC.Domain.Identity
|
|||||||
return claims;
|
return claims;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task UpdatePasswordAsync(long userId, string newPassword, string oldPassword)
|
||||||
|
{
|
||||||
|
var user = await _repository.GetByIdAsync(userId);
|
||||||
|
|
||||||
|
if (!user.JudgePassword(oldPassword))
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException("无效更新!新密码不能与老密码相同");
|
||||||
|
}
|
||||||
|
user.Password = newPassword;
|
||||||
|
user.BuildPassword();
|
||||||
|
await _repository.UpdateAsync(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<bool> RestPasswordAsync(long userId, string password)
|
||||||
|
{
|
||||||
|
var user = await _repository.GetByIdAsync(userId);
|
||||||
|
user.Id = userId;
|
||||||
|
user.Password = password;
|
||||||
|
user.BuildPassword();
|
||||||
|
return await _repository.UpdateAsync(user);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Ddd.Repositories;
|
||||||
|
using Yi.RBAC.Domain.Identity.Entities;
|
||||||
|
|
||||||
|
namespace Yi.RBAC.Domain.Identity
|
||||||
|
{
|
||||||
|
[AppService]
|
||||||
|
public class RoleManager
|
||||||
|
{
|
||||||
|
private IRepository<RoleEntity> _repository;
|
||||||
|
private IRepository<RoleMenuEntity> _roleMenuRepository;
|
||||||
|
public RoleManager(IRepository<RoleEntity> repository, IRepository<RoleMenuEntity> roleMenuRepository)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
_roleMenuRepository = roleMenuRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 给角色设置菜单
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="roleIds"></param>
|
||||||
|
/// <param name="menuIds"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task GiveRoleSetMenuAsync(List<long> roleIds, List<long> menuIds)
|
||||||
|
{
|
||||||
|
//这个是需要事务的,在service中进行工作单元
|
||||||
|
await _roleMenuRepository.DeleteAsync(u => roleIds.Contains(u.RoleId));
|
||||||
|
//遍历用户
|
||||||
|
foreach (var roleId in roleIds)
|
||||||
|
{
|
||||||
|
//添加新的关系
|
||||||
|
List<RoleMenuEntity> roleMenuEntity = new();
|
||||||
|
foreach (var menu in menuIds)
|
||||||
|
{
|
||||||
|
roleMenuEntity.Add(new RoleMenuEntity() {Id=SnowflakeHelper.NextId, RoleId = roleId, MenuId = menu });
|
||||||
|
}
|
||||||
|
//一次性批量添加
|
||||||
|
await _roleMenuRepository.InsertRangeAsync(roleMenuEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -55,7 +55,7 @@ export function delDept(deptId) {
|
|||||||
// 根据角色ID查询菜单下拉树结构
|
// 根据角色ID查询菜单下拉树结构
|
||||||
export function roleDeptTreeselect(roleId) {
|
export function roleDeptTreeselect(roleId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/dept/getListByRoleId/' + roleId,
|
url: '/dept/role-id/' + roleId,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ export function treeselect() {
|
|||||||
// 根据角色ID查询菜单下拉树结构
|
// 根据角色ID查询菜单下拉树结构
|
||||||
export function roleMenuTreeselect(roleId) {
|
export function roleMenuTreeselect(roleId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/menu/getListByRoleId/' + roleId,
|
url: '/menu/role-id/' + roleId,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export function getUser(userId) {
|
|||||||
// 新增用户
|
// 新增用户
|
||||||
export function addUser(data) {
|
export function addUser(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/user/add',
|
url: '/user',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
@@ -32,22 +32,7 @@ export function updateUser(id, data) {
|
|||||||
return request({
|
return request({
|
||||||
url: `/user/${id}`,
|
url: `/user/${id}`,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: {
|
data: data
|
||||||
|
|
||||||
userName: data.user.userName,
|
|
||||||
nick: data.user.nick,
|
|
||||||
password: data.user.password,
|
|
||||||
phone: data.user.phone,
|
|
||||||
email: data.user.email,
|
|
||||||
sex: data.user.sex,
|
|
||||||
state: data.user.state,
|
|
||||||
remark: data.user.remark,
|
|
||||||
postIds: data.postIds,
|
|
||||||
roleIds: data.roleIds,
|
|
||||||
deptId: data.deptId
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,13 +47,12 @@ export function delUser(userId) {
|
|||||||
// 用户密码重置
|
// 用户密码重置
|
||||||
export function resetUserPwd(id, password) {
|
export function resetUserPwd(id, password) {
|
||||||
const data = {
|
const data = {
|
||||||
id,
|
|
||||||
password
|
password
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return request({
|
return request({
|
||||||
url: '/user/restPassword',
|
url: `/account/rest-password/${id}`,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
@@ -106,7 +90,7 @@ export function updateUserPwd(oldPassword, newPassword) {
|
|||||||
newPassword
|
newPassword
|
||||||
}
|
}
|
||||||
return request({
|
return request({
|
||||||
url: '/account/UpdatePassword',
|
url: '/account/password',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -24,9 +24,9 @@
|
|||||||
@keyup.enter="handleQuery"
|
@keyup.enter="handleQuery"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="isDeleted">
|
<el-form-item label="状态" prop="state">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="queryParams.isDeleted"
|
v-model="queryParams.state"
|
||||||
placeholder="角色状态"
|
placeholder="角色状态"
|
||||||
clearable
|
clearable
|
||||||
style="width: 240px"
|
style="width: 240px"
|
||||||
@@ -129,7 +129,7 @@
|
|||||||
<el-table-column label="状态" align="center" width="100">
|
<el-table-column label="状态" align="center" width="100">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-switch
|
<el-switch
|
||||||
v-model="scope.row.isDeleted"
|
v-model="scope.row.state"
|
||||||
:active-value="false"
|
:active-value="false"
|
||||||
:inactive-value="true"
|
:inactive-value="true"
|
||||||
@change="handleStatusChange(scope.row)"
|
@change="handleStatusChange(scope.row)"
|
||||||
@@ -214,12 +214,12 @@
|
|||||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||||
<el-form
|
<el-form
|
||||||
ref="roleRef"
|
ref="roleRef"
|
||||||
:model="form.role"
|
:model="form"
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
label-width="100px"
|
label-width="100px"
|
||||||
>
|
>
|
||||||
<el-form-item label="角色名称" prop="roleName">
|
<el-form-item label="角色名称" prop="roleName">
|
||||||
<el-input v-model="form.role.roleName" placeholder="请输入角色名称" />
|
<el-input v-model="form.roleName" placeholder="请输入角色名称" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="roleCode">
|
<el-form-item prop="roleCode">
|
||||||
<template #label>
|
<template #label>
|
||||||
@@ -235,17 +235,17 @@
|
|||||||
权限字符
|
权限字符
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<el-input v-model="form.role.roleCode" placeholder="请输入权限字符" />
|
<el-input v-model="form.roleCode" placeholder="请输入权限字符" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="角色顺序" prop="orderNum">
|
<el-form-item label="角色顺序" prop="orderNum">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="form.role.orderNum"
|
v-model="form.orderNum"
|
||||||
controls-position="right"
|
controls-position="right"
|
||||||
:min="0"
|
:min="0"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态">
|
<el-form-item label="状态">
|
||||||
<el-radio-group v-model="form.role.isDeleted">
|
<el-radio-group v-model="form.state">
|
||||||
<el-radio
|
<el-radio
|
||||||
v-for="dict in sys_normal_disable"
|
v-for="dict in sys_normal_disable"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
@@ -266,7 +266,7 @@
|
|||||||
>全选/全不选</el-checkbox
|
>全选/全不选</el-checkbox
|
||||||
>
|
>
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-model="form.role.menuCheckStrictly"
|
v-model="form.menuCheckStrictly"
|
||||||
@change="handleCheckedTreeConnect($event, 'menu')"
|
@change="handleCheckedTreeConnect($event, 'menu')"
|
||||||
>父子联动
|
>父子联动
|
||||||
</el-checkbox>
|
</el-checkbox>
|
||||||
@@ -276,14 +276,14 @@
|
|||||||
show-checkbox
|
show-checkbox
|
||||||
ref="menuRef"
|
ref="menuRef"
|
||||||
node-key="id"
|
node-key="id"
|
||||||
:check-strictly="!form.role.menuCheckStrictly"
|
:check-strictly="!form.menuCheckStrictly"
|
||||||
empty-text="加载中,请稍候"
|
empty-text="加载中,请稍候"
|
||||||
:props="{ label: 'label', children: 'children' }"
|
:props="{ label: 'label', children: 'children' }"
|
||||||
></el-tree>
|
></el-tree>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="备注">
|
<el-form-item label="备注">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.role.remark"
|
v-model="form.remark"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
placeholder="请输入内容"
|
placeholder="请输入内容"
|
||||||
></el-input>
|
></el-input>
|
||||||
@@ -306,14 +306,14 @@
|
|||||||
>
|
>
|
||||||
<el-form :model="form" label-width="80px">
|
<el-form :model="form" label-width="80px">
|
||||||
<el-form-item label="角色名称">
|
<el-form-item label="角色名称">
|
||||||
<el-input v-model="form.role.roleName" :disabled="true" />
|
<el-input v-model="form.roleName" :disabled="true" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="权限字符">
|
<el-form-item label="权限字符">
|
||||||
<el-input v-model="form.role.roleCode" :disabled="true" />
|
<el-input v-model="form.roleCode" :disabled="true" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="权限范围">
|
<el-form-item label="权限范围">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="form.role.dataScope"
|
v-model="form.dataScope"
|
||||||
@change="dataScopeSelectChange"
|
@change="dataScopeSelectChange"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
@@ -325,7 +325,7 @@
|
|||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="数据权限" v-show="form.role.dataScope == 1">
|
<el-form-item label="数据权限" v-show="form.dataScope == 1">
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-model="deptExpand"
|
v-model="deptExpand"
|
||||||
@change="handleCheckedTreeExpand($event, 'dept')"
|
@change="handleCheckedTreeExpand($event, 'dept')"
|
||||||
@@ -420,7 +420,7 @@ const data = reactive({
|
|||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
roleName: undefined,
|
roleName: undefined,
|
||||||
roleCode: undefined,
|
roleCode: undefined,
|
||||||
isDeleted: undefined,
|
state: undefined,
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
roleName: [
|
roleName: [
|
||||||
@@ -491,17 +491,17 @@ function handleSelectionChange(selection) {
|
|||||||
}
|
}
|
||||||
/** 角色状态修改 */
|
/** 角色状态修改 */
|
||||||
function handleStatusChange(row) {
|
function handleStatusChange(row) {
|
||||||
let text = row.isDeleted === false ? "启用" : "停用";
|
let text = row.state === false ? "启用" : "停用";
|
||||||
proxy.$modal
|
proxy.$modal
|
||||||
.confirm('确认要"' + text + '""' + row.roleName + '"角色吗?')
|
.confirm('确认要"' + text + '""' + row.roleName + '"角色吗?')
|
||||||
.then(function () {
|
.then(function () {
|
||||||
return changeRoleStatus(row.id, row.isDeleted);
|
return changeRoleStatus(row.id, row.state);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
proxy.$modal.msgSuccess(text + "成功");
|
proxy.$modal.msgSuccess(text + "成功");
|
||||||
})
|
})
|
||||||
.catch(function () {
|
.catch(function () {
|
||||||
row.isDeleted = row.isDeleted === "0" ? "1" : "0";
|
row.state = row.state === "0" ? "1" : "0";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/** 更多操作 */
|
/** 更多操作 */
|
||||||
@@ -555,17 +555,16 @@ function reset() {
|
|||||||
deptExpand.value = true;
|
deptExpand.value = true;
|
||||||
deptNodeAll.value = false;
|
deptNodeAll.value = false;
|
||||||
form.value = {
|
form.value = {
|
||||||
role: {
|
|
||||||
id: undefined,
|
id: undefined,
|
||||||
roleName: undefined,
|
roleName: undefined,
|
||||||
roleCode: undefined,
|
roleCode: undefined,
|
||||||
orderNum: 0,
|
orderNum: 0,
|
||||||
IsDeleted: false,
|
state: false,
|
||||||
menuCheckStrictly: false,
|
menuCheckStrictly: false,
|
||||||
deptCheckStrictly: false,
|
deptCheckStrictly: false,
|
||||||
remark: undefined,
|
remark: undefined,
|
||||||
dataScope: 0,
|
dataScope: 0,
|
||||||
},
|
|
||||||
menuIds: [],
|
menuIds: [],
|
||||||
deptIds: [],
|
deptIds: [],
|
||||||
};
|
};
|
||||||
@@ -584,8 +583,8 @@ function handleUpdate(row) {
|
|||||||
const roleId = row.id || ids.value;
|
const roleId = row.id || ids.value;
|
||||||
getRoleMenuTreeselect(roleId);
|
getRoleMenuTreeselect(roleId);
|
||||||
getRole(roleId).then((response) => {
|
getRole(roleId).then((response) => {
|
||||||
form.value.role = response.data;
|
form.value= response.data;
|
||||||
form.value.role.orderNum = Number(form.value.role.orderNum);
|
form.value.orderNum = Number(form.value.orderNum);
|
||||||
open.value = true;
|
open.value = true;
|
||||||
title.value = "修改角色";
|
title.value = "修改角色";
|
||||||
});
|
});
|
||||||
@@ -598,7 +597,7 @@ function getRoleMenuTreeselect(roleId) {
|
|||||||
|
|
||||||
roleMenuTreeselect(roleId).then((response) => {
|
roleMenuTreeselect(roleId).then((response) => {
|
||||||
const menuIds = [];
|
const menuIds = [];
|
||||||
response.data.forEach((m) => {
|
response.data.item.forEach((m) => {
|
||||||
menuIds.push(m.id);
|
menuIds.push(m.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -680,7 +679,7 @@ function getMenuAllCheckedKeys() {
|
|||||||
function submitForm() {
|
function submitForm() {
|
||||||
proxy.$refs["roleRef"].validate((valid) => {
|
proxy.$refs["roleRef"].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (form.value.role.id != undefined) {
|
if (form.value.id != undefined) {
|
||||||
form.value.menuIds = getMenuAllCheckedKeys();
|
form.value.menuIds = getMenuAllCheckedKeys();
|
||||||
updateRole(form.value).then((response) => {
|
updateRole(form.value).then((response) => {
|
||||||
proxy.$modal.msgSuccess("修改成功");
|
proxy.$modal.msgSuccess("修改成功");
|
||||||
@@ -714,14 +713,14 @@ function handleDataScope(row) {
|
|||||||
reset();
|
reset();
|
||||||
getDeptTree(row.id);
|
getDeptTree(row.id);
|
||||||
getRole(row.id).then((response) => {
|
getRole(row.id).then((response) => {
|
||||||
form.value.role = response.data;
|
form.value = response.data;
|
||||||
openDataScope.value = true;
|
openDataScope.value = true;
|
||||||
title.value = "分配数据权限";
|
title.value = "分配数据权限";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/** 提交按钮(数据权限) */
|
/** 提交按钮(数据权限) */
|
||||||
function submitDataScope() {
|
function submitDataScope() {
|
||||||
if (form.value.role.id != undefined) {
|
if (form.value.id != undefined) {
|
||||||
form.value.deptIds = getDeptAllCheckedKeys();
|
form.value.deptIds = getDeptAllCheckedKeys();
|
||||||
dataScope(form.value).then((response) => {
|
dataScope(form.value).then((response) => {
|
||||||
proxy.$modal.msgSuccess("修改成功");
|
proxy.$modal.msgSuccess("修改成功");
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
<el-input v-model="queryParams.phone" placeholder="请输入手机号码" clearable style="width: 240px"
|
<el-input v-model="queryParams.phone" placeholder="请输入手机号码" clearable style="width: 240px"
|
||||||
@keyup.enter="handleQuery" />
|
@keyup.enter="handleQuery" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="isDeleted">
|
<el-form-item label="状态" prop="state">
|
||||||
<el-select v-model="queryParams.isDeleted" placeholder="用户状态" clearable style="width: 240px">
|
<el-select v-model="queryParams.state" placeholder="用户状态" clearable style="width: 240px">
|
||||||
<el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label"
|
<el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label"
|
||||||
:value="dict.value" />
|
:value="dict.value" />
|
||||||
</el-select>
|
</el-select>
|
||||||
@@ -75,9 +75,9 @@
|
|||||||
:show-overflow-tooltip="true" />
|
:show-overflow-tooltip="true" />
|
||||||
<el-table-column label="手机号码" align="center" key="phone" prop="phone" v-if="columns[4].visible"
|
<el-table-column label="手机号码" align="center" key="phone" prop="phone" v-if="columns[4].visible"
|
||||||
width="120" />
|
width="120" />
|
||||||
<el-table-column label="状态" align="isDeleted" key="isDeleted" v-if="columns[5].visible">
|
<el-table-column label="状态" align="state" key="state" v-if="columns[5].visible">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-switch v-model="scope.row.isDeleted" :active-value=false :inactive-value=true
|
<el-switch v-model="scope.row.state" :active-value=false :inactive-value=true
|
||||||
@change="handleStatusChange(scope.row)"></el-switch>
|
@change="handleStatusChange(scope.row)"></el-switch>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -114,11 +114,11 @@
|
|||||||
|
|
||||||
<!-- 添加或修改用户配置对话框 -->
|
<!-- 添加或修改用户配置对话框 -->
|
||||||
<el-dialog :title="title" v-model="open" width="600px" append-to-body>
|
<el-dialog :title="title" v-model="open" width="600px" append-to-body>
|
||||||
<el-form :model="form.user" :rules="rules" ref="userRef" label-width="80px">
|
<el-form :model="form" :rules="rules" ref="userRef" label-width="80px">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="用户昵称" prop="nick">
|
<el-form-item label="用户昵称" prop="nick">
|
||||||
<el-input v-model="form.user.nick" placeholder="请输入用户昵称" maxlength="30" />
|
<el-input v-model="form.nick" placeholder="请输入用户昵称" maxlength="30" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
@@ -132,24 +132,24 @@
|
|||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="手机号码" prop="phone">
|
<el-form-item label="手机号码" prop="phone">
|
||||||
<el-input v-model="form.user.phone" placeholder="请输入手机号码" maxlength="11" />
|
<el-input v-model="form.phone" placeholder="请输入手机号码" maxlength="11" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="邮箱" prop="email">
|
<el-form-item label="邮箱" prop="email">
|
||||||
<el-input v-model="form.user.email" placeholder="请输入邮箱" maxlength="50" />
|
<el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item v-if="form.id == undefined" label="用户账号" prop="userName">
|
<el-form-item v-if="form.id == undefined" label="用户账号" prop="userName">
|
||||||
<el-input v-model="form.user.userName" placeholder="请输入用户账号" maxlength="30" />
|
<el-input v-model="form.userName" placeholder="请输入用户账号" maxlength="30" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item v-if="form.id == undefined" label="用户密码" prop="password">
|
<el-form-item v-if="form.id == undefined" label="用户密码" prop="password">
|
||||||
<el-input v-model="form.user.password" placeholder="请输入用户密码" type="password" maxlength="20"
|
<el-input v-model="form.password" placeholder="请输入用户密码" type="password" maxlength="20"
|
||||||
show-password />
|
show-password />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -157,14 +157,14 @@
|
|||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="用户性别">
|
<el-form-item label="用户性别">
|
||||||
<el-select v-model="form.user.sex" placeholder="请选择">
|
<el-select v-model="form.sex" placeholder="请选择">
|
||||||
<el-option v-for="dict in sys_user_sex" :key="dict.value" :label="dict.label" :value="JSON.parse(dict.value) "></el-option>
|
<el-option v-for="dict in sys_user_sex" :key="dict.value" :label="dict.label" :value="JSON.parse(dict.value) "></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="状态">
|
<el-form-item label="状态">
|
||||||
<el-radio-group v-model="form.user.isDeleted">
|
<el-radio-group v-model="form.state">
|
||||||
<el-radio v-for="dict in sys_normal_disable" :key="dict.value" :label="JSON.parse(dict.value)">{{dict.label}}</el-radio>
|
<el-radio v-for="dict in sys_normal_disable" :key="dict.value" :label="JSON.parse(dict.value)">{{dict.label}}</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -175,7 +175,7 @@
|
|||||||
<el-form-item label="岗位">
|
<el-form-item label="岗位">
|
||||||
<el-select v-model="form.postIds" multiple placeholder="请选择">
|
<el-select v-model="form.postIds" multiple placeholder="请选择">
|
||||||
<el-option v-for="item in postOptions" :key="item.id" :label="item.postName"
|
<el-option v-for="item in postOptions" :key="item.id" :label="item.postName"
|
||||||
:value="item.id" :disabled="item.isDeleted == true"></el-option>
|
:value="item.id" :disabled="item.state == false"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -183,7 +183,7 @@
|
|||||||
<el-form-item label="角色">
|
<el-form-item label="角色">
|
||||||
<el-select v-model="form.roleIds" multiple placeholder="请选择">
|
<el-select v-model="form.roleIds" multiple placeholder="请选择">
|
||||||
<el-option v-for="item in roleOptions" :key="item.id" :label="item.roleName" :value="item.id"
|
<el-option v-for="item in roleOptions" :key="item.id" :label="item.roleName" :value="item.id"
|
||||||
:disabled="item.isDeleted ==true"></el-option>
|
:disabled="item.state ==false"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -191,7 +191,7 @@
|
|||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item label="备注">
|
<el-form-item label="备注">
|
||||||
<el-input v-model="form.user.remark" type="textarea" placeholder="请输入内容"></el-input>
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -288,13 +288,14 @@ const columns = ref([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
form: {},
|
form : {
|
||||||
|
},
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
userName: undefined,
|
userName: undefined,
|
||||||
phone: undefined,
|
phone: undefined,
|
||||||
isDeleted: undefined,
|
state: true,
|
||||||
deptId: undefined
|
deptId: undefined
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
@@ -374,14 +375,13 @@ function handleExport() {
|
|||||||
};
|
};
|
||||||
/** 用户状态修改 */
|
/** 用户状态修改 */
|
||||||
function handleStatusChange(row) {
|
function handleStatusChange(row) {
|
||||||
console.log(row)
|
let text = row.state === false ? "启用" : "停用";
|
||||||
let text = row.isDeleted === false ? "启用" : "停用";
|
|
||||||
proxy.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function () {
|
proxy.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function () {
|
||||||
return changeUserStatus(row.id, row.isDeleted);
|
return changeUserStatus(row.id, row.state);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
proxy.$modal.msgSuccess(text + "成功");
|
proxy.$modal.msgSuccess(text + "成功");
|
||||||
}).catch(function () {
|
}).catch(function () {
|
||||||
row.isDeleted = row.isDeleted === true ? false : true;
|
row.state = row.state === true ? false : true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
/** 更多操作 */
|
/** 更多操作 */
|
||||||
@@ -450,16 +450,14 @@ function submitFileForm() {
|
|||||||
/** 重置操作表单 */
|
/** 重置操作表单 */
|
||||||
function reset() {
|
function reset() {
|
||||||
form.value = {
|
form.value = {
|
||||||
user: {
|
|
||||||
userName: undefined,
|
userName: undefined,
|
||||||
nick: undefined,
|
nick: undefined,
|
||||||
password: undefined,
|
password: undefined,
|
||||||
phone: undefined,
|
phone: undefined,
|
||||||
email: undefined,
|
email: undefined,
|
||||||
sex: undefined,
|
sex: undefined,
|
||||||
isDeleted: false,
|
state: true,
|
||||||
remark: undefined,
|
remark: undefined,
|
||||||
},
|
|
||||||
postIds: [],
|
postIds: [],
|
||||||
roleIds: [],
|
roleIds: [],
|
||||||
deptId: undefined
|
deptId: undefined
|
||||||
@@ -505,19 +503,20 @@ function handleUpdate(row) {
|
|||||||
getUser(userId).then(response => {
|
getUser(userId).then(response => {
|
||||||
|
|
||||||
|
|
||||||
form.value.user = response.data;
|
form.value = response.data;
|
||||||
|
form.value.postIds=[];
|
||||||
response.data.posts.forEach(post => {
|
response.data.posts.forEach(post => {
|
||||||
form.value.postIds.push(post.id)
|
form.value.postIds.push(post.id)
|
||||||
});
|
});
|
||||||
|
|
||||||
form.value.deptId= response.data.deptId;
|
form.value.deptId= response.data.deptId;
|
||||||
|
form.value.roleIds=[];
|
||||||
response.data.roles.forEach(role => {
|
response.data.roles.forEach(role => {
|
||||||
form.value.roleIds.push(role.id)
|
form.value.roleIds.push(role.id)
|
||||||
});
|
});
|
||||||
open.value = true;
|
open.value = true;
|
||||||
title.value = "修改用户";
|
title.value = "修改用户";
|
||||||
form.value.user.password = null;
|
form.value.password = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -527,8 +526,8 @@ form.value.user.password = null;
|
|||||||
function submitForm() {
|
function submitForm() {
|
||||||
proxy.$refs["userRef"].validate(valid => {
|
proxy.$refs["userRef"].validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (form.value.user.id != undefined) {
|
if (form.value.id != undefined) {
|
||||||
updateUser(form.value.user.id,form.value).then(response => {
|
updateUser(form.value.id,form.value).then(response => {
|
||||||
proxy.$modal.msgSuccess("修改成功");
|
proxy.$modal.msgSuccess("修改成功");
|
||||||
open.value = false;
|
open.value = false;
|
||||||
getList();
|
getList();
|
||||||
|
|||||||
Reference in New Issue
Block a user