48 changed files with 6640 additions and 3169 deletions
@ -0,0 +1,20 @@ |
|||
@ECHO off |
|||
cls |
|||
|
|||
ECHO Deleting all BIN and OBJ folders... |
|||
ECHO. |
|||
|
|||
FOR /d /r . %%d in (bin,obj) DO ( |
|||
IF EXIST "%%d" ( |
|||
ECHO %%d | FIND /I "\node_modules\" > Nul && ( |
|||
ECHO.Skipping: %%d |
|||
) || ( |
|||
ECHO.Deleting: %%d |
|||
rd /s/q "%%d" |
|||
) |
|||
) |
|||
) |
|||
|
|||
ECHO. |
|||
ECHO.BIN and OBJ folders have been successfully deleted. Press any key to exit. |
|||
pause > nul |
|||
@ -0,0 +1,66 @@ |
|||
{ |
|||
"App": { |
|||
"SelfUrl": "http://localhost:44315", |
|||
"CorsOrigins": "https://*.AbpPro.com,http://localhost:4200,http://localhost:3100" |
|||
}, |
|||
"ConnectionStrings": { |
|||
"Default": "Data Source=120.24.194.14;Database=LionAbpProDB;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" |
|||
}, |
|||
"Redis": { |
|||
"Configuration": "localhost,password=mypassword,defaultdatabase=1" |
|||
}, |
|||
"Jwt": { |
|||
"Audience": "http://localhost:5010", |
|||
"SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=", |
|||
"Issuer": "YHWmsOperationApiGateway", |
|||
"ExpirationTime": 30 |
|||
}, |
|||
"Cap": { |
|||
"Enabled": "true", |
|||
"RabbitMq": { |
|||
"HostName": "localhost", |
|||
"UserName": "admin", |
|||
"Password": "admin" |
|||
} |
|||
}, |
|||
"ElasticSearch": { |
|||
"Enabled": "false", |
|||
"Url": "http://es.cn", |
|||
"IndexFormat": "Lion.AbpPro.development.{0:yyyy.MM.dd}", |
|||
"UserName": "elastic", |
|||
"Password": "aVVhjQ95RP7nbwNy", |
|||
"SearchIndexFormat": "Lion.AbpPro.development*" |
|||
}, |
|||
"HttpClient": { |
|||
"Sts": { |
|||
"Name": "Sts", |
|||
"Url": "http://localhost:44354" |
|||
}, |
|||
"Github": { |
|||
"Name": "Github", |
|||
"Url": "https://github.com", |
|||
"ClientId": "127fc528f611879fba03", |
|||
"ClientSecret": "fd0914e9e8e28b51dd5efe381121429279e43973" |
|||
}, |
|||
"GithubApi": { |
|||
"Name": "GithubApi", |
|||
"Url": "https://api.github.com", |
|||
"ClientName": "AbpPro" |
|||
} |
|||
}, |
|||
"Consul": { |
|||
"Enabled": false, |
|||
"Host": "http://localhost:8500", |
|||
"Service": "Project-Service" |
|||
}, |
|||
"AliYun": { |
|||
"OSS": { |
|||
"AccessKeyId": "LTAI5tLkt3vvScGPVZ5qKJDc1S", |
|||
"AccessKeySecret": "BixV8vP5uPrbsdwjYzzsEXOPjkxPST2S", |
|||
"Endpoint": "oss-cn-shenzhen.aliyuncs.com", |
|||
"ContainerName": "lion-abp-pro", |
|||
"RegionId": "oss-cn-shenzhen", |
|||
"RoleArn": "acs:ram::1846393972471789:role/ramosstestst" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class AddRoleToOrganizationUnitInput |
|||
{ |
|||
public List<Guid> RoleId { get; set; } |
|||
|
|||
public Guid OrganizationUnitId { get; set; } |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class AddUserToOrganizationUnitInput |
|||
{ |
|||
public List<Guid> UserId { get; set; } |
|||
|
|||
public Guid OrganizationUnitId { get; set; } |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class CreateOrganizationUnitInput |
|||
{ |
|||
[Required] public string DisplayName { get; set; } |
|||
|
|||
public Guid? ParentId { get; set; } |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System; |
|||
using Lion.AbpPro.Extension.Customs.Dtos; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class GetOrganizationUnitRoleInput : PagingBase |
|||
{ |
|||
public Guid OrganizationUnitId { get; set; } |
|||
|
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using Lion.AbpPro.Extension.Customs.Dtos; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class GetOrganizationUnitRoleOutput |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using Lion.AbpPro.Extension.Customs.Dtos; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class GetOrganizationUnitUserInput : PagingBase |
|||
{ |
|||
public Guid OrganizationUnitId { get; set; } |
|||
|
|||
public string Filter { get; set; } |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using System; |
|||
using Lion.AbpPro.Extension.Customs.Dtos; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class GetOrganizationUnitUserOutput |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
public string UserName { get; set; } |
|||
|
|||
public string Email { get; set; } |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using Lion.AbpPro.Extension.Customs.Dtos; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class GetUnAddRoleInput : PagingBase |
|||
{ |
|||
public Guid OrganizationUnitId { get; set; } |
|||
|
|||
public string Filter { get; set; } |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class GetUnAddRoleOutput |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using Lion.AbpPro.Extension.Customs.Dtos; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class GetUnAddUserInput : PagingBase |
|||
{ |
|||
public Guid OrganizationUnitId { get; set; } |
|||
|
|||
public string Filter { get; set; } |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class GetUnAddUserOutput |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
public string UserName { get; set; } |
|||
|
|||
public string Email { get; set; } |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using System; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class OrganizationUnitDto |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
public Guid? TenantId { get; set; } |
|||
|
|||
public string Code { get; set; } |
|||
|
|||
public string DisplayName { get; set; } |
|||
|
|||
public Guid? ParentId { get; set; } |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class RemoveRoleToOrganizationUnitInput |
|||
{ |
|||
public Guid RoleId { get; set; } |
|||
|
|||
public Guid OrganizationUnitId { get; set; } |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class RemoveUserToOrganizationUnitInput |
|||
{ |
|||
public Guid UserId { get; set; } |
|||
|
|||
public Guid OrganizationUnitId { get; set; } |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class TreeOutput |
|||
{ |
|||
public string Title { get; set; } |
|||
|
|||
public Guid Key { get; set; } |
|||
|
|||
public List<TreeOutput> Children { get; set; } |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits.Dto; |
|||
|
|||
public class UpdateOrganizationUnitInput |
|||
{ |
|||
[Required] public string DisplayName { get; set; } |
|||
|
|||
public Guid Id { get; set; } |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Lion.AbpPro.Extension.Customs.Dtos; |
|||
using Lion.AbpPro.OrganizationUnits.Dto; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits; |
|||
|
|||
public interface IOrganizationUnitAppService : IApplicationService |
|||
{ |
|||
/// <summary>
|
|||
/// 获取组织机构树结构
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
Task<List<TreeOutput>> GetTreeAsync(); |
|||
|
|||
/// <summary>
|
|||
/// 创建组织机构
|
|||
/// </summary>
|
|||
Task CreateAsync(CreateOrganizationUnitInput input); |
|||
|
|||
/// <summary>
|
|||
/// 删除组织机构
|
|||
/// </summary>
|
|||
Task DeleteAsync(IdInput input); |
|||
|
|||
/// <summary>
|
|||
/// 编辑组织机构
|
|||
/// </summary>
|
|||
Task UpdateAsync(UpdateOrganizationUnitInput input); |
|||
|
|||
/// <summary>
|
|||
/// 向组织机构添加角色
|
|||
/// </summary>
|
|||
Task AddRoleToOrganizationUnitAsync(AddRoleToOrganizationUnitInput input); |
|||
|
|||
/// <summary>
|
|||
/// 向组织机构删除角色
|
|||
/// </summary>
|
|||
Task RemoveRoleFromOrganizationUnitAsync(RemoveRoleToOrganizationUnitInput input); |
|||
|
|||
/// <summary>
|
|||
/// 向组织机构添加用户
|
|||
/// </summary>
|
|||
Task AddUserToOrganizationUnitAsync(AddUserToOrganizationUnitInput input); |
|||
|
|||
/// <summary>
|
|||
/// 向组织机构删除用户
|
|||
/// </summary>
|
|||
Task RemoveUserFromOrganizationUnitAsync(RemoveUserToOrganizationUnitInput input); |
|||
|
|||
/// <summary>
|
|||
/// 分页获取组织机构下用户
|
|||
/// </summary>
|
|||
Task<PagedResultDto<GetOrganizationUnitUserOutput>> GetUsersAsync(GetOrganizationUnitUserInput input); |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 分页获取组织机构下角色
|
|||
/// </summary>
|
|||
Task<PagedResultDto<GetOrganizationUnitRoleOutput>> GetRolesAsync(GetOrganizationUnitRoleInput input); |
|||
|
|||
/// <summary>
|
|||
/// 获取不在组织机构的用户
|
|||
/// </summary>
|
|||
Task<PagedResultDto<GetUnAddUserOutput>> GetUnAddUsersAsync(GetUnAddUserInput input); |
|||
|
|||
/// <summary>
|
|||
/// 获取不在组织机构的角色
|
|||
/// </summary>
|
|||
Task<PagedResultDto<GetUnAddRoleOutput>> GetUnAddRolessAsync(GetUnAddRoleInput input); |
|||
} |
|||
@ -0,0 +1,199 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Lion.AbpPro.Extension.Customs.Dtos; |
|||
using Lion.AbpPro.IdentityServers.ApiResources.Dtos; |
|||
using Lion.AbpPro.OrganizationUnits.Dto; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace Lion.AbpPro.OrganizationUnits; |
|||
|
|||
public class OrganizationUnitAppService : AbpProAppService, IOrganizationUnitAppService |
|||
{ |
|||
private readonly OrganizationUnitManager _organizationUnitManager; |
|||
private readonly IdentityUserManager _identityUserManager; |
|||
private readonly IOrganizationUnitRepository _organizationUnitRepository; |
|||
|
|||
public OrganizationUnitAppService( |
|||
OrganizationUnitManager OrganizationUnitManager, |
|||
IdentityUserManager identityUserManager, |
|||
IOrganizationUnitRepository organizationUnitRepository) |
|||
{ |
|||
_organizationUnitManager = OrganizationUnitManager; |
|||
_identityUserManager = identityUserManager; |
|||
_organizationUnitRepository = organizationUnitRepository; |
|||
} |
|||
|
|||
public async Task<List<TreeOutput>> GetTreeAsync() |
|||
{ |
|||
var organizationUnits = await _organizationUnitRepository.GetListAsync(); |
|||
var organizationUnitDtos = ObjectMapper.Map<List<OrganizationUnit>, List<OrganizationUnitDto>>(organizationUnits); |
|||
return ConvertToTree(organizationUnitDtos); |
|||
} |
|||
|
|||
public async Task CreateAsync(CreateOrganizationUnitInput input) |
|||
{ |
|||
var entity = new OrganizationUnit |
|||
( |
|||
GuidGenerator.Create(), |
|||
input.DisplayName, |
|||
input.ParentId, |
|||
CurrentTenant.Id |
|||
); |
|||
await _organizationUnitManager.CreateAsync(entity); |
|||
} |
|||
|
|||
public Task DeleteAsync(IdInput input) |
|||
{ |
|||
return _organizationUnitManager.DeleteAsync(input.Id); |
|||
} |
|||
|
|||
public async Task UpdateAsync(UpdateOrganizationUnitInput input) |
|||
{ |
|||
var entity = await _organizationUnitRepository.FindAsync(input.Id); |
|||
if (entity != null) |
|||
{ |
|||
entity.DisplayName = input.DisplayName; |
|||
await _organizationUnitManager.UpdateAsync(entity); |
|||
} |
|||
} |
|||
|
|||
public async Task AddRoleToOrganizationUnitAsync(AddRoleToOrganizationUnitInput input) |
|||
{ |
|||
foreach (var roleId in input.RoleId) |
|||
{ |
|||
await _organizationUnitManager.AddRoleToOrganizationUnitAsync(roleId, input.OrganizationUnitId); |
|||
} |
|||
} |
|||
|
|||
public async Task RemoveRoleFromOrganizationUnitAsync(RemoveRoleToOrganizationUnitInput input) |
|||
{ |
|||
await _organizationUnitManager.RemoveRoleFromOrganizationUnitAsync(input.RoleId, input.OrganizationUnitId); |
|||
} |
|||
|
|||
public async Task AddUserToOrganizationUnitAsync(AddUserToOrganizationUnitInput input) |
|||
{ |
|||
foreach (var userId in input.UserId) |
|||
{ |
|||
await _identityUserManager.AddToOrganizationUnitAsync(userId, input.OrganizationUnitId); |
|||
} |
|||
} |
|||
|
|||
public async Task RemoveUserFromOrganizationUnitAsync(RemoveUserToOrganizationUnitInput input) |
|||
{ |
|||
await _identityUserManager.RemoveFromOrganizationUnitAsync(input.UserId, input.OrganizationUnitId); |
|||
} |
|||
|
|||
public async Task<PagedResultDto<GetOrganizationUnitUserOutput>> GetUsersAsync(GetOrganizationUnitUserInput input) |
|||
{ |
|||
var listResult = new List<GetOrganizationUnitUserOutput>(); |
|||
var organizationUnit = await _organizationUnitRepository.FindAsync(input.OrganizationUnitId); |
|||
if (organizationUnit == null) throw new UserFriendlyException("组织机构不存在"); |
|||
|
|||
var count = await _organizationUnitRepository.GetMembersCountAsync(organizationUnit, filter: input.Filter); |
|||
if (count > 0) |
|||
{ |
|||
var list = await _organizationUnitRepository.GetMembersAsync |
|||
( |
|||
organizationUnit, |
|||
maxResultCount: input.PageSize, |
|||
skipCount: input.SkipCount, |
|||
filter: input.Filter |
|||
); |
|||
listResult = ObjectMapper.Map<List<IdentityUser>, List<GetOrganizationUnitUserOutput>>(list); |
|||
} |
|||
|
|||
return new PagedResultDto<GetOrganizationUnitUserOutput>(count, listResult); |
|||
} |
|||
|
|||
public async Task<PagedResultDto<GetUnAddUserOutput>> GetUnAddUsersAsync(GetUnAddUserInput input) |
|||
{ |
|||
var listResult = new List<GetUnAddUserOutput>(); |
|||
var organizationUnit = await _organizationUnitRepository.FindAsync(input.OrganizationUnitId); |
|||
if (organizationUnit == null) throw new UserFriendlyException("组织机构不存在"); |
|||
var count = await _organizationUnitRepository.GetUnaddedUsersCountAsync(organizationUnit, input.Filter); |
|||
if (count > 0) |
|||
{ |
|||
var users = await _organizationUnitRepository.GetUnaddedUsersAsync |
|||
( |
|||
organizationUnit, |
|||
maxResultCount: input.PageSize, |
|||
skipCount: input.SkipCount, |
|||
filter: input.Filter |
|||
); |
|||
listResult = ObjectMapper.Map<List<IdentityUser>, List<GetUnAddUserOutput>>(users); |
|||
} |
|||
|
|||
return new PagedResultDto<GetUnAddUserOutput>(count, listResult); |
|||
} |
|||
|
|||
public async Task<PagedResultDto<GetOrganizationUnitRoleOutput>> GetRolesAsync(GetOrganizationUnitRoleInput input) |
|||
{ |
|||
var listResult = new List<GetOrganizationUnitRoleOutput>(); |
|||
var organizationUnit = await _organizationUnitRepository.FindAsync(input.OrganizationUnitId); |
|||
if (organizationUnit == null) throw new UserFriendlyException("组织机构不存在"); |
|||
|
|||
var count = await _organizationUnitRepository.GetRolesCountAsync(organizationUnit); |
|||
if (count > 0) |
|||
{ |
|||
var list = await _organizationUnitRepository.GetRolesAsync(organizationUnit, maxResultCount: input.PageSize, skipCount: input.SkipCount); |
|||
listResult = ObjectMapper.Map<List<IdentityRole>, List<GetOrganizationUnitRoleOutput>>(list); |
|||
} |
|||
|
|||
return new PagedResultDto<GetOrganizationUnitRoleOutput>(count, listResult); |
|||
} |
|||
|
|||
public async Task<PagedResultDto<GetUnAddRoleOutput>> GetUnAddRolessAsync(GetUnAddRoleInput input) |
|||
{ |
|||
var listResult = new List<GetUnAddRoleOutput>(); |
|||
var organizationUnit = await _organizationUnitRepository.FindAsync(input.OrganizationUnitId); |
|||
if (organizationUnit == null) throw new UserFriendlyException("组织机构不存在"); |
|||
var count = await _organizationUnitRepository.GetUnaddedRolesCountAsync(organizationUnit, input.Filter); |
|||
if (count > 0) |
|||
{ |
|||
var roles = await _organizationUnitRepository.GetUnaddedRolesAsync |
|||
( |
|||
organizationUnit, |
|||
maxResultCount: input.PageSize, |
|||
skipCount: input.SkipCount, |
|||
filter: input.Filter |
|||
); |
|||
listResult = ObjectMapper.Map<List<IdentityRole>, List<GetUnAddRoleOutput>>(roles); |
|||
} |
|||
|
|||
return new PagedResultDto<GetUnAddRoleOutput>(count, listResult); |
|||
} |
|||
|
|||
#region 私有方法
|
|||
|
|||
private List<TreeOutput> ConvertToTree(List<OrganizationUnitDto> list, |
|||
Guid? Id = null) |
|||
{ |
|||
var result = new List<TreeOutput>(); |
|||
var childList = Children(list, Id); |
|||
foreach (var item in childList) |
|||
{ |
|||
var tree = new TreeOutput |
|||
{ |
|||
Key = item.Id, |
|||
Title = item.DisplayName, |
|||
Children = ConvertToTree(list, item.Id) |
|||
}; |
|||
result.Add(tree); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
private List<OrganizationUnitDto> Children(List<OrganizationUnitDto> list, |
|||
Guid? Id) |
|||
{ |
|||
var childList = list.Where(x => x.ParentId == Id).ToList(); |
|||
return childList; |
|||
} |
|||
|
|||
#endregion
|
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
{ |
|||
"ConnectionStrings": { |
|||
"Default": "Data Source=localhost;Database=LionAbpProDB123123;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" |
|||
} |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
{ |
|||
"ConnectionStrings": { |
|||
"Default": "Data Source=localhost;Database=LionAbpProDB123123Staging;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" |
|||
} |
|||
} |
|||
@ -1,9 +1,8 @@ |
|||
using System.Threading.Tasks; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Lion.AbpPro.Data |
|||
namespace Lion.AbpPro.Data; |
|||
|
|||
public interface IAbpProDbSchemaMigrator |
|||
{ |
|||
public interface IAbpProDbSchemaMigrator |
|||
{ |
|||
Task MigrateAsync(); |
|||
} |
|||
Task MigrateAsync(); |
|||
} |
|||
|
|||
@ -1,16 +1,15 @@ |
|||
using System.Threading.Tasks; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Lion.AbpPro.Data |
|||
namespace Lion.AbpPro.Data; |
|||
|
|||
/* This is used if database provider does't define |
|||
* IAbpProDbSchemaMigrator implementation. |
|||
*/ |
|||
public class NullAbpProDbSchemaMigrator : IAbpProDbSchemaMigrator, ITransientDependency |
|||
{ |
|||
/* This is used if database provider does't define |
|||
* IAbpProDbSchemaMigrator implementation. |
|||
*/ |
|||
public class NullAbpProDbSchemaMigrator : IAbpProDbSchemaMigrator, ITransientDependency |
|||
public Task MigrateAsync() |
|||
{ |
|||
public Task MigrateAsync() |
|||
{ |
|||
return Task.CompletedTask; |
|||
} |
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,105 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Lion.AbpPro.Extension.Customs.Dtos; |
|||
using Lion.AbpPro.OrganizationUnits; |
|||
using Lion.AbpPro.OrganizationUnits.Dto; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Swashbuckle.AspNetCore.Annotations; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace Lion.AbpPro.Controllers.Systems; |
|||
|
|||
[Route("OrganizationUnits")] |
|||
public class OrganizationUnitController : AbpProController, IOrganizationUnitAppService |
|||
{ |
|||
private readonly IOrganizationUnitAppService _organizationUnitAppService; |
|||
|
|||
public OrganizationUnitController(IOrganizationUnitAppService organizationUnitAppService) |
|||
{ |
|||
_organizationUnitAppService = organizationUnitAppService; |
|||
} |
|||
|
|||
[HttpPost("tree")] |
|||
[SwaggerOperation(summary: "获取组织机构树", Tags = new[] { "OrganizationUnits" })] |
|||
public Task<List<TreeOutput>> GetTreeAsync() |
|||
{ |
|||
return _organizationUnitAppService.GetTreeAsync(); |
|||
} |
|||
|
|||
[HttpPost("create")] |
|||
[SwaggerOperation(summary: "创建组织机构", Tags = new[] { "OrganizationUnits" })] |
|||
public Task CreateAsync(CreateOrganizationUnitInput input) |
|||
{ |
|||
return _organizationUnitAppService.CreateAsync(input); |
|||
} |
|||
|
|||
[HttpPost("delete")] |
|||
[SwaggerOperation(summary: "删除组织机构", Tags = new[] { "OrganizationUnits" })] |
|||
public Task DeleteAsync(IdInput input) |
|||
{ |
|||
return _organizationUnitAppService.DeleteAsync(input); |
|||
} |
|||
|
|||
[HttpPost("update")] |
|||
[SwaggerOperation(summary: "编辑组织机构", Tags = new[] { "OrganizationUnits" })] |
|||
public Task UpdateAsync(UpdateOrganizationUnitInput input) |
|||
{ |
|||
return _organizationUnitAppService.UpdateAsync(input); |
|||
} |
|||
|
|||
[HttpPost("addRoleToOrganizationUnitAsync")] |
|||
[SwaggerOperation(summary: "向组织机构添加角色", Tags = new[] { "OrganizationUnits" })] |
|||
public Task AddRoleToOrganizationUnitAsync(AddRoleToOrganizationUnitInput input) |
|||
{ |
|||
return _organizationUnitAppService.AddRoleToOrganizationUnitAsync(input); |
|||
} |
|||
|
|||
[HttpPost("removeRoleFromOrganizationUnitAsync")] |
|||
[SwaggerOperation(summary: "向组织机构删除角色", Tags = new[] { "OrganizationUnits" })] |
|||
public Task RemoveRoleFromOrganizationUnitAsync(RemoveRoleToOrganizationUnitInput input) |
|||
{ |
|||
return _organizationUnitAppService.RemoveRoleFromOrganizationUnitAsync(input); |
|||
} |
|||
|
|||
[HttpPost("addUserToOrganizationUnit")] |
|||
[SwaggerOperation(summary: "向组织机构添加用户", Tags = new[] { "OrganizationUnits" })] |
|||
public Task AddUserToOrganizationUnitAsync(AddUserToOrganizationUnitInput input) |
|||
{ |
|||
return _organizationUnitAppService.AddUserToOrganizationUnitAsync(input); |
|||
} |
|||
|
|||
[HttpPost("removeUserFromOrganizationUnit")] |
|||
[SwaggerOperation(summary: "向组织机构删除用户", Tags = new[] { "OrganizationUnits" })] |
|||
public Task RemoveUserFromOrganizationUnitAsync(RemoveUserToOrganizationUnitInput input) |
|||
{ |
|||
return _organizationUnitAppService.RemoveUserFromOrganizationUnitAsync(input); |
|||
} |
|||
|
|||
[HttpPost("getUsers")] |
|||
[SwaggerOperation(summary: "分页获取组织机构下用户", Tags = new[] { "OrganizationUnits" })] |
|||
public Task<PagedResultDto<GetOrganizationUnitUserOutput>> GetUsersAsync(GetOrganizationUnitUserInput input) |
|||
{ |
|||
return _organizationUnitAppService.GetUsersAsync(input); |
|||
} |
|||
|
|||
[HttpPost("getRoles")] |
|||
[SwaggerOperation(summary: "分页获取组织机构下角色", Tags = new[] { "OrganizationUnits" })] |
|||
public Task<PagedResultDto<GetOrganizationUnitRoleOutput>> GetRolesAsync(GetOrganizationUnitRoleInput input) |
|||
{ |
|||
return _organizationUnitAppService.GetRolesAsync(input); |
|||
} |
|||
|
|||
[HttpPost("getUnAddUsers")] |
|||
[SwaggerOperation(summary: "获取不在组织机构的用户", Tags = new[] { "OrganizationUnits" })] |
|||
public Task<PagedResultDto<GetUnAddUserOutput>> GetUnAddUsersAsync(GetUnAddUserInput input) |
|||
{ |
|||
return _organizationUnitAppService.GetUnAddUsersAsync(input); |
|||
} |
|||
|
|||
[HttpPost("getUnAddRoles")] |
|||
[SwaggerOperation(summary: "获取不在组织机构的角色", Tags = new[] { "OrganizationUnits" })] |
|||
public Task<PagedResultDto<GetUnAddRoleOutput>> GetUnAddRolessAsync(GetUnAddRoleInput input) |
|||
{ |
|||
return _organizationUnitAppService.GetUnAddRolessAsync(input); |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,84 @@ |
|||
<template> |
|||
<div> |
|||
<BasicModal |
|||
:title="t('common.createText')" |
|||
:canFullscreen="false" |
|||
@ok="submit" |
|||
:maskClosable="false" |
|||
@cancel="cancel" |
|||
@register="registerModal" |
|||
:minHeight="100" |
|||
:destroyOnClose="true" |
|||
> |
|||
<BasicTable @register="registerRoleTable" size="small"/> |
|||
</BasicModal> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import { defineComponent } from "vue"; |
|||
import { BasicModal, useModalInner } from "/@/components/Modal"; |
|||
import { BasicForm } from "/@/components/Form/index"; |
|||
import { useI18n } from "/@/hooks/web/useI18n"; |
|||
import { |
|||
getUnAddRolesAsync, addRoleTableColumns, searchAddRoleFormSchema |
|||
} from "/@/views/admin/organizationUnits/OrganizationUnit"; |
|||
import { AddRoleToOrganizationUnitInput } from "/@/services/ServiceProxies"; |
|||
import { useTable } from "/@/components/Table"; |
|||
|
|||
export default defineComponent({ |
|||
name: "AddRoleToOrganizationUnit", |
|||
components: { |
|||
BasicModal, |
|||
BasicForm |
|||
}, |
|||
|
|||
setup(_, { emit }) { |
|||
const { t } = useI18n(); |
|||
const [registerModal, { closeModal, changeOkLoading }] = useModalInner((data) => { |
|||
getForm().setFieldsValue({ |
|||
organizationUnitId: data.organizationUnitId |
|||
}); |
|||
}); |
|||
const [registerRoleTable, { getForm,getSelectRowKeys }] = useTable({ |
|||
columns: addRoleTableColumns, |
|||
formConfig: { |
|||
labelWidth: 70, |
|||
schemas: searchAddRoleFormSchema |
|||
}, |
|||
api: getUnAddRolesAsync, |
|||
showTableSetting: true, |
|||
useSearchForm: false, |
|||
bordered: true, |
|||
canResize: true, |
|||
showIndexColumn: true |
|||
}); |
|||
const submit = async () => { |
|||
try { |
|||
let selectedRoles = getSelectRowKeys(); |
|||
console.log(selectedRoles); |
|||
let request = new AddRoleToOrganizationUnitInput(); |
|||
request.organizationUnitId = getForm().getFieldsValue().organizationUnitId; |
|||
|
|||
emit("reload"); |
|||
} catch (error) { |
|||
changeOkLoading(false); |
|||
} |
|||
}; |
|||
|
|||
const cancel = () => { |
|||
closeModal(); |
|||
}; |
|||
|
|||
return { |
|||
registerModal, |
|||
registerRoleTable, |
|||
submit, |
|||
t, |
|||
cancel |
|||
}; |
|||
} |
|||
}); |
|||
</script> |
|||
|
|||
<style lang="less" scoped></style> |
|||
@ -0,0 +1,89 @@ |
|||
<template> |
|||
<div> |
|||
<BasicModal |
|||
:title="t('common.createText')" |
|||
:canFullscreen="false" |
|||
@ok="submit" |
|||
:maskClosable="false" |
|||
@cancel="cancel" |
|||
@register="registerModal" |
|||
:minHeight="100" |
|||
:destroyOnClose="true" |
|||
> |
|||
<BasicForm @register="registerOrganizationUnitForm" /> |
|||
</BasicModal> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import { defineComponent } from 'vue'; |
|||
import { BasicModal, useModalInner } from '/@/components/Modal'; |
|||
import { BasicForm, useForm } from '/@/components/Form/index'; |
|||
import { useI18n } from '/@/hooks/web/useI18n'; |
|||
import { |
|||
createOrganizationUnitFormSchema, |
|||
createOrganizationUnitAsync, |
|||
} from "/@/views/admin/organizationUnits/OrganizationUnit"; |
|||
|
|||
export default defineComponent({ |
|||
name: 'CreateOrganizationUnit', |
|||
components: { |
|||
BasicModal, |
|||
BasicForm, |
|||
}, |
|||
|
|||
setup(_, { emit }) { |
|||
const { t } = useI18n(); |
|||
const [registerModal, { closeModal, changeOkLoading }] = useModalInner((data) => { |
|||
if (data.record.parentId == '') { |
|||
updateSchema({ field: 'parentDisplayName', ifShow: false }); |
|||
} else { |
|||
updateSchema({ field: 'parentDisplayName', ifShow: true }); |
|||
setFieldsValue({ |
|||
parentDisplayName: data.record.parentDisplayName, |
|||
parentId: data.record.parentId, |
|||
}); |
|||
} |
|||
}); |
|||
const [ |
|||
registerOrganizationUnitForm, |
|||
{ resetFields, getFieldsValue, validate, setFieldsValue, updateSchema }, |
|||
] = useForm({ |
|||
labelWidth: 120, |
|||
schemas: createOrganizationUnitFormSchema, |
|||
showActionButtonGroup: false, |
|||
}); |
|||
const submit = async () => { |
|||
try { |
|||
let request = getFieldsValue(); |
|||
await createOrganizationUnitAsync({ |
|||
request, |
|||
changeOkLoading, |
|||
validate, |
|||
resetFields, |
|||
closeModal, |
|||
}); |
|||
emit('reload'); |
|||
} catch (error) { |
|||
changeOkLoading(false); |
|||
} |
|||
}; |
|||
|
|||
const cancel = () => { |
|||
resetFields(); |
|||
// emit('clearSelectedRowKeys'); |
|||
closeModal(); |
|||
}; |
|||
|
|||
return { |
|||
registerModal, |
|||
registerOrganizationUnitForm, |
|||
submit, |
|||
t, |
|||
cancel, |
|||
}; |
|||
}, |
|||
}); |
|||
</script> |
|||
|
|||
<style lang="less" scoped></style> |
|||
@ -0,0 +1,75 @@ |
|||
<template> |
|||
<div> |
|||
<BasicModal |
|||
:title="t('common.editText')" |
|||
:canFullscreen="false" |
|||
@ok="submit" |
|||
:maskClosable="false" |
|||
@cancel="cancel" |
|||
@register="registerModal" |
|||
:minHeight="100" |
|||
:destroyOnClose="true" |
|||
> |
|||
<BasicForm @register="registerOrganizationUnitForm" /> |
|||
</BasicModal> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import { defineComponent } from 'vue'; |
|||
import { BasicModal, useModalInner } from '/@/components/Modal'; |
|||
import { BasicForm, useForm } from '/@/components/Form/index'; |
|||
import { useI18n } from '/@/hooks/web/useI18n'; |
|||
import { editOrganizationUnitFormSchema, editOrganizationUnitAsync } from "/@/views/admin/organizationUnits/OrganizationUnit"; |
|||
|
|||
export default defineComponent({ |
|||
name: 'EditOrganizationUnit', |
|||
components: { |
|||
BasicModal, |
|||
BasicForm, |
|||
}, |
|||
|
|||
setup(_, { emit }) { |
|||
const { t } = useI18n(); |
|||
const [registerModal, { closeModal, changeOkLoading }] = useModalInner((data) => { |
|||
setFieldsValue({ |
|||
displayName: data.record.displayName, |
|||
id: data.record.id, |
|||
}); |
|||
}); |
|||
const [registerOrganizationUnitForm, { getFieldsValue, validate, setFieldsValue }] = useForm({ |
|||
labelWidth: 120, |
|||
schemas: editOrganizationUnitFormSchema, |
|||
showActionButtonGroup: false, |
|||
}); |
|||
const submit = async () => { |
|||
try { |
|||
let request = getFieldsValue(); |
|||
await editOrganizationUnitAsync({ |
|||
request, |
|||
changeOkLoading, |
|||
validate, |
|||
closeModal, |
|||
}); |
|||
emit('reload'); |
|||
} catch (error) { |
|||
changeOkLoading(false); |
|||
} |
|||
}; |
|||
|
|||
const cancel = () => { |
|||
closeModal(); |
|||
}; |
|||
|
|||
return { |
|||
registerModal, |
|||
registerOrganizationUnitForm, |
|||
submit, |
|||
t, |
|||
cancel, |
|||
}; |
|||
}, |
|||
}); |
|||
</script> |
|||
|
|||
<style lang="less" scoped></style> |
|||
@ -0,0 +1,234 @@ |
|||
import { |
|||
OrganizationUnitsServiceProxy, |
|||
IdInput, |
|||
GetOrganizationUnitUserInput, |
|||
GetOrganizationUnitRoleInput, |
|||
RemoveUserToOrganizationUnitInput, |
|||
RemoveRoleToOrganizationUnitInput, |
|||
AddRoleToOrganizationUnitInput, |
|||
AddUserToOrganizationUnitInput, |
|||
GetUnAddRoleInput, |
|||
GetUnAddUserInput |
|||
} from "/@/services/ServiceProxies"; |
|||
import { FormSchema } from '/@/components/Table'; |
|||
import { BasicColumn } from '/@/components/Table'; |
|||
import { useI18n } from '/@/hooks/web/useI18n'; |
|||
const { t } = useI18n(); |
|||
|
|||
export const createOrganizationUnitFormSchema: FormSchema[] = [ |
|||
{ |
|||
field: 'parentDisplayName', |
|||
label: t('routes.admin.parentOrganizationUnitName'), |
|||
component: 'Input', |
|||
componentProps: { |
|||
disabled: true, |
|||
}, |
|||
colProps: { |
|||
span: 18, |
|||
}, |
|||
}, |
|||
{ |
|||
field: 'displayName', |
|||
label: t('routes.admin.organizationUnitName'), |
|||
component: 'Input', |
|||
colProps: { |
|||
span: 18, |
|||
}, |
|||
}, |
|||
{ |
|||
field: 'parentId', |
|||
label: '', |
|||
component: 'Input', |
|||
colProps: { |
|||
span: 18, |
|||
}, |
|||
ifShow: false, |
|||
}, |
|||
]; |
|||
|
|||
export const editOrganizationUnitFormSchema: FormSchema[] = [ |
|||
{ |
|||
field: 'displayName', |
|||
label: t('routes.admin.organizationUnitName'), |
|||
component: 'Input', |
|||
colProps: { |
|||
span: 18, |
|||
}, |
|||
}, |
|||
{ |
|||
field: 'id', |
|||
label: '', |
|||
component: 'Input', |
|||
colProps: { |
|||
span: 18, |
|||
}, |
|||
ifShow: false, |
|||
}, |
|||
]; |
|||
export const addRoleToOrganizationUnitFormSchema: FormSchema[] = [ |
|||
{ |
|||
field: 'displayName', |
|||
label: t('routes.admin.organizationUnitName'), |
|||
component: 'Input', |
|||
colProps: { |
|||
span: 18, |
|||
}, |
|||
}, |
|||
{ |
|||
field: 'organizationUnitId', |
|||
label: '', |
|||
component: 'Input', |
|||
colProps: { |
|||
span: 18, |
|||
}, |
|||
ifShow: false, |
|||
}, |
|||
]; |
|||
export const userTableColumns: BasicColumn[] = [ |
|||
{ |
|||
title: t('routes.admin.userManagement_userName'), |
|||
dataIndex: 'userName', |
|||
}, |
|||
{ |
|||
title: t('routes.admin.userManagement_email'), |
|||
dataIndex: 'email', |
|||
} |
|||
]; |
|||
|
|||
export const addUserTableColumns: BasicColumn[] = [ |
|||
{ |
|||
title: t('routes.admin.userManagement_userName'), |
|||
dataIndex: 'userName', |
|||
}, |
|||
{ |
|||
title: t('routes.admin.userManagement_email'), |
|||
dataIndex: 'email', |
|||
} |
|||
]; |
|||
|
|||
export const roleTableColumns: BasicColumn[] = [ |
|||
{ |
|||
title: t('routes.admin.userManagement_roleName'), |
|||
dataIndex: 'name', |
|||
} |
|||
]; |
|||
export const addRoleTableColumns: BasicColumn[] = [ |
|||
{ |
|||
title: t('routes.admin.userManagement_roleName'), |
|||
dataIndex: 'name', |
|||
} |
|||
]; |
|||
export const searchAddRoleFormSchema: FormSchema[] = [ |
|||
{ |
|||
field: 'filter', |
|||
label: t('routes.admin.userManagement_roleName'), |
|||
component: 'Input', |
|||
colProps: { span: 8 }, |
|||
}, |
|||
{ |
|||
field: 'organizationUnitId', |
|||
label: '', |
|||
component: 'Input', |
|||
ifShow:false, |
|||
colProps: { span: 8 }, |
|||
} |
|||
]; |
|||
|
|||
export const searchUserFormSchema: FormSchema[] = [ |
|||
{ |
|||
field: 'filter', |
|||
label: t('routes.admin.userManagement_userName'), |
|||
component: 'Input', |
|||
colProps: { span: 8 }, |
|||
}, |
|||
{ |
|||
field: 'organizationUnitId', |
|||
label: '', |
|||
component: 'Input', |
|||
ifShow:false, |
|||
colProps: { span: 8 }, |
|||
} |
|||
]; |
|||
export async function getTreeAsync() { |
|||
const _organizationUnitsServiceProxy = new OrganizationUnitsServiceProxy(); |
|||
return await _organizationUnitsServiceProxy.tree(); |
|||
} |
|||
export async function deleteTreeNodeAsync({ id }) { |
|||
const _organizationUnitsServiceProxy = new OrganizationUnitsServiceProxy(); |
|||
const request = new IdInput(); |
|||
request.id = id; |
|||
return await _organizationUnitsServiceProxy.delete(request); |
|||
} |
|||
export async function createOrganizationUnitAsync({ |
|||
request, |
|||
changeOkLoading, |
|||
closeModal, |
|||
validate, |
|||
resetFields, |
|||
}) { |
|||
changeOkLoading(true); |
|||
await validate(); |
|||
const _organizationUnitsServiceProxy = new OrganizationUnitsServiceProxy(); |
|||
await _organizationUnitsServiceProxy.create(request); |
|||
resetFields(); |
|||
changeOkLoading(false); |
|||
closeModal(); |
|||
} |
|||
|
|||
export async function editOrganizationUnitAsync({ |
|||
request, |
|||
changeOkLoading, |
|||
closeModal, |
|||
validate, |
|||
}) { |
|||
changeOkLoading(true); |
|||
await validate(); |
|||
const _organizationUnitsServiceProxy = new OrganizationUnitsServiceProxy(); |
|||
await _organizationUnitsServiceProxy.update(request); |
|||
changeOkLoading(false); |
|||
closeModal(); |
|||
} |
|||
|
|||
export async function getUserTableListAsync(params: GetOrganizationUnitUserInput) { |
|||
const _organizationUnitsServiceProxy = new OrganizationUnitsServiceProxy(); |
|||
return _organizationUnitsServiceProxy.getUsers(params); |
|||
} |
|||
export async function getRoleTableListAsync(params: GetOrganizationUnitRoleInput) { |
|||
const _organizationUnitsServiceProxy = new OrganizationUnitsServiceProxy(); |
|||
return _organizationUnitsServiceProxy.getRoles(params); |
|||
} |
|||
|
|||
|
|||
export async function removeUserFromOrganizationUnitAsync(params:RemoveUserToOrganizationUnitInput) |
|||
{ |
|||
const _organizationUnitsServiceProxy = new OrganizationUnitsServiceProxy(); |
|||
return _organizationUnitsServiceProxy.removeUserFromOrganizationUnit(params); |
|||
} |
|||
export async function removeRoleFromOrganizationUnitAsync(params:RemoveRoleToOrganizationUnitInput) |
|||
{ |
|||
const _organizationUnitsServiceProxy = new OrganizationUnitsServiceProxy(); |
|||
return _organizationUnitsServiceProxy.removeRoleFromOrganizationUnit(params); |
|||
} |
|||
export async function addRoleToOrganizationUnitAsync(params:AddRoleToOrganizationUnitInput) |
|||
{ |
|||
const _organizationUnitsServiceProxy = new OrganizationUnitsServiceProxy(); |
|||
return _organizationUnitsServiceProxy.addRoleToOrganizationUnit(params); |
|||
} |
|||
export async function addUserToOrganizationUnitAsync(params:AddUserToOrganizationUnitInput) |
|||
{ |
|||
const _organizationUnitsServiceProxy = new OrganizationUnitsServiceProxy(); |
|||
return _organizationUnitsServiceProxy.addUserToOrganizationUnit(params); |
|||
} |
|||
|
|||
export async function GetUnAddUserAsync(params:GetUnAddUserInput) |
|||
{ |
|||
const _organizationUnitsServiceProxy = new OrganizationUnitsServiceProxy(); |
|||
return _organizationUnitsServiceProxy.getUnAddUsers(params); |
|||
} |
|||
|
|||
|
|||
export async function getUnAddRolesAsync(params:GetUnAddRoleInput) |
|||
{ |
|||
const _organizationUnitsServiceProxy = new OrganizationUnitsServiceProxy(); |
|||
return _organizationUnitsServiceProxy.getUnAddRoles(params); |
|||
} |
|||
@ -0,0 +1,344 @@ |
|||
<template> |
|||
<div> |
|||
<PageWrapper dense contentFullHeight fixedHeight contentClass="flex"> |
|||
<div class="bg-white m-4 mr-0 overflow-hidden"> |
|||
<BasicTree |
|||
toolbar |
|||
search |
|||
:treeData="treeData" |
|||
:beforeRightClick="getRightMenuList" |
|||
@select="handleSelect" |
|||
> |
|||
<template #headerTitle> |
|||
<span style="font-weight: 500">组织机构</span> |
|||
<a-button |
|||
type="primary" |
|||
style="margin-left: 20px" |
|||
size="small" |
|||
@click="createRootOrganizationUnit" |
|||
> |
|||
添加根机构 |
|||
</a-button> |
|||
</template> |
|||
</BasicTree> |
|||
</div> |
|||
<div class="bg-white m-4 mr-0 w-3/4 xl:w-4/5"> |
|||
|
|||
<a-tabs v-model:activeKey="activeKey" @change="activeKeyChange"> |
|||
<a-tab-pane key="1" tab="成员"> |
|||
<BasicTable @register="registerUserTable" size="small"> |
|||
<template #action="{ record }"> |
|||
<TableAction |
|||
:actions="[ |
|||
{ |
|||
icon: 'ant-design:delete-outlined', |
|||
label: '删除', |
|||
onClick: handleUserDelete.bind(null, record), |
|||
}, |
|||
]" |
|||
/> |
|||
</template> |
|||
|
|||
</BasicTable> |
|||
</a-tab-pane> |
|||
<a-tab-pane key="2" tab="角色" force-render> |
|||
<BasicTable @register="registerRoleTable" size="small"> |
|||
<template #toolbar> |
|||
<a-button |
|||
preIcon="ant-design:plus-circle-outlined" |
|||
type="primary" |
|||
@click="AddRoleToOrganizationUnitModal" |
|||
> |
|||
{{ t("common.createText") }} |
|||
</a-button> |
|||
|
|||
</template> |
|||
<template #action="{ record }"> |
|||
<TableAction |
|||
:actions="[ |
|||
{ |
|||
icon: 'ant-design:delete-outlined', |
|||
|
|||
label: '删除', |
|||
onClick: handleRoleDelete.bind(null, record), |
|||
}, |
|||
]" |
|||
/> |
|||
</template> |
|||
</BasicTable> |
|||
</a-tab-pane> |
|||
</a-tabs> |
|||
</div> |
|||
</PageWrapper> |
|||
<CreateOrganizationUnit |
|||
@register="registerCreateOrganizationUnit" |
|||
@reload="initOrganizationUnit" |
|||
/> |
|||
<EditOrganizationUnit @register="registerEditOrganizationUnit" @reload="initOrganizationUnit" /> |
|||
<AddRoleToOrganizationUnit @register="registerAddRoleToOrganizationUnit" @reload="initOrganizationUnit" /> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import { defineComponent, onMounted, ref } from "vue"; |
|||
import { PageWrapper } from "/@/components/Page"; |
|||
import { BasicTree, ContextMenuItem } from "/@/components/Tree"; |
|||
import { BasicTable, useTable, TableAction } from "/@/components/Table"; |
|||
import { |
|||
getTreeAsync, |
|||
deleteTreeNodeAsync, |
|||
getUserTableListAsync, |
|||
getRoleTableListAsync, |
|||
userTableColumns, |
|||
roleTableColumns, |
|||
searchUserFormSchema, |
|||
removeRoleFromOrganizationUnitAsync, |
|||
removeUserFromOrganizationUnitAsync |
|||
} from "/@/views/admin/organizationUnits/OrganizationUnit"; |
|||
import { |
|||
TreeOutput, |
|||
GetOrganizationUnitUserInput, |
|||
GetOrganizationUnitRoleInput, RemoveUserToOrganizationUnitInput, RemoveRoleToOrganizationUnitInput |
|||
} from "/@/services/ServiceProxies"; |
|||
import { Tabs } from "ant-design-vue"; |
|||
import CreateOrganizationUnit from "./CreateOrganizationUnit.vue"; |
|||
import EditOrganizationUnit from "./EditOrganizationUnit.vue"; |
|||
import AddRoleToOrganizationUnit from './AddRoleToOrganizationUnit.vue'; |
|||
|
|||
import { useModal } from "/@/components/Modal"; |
|||
import { useMessage } from "/@/hooks/web/useMessage"; |
|||
import { useI18n } from "/@/hooks/web/useI18n"; |
|||
|
|||
|
|||
export default defineComponent({ |
|||
name: "OrganizationUnit", |
|||
components: { |
|||
BasicTree, |
|||
PageWrapper, |
|||
Tabs, |
|||
TabPane: Tabs.TabPane, |
|||
CreateOrganizationUnit, |
|||
EditOrganizationUnit, |
|||
BasicTable, |
|||
TableAction, |
|||
AddRoleToOrganizationUnit |
|||
}, |
|||
setup() { |
|||
const { t } = useI18n(); |
|||
const { createConfirm } = useMessage(); |
|||
const treeData = ref<TreeOutput[]>([]); |
|||
const activeKey = ref("1"); |
|||
const [registerCreateOrganizationUnit, { openModal: CreateOrganizationUnitModal }] = |
|||
useModal(); |
|||
const [registerEditOrganizationUnit, { openModal: EditOrganizationUnitModal }] = useModal(); |
|||
const [registerAddRoleToOrganizationUnit, { openModal: AddRoleToOrganizationUnitModal }] = |
|||
useModal(); |
|||
const initOrganizationUnit = async () => { |
|||
treeData.value = await getTreeAsync(); |
|||
}; |
|||
onMounted(async () => { |
|||
await initOrganizationUnit(); |
|||
}); |
|||
|
|||
// 新增根节点 |
|||
function createRootOrganizationUnit() { |
|||
let record = { |
|||
parentId: "", |
|||
parentDisplayName: "" |
|||
}; |
|||
CreateOrganizationUnitModal(true, { record }); |
|||
} |
|||
|
|||
function getRightMenuList(node: any): ContextMenuItem[] { |
|||
return [ |
|||
{ |
|||
label: t("common.createText"), |
|||
handler: () => { |
|||
let record = { |
|||
parentId: "", |
|||
parentDisplayName: "" |
|||
}; |
|||
record.parentId = node.$attrs.node.key; |
|||
record.parentDisplayName = node.$attrs.node.title; |
|||
CreateOrganizationUnitModal(true, { record }); |
|||
}, |
|||
icon: "bi:plus" |
|||
}, |
|||
{ |
|||
label: t("common.editText"), |
|||
handler: () => { |
|||
let record = { |
|||
id: node.$attrs.node.key, |
|||
displayName: node.$attrs.node.title |
|||
}; |
|||
EditOrganizationUnitModal(true, { record }); |
|||
}, |
|||
icon: "ant-design:edit-outlined" |
|||
}, |
|||
{ |
|||
label: t("common.delText"), |
|||
handler: () => { |
|||
createConfirm({ |
|||
iconType: "warning", |
|||
title: t("common.tip"), |
|||
content: t("common.askDelete"), |
|||
onOk: async () => { |
|||
await deleteTreeNodeAsync({ id: node.eventKey }); |
|||
await initOrganizationUnit(); |
|||
} |
|||
}); |
|||
}, |
|||
icon: "ant-design:delete-outlined" |
|||
} |
|||
]; |
|||
} |
|||
|
|||
let organizationUnitId: string = ""; |
|||
|
|||
async function handleSelect(keys) { |
|||
console.log(keys); |
|||
if (keys.length > 0) { |
|||
organizationUnitId = keys[0]; |
|||
if (activeKey.value == "1") { |
|||
await reloadUser(); |
|||
} else { |
|||
await reloadRole(); |
|||
} |
|||
} else { |
|||
organizationUnitId = ""; |
|||
} |
|||
|
|||
} |
|||
|
|||
const getUserAsync = async () => { |
|||
if (organizationUnitId) { |
|||
let request = new GetOrganizationUnitUserInput(); |
|||
request.filter = getUserForm().getFieldsValue().filter; |
|||
request.organizationUnitId = organizationUnitId; |
|||
return await getUserTableListAsync(request); |
|||
} |
|||
|
|||
}; |
|||
|
|||
const getRoleAsync = async () => { |
|||
if (organizationUnitId) { |
|||
let request = new GetOrganizationUnitRoleInput(); |
|||
request.organizationUnitId = organizationUnitId; |
|||
return await getRoleTableListAsync(request); |
|||
} |
|||
|
|||
}; |
|||
const [registerUserTable, { reload: reloadUser, getForm: getUserForm }] = useTable({ |
|||
columns: userTableColumns, |
|||
formConfig: { |
|||
labelWidth: 70, |
|||
schemas: searchUserFormSchema |
|||
}, |
|||
api: getUserAsync, |
|||
showTableSetting: true, |
|||
useSearchForm: true, |
|||
bordered: true, |
|||
canResize: true, |
|||
showIndexColumn: true, |
|||
actionColumn: { |
|||
width: 120, |
|||
title: t("common.action"), |
|||
dataIndex: "action", |
|||
slots: { |
|||
customRender: "action" |
|||
}, |
|||
fixed: "right" |
|||
} |
|||
}); |
|||
|
|||
|
|||
const [registerRoleTable, { reload: reloadRole }] = useTable({ |
|||
columns: roleTableColumns, |
|||
api: getRoleAsync, |
|||
showTableSetting: true, |
|||
useSearchForm: false, |
|||
bordered: true, |
|||
canResize: true, |
|||
showIndexColumn: true, |
|||
actionColumn: { |
|||
width: 120, |
|||
title: t("common.action"), |
|||
dataIndex: "action", |
|||
slots: { |
|||
customRender: "action" |
|||
}, |
|||
fixed: "right" |
|||
} |
|||
}); |
|||
const activeKeyChange = async (activeKey) => { |
|||
console.log(activeKey); |
|||
if (organizationUnitId) { |
|||
if (activeKey == 1) { |
|||
await reloadUser(); |
|||
} else { |
|||
await reloadRole(); |
|||
} |
|||
} |
|||
|
|||
|
|||
}; |
|||
|
|||
// 删除用户 |
|||
const handleUserDelete = async (record: Recordable) => { |
|||
let msg = t("common.askDelete"); |
|||
createConfirm({ |
|||
iconType: "warning", |
|||
title: t("common.tip"), |
|||
content: msg, |
|||
onOk: async () => { |
|||
let request = new RemoveUserToOrganizationUnitInput(); |
|||
request.userId = record.id; |
|||
request.organizationUnitId = organizationUnitId; |
|||
await removeUserFromOrganizationUnitAsync(request); |
|||
await reloadUser(); |
|||
} |
|||
}); |
|||
}; |
|||
|
|||
// 删除用户 |
|||
const handleRoleDelete = async (record: Recordable) => { |
|||
let msg = t("common.askDelete"); |
|||
createConfirm({ |
|||
iconType: "warning", |
|||
title: t("common.tip"), |
|||
content: msg, |
|||
onOk: async () => { |
|||
let request = new RemoveRoleToOrganizationUnitInput(); |
|||
request.roleId = record.id; |
|||
request.organizationUnitId = organizationUnitId; |
|||
await removeRoleFromOrganizationUnitAsync(request); |
|||
await reloadRole(); |
|||
} |
|||
}); |
|||
}; |
|||
return { |
|||
treeData, |
|||
getRightMenuList, |
|||
createRootOrganizationUnit, |
|||
activeKey, |
|||
registerCreateOrganizationUnit, |
|||
initOrganizationUnit, |
|||
handleSelect, |
|||
registerEditOrganizationUnit, |
|||
registerUserTable, |
|||
registerRoleTable, |
|||
activeKeyChange, |
|||
handleUserDelete, |
|||
handleRoleDelete, |
|||
t, |
|||
registerAddRoleToOrganizationUnit, |
|||
AddRoleToOrganizationUnitModal |
|||
}; |
|||
} |
|||
}); |
|||
</script> |
|||
<style scoped> |
|||
/*.ant-tabs-tabpane {*/ |
|||
/* background: #F0F2F5;*/ |
|||
/*}*/ |
|||
</style> |
|||
Loading…
Reference in new issue