Merge branch 'master' into features/UserManger

This commit is contained in:
2021-06-29 09:35:57 +08:00
64 changed files with 2464 additions and 1221 deletions

View File

@@ -120,7 +120,7 @@ WHERE HC.Id=@HouseCodeId", new { houseTask.HouseCodeId }
var houseEntity = await _houseInfoRep.DetachedEntities.FirstOrDefaultAsync(h => h.HouseCodeId == input.houseCode.Id); var houseEntity = await _houseInfoRep.DetachedEntities.FirstOrDefaultAsync(h => h.HouseCodeId == input.houseCode.Id);
//建档审核通过的房屋数据修改时对应的建档任务Task不处理 //建档审核通过的房屋数据修改时对应的建档任务Task不处理
if (houseEntity.State != 6) if (houseEntity == null || houseEntity.State != 6)
{ {
var houseTask = input.PatrolInfo.Adapt<BsHouseTask>(); var houseTask = input.PatrolInfo.Adapt<BsHouseTask>();
houseTask.HouseCodeId = input.houseCode.Id; houseTask.HouseCodeId = input.houseCode.Id;

View File

@@ -13,6 +13,7 @@ using Microsoft.EntityFrameworkCore;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System;
namespace Ewide.Application.Service namespace Ewide.Application.Service
{ {
@@ -108,10 +109,10 @@ WHERE 1=1";
var users = await _dapperRepository.QueryPageData<UserOutput>(sql, input, param); var users = await _dapperRepository.QueryPageData<UserOutput>(sql, input, param);
foreach (var user in users.Items) //foreach (var user in users.Items)
{ //{
user.SysEmpInfo = await _sysEmpService.GetEmpInfo(user.Id); // user.SysEmpInfo = await _sysEmpService.GetEmpInfo(user.Id);
} //}
return PageDataResult<UserOutput>.PageResult(users); return PageDataResult<UserOutput>.PageResult(users);
} }
@@ -170,7 +171,10 @@ WHERE 1=1";
[UnitOfWork] [UnitOfWork]
public async Task DeleteUser(DeleteUserInput input) public async Task DeleteUser(DeleteUserInput input)
{ {
// 片区监管员在本片区已有安全员的情况下无法删除 /*
* 未处理逻辑
* 片区监管员在本片区已有安全员的情况下无法删除
*/
await _sysUserService.DeleteUser(input); await _sysUserService.DeleteUser(input);
} }
@@ -185,6 +189,7 @@ WHERE 1=1";
public async Task UpdateUser(UpdateUserInput input) public async Task UpdateUser(UpdateUserInput input)
{ {
/* /*
* 未处理逻辑
* 如果移动组织架构,会产生以下几种逻辑 * 如果移动组织架构,会产生以下几种逻辑
* 片区1监管员(无安全员或有其他监管员)=>片区2,直接成功 * 片区1监管员(无安全员或有其他监管员)=>片区2,直接成功
* 片区1监管员(有安全员并且无其他监管员)=>片区2,无法移动 * 片区1监管员(有安全员并且无其他监管员)=>片区2,无法移动
@@ -203,7 +208,30 @@ WHERE 1=1";
[HttpGet("/houseMember/detail")] [HttpGet("/houseMember/detail")]
public async Task<dynamic> GetUser([FromQuery] QueryUserInput input) public async Task<dynamic> GetUser([FromQuery] QueryUserInput input)
{ {
return await _sysUserService.GetUser(input); var sql = @"SELECT
SU.*,
SO.Name OrgName,
SUR.RoleName,
SUR.RoleCode
FROM sys_user SU
LEFT JOIN sys_emp SE ON SU.Id = SE.Id
LEFT JOIN sys_org SO ON SE.OrgId = SO.Id
LEFT JOIN (
SELECT
SUR.SysUserId,
GROUP_CONCAT(SR.Name) RoleName,
GROUP_CONCAT(SR.Code) RoleCode
FROM sys_user_role SUR
LEFT JOIN sys_role SR ON SUR.SysRoleId = SR.Id
GROUP BY SUR.SysUserId
) SUR ON SU.Id = SUR.SysUserId
WHERE SU.Id=@Id";
var user = (await _dapperRepository.QueryAsync<UserOutput>(sql, new { input.Id })).SingleOrDefault();
if (user != null)
{
user.SysEmpInfo = await _sysEmpService.GetEmpInfo(user.Id);
}
return user;
} }
/// <summary> /// <summary>
@@ -254,7 +282,7 @@ WHERE 1=1";
var _sysOrgRep = Db.GetRepository<SysOrg>(); var _sysOrgRep = Db.GetRepository<SysOrg>();
var org = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == orgId); var org = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == orgId);
// 如果当前组织为街道, 则直接返回安全员 // 如果当前组织为街道, 则直接返回安全员
if (org == null || org.Type <= 30) if (org == null || org.Type <= (int)OrgType.)
{ {
return roles.LastOrDefault(); return roles.LastOrDefault();
} }
@@ -265,7 +293,7 @@ WHERE 1=1";
var roleIds = await _sysUserRoleRep.DetachedEntities.Where(p => userIds.Contains(p.SysUserId)).Select(p => p.SysRoleId).ToListAsync(); var roleIds = await _sysUserRoleRep.DetachedEntities.Where(p => userIds.Contains(p.SysUserId)).Select(p => p.SysRoleId).ToListAsync();
var _sysRoleRep = Db.GetRepository<SysRole>(); var _sysRoleRep = Db.GetRepository<SysRole>();
var isExistZoneManager = await _sysRoleRep.DetachedEntities.AnyAsync(p => roleIds.Contains(p.Id) && p.Code == System.Enum.GetName(HouseManagerRole.ZoneManager).ToUnderScoreCase()); var isExistZoneManager = await _sysRoleRep.DetachedEntities.AnyAsync(p => roleIds.Contains(p.Id) && p.Code == Enum.GetName(HouseManagerRole.ZoneManager).ToUnderScoreCase());
// 存在片区监管员,返回安全员, 否则返回监管员 // 存在片区监管员,返回安全员, 否则返回监管员
if (isExistZoneManager) if (isExistZoneManager)
{ {
@@ -282,7 +310,10 @@ WHERE 1=1";
[NonAction] [NonAction]
private async Task<List<SysRole>> GetRoleRange() private async Task<List<SysRole>> GetRoleRange()
{ {
var codes = System.Enum.GetNames(typeof(HouseManagerRole)).Select(p => p.ToUnderScoreCase()); var codes = (new[] {
Enum.GetName(HouseManagerRole.ZoneManager),
Enum.GetName(HouseManagerRole.HouseSecurityManager),
}).Select(p => p.ToUnderScoreCase());
var _sysRoleRep = Db.GetRepository<SysRole>(); var _sysRoleRep = Db.GetRepository<SysRole>();
var roles = await _sysRoleRep.DetachedEntities.Where(p => codes.Contains(p.Code)).ToListAsync(); var roles = await _sysRoleRep.DetachedEntities.Where(p => codes.Contains(p.Code)).ToListAsync();

View File

@@ -20,9 +20,9 @@ namespace Ewide.Core
MENU = 1, MENU = 1,
/// <summary> /// <summary>
/// 按钮 /// 功能
/// </summary> /// </summary>
[Description("按钮")] [Description("功能")]
BTN = 2 FUNCTION = 2
} }
} }

View File

@@ -2417,9 +2417,9 @@
菜单 菜单
</summary> </summary>
</member> </member>
<member name="F:Ewide.Core.MenuType.BTN"> <member name="F:Ewide.Core.MenuType.FUNCTION">
<summary> <summary>
按钮 功能
</summary> </summary>
</member> </member>
<member name="T:Ewide.Core.MenuWeight"> <member name="T:Ewide.Core.MenuWeight">
@@ -4933,7 +4933,7 @@
路由元信息(路由附带扩展信息) 路由元信息(路由附带扩展信息)
</summary> </summary>
</member> </member>
<member name="P:Ewide.Core.Service.AntDesignTreeNode.Path"> <member name="P:Ewide.Core.Service.AntDesignTreeNode.Link">
<summary> <summary>
路径 路径
</summary> </summary>
@@ -4943,6 +4943,11 @@
控制路由和子路由是否显示在 sidebar 控制路由和子路由是否显示在 sidebar
</summary> </summary>
</member> </member>
<member name="P:Ewide.Core.Service.AntDesignTreeNode.OpenType">
<summary>
打开方式
</summary>
</member>
<member name="T:Ewide.Core.Service.Meta"> <member name="T:Ewide.Core.Service.Meta">
<summary> <summary>
路由元信息内部类 路由元信息内部类
@@ -5068,6 +5073,11 @@
菜单类型(字典 0目录 1菜单 2按钮 菜单类型(字典 0目录 1菜单 2按钮
</summary> </summary>
</member> </member>
<member name="P:Ewide.Core.Service.AddMenuInput.OpenType">
<summary>
打开方式(字典 0无 1组件 2内链 3外链
</summary>
</member>
<member name="P:Ewide.Core.Service.DeleteMenuInput.Id"> <member name="P:Ewide.Core.Service.DeleteMenuInput.Id">
<summary> <summary>
菜单Id 菜单Id

View File

@@ -8,6 +8,8 @@ using System.Diagnostics;
using System.Security.Claims; using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using UAParser; using UAParser;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Ewide.Core namespace Ewide.Core
{ {
@@ -34,12 +36,29 @@ namespace Ewide.Core
var actionDescriptor = context.ActionDescriptor as ControllerActionDescriptor; var actionDescriptor = context.ActionDescriptor as ControllerActionDescriptor;
var descAtt = Attribute.GetCustomAttribute(actionDescriptor.MethodInfo, typeof(DescriptionAttribute)) as DescriptionAttribute; var descAtt = Attribute.GetCustomAttribute(actionDescriptor.MethodInfo, typeof(DescriptionAttribute)) as DescriptionAttribute;
var message = "请求成功";
if (isRequestSucceed)
{
var result = actionContext.Result;
var resultType = result.GetType();
if (resultType.Name == "ContentResult")
{
var resultContent = ((Microsoft.AspNetCore.Mvc.ContentResult)actionContext.Result)?.Content;
var resultJson = JsonConvert.DeserializeObject<JObject>(resultContent);
message = resultJson["message"]?.ToString();
}
}
else
{
message = actionContext.Exception.Message;
}
var sysOpLog = new SysLogOp var sysOpLog = new SysLogOp
{ {
Name = descAtt != null ? descAtt.Description : actionDescriptor.ActionName, Name = descAtt != null ? descAtt.Description : actionDescriptor.ActionName,
OpType = 1, OpType = 1,
Success = isRequestSucceed, Success = isRequestSucceed,
//Message = isRequestSucceed ? "成功" : "失败", Message = message,
Ip = httpContext.GetRemoteIpAddressToIPv4(), Ip = httpContext.GetRemoteIpAddressToIPv4(),
Location = httpRequest.GetRequestUrlAddress(), Location = httpRequest.GetRequestUrlAddress(),
Browser = clent.UA.Family + clent.UA.Major, Browser = clent.UA.Family + clent.UA.Major,
@@ -48,13 +67,13 @@ namespace Ewide.Core
ClassName = context.Controller.ToString(), ClassName = context.Controller.ToString(),
MethodName = actionDescriptor.ActionName, MethodName = actionDescriptor.ActionName,
ReqMethod = httpRequest.Method, ReqMethod = httpRequest.Method,
//Param = JsonSerializerUtility.Serialize(context.ActionArguments), Param = JsonConvert.SerializeObject(context.ActionArguments),
//Result = JsonSerializerUtility.Serialize(actionContext.Result), // Result = resultContent,
ElapsedTime = sw.ElapsedMilliseconds, ElapsedTime = sw.ElapsedMilliseconds,
OpTime = DateTime.Now, OpTime = DateTime.Now,
Account = httpContext.User?.FindFirstValue(ClaimConst.CLAINM_ACCOUNT) Account = httpContext.User?.FindFirstValue(ClaimConst.CLAINM_ACCOUNT)
}; };
await sysOpLog.InsertAsync(); await sysOpLog.InsertNowAsync();
} }
} }
} }

View File

@@ -101,6 +101,24 @@ namespace Ewide.Core.Service
// 设置刷新Token令牌 // 设置刷新Token令牌
_httpContextAccessor.HttpContext.Response.Headers["x-access-token"] = refreshToken; _httpContextAccessor.HttpContext.Response.Headers["x-access-token"] = refreshToken;
// 增加登录日志
var loginOutput = user.Adapt<LoginOutput>();
var clent = Parser.GetDefault().Parse(App.GetService<IHttpContextAccessor>().HttpContext.Request.Headers["User-Agent"]);
loginOutput.LastLoginBrowser = clent.UA.Family + clent.UA.Major;
loginOutput.LastLoginOs = clent.OS.Family + clent.OS.Major;
await new SysLogVis
{
Name = "登录",
Success = true,
Message = "登录成功",
Ip = loginOutput.LastLoginIp,
Browser = loginOutput.LastLoginBrowser,
Os = loginOutput.LastLoginOs,
VisType = 1,
VisTime = loginOutput.LastLoginTime,
Account = loginOutput.Account
}.InsertAsync();
return accessToken; return accessToken;
} }
@@ -163,20 +181,6 @@ namespace Ewide.Core.Service
loginOutput.Menus = await _sysMenuService.GetLoginMenusAntDesign(userId, defaultActiveAppCode); loginOutput.Menus = await _sysMenuService.GetLoginMenusAntDesign(userId, defaultActiveAppCode);
} }
// 增加登录日志
//await new SysLogVis
//{
// Name = "登录",
// Success = true,
// Message = "登录成功",
// Ip = loginOutput.LastLoginIp,
// Browser = loginOutput.LastLoginBrowser,
// Os = loginOutput.LastLoginOs,
// VisType = 1,
// VisTime = loginOutput.LastLoginTime,
// Account = loginOutput.Account
//}.InsertAsync();
return loginOutput; return loginOutput;
} }

View File

@@ -1,4 +1,5 @@
using Ewide.Core.Extension; using Dapper;
using Ewide.Core.Extension;
using Furion.DatabaseAccessor; using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions; using Furion.DatabaseAccessor.Extensions;
using Furion.DependencyInjection; using Furion.DependencyInjection;
@@ -20,10 +21,12 @@ namespace Ewide.Core.Service
public class SysOpLogService : ISysOpLogService, IDynamicApiController, ITransient public class SysOpLogService : ISysOpLogService, IDynamicApiController, ITransient
{ {
private readonly IRepository<SysLogOp> _sysOpLogRep; // 操作日志表仓储 private readonly IRepository<SysLogOp> _sysOpLogRep; // 操作日志表仓储
private readonly IDapperRepository<SysLogOp> _dapperRepository;
public SysOpLogService(IRepository<SysLogOp> sysOpLogRep) public SysOpLogService(IRepository<SysLogOp> sysOpLogRep, IDapperRepository<SysLogOp> dapperRepository)
{ {
_sysOpLogRep = sysOpLogRep; _sysOpLogRep = sysOpLogRep;
_dapperRepository = dapperRepository;
} }
/// <summary> /// <summary>
@@ -54,11 +57,7 @@ namespace Ewide.Core.Service
[HttpPost("/sysOpLog/delete")] [HttpPost("/sysOpLog/delete")]
public async Task ClearOpLog() public async Task ClearOpLog()
{ {
var opLogs = await _sysOpLogRep.Entities.ToListAsync(); await _dapperRepository.ExecuteAsync("DELETE FROM sys_log_op");
opLogs.ForEach(u =>
{
u.Delete();
});
} }
} }
} }

View File

@@ -38,12 +38,17 @@
/// <summary> /// <summary>
/// 路径 /// 路径
/// </summary> /// </summary>
public string Path { get; set; } public string Link { get; set; }
/// <summary> /// <summary>
/// 控制路由和子路由是否显示在 sidebar /// 控制路由和子路由是否显示在 sidebar
/// </summary> /// </summary>
public bool Hidden { get; set; } public bool Hidden { get; set; }
/// <summary>
/// 打开方式
/// </summary>
public int OpenType { get; set; }
} }
/// <summary> /// <summary>

View File

@@ -25,7 +25,7 @@ namespace Ewide.Core.Service
/// <summary> /// <summary>
/// 菜单类型(字典 0目录 1菜单 2按钮 /// 菜单类型(字典 0目录 1菜单 2按钮
/// </summary> /// </summary>
public virtual string Type { get; set; } public virtual int Type { get; set; }
/// <summary> /// <summary>
/// 图标 /// 图标
@@ -55,7 +55,7 @@ namespace Ewide.Core.Service
/// <summary> /// <summary>
/// 打开方式(字典 0无 1组件 2内链 3外链 /// 打开方式(字典 0无 1组件 2内链 3外链
/// </summary> /// </summary>
public virtual string OpenType { get; set; } public virtual int OpenType { get; set; }
/// <summary> /// <summary>
/// 是否可见Y-是N-否) /// 是否可见Y-是N-否)
@@ -99,7 +99,13 @@ namespace Ewide.Core.Service
/// 菜单类型(字典 0目录 1菜单 2按钮 /// 菜单类型(字典 0目录 1菜单 2按钮
/// </summary> /// </summary>
[Required(ErrorMessage = "菜单类型不能为空")] [Required(ErrorMessage = "菜单类型不能为空")]
public override string Type { get; set; } public override int Type { get; set; }
/// <summary>
/// 打开方式(字典 0无 1组件 2内链 3外链
/// </summary>
[Required(ErrorMessage = "打开方式不能为空")]
public override int OpenType { get; set; }
} }
public class DeleteMenuInput public class DeleteMenuInput

View File

@@ -53,7 +53,7 @@ namespace Ewide.Core.Service
var roleIdList = await _sysUserRoleService.GetUserRoleIdList(userId); var roleIdList = await _sysUserRoleService.GetUserRoleIdList(userId);
var menuIdList = await _sysRoleMenuService.GetRoleMenuIdList(roleIdList); var menuIdList = await _sysRoleMenuService.GetRoleMenuIdList(roleIdList);
permissions = await _sysMenuRep.DetachedEntities.Where(u => menuIdList.Contains(u.Id)) permissions = await _sysMenuRep.DetachedEntities.Where(u => menuIdList.Contains(u.Id))
.Where(u => u.Type == (int)MenuType.BTN) .Where(u => u.Type == (int)MenuType.FUNCTION)
.Where(u => u.Status == (int)CommonStatus.ENABLE) .Where(u => u.Status == (int)CommonStatus.ENABLE)
.Select(u => u.Permission).ToListAsync(); .Select(u => u.Permission).ToListAsync();
#if DEBUG #if DEBUG
@@ -83,8 +83,8 @@ namespace Ewide.Core.Service
sysMenuList = await _sysMenuRep.DetachedEntities sysMenuList = await _sysMenuRep.DetachedEntities
.Where(u => u.Status == (int)CommonStatus.ENABLE) .Where(u => u.Status == (int)CommonStatus.ENABLE)
.Where(u => u.Application == appCode) .Where(u => u.Application == appCode)
.Where(u => u.Type != (int)MenuType.BTN) .Where(u => u.Type != (int)MenuType.FUNCTION)
//.Where(u => u.Weight != (int)MenuWeight.DEFAULT_WEIGHT) .Where(u => u.Weight != (int)MenuWeight.DEFAULT_WEIGHT)
.OrderBy(u => u.Sort).ToListAsync(); .OrderBy(u => u.Sort).ToListAsync();
} }
else else
@@ -96,7 +96,7 @@ namespace Ewide.Core.Service
.Where(u => menuIdList.Contains(u.Id)) .Where(u => menuIdList.Contains(u.Id))
.Where(u => u.Status == (int)CommonStatus.ENABLE) .Where(u => u.Status == (int)CommonStatus.ENABLE)
.Where(u => u.Application == appCode) .Where(u => u.Application == appCode)
.Where(u => u.Type != (int)MenuType.BTN) .Where(u => u.Type != (int)MenuType.FUNCTION)
.OrderBy(u => u.Sort).ToListAsync(); .OrderBy(u => u.Sort).ToListAsync();
} }
// 转换成登录菜单 // 转换成登录菜单
@@ -106,8 +106,9 @@ namespace Ewide.Core.Service
Pid = u.Pid, Pid = u.Pid,
Name = u.Code, Name = u.Code,
Component = u.Component, Component = u.Component,
Redirect = u.OpenType == (int)MenuOpenType.OUTER ? u.Link : u.Redirect, Redirect = u.Redirect,
Path = u.OpenType == (int)MenuOpenType.OUTER ? u.Link : u.Router, Link = u.Link,
OpenType = u.OpenType,
Meta = new Meta Meta = new Meta
{ {
Title = u.Name, Title = u.Name,
@@ -185,7 +186,7 @@ namespace Ewide.Core.Service
/// 增加和编辑时检查参数 /// 增加和编辑时检查参数
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
private static void CheckMenuParam(MenuInput input) private async Task CheckMenuParam(MenuInput input)
{ {
var type = input.Type; var type = input.Type;
var router = input.Router; var router = input.Router;
@@ -195,17 +196,17 @@ namespace Ewide.Core.Service
if (type.Equals((int)MenuType.DIR)) if (type.Equals((int)MenuType.DIR))
{ {
if (string.IsNullOrEmpty(router)) //if (string.IsNullOrEmpty(router))
throw Oops.Oh(ErrorCode.D4001); // throw Oops.Oh(ErrorCode.D4001);
} }
else if (type.Equals((int)MenuType.MENU)) else if (type.Equals((int)MenuType.MENU))
{ {
if (string.IsNullOrEmpty(router)) //if (string.IsNullOrEmpty(router))
throw Oops.Oh(ErrorCode.D4001); // throw Oops.Oh(ErrorCode.D4001);
if (string.IsNullOrEmpty(openType)) //if (string.IsNullOrEmpty(openType))
throw Oops.Oh(ErrorCode.D4002); // throw Oops.Oh(ErrorCode.D4002);
} }
else if (type.Equals((int)MenuType.BTN)) else if (type.Equals((int)MenuType.FUNCTION))
{ {
if (string.IsNullOrEmpty(permission)) if (string.IsNullOrEmpty(permission))
throw Oops.Oh(ErrorCode.D4003); throw Oops.Oh(ErrorCode.D4003);
@@ -217,10 +218,37 @@ namespace Ewide.Core.Service
//if (!urlSet.Contains(permission.Replace(":","/"))) //if (!urlSet.Contains(permission.Replace(":","/")))
// throw Oops.Oh(ErrorCode.meu1005); // throw Oops.Oh(ErrorCode.meu1005);
} }
//按钮可以设置绑定菜单
if(!isVisibleParent && type.Equals((int)MenuType.BTN)) // 检查上级菜单的类型是否正确
var pid = input.Pid;
var flag = true;
var empty = System.Guid.Empty.ToString();
switch(type)
{ {
throw Oops.Oh(ErrorCode.D4004); // 目录必须在顶级下
case (int)MenuType.DIR:
flag = pid.Equals(empty);
break;
// 菜单必须在顶级或目录下
case (int)MenuType.MENU:
if (!pid.Equals(empty))
{
var parent = await _sysMenuRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == pid);
flag = parent.Type.Equals((int)MenuType.DIR);
}
break;
// 功能必须在菜单下
case (int)MenuType.FUNCTION:
{
var parent = await _sysMenuRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == pid);
flag = parent == null ? false : parent.Type.Equals((int)MenuType.MENU);
}
break;
}
if (!flag)
{
throw Oops.Oh("父级菜单类型错误");
} }
} }
@@ -240,7 +268,7 @@ namespace Ewide.Core.Service
} }
// 校验参数 // 校验参数
CheckMenuParam(input); await CheckMenuParam(input);
var menu = input.Adapt<SysMenu>(); var menu = input.Adapt<SysMenu>();
menu.Pids = await CreateNewPids(input.Pid); menu.Pids = await CreateNewPids(input.Pid);
@@ -296,7 +324,7 @@ namespace Ewide.Core.Service
} }
// 校验参数 // 校验参数
CheckMenuParam(input); await CheckMenuParam(input);
// 如果是编辑父id不能为自己的子节点 // 如果是编辑父id不能为自己的子节点
var childIdList = await _sysMenuRep.DetachedEntities.Where(u => u.Pids.Contains(input.Id.ToString())) var childIdList = await _sysMenuRep.DetachedEntities.Where(u => u.Pids.Contains(input.Id.ToString()))
.Select(u => u.Id).ToListAsync(); .Select(u => u.Id).ToListAsync();
@@ -360,7 +388,7 @@ namespace Ewide.Core.Service
// 更新当前菜单 // 更新当前菜单
oldMenu = input.Adapt<SysMenu>(); oldMenu = input.Adapt<SysMenu>();
oldMenu.Pids = newPids; oldMenu.Pids = newPids;
await oldMenu.UpdateAsync(ignoreNullValues: true); await oldMenu.UpdateExcludeAsync(new[] { nameof(SysMenu.Type) }, ignoreNullValues: true);
// 清除缓存 // 清除缓存
await _sysCacheService.DelByPatternAsync(CommonConst.CACHE_KEY_MENU); await _sysCacheService.DelByPatternAsync(CommonConst.CACHE_KEY_MENU);

View File

@@ -92,10 +92,10 @@ namespace Ewide.Core.Service
// emps.Add(_sysEmpService.GetEmpInfo(long.Parse(u.Id))); // emps.Add(_sysEmpService.GetEmpInfo(long.Parse(u.Id)));
//}); //});
//await Task.WhenAll(emps); //await Task.WhenAll(emps);
foreach (var user in users.Items) //foreach (var user in users.Items)
{ //{
user.SysEmpInfo = await _sysEmpService.GetEmpInfo(user.Id); // user.SysEmpInfo = await _sysEmpService.GetEmpInfo(user.Id);
} //}
return PageDataResult<UserOutput>.PageResult(users); return PageDataResult<UserOutput>.PageResult(users);
} }
@@ -176,8 +176,17 @@ namespace Ewide.Core.Service
if (isExist) throw Oops.Oh(ErrorCode.D1003); if (isExist) throw Oops.Oh(ErrorCode.D1003);
var user = input.Adapt<SysUser>(); var user = input.Adapt<SysUser>();
await user.UpdateExcludeAsync(new[] { nameof(SysUser.Password), nameof(SysUser.Status), nameof(SysUser.AdminType) }, true); await user.UpdateIncludeAsync(new[] {
user.UpdateIncludeNow(new[] { nameof(SysUser.Birthday) }); nameof(SysUser.Account),
nameof(SysUser.NickName),
nameof(SysUser.Name),
nameof(SysUser.Birthday),
nameof(SysUser.Sex),
nameof(SysUser.Email),
nameof(SysUser.Phone),
nameof(SysUser.Tel),
}, true);
// user.UpdateIncludeNow(new[] { nameof(SysUser.Birthday) });
input.SysEmpParam.Id = user.Id.ToString(); input.SysEmpParam.Id = user.Id.ToString();
// 更新员工及附属机构职位信息 // 更新员工及附属机构职位信息
await _sysEmpService.AddOrUpdate(input.SysEmpParam); await _sysEmpService.AddOrUpdate(input.SysEmpParam);

View File

@@ -20,6 +20,7 @@
"photoswipe": "^4.1.3", "photoswipe": "^4.1.3",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-json-view": "^1.21.3",
"react-monaco-editor": "^0.43.0", "react-monaco-editor": "^0.43.0",
"react-router": "^5.2.0", "react-router": "^5.2.0",
"react-router-dom": "^5.2.0", "react-router-dom": "^5.2.0",
@@ -58,4 +59,4 @@
"last 1 safari version" "last 1 safari version"
] ]
} }
} }

View File

@@ -1,7 +1,7 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Form, Spin } from 'antd' import { Form, Spin } from 'antd'
import { AntIcon } from 'components' import { AntIcon } from 'components'
import { cloneDeep } from 'lodash' import { api } from 'common/api'
const initialValues = {} const initialValues = {}
@@ -31,14 +31,15 @@ export default class form extends Component {
* @param {*} params * @param {*} params
*/ */
async fillData(params) { async fillData(params) {
this.record = cloneDeep(params.record) const state = { loading: false }
//#region 从后端转换成前段所需格式,也可以在此处调用获取详细数据接口 //#region 从后端转换成前段所需格式,也可以在此处调用获取详细数据接口
if (params.id) {
this.record = (await api).data
}
//#endregion //#endregion
this.form.current.setFieldsValue(this.record) this.form.current.setFieldsValue(this.record)
this.setState({ this.setState(state)
loading: false,
})
} }
/** /**

View File

@@ -63,16 +63,16 @@ export default class index extends Component {
title: '操作', title: '操作',
width: 150, width: 150,
dataIndex: 'actions', dataIndex: 'actions',
render: (text, record) => ( render: (text, { id }) => (
<QueryTableActions> <QueryTableActions>
<Auth auth={{ [authName]: 'edit' }}> <Auth auth={{ [authName]: 'edit' }}>
<a onClick={() => this.onOpen(this.editForm, record)}>编辑</a> <a onClick={() => this.onOpen(this.editForm, id)}>编辑</a>
</Auth> </Auth>
<Auth auth={{ [authName]: 'delete' }}> <Auth auth={{ [authName]: 'delete' }}>
<Popconfirm <Popconfirm
placement="topRight" placement="topRight"
title="是否确认删除" title="是否确认删除"
onConfirm={() => this.onDelete(record)} onConfirm={() => this.onDelete(id)}
> >
<a>删除</a> <a>删除</a>
</Popconfirm> </Popconfirm>
@@ -145,12 +145,10 @@ export default class index extends Component {
/** /**
* 打开新增/编辑弹窗 * 打开新增/编辑弹窗
* @param {*} modal * @param {*} modal
* @param {*} record * @param {*} id
*/ */
onOpen(modal, record) { onOpen(modal, id) {
modal.current.open({ modal.current.open({ id })
record,
})
} }
/** /**
@@ -177,10 +175,10 @@ export default class index extends Component {
/** /**
* 删除 * 删除
* @param {*} record * @param {*} id
*/ */
onDelete(record) { onDelete(id) {
this.onAction(apiAction.delete(record), '删除成功') this.onAction(apiAction.delete({ id }), '删除成功')
} }
//#region 自定义方法 //#region 自定义方法

View File

@@ -26,7 +26,7 @@
} }
} }
} }
>.ant-pagination { .ant-pagination {
margin: @padding-md 0; margin: @padding-md 0;
} }
.ant-descriptions { .ant-descriptions {
@@ -44,6 +44,14 @@
} }
} }
} }
&--scroll {
position: relative;
overflow-x: auto;
}
.ant-list-items {
min-width: 1000px;
}
.ant-list-item { .ant-list-item {
transition: @animation-duration-slow; transition: @animation-duration-slow;
transition-property: background, border-bottom-color; transition-property: background, border-bottom-color;
@@ -52,4 +60,36 @@
background: linear-gradient(90deg, transparent 10%, @background-color-light 70%, transparent); background: linear-gradient(90deg, transparent 10%, @background-color-light 70%, transparent);
} }
} }
&-container {
position: relative;
&::before,
&::after {
position: absolute;
top: 0;
bottom: 0;
z-index: 3;
width: 30px;
content: '';
transition: box-shadow @animation-duration-slow;
pointer-events: none;
}
&::before {
left: 0;
}
&::after {
right: 0;
}
&.yo-list--ping-left {
&::before {
box-shadow: inset 10px 0 8px -8px fade(@black, 15%);
}
}
&.yo-list--ping-right {
&::after {
box-shadow: inset -10px 0 8px -8px fade(@black, 15%);
}
}
}
} }

View File

@@ -22,6 +22,14 @@
} }
} }
} }
.ant-table {
.ant-table-container {
&::before,
&::after {
z-index: 3;
}
}
}
.ant-table-thead { .ant-table-thead {
th.ant-table-column-has-sorters { th.ant-table-column-has-sorters {
&:hover { &:hover {

View File

@@ -19,6 +19,20 @@
} }
} }
} }
&--collapsed {
position: absolute;
top: 0;
left: 0;
bottom: 0;
z-index: 4;
transform: translateX(-100%);
&.open {
transform: translateX(0);
box-shadow: 2px 0 8px fade(@black , 20%);
}
}
&--bar { &--bar {
line-height: 20px; line-height: 20px;

View File

@@ -26,3 +26,21 @@
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.ellipsis-2 {
display: -webkit-box;
overflow: hidden;
-webkit-box-orient: vertical;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
}
.ellipsis-3 {
display: -webkit-box;
overflow: hidden;
-webkit-box-orient: vertical;
text-overflow: ellipsis;
-webkit-line-clamp: 3;
}

View File

@@ -300,6 +300,14 @@
opacity: 0; opacity: 0;
} }
>iframe {
display: block;
width: 100%;
height: 100%;
border: 0;
}
} }
} }
} }

View File

@@ -1,6 +1,7 @@
const urls = { const urls = {
houseInfoGetByTaskId: ['/houseInfo/getByTaskId', 'get'], houseInfoGetByTaskId: ['/houseInfo/getByTaskId', 'get'],
houseInfoSave: ['houseInfo/save', 'post'] houseInfoSave: ['houseInfo/save', 'post'],
houseInfoSubmitToCheck: ['/houseInfo/submitToCheck', 'post']
} }
export default urls export default urls

View File

@@ -3,6 +3,7 @@ const urls = {
houseMemberAdd: ['/houseMember/add', 'post'], houseMemberAdd: ['/houseMember/add', 'post'],
houseMemberEdit: ['/houseMember/edit', 'post'], houseMemberEdit: ['/houseMember/edit', 'post'],
houseMemberDelete: ['/houseMember/delete', 'post'], houseMemberDelete: ['/houseMember/delete', 'post'],
houseMemberDetail: ['/houseMember/detail', 'detail'],
houseMemberOwnRole: ['/houseMember/ownRole', 'get'], houseMemberOwnRole: ['/houseMember/ownRole', 'get'],
houseMemberOwnData: ['/houseMember/ownData', 'get'], houseMemberOwnData: ['/houseMember/ownData', 'get'],
houseMemberGrantData: ['/houseMember/grantData', 'post'], houseMemberGrantData: ['/houseMember/grantData', 'post'],

View File

@@ -28,6 +28,7 @@ const urls = {
* 修改应用状态 * 修改应用状态
*/ */
sysAppChangeStatus: ['/sysApp/changeStatus', 'post'], sysAppChangeStatus: ['/sysApp/changeStatus', 'post'],
sysAppDetail: ['/sysApp/detail', 'get']
} }
export default urls export default urls

View File

@@ -17,11 +17,11 @@ function getVisible() {
const caseChildren = checked.filter(item => item.visibleParent || item.type != 2) const caseChildren = checked.filter(item => item.visibleParent || item.type != 2)
const visibleParents = [] const visibleParents = []
// 递归寻找父级 // 递归寻找父级
const findVisibleParents = (children) => { const findVisibleParents = children => {
const parents = [] const parents = []
children.forEach(item => { children.forEach(item => {
if (item.parentId) { if (item.parentId) {
const parent = this.list.find(item => item.id === item.parentId) const parent = this.list.find(p => p.id === item.parentId)
if (parent) { if (parent) {
parents.push(parent) parents.push(parent)
visibleParents.push(parent) visibleParents.push(parent)
@@ -50,7 +50,9 @@ function getVisible() {
function renderDescriptions(data) { function renderDescriptions(data) {
return data.map(item => { return data.map(item => {
return item.children && item.children.length ? renderItem.call(this, item) : renderCheckbox.call(this, item) return item.children && item.children.length
? renderItem.call(this, item)
: renderCheckbox.call(this, item)
}) })
} }
@@ -63,8 +65,10 @@ function renderItem(data) {
value={data.id} value={data.id}
checked={data.checked} checked={data.checked}
indeterminate={data.indeterminate} indeterminate={data.indeterminate}
onChange={(e) => this.onChange(e, data)} onChange={e => this.onChange(e, data)}
>{data.title}</Checkbox> >
{data.title}
</Checkbox>
} }
> >
{renderDescriptions.call(this, data.children)} {renderDescriptions.call(this, data.children)}
@@ -76,26 +80,22 @@ function renderItem(data) {
function renderCheckbox(data) { function renderCheckbox(data) {
return ( return (
<div className="yo-authority-view--checkbox"> <div className="yo-authority-view--checkbox">
<Checkbox <Checkbox value={data.id} checked={data.checked} onChange={e => this.onChange(e, data)}>
value={data.id} {data.title}
checked={data.checked} </Checkbox>
onChange={(e) => this.onChange(e, data)} {data.visibleParent && data.type == 2 && (
>{data.title}</Checkbox>
{
data.visibleParent && data.type == 2 &&
<Tooltip placement="top" title="选中此项才会显示菜单"> <Tooltip placement="top" title="选中此项才会显示菜单">
<AntIcon type="eye" style={{ color: '#1890ff' }} className="mr-xxs" /> <AntIcon type="eye" style={{ color: '#1890ff' }} className="mr-xxs" />
</Tooltip> </Tooltip>
} )}
</div> </div>
) )
} }
export default class AuthorityView extends Component { export default class AuthorityView extends Component {
state = { state = {
loading: false, loading: false,
dataSource: [] dataSource: [],
} }
list = [] list = []
@@ -104,7 +104,8 @@ export default class AuthorityView extends Component {
super(props) super(props)
this.autoLoad = typeof this.props.autoLoad === 'boolean' ? this.props.autoLoad : true this.autoLoad = typeof this.props.autoLoad === 'boolean' ? this.props.autoLoad : true
this.loadData = typeof this.props.loadData === 'function' ? this.props.loadData : async () => { } this.loadData =
typeof this.props.loadData === 'function' ? this.props.loadData : async () => {}
} }
/** /**
@@ -126,7 +127,10 @@ export default class AuthorityView extends Component {
if (this.props.defaultSelectedKeys) { if (this.props.defaultSelectedKeys) {
this.list.map(item => { this.list.map(item => {
if (this.props.defaultSelectedKeys.includes(item.id) && (!item.children || !item.children.length)) { if (
this.props.defaultSelectedKeys.includes(item.id) &&
(!item.children || !item.children.length)
) {
this.onSelect(true, item) this.onSelect(true, item)
} }
}) })
@@ -134,8 +138,10 @@ export default class AuthorityView extends Component {
this.setState({ this.setState({
dataSource: res, dataSource: res,
loading: false loading: false,
}) })
this.onChange()
} }
onReloadData = () => { onReloadData = () => {
@@ -143,16 +149,18 @@ export default class AuthorityView extends Component {
} }
onChange = (e, item) => { onChange = (e, item) => {
this.onSelect(e.target.checked, item) if (e && item) {
this.onSelect(e.target.checked, item)
}
const visible = getVisible.call(this) const visible = getVisible.call(this)
if (this.props.onSelect) { if (this.props.onSelect) {
this.props.onSelect( this.props.onSelect(
// 返回所有选中 // 返回所有选中
this.list.filter(item => item.checked).map(item => item.id), this.list.filter(p => p.checked).map(p => p.id),
// 返回所有选中和半选 // 返回所有选中和半选
this.list.filter(item => item.checked || item.indeterminate).map(item => item.id), this.list.filter(p => p.checked || p.indeterminate).map(p => p.id),
// 返回所有选中和半选,但是不返回没有子级选中visibleParent的半选 // 返回所有选中和半选,但是不返回没有子级选中visibleParent的半选
visible visible
) )
@@ -170,7 +178,7 @@ export default class AuthorityView extends Component {
} }
this.setState({ this.setState({
dataSource: this.list.filter(item => item.parentId === EMPTY_ID) dataSource: this.list.filter(p => p.parentId === EMPTY_ID),
}) })
} }
@@ -210,31 +218,30 @@ export default class AuthorityView extends Component {
return ( return (
<div className="yo-authority-view"> <div className="yo-authority-view">
<Spin spinning={this.state.loading} indicator={<AntIcon type="loading" />}> <Spin spinning={this.state.loading} indicator={<AntIcon type="loading" />}>
{ {!this.state.loading ? (
!this.state.loading ? <Descriptions bordered column={1} className="yo-authority-view--container">
<Descriptions bordered column={1} className="yo-authority-view--container"> {this.state.dataSource.map(item => {
{ return (
this.state.dataSource.map(item => { <Descriptions.Item
return ( label={
<Descriptions.Item <Checkbox
label={ value={item.id}
<Checkbox checked={item.checked}
value={item.id} indeterminate={item.indeterminate}
checked={item.checked} onChange={e => this.onChange(e, item)}
indeterminate={item.indeterminate}
onChange={(e) => this.onChange(e, item)}
>{item.title}</Checkbox>
}
> >
{renderDescriptions.call(this, item.children)} {item.title}
</Descriptions.Item> </Checkbox>
) }
}) >
} {renderDescriptions.call(this, item.children)}
</Descriptions> </Descriptions.Item>
: )
<Empty className="mt-lg mb-lg" /> })}
} </Descriptions>
) : (
<Empty className="mt-lg mb-lg" />
)}
</Spin> </Spin>
</div> </div>
) )

View File

@@ -3,56 +3,62 @@ import { Button, Drawer, message as Message, Modal } from 'antd'
import { cloneDeep, isEqual } from 'lodash' import { cloneDeep, isEqual } from 'lodash'
/** /**
* 渲染对话框 * 渲染对话框
* @param {*} props * @param {*} props
* @param {*} on * @param {*} on
* @param {*} childWithProps * @param {*} childWithProps
* @returns * @returns
*/ */
function renderModal(props, on, childWithProps) { function renderModal(props, on, childWithProps) {
on = { on = {
...on, ...on,
onCancel: () => this.onClose() onCancel: () => this.onClose(),
} }
return <Modal className="yo-modal-form" {...props} {...on}> return (
{childWithProps} <Modal className="yo-modal-form" {...props} {...on}>
</Modal> {childWithProps}
</Modal>
)
} }
/** /**
* 渲染抽屉 * 渲染抽屉
* @param {*} props * @param {*} props
* @param {*} on * @param {*} on
* @param {*} childWithProps * @param {*} childWithProps
* @returns * @returns
*/ */
function renderDrawer(props, on, childWithProps) { function renderDrawer(props, on, childWithProps) {
on = { on = {
...on, ...on,
onClose: () => this.onClose() onClose: () => this.onClose(),
} }
return <Drawer className="yo-drawer-form" {...props} {...on}> // react在这里会对该组件不存在的props抛出异常
<div class="yo-drawer-form--body"> ;['action', 'onSuccess', 'onOk', 'confirmLoading'].forEach(p => {
{childWithProps} delete props[p]
</div> })
<div className="ant-drawer-footer">
<Button onClick={on.onClose}>取消</Button> return (
<Button loading={this.state.confirmLoading} onClick={on.onOk} type="primary">确定</Button> <Drawer className="yo-drawer-form" {...props} onClose={() => on.onClose()}>
</div> <div className="yo-drawer-form--body">{childWithProps}</div>
</Drawer> <div className="ant-drawer-footer">
<Button onClick={on.onClose}>取消</Button>
<Button loading={this.state.confirmLoading} onClick={on.onOk} type="primary">
确定
</Button>
</div>
</Drawer>
)
} }
export default class ModalForm extends Component { export default class ModalForm extends Component {
state = { state = {
// 弹窗显示/隐藏 // 弹窗显示/隐藏
visible: false, visible: false,
// 提交状态 // 提交状态
confirmLoading: false confirmLoading: false,
} }
// 子元素实例 // 子元素实例
@@ -67,12 +73,11 @@ export default class ModalForm extends Component {
snapshot = null snapshot = null
// 完成操作 // 完成操作
action = async () => { } action = async () => {}
// 是否在关闭时校验数据改变 // 是否在关闭时校验数据改变
compareOnClose = true compareOnClose = true
constructor(props) { constructor(props) {
super(props) super(props)
@@ -93,7 +98,7 @@ export default class ModalForm extends Component {
/** /**
* 打开弹窗 * 打开弹窗
* @param {*} data * @param {*} data
*/ */
open = (data = {}) => { open = (data = {}) => {
this.data = data this.data = data
@@ -110,7 +115,7 @@ export default class ModalForm extends Component {
/** /**
* 子元素创建后回调 * 子元素创建后回调
* 对子元素数据进行填充,(如需关闭时对比)之后再获取结构调整后的数据快照 * 对子元素数据进行填充,(如需关闭时对比)之后再获取结构调整后的数据快照
* @returns * @returns
*/ */
onCreated = async () => { onCreated = async () => {
const body = this.childNode.current const body = this.childNode.current
@@ -126,7 +131,7 @@ export default class ModalForm extends Component {
/** /**
* 取消编辑 * 取消编辑
* (如需关闭时对比)获取当前数据结构与快照对比 * (如需关闭时对比)获取当前数据结构与快照对比
* @returns * @returns
*/ */
onClose = async () => { onClose = async () => {
const body = this.childNode.current const body = this.childNode.current
@@ -143,7 +148,7 @@ export default class ModalForm extends Component {
content: '当前内容已更改,是否确认不保存并且关闭', content: '当前内容已更改,是否确认不保存并且关闭',
onOk: () => { onOk: () => {
this.close() this.close()
} },
}) })
return return
} }
@@ -155,7 +160,7 @@ export default class ModalForm extends Component {
/** /**
* 完成编辑 * 完成编辑
* 校验并获取结构调整后的数据,调用this.action进行操作 * 校验并获取结构调整后的数据,调用this.action进行操作
* @returns * @returns
*/ */
onOk = async () => { onOk = async () => {
const body = this.childNode.current const body = this.childNode.current
@@ -175,39 +180,33 @@ export default class ModalForm extends Component {
this.props.onSuccess(postData) this.props.onSuccess(postData)
} }
} }
} finally { } finally {
this.setState({ confirmLoading: false }) this.setState({ confirmLoading: false })
} }
} }
render() { render() {
const props = { const props = {
...this.props, ...this.props,
visible: this.state.visible, visible: this.state.visible,
destroyOnClose: true, destroyOnClose: true,
confirmLoading: this.state.confirmLoading confirmLoading: this.state.confirmLoading,
} }
const on = { const on = {
onOk: () => this.onOk() onOk: () => this.onOk(),
} }
const childWithProps = React.cloneElement( const childWithProps = React.cloneElement(React.Children.only(this.props.children), {
React.Children.only(this.props.children), created: childNode => {
{ this.childNode.current = childNode
created: childNode => { this.onCreated()
this.childNode.current = childNode },
this.onCreated() })
}
}
)
return this.type === 'modal' ? return this.type === 'modal'
renderModal.call(this, props, on, childWithProps) ? renderModal.call(this, props, on, childWithProps)
: : renderDrawer.call(this, props, on, childWithProps)
renderDrawer.call(this, props, on, childWithProps)
} }
} }

View File

@@ -43,6 +43,8 @@ export default class QueryList extends Component {
state = { state = {
loading: false, loading: false,
dataSource: [], dataSource: [],
ping: [],
} }
// 查询表单实例 // 查询表单实例
@@ -91,6 +93,12 @@ export default class QueryList extends Component {
if (this.autoLoad) { if (this.autoLoad) {
this.onLoadData() this.onLoadData()
} }
window.addEventListener('resize', this.onResizeScroll)
}
componentWillUnmount() {
window.removeEventListener('resize', this.onResizeScroll)
} }
/** /**
@@ -108,9 +116,14 @@ export default class QueryList extends Component {
this.query this.query
) )
this.setState({ this.setState(
dataSource: res.rows || res.data || res.items, {
}) dataSource: res.rows || res.data || res.items,
},
() => {
this.onResizeScroll()
}
)
this.pagination.total = res.totalCount this.pagination.total = res.totalCount
@@ -174,7 +187,26 @@ export default class QueryList extends Component {
this.onLoadData() this.onLoadData()
} }
onResizeScroll = () => {
this.onListScrollX({ target: this.refs['scroll-x'] })
}
onListScrollX(e) {
const { offsetWidth, scrollWidth, scrollLeft } = e.target
const ping = []
if (offsetWidth + scrollLeft < scrollWidth && scrollLeft > 0) {
ping.push(...['left', 'right'])
} else if (offsetWidth + scrollLeft < scrollWidth) {
ping.push('right')
} else if (offsetWidth + scrollLeft >= scrollWidth && offsetWidth < scrollWidth) {
ping.push('left')
}
this.setState({ ping })
}
render() { render() {
const { loading, dataSource, ping } = this.state
const attrs = {} const attrs = {}
Object.keys(this.props).forEach(key => { Object.keys(this.props).forEach(key => {
if (!propsMap.includes(key)) { if (!propsMap.includes(key)) {
@@ -206,9 +238,21 @@ export default class QueryList extends Component {
</div> </div>
</div> </div>
<div className="yo-list"> <div className="yo-list">
<Spin spinning={this.state.loading} indicator={<AntIcon type="loading" />}> <Spin spinning={loading} indicator={<AntIcon type="loading" />}>
<List {...props} /> <div
{!!this.state.dataSource && !!this.state.dataSource.length && ( className={['yo-list-container', ...ping.map(p => `yo-list--ping-${p}`)]
.filter(p => p)
.join(' ')}
>
<div
className="yo-list--scroll"
ref="scroll-x"
onScroll={e => this.onListScrollX(e)}
>
<List {...props} />
</div>
</div>
{!!dataSource && !!dataSource.length && (
<Pagination <Pagination
size="small" size="small"
{...this.pagination} {...this.pagination}

View File

@@ -5,24 +5,41 @@ function renderActions() {
const { children } = this.props const { children } = this.props
const actions = [] const actions = []
Array.isArray(children) ? children Array.isArray(children)
.filter(action => action) ? children
.forEach((action, i) => { .filter(action => action)
actions.push(action) .forEach((action, i) => {
if (i < this.props.children.length - 1) { actions.push(action, <Divider type="vertical" key={i} />)
actions.push(<Divider type="vertical" key={i} />) })
} : actions.push(children)
}) : (actions.push(children))
return actions return actions
} }
export default class QueryTableActions extends Component { export default class QueryTableActions extends Component {
componentDidMount() {
// 删除多余的间隔线
const className = 'ant-divider ant-divider-vertical'
let series = false
for (const node of this.refs.inner.childNodes) {
if (
(series && node.className == className) ||
(!node.nextElementSibling && node.className == className)
) {
node.remove()
series = false
} else if (node.className == className) {
series = true
} else {
series = false
}
}
}
render() { render() {
return ( return (
<div className="yo-table-actions"> <div className="yo-table-actions">
<div className="yo-table-actions--inner"> <div className="yo-table-actions--inner" ref="inner">
{renderActions.call(this)} {renderActions.call(this)}
</div> </div>
</div> </div>

View File

@@ -298,7 +298,7 @@ export default class QueryTable extends Component {
columns: (() => { columns: (() => {
const c = [] const c = []
if (type !== 'tree' && rowNumber & !expandable & !expandedRowRender) { if (type !== 'tree' && rowNumber & !expandable & !expandedRowRender) {
c.push(rowNoColumn) //c.push(rowNoColumn)
} }
c.push(...(columns || [])) c.push(...(columns || []))
return c.filter(p => !p.hidden) return c.filter(p => !p.hidden)

View File

@@ -1,6 +1,7 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Breadcrumb, Empty, Input, Layout, Spin, Tooltip, Tree } from 'antd' import { Breadcrumb, Button, Col, Empty, Input, Layout, Row, Spin, Tooltip, Tree } from 'antd'
import { AntIcon, Container } from 'components' import { AntIcon, Container } from 'components'
import { SIDER_BREAK_POINT } from 'util/global'
function generateKey(data, level) { function generateKey(data, level) {
const n = level || [0] const n = level || [0]
@@ -23,7 +24,7 @@ function generateList(data) {
this.list.push({ this.list.push({
key, key,
[this.replaceFields.value]: data[i][this.replaceFields.value], [this.replaceFields.value]: data[i][this.replaceFields.value],
[this.replaceFields.title]: data[i][this.replaceFields.title] [this.replaceFields.title]: data[i][this.replaceFields.title],
}) })
if (data[i][this.replaceFields.children]) { if (data[i][this.replaceFields.children]) {
generateList.call(this, data[i][this.replaceFields.children]) generateList.call(this, data[i][this.replaceFields.children])
@@ -32,7 +33,7 @@ function generateList(data) {
} }
function getParentKey(key, tree) { function getParentKey(key, tree) {
let parentKey; let parentKey
for (let i = 0; i < tree.length; i++) { for (let i = 0; i < tree.length; i++) {
const node = tree[i] const node = tree[i]
if (node[this.replaceFields.children]) { if (node[this.replaceFields.children]) {
@@ -43,23 +44,26 @@ function getParentKey(key, tree) {
} }
} }
} }
return parentKey; return parentKey
} }
function renderTitle(nodeData) { function renderTitle(nodeData) {
const title = nodeData[this.replaceFields.title] const title = nodeData[this.replaceFields.title]
if (this.state.searchValue && title.indexOf(this.state.searchValue) > -1) { if (this.state.searchValue && title.indexOf(this.state.searchValue) > -1) {
return <> return (
{title.substr(0, title.indexOf(this.state.searchValue))} <>
<span style={{ color: '#f50' }}>{this.state.searchValue}</span> {title.substr(0, title.indexOf(this.state.searchValue))}
{title.substr(title.indexOf(this.state.searchValue) + this.state.searchValue.length)} <span style={{ color: '#f50' }}>{this.state.searchValue}</span>
</> {title.substr(
title.indexOf(this.state.searchValue) + this.state.searchValue.length
)}
</>
)
} }
return <>{title}</> return <>{title}</>
} }
function renderBreadcrumbItem() { function renderBreadcrumbItem() {
const path = ['顶级'] const path = ['顶级']
const findPath = (data, level) => { const findPath = (data, level) => {
@@ -91,14 +95,16 @@ function renderBreadcrumbItem() {
} }
export default class QueryTreeLayout extends Component { export default class QueryTreeLayout extends Component {
state = { state = {
loading: false, loading: false,
dataSource: [], dataSource: [],
expandedKeys: [], expandedKeys: [],
selectedKey: '', selectedKey: '',
autoExpandParent: true, autoExpandParent: true,
searchValue: '' searchValue: '',
collapsed: false,
showSider: false,
} }
list = [] list = []
@@ -108,16 +114,18 @@ export default class QueryTreeLayout extends Component {
replaceFields = { replaceFields = {
value: 'id', value: 'id',
title: 'title', title: 'title',
children: 'children' children: 'children',
} }
constructor(props) { constructor(props) {
super(props) super(props)
this.autoLoad = typeof this.props.autoLoad === 'boolean' ? this.props.autoLoad : true this.autoLoad = typeof this.props.autoLoad === 'boolean' ? this.props.autoLoad : true
this.loadData = typeof this.props.loadData === 'function' ? this.props.loadData : async () => { } this.loadData =
typeof this.props.loadData === 'function' ? this.props.loadData : async () => {}
this.defaultExpanded = typeof this.props.defaultExpanded === 'boolean' ? this.props.defaultExpanded : false this.defaultExpanded =
typeof this.props.defaultExpanded === 'boolean' ? this.props.defaultExpanded : false
if (this.props.replaceFields) { if (this.props.replaceFields) {
this.replaceFields = this.props.replaceFields this.replaceFields = this.props.replaceFields
@@ -131,6 +139,13 @@ export default class QueryTreeLayout extends Component {
if (this.autoLoad) { if (this.autoLoad) {
this.onLoadData() this.onLoadData()
} }
window.addEventListener('resize', this.onResizeLayout)
this.onResizeLayout()
}
componentWillUnmount() {
window.removeEventListener('resize', this.onResizeLayout)
} }
/** /**
@@ -151,7 +166,7 @@ export default class QueryTreeLayout extends Component {
} }
this.setState({ this.setState({
dataSource: data, dataSource: data,
expandedKeys expandedKeys,
}) })
this.onLoaded() this.onLoaded()
} }
@@ -162,8 +177,8 @@ export default class QueryTreeLayout extends Component {
onLoading = () => { onLoading = () => {
this.setState({ this.setState({
loading: { loading: {
indicator: <AntIcon type="loading" /> indicator: <AntIcon type="loading" />,
} },
}) })
} }
@@ -178,28 +193,28 @@ export default class QueryTreeLayout extends Component {
this.onLoadData() this.onLoadData()
} }
onExpand = (expandedKeys) => { onExpand = expandedKeys => {
this.setState({ this.setState({
expandedKeys, expandedKeys,
autoExpandParent: false autoExpandParent: false,
}) })
} }
onSelect = (selectedKeys) => { onSelect = selectedKeys => {
const selectedIds = [] const selectedIds = []
selectedKeys.forEach(p => { selectedKeys.forEach(p => {
const data = this.list.find(m => m.key === p) const data = this.list.find(m => m.key === p)
selectedIds.push(data[this.replaceFields.value]) selectedIds.push(data[this.replaceFields.value])
}) })
this.setState({ this.setState({
selectedKey: selectedIds[0] selectedKey: selectedIds[0],
}) })
if (this.props.onSelect) { if (this.props.onSelect) {
this.props.onSelect(selectedIds[0]) this.props.onSelect(selectedIds[0])
} }
} }
onSearch = (value) => { onSearch = value => {
const expandedKeys = this.list const expandedKeys = this.list
.map(p => { .map(p => {
if (p[this.replaceFields.title].indexOf(value) > -1) { if (p[this.replaceFields.title].indexOf(value) > -1) {
@@ -212,34 +227,49 @@ export default class QueryTreeLayout extends Component {
this.setState({ this.setState({
expandedKeys, expandedKeys,
autoExpandParent: !!value, autoExpandParent: !!value,
searchValue: value searchValue: value,
})
}
onResizeLayout = () => {
this.setState({
collapsed: window.innerWidth <= SIDER_BREAK_POINT,
}) })
} }
render() { render() {
const { loading, dataSource, expandedKeys, autoExpandParent, collapsed, showSider } =
const { dataSource, expandedKeys, autoExpandParent } = this.state this.state
const props = { const props = {
treeData: dataSource, treeData: dataSource,
expandedKeys, expandedKeys,
autoExpandParent autoExpandParent,
} }
const on = { const on = {
onExpand: (expandedKeys) => this.onExpand(expandedKeys), onExpand: expandedKeys => this.onExpand(expandedKeys),
onSelect: (selectedKeys) => this.onSelect(selectedKeys) onSelect: selectedKeys => this.onSelect(selectedKeys),
} }
return ( return (
<Layout className="yo-tree-layout"> <Layout className="yo-tree-layout">
<Layout.Sider width="240px"> <Layout.Sider
width="240px"
className={[
collapsed ? 'yo-tree-layout--collapsed' : '',
showSider ? 'open' : '',
]
.filter(p => p)
.join(' ')}
onMouseLeave={() => this.setState({ showSider: false })}
>
<Layout.Header> <Layout.Header>
<div className="header-actions"> <div className="header-actions">
<Input.Search <Input.Search
allowClear={true} allowClear={true}
placeholder="请输入检索关键字" placeholder="请输入检索关键字"
onSearch={(value) => this.onSearch(value)} onSearch={value => this.onSearch(value)}
/> />
</div> </div>
</Layout.Header> </Layout.Header>
@@ -248,37 +278,56 @@ export default class QueryTreeLayout extends Component {
<AntIcon type="undo" onClick={() => this.onReloadData()} /> <AntIcon type="undo" onClick={() => this.onReloadData()} />
</Tooltip> </Tooltip>
<Tooltip placement="bottom" title="折叠全部"> <Tooltip placement="bottom" title="折叠全部">
<AntIcon type="switcher" onClick={() => this.setState({ expandedKeys: [] })} /> <AntIcon
type="switcher"
onClick={() => this.setState({ expandedKeys: [] })}
/>
</Tooltip> </Tooltip>
</div> </div>
<div className="yo-tree-layout--content"> <div className="yo-tree-layout--content">
<Spin spinning={this.state.loading} indicator={<AntIcon type="loading" />} wrapperClassName="h-100-p"> <Spin
{ spinning={loading}
!this.state.loading && !this.state.dataSource.length ? indicator={<AntIcon type="loading" />}
<Empty wrapperClassName="h-100-p"
image={ >
<div className="text-center pt-md"> {!loading && !dataSource.length ? (
<AntIcon className="h3 mt-xl mb-md" type="smile" /> <Empty
<p>暂无数据</p> image={
</div> <div className="text-center pt-md">
} <AntIcon className="h3 mt-xl mb-md" type="smile" />
description={false} <p>暂无数据</p>
/> </div>
: }
<Tree description={false}
{...props} />
{...on} ) : (
titleRender={(nodeData) => renderTitle.call(this, nodeData)} <Tree
/> {...props}
} {...on}
titleRender={nodeData => renderTitle.call(this, nodeData)}
/>
)}
</Spin> </Spin>
</div> </div>
</Layout.Sider> </Layout.Sider>
<Layout.Content> <Layout.Content>
<Container mode="fluid"> <Container mode="fluid">
<Breadcrumb className="mt-md mb-md"> <Row gutter={16} align="middle">
{renderBreadcrumbItem.call(this)} {collapsed && (
</Breadcrumb> <Col>
<Button
type="text"
icon={<AntIcon type="menu" />}
onClick={() => this.setState({ showSider: true })}
/>
</Col>
)}
<Col flex="1">
<Breadcrumb className="mt-md mb-md">
{renderBreadcrumbItem.call(this)}
</Breadcrumb>
</Col>
</Row>
</Container> </Container>
{this.props.children} {this.props.children}
</Layout.Content> </Layout.Content>

View File

@@ -98,7 +98,44 @@ export default class ownership extends Component {
* @param {*} changedValues * @param {*} changedValues
* @param {*} allValues * @param {*} allValues
*/ */
async onValuesChange(changedValues, allValues) {} async onValuesChange(changedValues, allValues) {
const form = this.form.current
const { houseInfo } = changedValues
if (
houseInfo.hasOwnProperty('straightHouseCount') ||
houseInfo.hasOwnProperty('selfHouseCount') ||
houseInfo.hasOwnProperty('otherCount') ||
houseInfo.hasOwnProperty('businessCount') ||
houseInfo.hasOwnProperty('changeHouseCount') ||
houseInfo.hasOwnProperty('resettlementHouseCount') ||
houseInfo.hasOwnProperty('privateHouseCount')
) {
const {
houseInfo: {
straightHouseCount,
selfHouseCount,
otherCount,
businessCount,
changeHouseCount,
resettlementHouseCount,
privateHouseCount,
},
} = allValues
form.setFieldsValue({
houseInfo: {
houseCount:
+straightHouseCount +
+selfHouseCount +
+otherCount +
+businessCount +
+changeHouseCount +
+resettlementHouseCount +
+privateHouseCount,
},
})
}
}
//#endregion //#endregion
render() { render() {

View File

@@ -1,5 +1,5 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Button, Descriptions, message as Message, Spin, Tabs } from 'antd' import { Form, Button, Input, Descriptions, message as Message, Spin, Tabs } from 'antd'
import { merge, isEqual } from 'lodash' import { merge, isEqual } from 'lodash'
import { AntIcon, ComponentDynamic, Container } from 'components' import { AntIcon, ComponentDynamic, Container } from 'components'
import { api } from 'common/api' import { api } from 'common/api'
@@ -56,11 +56,13 @@ export default class index extends Component {
saveDisabled: true, saveDisabled: true,
saving: false, saving: false,
taskStatus: 0,
} }
children = [] children = []
formData = {} formData = {}
checkform = React.createRef()
shouldComponentUpdate(props, state) { shouldComponentUpdate(props, state) {
return !isEqual(this.state, state) return !isEqual(this.state, state)
@@ -72,6 +74,7 @@ export default class index extends Component {
if (taskId) { if (taskId) {
api.houseInfoGetByTaskId({ taskId }).then(({ data }) => { api.houseInfoGetByTaskId({ taskId }).then(({ data }) => {
this.setState({ this.setState({
taskStatus: data.patrolInfo.status,
record: data, record: data,
loading: false, loading: false,
}) })
@@ -86,7 +89,7 @@ export default class index extends Component {
} }
} }
async onSubmit() { async onSubmit(action, append) {
for (const child of this.children) { for (const child of this.children) {
try { try {
const data = await child.getData() const data = await child.getData()
@@ -97,13 +100,35 @@ export default class index extends Component {
} }
//#region 提交数据 //#region 提交数据
if (append) {
this.formData = {
...this.formData,
...append,
}
}
if (this.formData.houseCode) {
this.formData.houseCode.id = this.state.record.houseCode.id
}
if (this.formData.patrolInfo && this.props.param.taskId) {
this.formData.patrolInfo.id = this.props.param.taskId
}
console.log(this.formData) console.log(this.formData)
this.setState({ saving: true }) this.setState({ saving: true })
setTimeout(() => { api[action](this.formData)
Message.success('提交成功') .then(({ data }) => {})
this.setState({ saving: false }) .catch(() => {})
}, 3000) .finally(() => {
this.setState({ saving: false })
})
// setTimeout(() => {
// Message.success('提交成功')
// this.setState({ saving: false })
// }, 3000)
//#endregion //#endregion
} }
@@ -117,19 +142,55 @@ export default class index extends Component {
<div className="yo-form-page--bar yo-form-page--bar--with-tab"> <div className="yo-form-page--bar yo-form-page--bar--with-tab">
<Container mode="fluid"> <Container mode="fluid">
<div className="yo-form-page--bar-inner"> <div className="yo-form-page--bar-inner">
<span></span>
<span> <span>
{this.state.taskStatus == 3 && (
<Form ref={this.checkForm} layout="inline">
<Form.Item
label="审核意见"
name={['taskCheckRecord', 'content']}
rules={[
{
required: true,
message: '请输入审核意见',
},
]}
>
<Input.TextArea
autoSize
autoComplete="off"
placeholder="请输入审核意见"
className="w-500"
/>
</Form.Item>
<Form.Item>
<Button type="primary">通过</Button>
<Button type="primary">退回</Button>
</Form.Item>
</Form>
)}
</span>
<span>
{this.state.taskStatus >= -1 && this.state.taskStatus < 3 && (
<Button
disabled={saveDisabled}
loading={saving}
type="primary"
onClick={() => this.onSubmit('houseInfoSave')}
>
保存
</Button>
)}
{this.state.taskStatus == 2 && (
<Button
type="primary"
onClick={() => this.onSubmit('houseInfoSubmitToCheck')}
>
提交审核
</Button>
)}
<Button onClick={() => window.closeContentWindow()}> <Button onClick={() => window.closeContentWindow()}>
取消 取消
</Button> </Button>
<Button
disabled={saveDisabled}
loading={saving}
type="primary"
onClick={() => this.onSubmit()}
>
保存
</Button>
</span> </span>
</div> </div>
</Container> </Container>

View File

@@ -69,7 +69,8 @@ export default class handling extends Component {
//#region 从后端转换成前段所需格式 //#region 从后端转换成前段所需格式
if (this.record) { if (this.record) {
const { patrolInfo } = this.record const { patrolInfo } = this.record
patrolInfo.initGrade = this.getInitGrade(getState('business').completedDate) if (this.record.houseInfo.completedDate)
patrolInfo.initGrade = this.getInitGrade(getState('business').completedDate)
} }
_state.codes = await getDictData( _state.codes = await getDictData(
'house_patrol_init_grade', 'house_patrol_init_grade',
@@ -130,19 +131,18 @@ export default class handling extends Component {
<Form.Item <Form.Item
label="初始等级" label="初始等级"
name={['patrolInfo', 'initGrade']} name={['patrolInfo', 'initGrade']}
tooltip="初始等级无法手动更改由房屋详情的竣工日期决定2000年之后竣工的为一级1995年~1999年竣工的为二级1980年~1994年竣工的为三级早于1980年竣工的为四级。选择房屋竣工日期后初始等级会自动填充。"
rules={[{ required: true, message: '请选择初始等级' }]} rules={[{ required: true, message: '请选择初始等级' }]}
> >
<Tooltip title="初始等级无法手动更改由房屋详情的竣工日期决定2000年之后竣工的为一级1995年~1999年竣工的为二级1980年~1994年竣工的为三级早于1980年竣工的为四级。选择房屋竣工日期后初始等级会自动填充。"> <Radio.Group disabled buttonStyle="solid">
<Radio.Group disabled buttonStyle="solid"> {codes.housePatrolInitGrade.map(item => {
{codes.housePatrolInitGrade.map(item => { return (
return ( <Radio.Button key={item.code} value={+item.code}>
<Radio.Button key={item.code} value={+item.code}> {item.value}
{item.value} </Radio.Button>
</Radio.Button> )
) })}
})} </Radio.Group>
</Radio.Group>
</Tooltip>
</Form.Item> </Form.Item>
<Form.Item <Form.Item

View File

@@ -20,7 +20,7 @@ export default class dataForm extends Component {
form = React.createRef() form = React.createRef()
// 初始化数据 // 初始化数据
record = {} id = ''
/** /**
* mount后回调 * mount后回调
@@ -29,11 +29,11 @@ export default class dataForm extends Component {
this.props.created && this.props.created(this) this.props.created && this.props.created(this)
} }
async fillData(params) { async fillData(params) {
this.record = cloneDeep(params.record) this.id = params.id
//#region 从后端转换成前段所需格式 //#region 从后端转换成前段所需格式
const orgData = await this.loadOrgData() const orgData = await this.loadOrgData()
const areaData = await this.loadAreaData() const areaData = await this.loadAreaData()
const orgCheckedKeys = await this.loadMemberOwn(this.record.id) const orgCheckedKeys = await this.loadMemberOwn(this.id)
this.setState({ this.setState({
options: { options: {
orgData, orgData,
@@ -42,7 +42,7 @@ export default class dataForm extends Component {
}, },
}) })
this.form.current.setFieldsValue({ this.form.current.setFieldsValue({
id: this.record.id, id: this.id,
grantOrgIdList: orgCheckedKeys, grantOrgIdList: orgCheckedKeys,
grantAreaCodeList: [], grantAreaCodeList: [],
}) })
@@ -63,8 +63,8 @@ export default class dataForm extends Component {
const valid = await form.validateFields() const valid = await form.validateFields()
if (valid) { if (valid) {
const postData = form.getFieldsValue() const postData = form.getFieldsValue()
if (this.record) { if (this.id) {
postData.id = this.record.id postData.id = this.id
} }
//#region 从前段转换后端所需格式 //#region 从前段转换后端所需格式
//#endregion //#endregion

View File

@@ -41,8 +41,10 @@ export default class form extends Component {
* @param {*} params * @param {*} params
*/ */
async fillData(params) { async fillData(params) {
this.record = cloneDeep(params.record || {})
//#region 从后端转换成前段所需格式 //#region 从后端转换成前段所需格式
if (params.id) {
this.record = (await api.houseMemberDetail({ id: params.id })).data
}
const orgData = await this.loadOrgData() const orgData = await this.loadOrgData()
const roleData = await this.LoadRoleData() const roleData = await this.LoadRoleData()
@@ -64,30 +66,22 @@ export default class form extends Component {
if (params.orgId) { if (params.orgId) {
this.record.sysEmpParam.orgId = params.orgId this.record.sysEmpParam.orgId = params.orgId
} }
const defaultRole = params.record const defaultRole = params.id
? await this.loadOwnRole(params.record.id) ? await this.loadOwnRole(params.id)
: params.orgId : await this.loadDefaultRole(params.orgId)
? await this.loadDefaultRole(params.orgId)
: []
if (defaultRole.constructor === Array) { if (defaultRole.constructor === Array) {
this.record.roleId = defaultRole.length > 0 ? defaultRole[0] : '' this.record.roleId = defaultRole[0]
this.setState({
lockRole: true,
})
} else { } else {
this.record.roleId = defaultRole.id this.record.roleId = defaultRole.id
this.setState({
lockRole: defaultRole.code === 'zone_manager',
})
} }
const lockRole = this.doLockRole(defaultRole)
this.setState({ this.setState({
options: { options: {
...this.state.options,
orgData, orgData,
roleData, roleData,
}, },
lockRole,
}) })
this.record = { this.record = {
@@ -141,6 +135,27 @@ export default class form extends Component {
const { data } = await api.houseMemberDefaultRole({ orgId }) const { data } = await api.houseMemberDefaultRole({ orgId })
return data return data
} }
async onOrgChange(orgId) {
this.setState({ loading: true })
const defaultRole = await this.loadDefaultRole(orgId)
const lockRole = this.doLockRole(defaultRole)
this.setState({ loading: false, lockRole })
}
doLockRole(defaultRole) {
if (defaultRole.constructor === Array) {
this.form.current.setFieldsValue({
roleId: defaultRole[0].id,
})
return true
} else {
this.form.current.setFieldsValue({
roleId: defaultRole.id,
})
return defaultRole.code === 'zone_manager'
}
}
render() { render() {
return ( return (
<Form initialValues={initialValues} ref={this.form} className="yo-form"> <Form initialValues={initialValues} ref={this.form} className="yo-form">
@@ -156,6 +171,7 @@ export default class form extends Component {
dropdownStyle={{ maxHeight: '300px', overflow: 'auto' }} dropdownStyle={{ maxHeight: '300px', overflow: 'auto' }}
treeDefaultExpandAll treeDefaultExpandAll
placeholder="请选择所属组织机构" placeholder="请选择所属组织机构"
onChange={value => this.onOrgChange(value)}
/> />
</Form.Item> </Form.Item>
<Form.Item <Form.Item

View File

@@ -13,7 +13,16 @@ import {
Switch, Switch,
Tag, Tag,
} from 'antd' } from 'antd'
import { AntIcon, Auth, Container, Image, ModalForm, QueryList, QueryTreeLayout } from 'components' import {
AntIcon,
Auth,
Container,
Image,
ModalForm,
QueryList,
QueryTableActions,
QueryTreeLayout,
} from 'components'
import { api } from 'common/api' import { api } from 'common/api'
import { toCamelCase } from 'util/format' import { toCamelCase } from 'util/format'
import { isEqual } from 'lodash' import { isEqual } from 'lodash'
@@ -149,12 +158,12 @@ export default class index extends Component {
/** /**
* 打开新增/编辑弹窗 * 打开新增/编辑弹窗
* @param {*} modal * @param {*} modal
* @param {*} record * @param {*} id
*/ */
onOpen(modal, record) { onOpen(modal, id) {
modal.current.open({ modal.current.open({
orgId: this.selectId, orgId: this.selectId,
record, id,
}) })
} }
@@ -177,36 +186,52 @@ export default class index extends Component {
/** /**
* 删除 * 删除
* @param {*} record * @param {*} id
*/ */
onDelete(record) { onDelete(id) {
this.onAction(apiAction.delete(record), '删除成功') this.onAction(apiAction.delete({ id }), '删除成功')
} }
//#region 自定义方法 //#region 自定义方法
renderItem(record) { renderItem(record) {
const {
id,
account,
name,
nickName,
avatar,
sex,
phone,
email,
status,
roleCode,
roleName,
orgName,
} = record
return ( return (
<List.Item <List.Item
key={record.id} key={id}
actions={[ actions={[
<Auth auth="houseMember:edit"> <QueryTableActions>
<a onClick={() => this.onOpen(this.editForm, record)}>编辑</a> <Auth auth="houseMember:edit">
</Auth>, <a onClick={() => this.onOpen(this.editForm, id)}>编辑</a>
<Auth auth="houseMember:delete"> </Auth>
<Popconfirm <Auth auth="houseMember:delete">
placement="topRight" <Popconfirm
title="是否确认删除" placement="topRight"
onConfirm={() => this.onDelete(record)} title="是否确认删除"
> onConfirm={() => this.onDelete(id)}
<a>删除</a> >
</Popconfirm> <a>删除</a>
</Auth>, </Popconfirm>
<Auth aut="houseMember:resetPwd"> </Auth>
<a onClick={() => this.onResetPassword(record)}>重置密码</a> <Auth auth="houseMember:resetPwd">
</Auth>, <a onClick={() => this.onResetPassword(id)}>重置密码</a>
<Auth auth="houseMember:grantData"> </Auth>
<a onClick={() => this.onOpen(this.dataForm, record)}>授权额外数据</a> <Auth auth="houseMember:grantData">
</Auth>, <a onClick={() => this.onOpen(this.dataForm, id)}>授权额外数据</a>
</Auth>
</QueryTableActions>,
]} ]}
> >
<List.Item.Meta <List.Item.Meta
@@ -216,10 +241,10 @@ export default class index extends Component {
type="avatar" type="avatar"
shape="square" shape="square"
size={48} size={48}
id={record.avatar} id={avatar}
icon={<AntIcon type="user" />} icon={<AntIcon type="user" />}
/> />
{record.roleCode && record.roleCode.includes('house_security_manager') && ( {roleCode && roleCode.includes('house_security_manager') && (
<Button <Button
size="small" size="small"
type="primary" type="primary"
@@ -233,9 +258,9 @@ export default class index extends Component {
} }
title={ title={
<> <>
{record.nickName || record.name} {nickName || name}
{record.roleName && {roleName &&
record.roleName.split(',').map((item, i) => ( roleName.split(',').map((item, i) => (
<span key={i}> <span key={i}>
<Divider type="vertical" /> <Divider type="vertical" />
<Tag color="pink">{item}</Tag> <Tag color="pink">{item}</Tag>
@@ -243,25 +268,24 @@ export default class index extends Component {
))} ))}
</> </>
} }
description={record.account} description={account}
/> />
<Descriptions className="flex-1" column={2}> <Descriptions className="flex-1" column={2}>
<Descriptions.Item label="部门">{record.orgName}</Descriptions.Item> <Descriptions.Item label="部门">{orgName}</Descriptions.Item>
<Descriptions.Item label="性别"> <Descriptions.Item label="性别">
{this.bindCodeValue(record.sex, 'sex')} {this.bindCodeValue(sex, 'sex')}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label="手机">{record.phone || '未设置'}</Descriptions.Item> <Descriptions.Item label="手机">{phone || '未设置'}</Descriptions.Item>
<Descriptions.Item label="邮箱">{record.email || '未设置'}</Descriptions.Item> <Descriptions.Item label="邮箱">{email || '未设置'}</Descriptions.Item>
</Descriptions> </Descriptions>
<div className="yo-list-content--h"> <div className="yo-list-content--h">
<Auth auth="houseMember:changeStatus"> <Auth auth="houseMember:changeStatus">
<div className="yo-list-content--h--item text-center"> <div className="yo-list-content--h--item text-center">
<Switch <Switch
checked={!record.status} checked={!status}
loading={record.statusChanging}
checkedChildren={this.bindCodeValue(0, 'common_status')} checkedChildren={this.bindCodeValue(0, 'common_status')}
unCheckedChildren={this.bindCodeValue(1, 'common_status')} unCheckedChildren={this.bindCodeValue(1, 'common_status')}
onChange={checked => this.onSetUserStatus(record, checked)} onChange={checked => this.onSetUserStatus(id, checked)}
/> />
</div> </div>
</Auth> </Auth>
@@ -270,18 +294,18 @@ export default class index extends Component {
) )
} }
onSetUserStatus(record, checked) { onSetUserStatus(id, checked) {
this.onAction( this.onAction(
apiAction.changeStatus({ apiAction.changeStatus({
id: record.id, id,
status: +!checked, status: +!checked,
}), }),
'设置成功' '设置成功'
) )
} }
onResetPassword(record) { onResetPassword(id) {
this.onAction(apiAction.resetPwd(record), '重置成功') this.onAction(apiAction.resetPwd({ id }), '重置成功')
} }
//#endregion //#endregion

View File

@@ -26,7 +26,7 @@ export default class index extends Component {
*/ */
async fillData(params) { async fillData(params) {
this.setState({ this.setState({
userId: params.record.id, userId: params.id,
}) })
} }

View File

@@ -0,0 +1,265 @@
import React, { Component } from 'react'
import { Button, Card, Form, Input, message as Message, Popconfirm, Radio, Select, Tag } from 'antd'
import { AntIcon, Auth, Container, ModalForm, QueryTable, QueryTableActions } from 'components'
import { api } from 'common/api'
import auth from 'components/authorized/handler'
import { isEqual } from 'lodash'
import getDictData from 'util/dic'
import { toCamelCase } from 'util/format'
/**
* 注释段[\/**\/]为必须要改
*/
/**
* 配置页面所需接口函数
*/
const apiAction = {
page: api.houseTaskPage,
}
/**
* 统一配置权限标识
* [必要]
*/
const authName = 'houseTask'
export default class index extends Component {
state = {
codes: {
houseType: [],
houseIndustry: [],
},
type: '',
}
// 表格实例
table = React.createRef()
// 新增窗口实例
addForm = React.createRef()
// 编辑窗口实例
editForm = React.createRef()
columns = [
{
title: '房屋编码',
dataIndex: 'houseCode',
sorter: true,
width: 300,
render: (text, record) => (
<>
{`${record.areaName}-${record.roadName}-${record.commName}-${
record.note
}-${record.no.toString().padStart(3, '0')}`}
<br />
<Tag color="purple">{text}</Tag>
</>
),
},
{
title: '房屋性质及行业',
dataIndex: 'type',
sorter: true,
width: 150,
render: text => this.bindCodeValue(text, 'house_type'),
},
{
title: '地址',
dataIndex: 'address',
sorter: true,
},
{
title: '任务截止时间',
dataIndex: 'endTime',
sorter: true,
width: 150,
},
]
/**
* 构造函数,在渲染前动态添加操作字段等
* @param {*} props
*/
constructor(props) {
super(props)
const flag = auth({ houseInfo: 'getByTaskId' })
if (flag) {
this.columns.push({
title: '操作',
width: 150,
dataIndex: 'actions',
render: (text, record) => (
<QueryTableActions>
<Auth auth={{ houseInfo: 'getByTaskId' }}>
<a onClick={() => this.onOpen(record.id)}>审核</a>
</Auth>
</QueryTableActions>
),
})
}
}
/**
* 阻止外部组件引发的渲染,提升性能
* 可自行添加渲染条件
* [必要]
* @param {*} props
* @param {*} state
* @returns
*/
shouldComponentUpdate(props, state) {
return !isEqual(this.state, state)
}
/**
* 加载字典数据,之后开始加载表格数据
* 如果必须要加载字典数据,可直接对表格设置autoLoad=true
*/
componentDidMount() {
const { onLoading, onLoadData } = this.table.current
onLoading()
getDictData('house_type', 'house_industry').then(codes => {
this.setState({ codes }, () => {
onLoadData()
})
})
}
/**
* 调用加载数据接口,可在调用前对query进行处理
* [异步,必要]
* @param {*} params
* @param {*} query
* @returns
*/
loadData = async (params, query) => {
const { data } = await apiAction.page({
...params,
...query,
})
return data
}
/**
* 绑定字典数据
* @param {*} code
* @param {*} name
* @returns
*/
bindCodeValue(code, name) {
name = toCamelCase(name)
const codes = this.state.codes[name]
if (codes) {
const c = codes.find(p => p.code == code)
if (c) {
return c.value
}
}
return null
}
/**
* 打开新增/编辑弹窗
* @param {*} modal
* @param {*} record
*/
onOpen(taskId) {
window.openContentWindow({
title: '房屋登记',
path: 'business/house/info/form',
param: {
taskId,
},
})
}
/**
* 对表格上的操作进行统一处理
* [异步]
* @param {*} action
* @param {*} successMessage
*/
async onAction(action, successMessage) {
const { onLoading, onLoaded, onReloadData } = this.table.current
onLoading()
try {
if (action) {
await action
}
if (successMessage) {
Message.success(successMessage)
}
onReloadData()
} catch {
onLoaded()
}
}
//#region 自定义方法
//#endregion
render() {
const { codes, type } = this.state
return (
<Container mode="fluid">
<br />
<Card bordered={false}>
<QueryTable
ref={this.table}
autoLoad={false}
loadData={this.loadData}
columns={this.columns}
queryInitialValues={{
type: '',
}}
onQueryChange={values => {
if (values.hasOwnProperty('type')) {
this.setState({ type: values.type })
}
}}
query={
<Auth auth={{ [authName]: 'page' }}>
<Form.Item label="房屋性质" name="type">
<Radio.Group buttonStyle="solid">
<Radio.Button value="">全部</Radio.Button>
{codes.houseType.map(item => (
<Radio.Button key={item.code} value={item.code}>
{item.value}
</Radio.Button>
))}
</Radio.Group>
</Form.Item>
{type == 2 && (
<Form.Item label="行业" name="industry">
<Select
allowClear
className="w-150"
placeholder="请选择行业"
>
{codes.houseIndustry.map(item => (
<Select.Option key={item.code} value={item.code}>
{item.value}
</Select.Option>
))}
</Select>
</Form.Item>
)}
<Form.Item label="地址" name="address">
<Input autoComplete="off" placeholder="请输入地址" />
</Form.Item>
<Form.Item label="房屋唯一编码" name="houseCode">
<Input autoComplete="off" placeholder="请输入房屋唯一编码" />
</Form.Item>
</Auth>
}
/>
</Card>
</Container>
)
}
}

View File

@@ -1,6 +1,6 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Button, Card, Form, Input, message as Message, Popconfirm, Radio, Select, Tag } from 'antd' import { Card, Form, Input, message as Message, Radio, Select, Tag } from 'antd'
import { AntIcon, Auth, Container, ModalForm, QueryTable, QueryTableActions } from 'components' import { Auth, Container, QueryTable, QueryTableActions } from 'components'
import { api } from 'common/api' import { api } from 'common/api'
import auth from 'components/authorized/handler' import auth from 'components/authorized/handler'
import { isEqual } from 'lodash' import { isEqual } from 'lodash'

View File

@@ -2,13 +2,13 @@ import React, { Component } from 'react'
import { Form, Input, InputNumber, Spin } from 'antd' import { Form, Input, InputNumber, Spin } from 'antd'
import { AntIcon, IconSelector } from 'components' import { AntIcon, IconSelector } from 'components'
import { cloneDeep } from 'lodash' import { cloneDeep } from 'lodash'
import { api } from 'common/api'
const initialValues = { const initialValues = {
sort: 100 sort: 100,
} }
export default class form extends Component { export default class form extends Component {
state = { state = {
// 加载状态 // 加载状态
loading: true, loading: true,
@@ -33,17 +33,18 @@ export default class form extends Component {
* 填充数据 * 填充数据
* 可以在设置this.record之后对其作出数据结构调整 * 可以在设置this.record之后对其作出数据结构调整
* [异步,必要] * [异步,必要]
* @param {*} params * @param {*} params
*/ */
async fillData(params) { async fillData(params) {
this.record = cloneDeep(params.record)
//#region 从后端转换成前段所需格式 //#region 从后端转换成前段所需格式
if (params.id) {
this.record = (await api.sysAppDetail({ id: params.id })).data
}
//#endregion //#endregion
this.form.current.setFieldsValue(this.record) this.form.current.setFieldsValue(this.record)
this.setState({ this.setState({
loading: false loading: false,
}) })
} }
@@ -51,7 +52,7 @@ export default class form extends Component {
* 获取数据 * 获取数据
* 可以对postData进行数据结构调整 * 可以对postData进行数据结构调整
* [异步,必要] * [异步,必要]
* @returns * @returns
*/ */
async getData() { async getData() {
const form = this.form.current const form = this.form.current
@@ -73,17 +74,21 @@ export default class form extends Component {
render() { render() {
return ( return (
<Form <Form initialValues={initialValues} ref={this.form} className="yo-form">
initialValues={initialValues}
ref={this.form}
className="yo-form"
>
<Spin spinning={this.state.loading} indicator={<AntIcon type="loading" />}> <Spin spinning={this.state.loading} indicator={<AntIcon type="loading" />}>
<div className="yo-form-group"> <div className="yo-form-group">
<Form.Item label="应用名称" name="name" rules={[{ required: true, message: '请输入应用名称' }]}> <Form.Item
label="应用名称"
name="name"
rules={[{ required: true, message: '请输入应用名称' }]}
>
<Input autoComplete="off" placeholder="请输入应用名称" /> <Input autoComplete="off" placeholder="请输入应用名称" />
</Form.Item> </Form.Item>
<Form.Item label="唯一编码" name="code" rules={[{ required: true, message: '请输入唯一编码' }]}> <Form.Item
label="唯一编码"
name="code"
rules={[{ required: true, message: '请输入唯一编码' }]}
>
<Input autoComplete="off" placeholder="请输入唯一编码" /> <Input autoComplete="off" placeholder="请输入唯一编码" />
</Form.Item> </Form.Item>
<Form.Item label="图标" name="icon"> <Form.Item label="图标" name="icon">
@@ -94,10 +99,9 @@ export default class form extends Component {
<AntIcon <AntIcon
type="setting" type="setting"
onClick={() => onClick={() =>
this this.iconSelector.current.open(
.iconSelector this.form.current.getFieldValue('icon')
.current )
.open(this.form.current.getFieldValue('icon'))
} }
/> />
} }
@@ -113,9 +117,14 @@ export default class form extends Component {
</Form.Item> </Form.Item>
</div> </div>
</Spin> </Spin>
<IconSelector ref={this.iconSelector} onSelect={(icon) => this.form.current.setFieldsValue({ <IconSelector
icon ref={this.iconSelector}
})} /> onSelect={icon =>
this.form.current.setFieldsValue({
icon,
})
}
/>
</Form> </Form>
) )
} }

View File

@@ -87,6 +87,7 @@ export default class index extends Component {
dataIndex: 'sort', dataIndex: 'sort',
width: 100, width: 100,
sorter: true, sorter: true,
defaultSortOrder: 'ascend',
}, },
] ]
@@ -107,7 +108,7 @@ export default class index extends Component {
render: (text, record) => ( render: (text, record) => (
<QueryTableActions> <QueryTableActions>
<Auth auth="sysApp:edit"> <Auth auth="sysApp:edit">
<a onClick={() => this.onOpen(this.editForm, record)}>编辑</a> <a onClick={() => this.onOpen(this.editForm, record.id)}>编辑</a>
</Auth> </Auth>
<Auth auth="sysApp:delete"> <Auth auth="sysApp:delete">
<Popconfirm <Popconfirm
@@ -191,11 +192,11 @@ export default class index extends Component {
/** /**
* 打开新增/编辑弹窗 * 打开新增/编辑弹窗
* @param {*} modal * @param {*} modal
* @param {*} record * @param {*} id
*/ */
onOpen(modal, record) { onOpen(modal, id) {
modal.current.open({ modal.current.open({
record, id,
}) })
} }

View File

@@ -48,7 +48,7 @@ export default class index extends Component {
title: '区域类型', title: '区域类型',
dataIndex: 'levelType', dataIndex: 'levelType',
sorter: true, sorter: true,
width: 50, width: 100,
render: text => <>{this.bindCodeValue(text, 'areacode_type')}</>, render: text => <>{this.bindCodeValue(text, 'areacode_type')}</>,
}, },
{ {
@@ -60,14 +60,15 @@ export default class index extends Component {
{ {
title: '区域编号', title: '区域编号',
dataIndex: 'code', dataIndex: 'code',
width: 80, width: 100,
sorter: true, sorter: true,
}, },
{ {
title: '行政编号', title: '行政编号',
dataIndex: 'adCode', dataIndex: 'adCode',
width: 80, width: 100,
sorter: true, sorter: true,
defaultSortOrder: 'ascend',
}, },
{ {
title: '描述', title: '描述',

View File

@@ -1,5 +1,5 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Button, Card, Form, Input, message as Message, Popconfirm } from 'antd' import { Button, Card, Form, Input, message as Message, Popconfirm, Tooltip } from 'antd'
import { AntIcon, Auth, Container, ModalForm, QueryTable, QueryTableActions } from 'components' import { AntIcon, Auth, Container, ModalForm, QueryTable, QueryTableActions } from 'components'
import { api } from 'common/api' import { api } from 'common/api'
import auth from 'components/authorized/handler' import auth from 'components/authorized/handler'
@@ -41,28 +41,41 @@ export default class index extends Component {
{ {
title: '参数名称', title: '参数名称',
dataIndex: 'name', dataIndex: 'name',
width: 200,
sorter: true, sorter: true,
}, },
{ {
title: '唯一编码', title: '唯一编码',
dataIndex: 'code', dataIndex: 'code',
width: 200,
sorter: true, sorter: true,
ellipsis: {
showTitle: false,
},
render: text => <Tooltip title={text}>{text}</Tooltip>,
}, },
{ {
title: '参数值', title: '参数值',
dataIndex: 'value', dataIndex: 'value',
width: 200,
sorter: true, sorter: true,
}, },
{ {
title: '所属分类', title: '所属分类',
dataIndex: 'groupCode', dataIndex: 'groupCode',
width: 140,
sorter: true, sorter: true,
render: text => this.bindCodeValue(text, 'consts_type'), render: text => this.bindCodeValue(text, 'consts_type'),
}, },
{ {
title: '备注', title: '备注',
dataIndex: 'remark', dataIndex: 'remark',
width: 400,
sorter: true, sorter: true,
ellipsis: {
showTitle: false,
},
render: text => <Tooltip title={text}>{text}</Tooltip>,
}, },
] ]
@@ -213,6 +226,7 @@ export default class index extends Component {
autoLoad={false} autoLoad={false}
loadData={this.loadData} loadData={this.loadData}
columns={this.columns} columns={this.columns}
scroll={{ x: 1140 }}
query={ query={
<Auth auth={{ [authName]: 'page' }}> <Auth auth={{ [authName]: 'page' }}>
<Form.Item label="参数名称" name="name"> <Form.Item label="参数名称" name="name">

View File

@@ -14,20 +14,19 @@ const apiAction = {
add: api.sysDictDataAdd, add: api.sysDictDataAdd,
edit: api.sysDictDataEdit, edit: api.sysDictDataEdit,
delete: api.sysDictDataDelete, delete: api.sysDictDataDelete,
deleteBatch: api.sysDictDataDeleteBatch deleteBatch: api.sysDictDataDeleteBatch,
} }
// 用于弹窗标题 // 用于弹窗标题
const name = '字典值' const name = '字典值'
export default class index extends Component { export default class index extends Component {
state = { state = {
codes: { codes: {
commonStatus: [] commonStatus: [],
}, },
selectedRowKeys: [] selectedRowKeys: [],
} }
// 表格实例 // 表格实例
@@ -45,7 +44,7 @@ export default class index extends Component {
dataIndex: 'value', dataIndex: 'value',
sorter: true, sorter: true,
width: 200, width: 200,
render: (text, record, index) => render: (text, record, index) => (
<Form.Item <Form.Item
name={[index, 'value']} name={[index, 'value']}
rules={[{ required: true, message: '请输入文本' }]} rules={[{ required: true, message: '请输入文本' }]}
@@ -53,13 +52,14 @@ export default class index extends Component {
> >
<Input autoComplete="off" placeholder="请输入文本" /> <Input autoComplete="off" placeholder="请输入文本" />
</Form.Item> </Form.Item>
),
}, },
{ {
title: '字典值', title: '字典值',
dataIndex: 'code', dataIndex: 'code',
sorter: true, sorter: true,
width: 200, width: 200,
render: (text, record, index) => render: (text, record, index) => (
<Form.Item <Form.Item
name={[index, 'code']} name={[index, 'code']}
rules={[{ required: true, message: '请输入文本' }]} rules={[{ required: true, message: '请输入文本' }]}
@@ -67,18 +67,19 @@ export default class index extends Component {
> >
<Input autoComplete="off" placeholder="请输入字典值" /> <Input autoComplete="off" placeholder="请输入字典值" />
</Form.Item> </Form.Item>
),
}, },
{ {
title: '扩展值', title: '扩展值',
dataIndex: 'extCode', dataIndex: 'extCode',
width: 80, width: 80,
align: 'center', align: 'center',
render: (text, record, index) => render: (text, record, index) => (
<> <>
<Form.Item name={[index, 'extCode']} className="hidden"> <Form.Item name={[index, 'extCode']} className="hidden">
<Input type="hidden" /> <Input type="hidden" />
</Form.Item> </Form.Item>
{auth('sysDictData:edit') ? {auth('sysDictData:edit') ? (
<a <a
onClick={() => this.onOpen(this.jsonForm, record)} onClick={() => this.onOpen(this.jsonForm, record)}
style={{ style={{
@@ -87,50 +88,58 @@ export default class index extends Component {
transform: 'scaleY(.85)', transform: 'scaleY(.85)',
color: 'transparent', color: 'transparent',
backgroundImage: 'linear-gradient(135deg, #007bff, #52c41a)', backgroundImage: 'linear-gradient(135deg, #007bff, #52c41a)',
WebkitBackgroundClip: 'text' WebkitBackgroundClip: 'text',
}} }}
>JSON</a> >
: JSON
</a>
) : (
<>{text}</> <>{text}</>
} )}
</> </>
),
}, },
{ {
title: '排序', title: '排序',
dataIndex: 'sort', dataIndex: 'sort',
sorter: true, sorter: true,
width: 100, width: 100,
render: (text, record, index) => <Form.Item name={[index, 'sort']} className="mb-none"> render: (text, record, index) => (
<InputNumber <Form.Item name={[index, 'sort']} className="mb-none">
max={1000} <InputNumber
min={0} max={1000}
step={1} min={0}
className="w-100-p" step={1}
autoComplete="off" className="w-100-p"
placeholder="排序" autoComplete="off"
/> placeholder="排序"
</Form.Item> />
</Form.Item>
),
defaultSortOrder: 'ascend',
}, },
{ {
title: '备注', title: '备注',
dataIndex: 'remark', dataIndex: 'remark',
sorter: true, sorter: true,
render: (text, record, index) => <Form.Item name={[index, 'remark']} className="mb-none"> render: (text, record, index) => (
<Input autoComplete="off" placeholder="请输入备注" /> <Form.Item name={[index, 'remark']} className="mb-none">
</Form.Item> <Input autoComplete="off" placeholder="请输入备注" />
</Form.Item>
),
}, },
{ {
title: '状态', title: '状态',
dataIndex: 'status', dataIndex: 'status',
sorter: true, sorter: true,
width: 80, width: 80,
render: text => this.bindCodeValue(text, 'common_status') render: text => this.bindCodeValue(text, 'common_status'),
} },
] ]
/** /**
* 构造函数,在渲染前动态添加操作字段等 * 构造函数,在渲染前动态添加操作字段等
* @param {*} props * @param {*} props
*/ */
constructor(props) { constructor(props) {
super(props) super(props)
@@ -142,27 +151,28 @@ export default class index extends Component {
title: '操作', title: '操作',
width: 150, width: 150,
dataIndex: 'actions', dataIndex: 'actions',
render: (text, record, index) => (<QueryTableActions> render: (text, record, index) => (
{ <QueryTableActions>
record.id !== -1 ? {record.id !== -1 ? (
<Auth auth="sysDictData:edit"> <Auth auth="sysDictData:edit">
<a onClick={() => this.onEdit(index)}>保存编辑</a> <a onClick={() => this.onEdit(index)}>保存编辑</a>
</Auth> </Auth>
: ) : (
<Auth auth="sysDictData:add"> <Auth auth="sysDictData:add">
<a onClick={() => this.onAdd(index)}>保存新增</a> <a onClick={() => this.onAdd(index)}>保存新增</a>
</Auth> </Auth>
} )}
<Auth auth="sysDictData:delete"> <Auth auth="sysDictData:delete">
<Popconfirm <Popconfirm
placement="topRight" placement="topRight"
title="是否确认删除" title="是否确认删除"
onConfirm={() => this.onDelete(record)} onConfirm={() => this.onDelete(record)}
> >
<a>删除</a> <a>删除</a>
</Popconfirm> </Popconfirm>
</Auth> </Auth>
</QueryTableActions>) </QueryTableActions>
),
}) })
} }
} }
@@ -171,9 +181,9 @@ export default class index extends Component {
* 阻止外部组件引发的渲染,提升性能 * 阻止外部组件引发的渲染,提升性能
* 可自行添加渲染条件 * 可自行添加渲染条件
* [必要] * [必要]
* @param {*} props * @param {*} props
* @param {*} state * @param {*} state
* @returns * @returns
*/ */
shouldComponentUpdate(props, state) { shouldComponentUpdate(props, state) {
return !isEqual(this.state, state) return !isEqual(this.state, state)
@@ -186,26 +196,28 @@ export default class index extends Component {
componentDidMount() { componentDidMount() {
this.table.current.onLoading() this.table.current.onLoading()
getDictData('common_status').then(res => { getDictData('common_status').then(res => {
this.setState({ this.setState(
codes: res {
}, () => { codes: res,
this.table.current.onLoadData() },
}) () => {
this.table.current.onLoadData()
}
)
}) })
} }
/** /**
* 调用加载数据接口,可在调用前对query进行处理 * 调用加载数据接口,可在调用前对query进行处理
* [异步,必要] * [异步,必要]
* @param {*} params * @param {*} params
* @param {*} query * @param {*} query
* @returns * @returns
*/ */
loadData = async (params, query) => { loadData = async (params, query) => {
query = { query = {
...query, ...query,
typeId: this.props.type.id typeId: this.props.type.id,
} }
const { data } = await apiAction.page({ const { data } = await apiAction.page({
@@ -225,15 +237,15 @@ export default class index extends Component {
/** /**
* 绑定字典数据 * 绑定字典数据
* @param {*} code * @param {*} code
* @param {*} name * @param {*} name
* @returns * @returns
*/ */
bindCodeValue(code, name) { bindCodeValue(code, name) {
name = toCamelCase(name) name = toCamelCase(name)
const codes = this.state.codes[name] const codes = this.state.codes[name]
if (codes) { if (codes) {
const c = codes.find((p) => p.code == code) const c = codes.find(p => p.code == code)
if (c) { if (c) {
return c.value return c.value
} }
@@ -243,20 +255,20 @@ export default class index extends Component {
/** /**
* 打开新增/编辑弹窗 * 打开新增/编辑弹窗
* @param {*} modal * @param {*} modal
* @param {*} record * @param {*} record
*/ */
onOpen(modal, record) { onOpen(modal, record) {
modal.current.open({ modal.current.open({
record record,
}) })
} }
/** /**
* 对表格上的操作进行统一处理 * 对表格上的操作进行统一处理
* [异步] * [异步]
* @param {*} action * @param {*} action
* @param {*} successMessage * @param {*} successMessage
*/ */
async onAction(action, successMessage, reload = true) { async onAction(action, successMessage, reload = true) {
const table = this.table.current const table = this.table.current
@@ -276,13 +288,10 @@ export default class index extends Component {
/** /**
* 删除 * 删除
* @param {*} record * @param {*} record
*/ */
onDelete(record) { onDelete(record) {
this.onAction( this.onAction(apiAction.delete(record), '删除成功')
apiAction.delete(record),
'删除成功'
)
} }
//#region 自定义方法 //#region 自定义方法
@@ -295,12 +304,12 @@ export default class index extends Component {
typeId: this.props.type.id, typeId: this.props.type.id,
sort: 100, sort: 100,
status: 0, status: 0,
remark: null remark: null,
} }
const index = this.table.current.onAddRow(record) const index = this.table.current.onAddRow(record)
if (index !== false) { if (index !== false) {
this.form.current.setFieldsValue({ this.form.current.setFieldsValue({
[index]: record [index]: record,
}) })
} }
} }
@@ -318,10 +327,7 @@ export default class index extends Component {
const record = form.getFieldsValue([index])[index] const record = form.getFieldsValue([index])[index]
// 为了正常显示checkbox,默认给id赋予了-1,在这里删除id以表示新增 // 为了正常显示checkbox,默认给id赋予了-1,在这里删除id以表示新增
record.id = undefined record.id = undefined
this.onAction( this.onAction(apiAction.add(record), '新增成功')
apiAction.add(record),
'新增成功'
)
} }
async onEdit(index) { async onEdit(index) {
@@ -335,21 +341,14 @@ export default class index extends Component {
} }
} }
const record = form.getFieldsValue([index])[index] const record = form.getFieldsValue([index])[index]
this.onAction( this.onAction(apiAction.edit(record), '编辑成功', false)
apiAction.edit(record),
'编辑成功',
false
)
} }
async onDeleteBatch() { async onDeleteBatch() {
await this.onAction( await this.onAction(apiAction.deleteBatch(this.state.selectedRowKeys), '删除成功')
apiAction.deleteBatch(this.state.selectedRowKeys),
'删除成功'
)
this.setState({ this.setState({
selectedRowKeys: [] selectedRowKeys: [],
}) })
} }
@@ -360,8 +359,8 @@ export default class index extends Component {
index = dataSource.indexOf(data) index = dataSource.indexOf(data)
this.form.current.setFieldsValue({ this.form.current.setFieldsValue({
[index]: { [index]: {
extCode extCode,
} },
}) })
dataSource[index].extCode = extCode dataSource[index].extCode = extCode
table.setState({ dataSource }) table.setState({ dataSource })
@@ -369,7 +368,6 @@ export default class index extends Component {
//#endregion //#endregion
render() { render() {
const { selectedRowKeys } = this.state const { selectedRowKeys } = this.state
return ( return (
@@ -387,9 +385,9 @@ export default class index extends Component {
rowSelection={{ rowSelection={{
selectedRowKeys, selectedRowKeys,
onChange: selectedRowKeys => this.setState({ selectedRowKeys }), onChange: selectedRowKeys => this.setState({ selectedRowKeys }),
getCheckboxProps: (record) => ({ getCheckboxProps: record => ({
disabled: record.id === -1 disabled: record.id === -1,
}) }),
}} }}
query={ query={
<Auth auth="sysDictData:page"> <Auth auth="sysDictData:page">
@@ -409,28 +407,27 @@ export default class index extends Component {
title="是否确认批量删除" title="是否确认批量删除"
onConfirm={() => this.onDeleteBatch()} onConfirm={() => this.onDeleteBatch()}
> >
<Button disabled={!selectedRowKeys.length} danger>批量删除</Button> <Button disabled={!selectedRowKeys.length} danger>
批量删除
</Button>
</Popconfirm> </Popconfirm>
</Auth> </Auth>
} }
footer={ footer={() => (
() => <Auth auth="sysDictData:add">
<Auth auth="sysDictData:add"> <Button
<Button block
block icon={<AntIcon type="plus" />}
icon={<AntIcon type="plus" />} onClick={() => this.onAddRow()}
onClick={() => this.onAddRow()} >
>新增{name}</Button> 新增{name}
</Auth> </Button>
} </Auth>
)}
/> />
</Card> </Card>
<ModalForm <ModalForm title="编辑" action={this.onSaveExtCode} ref={this.jsonForm}>
title="编辑"
action={this.onSaveExtCode}
ref={this.jsonForm}
>
<FormBody /> <FormBody />
</ModalForm> </ModalForm>
</Container> </Container>

View File

@@ -1,6 +1,14 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Button, Card, Form, Input, message as Message, Popconfirm, Radio } from 'antd' import { Button, Card, Form, Input, message as Message, Popconfirm, Radio } from 'antd'
import { AntIcon, Auth, Container, ModalForm, QueryTable, QueryTableActions, QueryTreeLayout } from 'components' import {
AntIcon,
Auth,
Container,
ModalForm,
QueryTable,
QueryTableActions,
QueryTreeLayout,
} from 'components'
import { api } from 'common/api' import { api } from 'common/api'
import auth from 'components/authorized/handler' import auth from 'components/authorized/handler'
import { toCamelCase } from 'util/format' import { toCamelCase } from 'util/format'
@@ -14,17 +22,16 @@ const apiAction = {
page: api.sysDictTypePage, page: api.sysDictTypePage,
add: api.sysDictTypeAdd, add: api.sysDictTypeAdd,
edit: api.sysDictTypeEdit, edit: api.sysDictTypeEdit,
delete: api.sysDictTypeDelete delete: api.sysDictTypeDelete,
} }
const name = '字典' const name = '字典'
export default class index extends Component { export default class index extends Component {
state = { state = {
codes: { codes: {
commonStatus: [] commonStatus: [],
} },
} }
// 表格实例 // 表格实例
@@ -43,24 +50,29 @@ export default class index extends Component {
{ {
title: '字典名称', title: '字典名称',
dataIndex: 'name', dataIndex: 'name',
width: 200,
sorter: true, sorter: true,
}, },
{ {
title: '类型', title: '类型',
key: 'type', key: 'type',
dataIndex: 'code', dataIndex: 'code',
width: 120,
sorter: true, sorter: true,
render: text => text ? '字典类型' : '目录' render: text => (text ? '字典类型' : '目录'),
}, },
{ {
title: '唯一编码', title: '唯一编码',
dataIndex: 'code', dataIndex: 'code',
width: 120,
sorter: true, sorter: true,
}, },
{ {
title: '排序', title: '排序',
dataIndex: 'sort', dataIndex: 'sort',
width: 80,
sorter: true, sorter: true,
defaultSortOrder: 'ascend',
}, },
{ {
title: '备注', title: '备注',
@@ -71,14 +83,15 @@ export default class index extends Component {
{ {
title: '状态', title: '状态',
dataIndex: 'status', dataIndex: 'status',
width: 80,
sorter: true, sorter: true,
render: text => this.bindCodeValue(text, 'common_status') render: text => this.bindCodeValue(text, 'common_status'),
}, },
] ]
/** /**
* 构造函数,在渲染前动态添加操作字段等 * 构造函数,在渲染前动态添加操作字段等
* @param {*} props * @param {*} props
*/ */
constructor(props) { constructor(props) {
super(props) super(props)
@@ -90,20 +103,22 @@ export default class index extends Component {
title: '操作', title: '操作',
width: 150, width: 150,
dataIndex: 'actions', dataIndex: 'actions',
render: (text, record) => (<QueryTableActions> render: (text, record) => (
<Auth auth="sysDict:edit"> <QueryTableActions>
<a onClick={() => this.onOpen(this.editForm, record)}>编辑</a> <Auth auth="sysDict:edit">
</Auth> <a onClick={() => this.onOpen(this.editForm, record)}>编辑</a>
<Auth auth="sysDict:delete"> </Auth>
<Popconfirm <Auth auth="sysDict:delete">
placement="topRight" <Popconfirm
title="是否确认删除" placement="topRight"
onConfirm={() => this.onDelete(record)} title="是否确认删除"
> onConfirm={() => this.onDelete(record)}
<a>删除</a> >
</Popconfirm> <a>删除</a>
</Auth> </Popconfirm>
</QueryTableActions>) </Auth>
</QueryTableActions>
),
}) })
} }
} }
@@ -112,9 +127,9 @@ export default class index extends Component {
* 阻止外部组件引发的渲染,提升性能 * 阻止外部组件引发的渲染,提升性能
* 可自行添加渲染条件 * 可自行添加渲染条件
* [必要] * [必要]
* @param {*} props * @param {*} props
* @param {*} state * @param {*} state
* @returns * @returns
*/ */
shouldComponentUpdate(props, state) { shouldComponentUpdate(props, state) {
return !isEqual(this.state, state) return !isEqual(this.state, state)
@@ -127,26 +142,28 @@ export default class index extends Component {
componentDidMount() { componentDidMount() {
this.table.current.onLoading() this.table.current.onLoading()
getDictData('common_status').then(res => { getDictData('common_status').then(res => {
this.setState({ this.setState(
codes: res {
}, () => { codes: res,
this.table.current.onLoadData() },
}) () => {
this.table.current.onLoadData()
}
)
}) })
} }
/** /**
* 调用加载数据接口,可在调用前对query进行处理 * 调用加载数据接口,可在调用前对query进行处理
* [异步,必要] * [异步,必要]
* @param {*} params * @param {*} params
* @param {*} query * @param {*} query
* @returns * @returns
*/ */
loadData = async (params, query) => { loadData = async (params, query) => {
query = { query = {
...query, ...query,
pid: this.selectId pid: this.selectId,
} }
const { data } = await apiAction.page({ const { data } = await apiAction.page({
@@ -157,10 +174,10 @@ export default class index extends Component {
} }
/** /**
* 调用树结构数据接口 * 调用树结构数据接口
* [异步,必要] * [异步,必要]
* @returns * @returns
*/ */
loadTreeData = async () => { loadTreeData = async () => {
const { data } = await apiAction.tree() const { data } = await apiAction.tree()
return data return data
@@ -169,7 +186,7 @@ export default class index extends Component {
/** /**
* 树节点选中事件 * 树节点选中事件
* [必要] * [必要]
* @param {*} id * @param {*} id
*/ */
onSelectTree(id) { onSelectTree(id) {
this.selectId = id this.selectId = id
@@ -178,15 +195,15 @@ export default class index extends Component {
/** /**
* 绑定字典数据 * 绑定字典数据
* @param {*} code * @param {*} code
* @param {*} name * @param {*} name
* @returns * @returns
*/ */
bindCodeValue(code, name) { bindCodeValue(code, name) {
name = toCamelCase(name) name = toCamelCase(name)
const codes = this.state.codes[name] const codes = this.state.codes[name]
if (codes) { if (codes) {
const c = codes.find((p) => p.code == code) const c = codes.find(p => p.code == code)
if (c) { if (c) {
return c.value return c.value
} }
@@ -196,21 +213,21 @@ export default class index extends Component {
/** /**
* 打开新增/编辑弹窗 * 打开新增/编辑弹窗
* @param {*} modal * @param {*} modal
* @param {*} record * @param {*} record
*/ */
onOpen(modal, record) { onOpen(modal, record) {
modal.current.open({ modal.current.open({
pid: this.selectId, pid: this.selectId,
record record,
}) })
} }
/** /**
* 对表格上的操作进行统一处理 * 对表格上的操作进行统一处理
* [异步] * [异步]
* @param {*} action * @param {*} action
* @param {*} successMessage * @param {*} successMessage
*/ */
async onAction(action, successMessage) { async onAction(action, successMessage) {
this.table.current.onLoading() this.table.current.onLoading()
@@ -225,13 +242,10 @@ export default class index extends Component {
/** /**
* 删除 * 删除
* @param {*} record * @param {*} record
*/ */
onDelete(record) { onDelete(record) {
this.onAction( this.onAction(apiAction.delete(record), '删除成功')
apiAction.delete(record),
'删除成功'
)
} }
//#region 自定义方法 //#region 自定义方法
@@ -242,7 +256,7 @@ export default class index extends Component {
<QueryTreeLayout <QueryTreeLayout
loadData={this.loadTreeData} loadData={this.loadTreeData}
defaultExpanded={true} defaultExpanded={true}
onSelect={(key) => this.onSelectTree(key)} onSelect={key => this.onSelectTree(key)}
> >
<Container mode="fluid"> <Container mode="fluid">
<Card bordered={false}> <Card bordered={false}>
@@ -252,7 +266,7 @@ export default class index extends Component {
loadData={this.loadData} loadData={this.loadData}
columns={this.columns} columns={this.columns}
queryInitialValues={{ queryInitialValues={{
type: 2 type: 2,
}} }}
query={ query={
<Auth auth="sysDict:page"> <Auth auth="sysDict:page">
@@ -275,12 +289,14 @@ export default class index extends Component {
<Button <Button
icon={<AntIcon type="plus" />} icon={<AntIcon type="plus" />}
onClick={() => this.onOpen(this.addForm)} onClick={() => this.onOpen(this.addForm)}
>新增{name}</Button> >
新增{name}
</Button>
</Auth> </Auth>
} }
expandable={{ expandable={{
expandedRowRender: record => <DictData type={record} />, expandedRowRender: record => <DictData type={record} />,
rowExpandable: record => !!record.code rowExpandable: record => !!record.code,
}} }}
/> />
</Card> </Card>

View File

@@ -1,23 +1,42 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Alert, Button, Card, Descriptions, Form, Popconfirm, Input, message as Message, Select, DatePicker } from 'antd' import {
Alert,
Button,
Card,
Descriptions,
Form,
Popconfirm,
Input,
message as Message,
Select,
DatePicker,
Tag,
} from 'antd'
import { Auth, Container, QueryTable } from 'components' import { Auth, Container, QueryTable } from 'components'
import { api } from 'common/api' import { api } from 'common/api'
import { toCamelCase } from 'util/format' import { toCamelCase } from 'util/format'
import { isEqual } from 'lodash' import { isEqual } from 'lodash'
import getDictData from 'util/dic' import getDictData from 'util/dic'
import moment from 'moment' import moment from 'moment'
import ReactJson from 'react-json-view'
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker
const apiAction = { const apiAction = {
page: api.sysOpLogPage, page: api.sysOpLogPage,
delete: api.sysOpLogDelete delete: api.sysOpLogDelete,
} }
const methodColor = {
POST: 'orange',
GET: 'green',
}
export default class index extends Component { export default class index extends Component {
state = { state = {
codes: { codes: {
opType: [] opType: [],
} },
} }
// 表格实例 // 表格实例
table = React.createRef() table = React.createRef()
@@ -26,37 +45,54 @@ export default class index extends Component {
{ {
title: '日志名称', title: '日志名称',
dataIndex: 'name', dataIndex: 'name',
sorter: true, width: 200,
},
{
title: '操作类型',
dataIndex: 'opType',
render: text => (<>{this.bindCodeValue(text, 'op_type')}</>),
sorter: true,
},
{
title: '是否成功',
dataIndex: 'success',
render: text => (<> {text ? '是' : '否'}</>),
sorter: true,
},
{
title: 'ip',
dataIndex: 'ip',
sorter: true, sorter: true,
}, },
{ {
title: '请求地址', title: '请求地址',
dataIndex: 'url', dataIndex: 'url',
width: 300,
sorter: true,
render: (text, record) => (
<>
<Tag color={methodColor[record.reqMethod.toUpperCase()]}>
{record.reqMethod}
</Tag>{' '}
{text}
</>
),
},
{
title: '是否成功',
dataIndex: 'success',
width: 100,
render: text => (
<>
{text ? (
<span className="text-success"></span>
) : (
<span className="text-error"></span>
)}
</>
),
sorter: true,
},
{
title: 'ip',
dataIndex: 'ip',
width: 120,
sorter: true, sorter: true,
}, },
{ {
title: '操作时间', title: '操作时间',
dataIndex: 'opTime', dataIndex: 'opTime',
width: 140,
sorter: true, sorter: true,
defaultSortOrder: 'descend',
}, },
{ {
title: '操作人', title: '操作人',
width: 140,
dataIndex: 'account', dataIndex: 'account',
sorter: true, sorter: true,
}, },
@@ -66,9 +102,9 @@ export default class index extends Component {
* 阻止外部组件引发的渲染,提升性能 * 阻止外部组件引发的渲染,提升性能
* 可自行添加渲染条件 * 可自行添加渲染条件
* [必要] * [必要]
* @param {*} props * @param {*} props
* @param {*} state * @param {*} state
* @returns * @returns
*/ */
shouldComponentUpdate(props, state) { shouldComponentUpdate(props, state) {
return !isEqual(this.state, state) return !isEqual(this.state, state)
@@ -78,29 +114,20 @@ export default class index extends Component {
* 加载字典数据,之后开始加载表格数据 * 加载字典数据,之后开始加载表格数据
* 如果必须要加载字典数据,可直接对表格设置autoLoad=true * 如果必须要加载字典数据,可直接对表格设置autoLoad=true
*/ */
componentDidMount() { componentDidMount() {}
this.table.current.onLoading()
getDictData('op_type').then(res => {
this.setState({
codes: res
}, () => {
this.table.current.onLoadData()
})
})
}
/** /**
* 调用加载数据接口,可在调用前对query进行处理 * 调用加载数据接口,可在调用前对query进行处理
* [异步,必要] * [异步,必要]
* @param {*} params * @param {*} params
* @param {*} query * @param {*} query
* @returns * @returns
*/ */
loadData = async (params, query) => { loadData = async (params, query) => {
if (query.dates && query.dates.length) { if (query.dates && query.dates.length) {
query.searchBeginTime = moment(query.dates[0]).format('YYYY-MM-DD HH:mm:ss'); query.searchBeginTime = moment(query.dates[0]).format('YYYY-MM-DD HH:mm:ss')
query.searchEndTime = moment(query.dates[1]).format('YYYY-MM-DD HH:mm:ss'); query.searchEndTime = moment(query.dates[1]).format('YYYY-MM-DD HH:mm:ss')
delete query.dates; delete query.dates
} }
const { data } = await apiAction.page({ const { data } = await apiAction.page({
...params, ...params,
@@ -109,16 +136,16 @@ export default class index extends Component {
return data return data
} }
/** /**
* 绑定字典数据 * 绑定字典数据
* @param {*} code * @param {*} code
* @param {*} name * @param {*} name
* @returns * @returns
*/ */
bindCodeValue(code, name) { bindCodeValue(code, name) {
name = toCamelCase(name) name = toCamelCase(name)
const codes = this.state.codes[name] const codes = this.state.codes[name]
if (codes) { if (codes) {
const c = codes.find((p) => +p.code === code) const c = codes.find(p => +p.code === code)
if (c) { if (c) {
return c.value return c.value
} }
@@ -129,8 +156,8 @@ export default class index extends Component {
/** /**
* 对表格上的操作进行统一处理 * 对表格上的操作进行统一处理
* [异步] * [异步]
* @param {*} action * @param {*} action
* @param {*} successMessage * @param {*} successMessage
*/ */
async onAction(action, successMessage) { async onAction(action, successMessage) {
this.table.current.onLoading() this.table.current.onLoading()
@@ -144,27 +171,27 @@ export default class index extends Component {
} }
onOpLogClear() { onOpLogClear() {
this.onAction( this.onAction(apiAction.delete(), '清空成功')
apiAction.delete(),
'清空成功'
)
} }
render() { render() {
return ( return (
<Container mode="fluid"> <Container mode="fluid">
<br /> <br />
<Alert closable type="error" message={ <Alert
<> closable
<div>后端bug:任何操作的操作类型都是增加</div> type="error"
<div>没有记录请求参数.返回结果等信息</div> message={
</> <>
} /> <div>后端bug:任何操作的操作类型都是增加</div>
<div>没有记录请求参数.返回结果等信息</div>
</>
}
/>
<br /> <br />
<Card bordered={false}> <Card bordered={false}>
<QueryTable <QueryTable
ref={this.table} ref={this.table}
autoLoad={false}
loadData={this.loadData} loadData={this.loadData}
columns={this.columns} columns={this.columns}
query={ query={
@@ -172,41 +199,23 @@ export default class index extends Component {
<Form.Item label="日志名称" name="name"> <Form.Item label="日志名称" name="name">
<Input autoComplete="off" placeholder="请输入日志名称" /> <Input autoComplete="off" placeholder="请输入日志名称" />
</Form.Item> </Form.Item>
<Form.Item label="操作类型" name="opType">
<Select placeholder="请选择操作类型">
{
this.state.codes.opType.map(item => {
return <Select.Option
key={item.code}
value={+item.code}
>{item.value}</Select.Option>
})
}
</Select>
</Form.Item>
<Form.Item label="是否成功" name="success"> <Form.Item label="是否成功" name="success">
<Select placeholder="请选择是否成功" style={{ width: '170px' }}> <Select placeholder="请选择是否成功" style={{ width: '170px' }}>
<Select.Option <Select.Option key="true"></Select.Option>
key='true' <Select.Option key="false"></Select.Option>
>
</Select.Option>
<Select.Option
key='false'
>
</Select.Option>
</Select> </Select>
</Form.Item> </Form.Item>
<Form.Item label="操作时间" name="dates"> <Form.Item label="操作时间" name="dates">
<RangePicker <RangePicker
showTime={ showTime={{
{ hideDisabledOptions: true,
hideDisabledOptions: true, defaultValue: [
defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')] moment('00:00:00', 'HH:mm:ss'),
} moment('23:59:59', 'HH:mm:ss'),
} ],
}}
format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
> ></RangePicker>
</RangePicker>
</Form.Item> </Form.Item>
</Auth> </Auth>
} }
@@ -222,8 +231,8 @@ export default class index extends Component {
</Auth> </Auth>
} }
expandable={{ expandable={{
expandedRowRender: record => expandedRowRender: record => (
<Descriptions bordered size="small"> <Descriptions bordered size="small" labelStyle={{ width: '150px' }}>
<Descriptions.Item span="1" label="方法名称"> <Descriptions.Item span="1" label="方法名称">
{record.methodName} {record.methodName}
</Descriptions.Item> </Descriptions.Item>
@@ -240,20 +249,26 @@ export default class index extends Component {
{record.className} {record.className}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item span="3" label="返回结果"> <Descriptions.Item span="3" label="返回结果">
{record.result} <ReactJson
src={JSON.parse(record.result || '{}')}
collapsed
/>
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item span="3" label="请求参数"> <Descriptions.Item span="3" label="请求参数">
{record.param} <ReactJson
src={JSON.parse(record.param || '{}')}
collapsed
/>
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item span="3" label="具体消息"> <Descriptions.Item span="3" label="具体消息">
{record.message} {record.message}
</Descriptions.Item> </Descriptions.Item>
</Descriptions> </Descriptions>
),
}} }}
/> />
</Card> </Card>
</Container> </Container>
) )
} }
} }

View File

@@ -1,5 +1,16 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Alert, Button, Card, Descriptions, Form, Popconfirm, Input, message as Message, Select, DatePicker } from 'antd' import {
Alert,
Button,
Card,
Descriptions,
Form,
Popconfirm,
Input,
message as Message,
Select,
DatePicker,
} from 'antd'
import { Auth, Container, QueryTable } from 'components' import { Auth, Container, QueryTable } from 'components'
import { api } from 'common/api' import { api } from 'common/api'
import { toCamelCase } from 'util/format' import { toCamelCase } from 'util/format'
@@ -7,17 +18,17 @@ import { isEqual } from 'lodash'
import getDictData from 'util/dic' import getDictData from 'util/dic'
import moment from 'moment' import moment from 'moment'
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker
const apiAction = { const apiAction = {
page: api.sysVisLogPage, page: api.sysVisLogPage,
delete: api.sysVisLogDelete delete: api.sysVisLogDelete,
} }
export default class index extends Component { export default class index extends Component {
state = { state = {
codes: { codes: {
visType: [] visType: [],
} },
} }
// 表格实例 // 表格实例
table = React.createRef() table = React.createRef()
@@ -26,38 +37,54 @@ export default class index extends Component {
{ {
title: '日志名称', title: '日志名称',
dataIndex: 'name', dataIndex: 'name',
width: 200,
sorter: true, sorter: true,
}, },
{ {
title: '访问类型', title: '访问类型',
dataIndex: 'visType', dataIndex: 'visType',
render: text => (<>{this.bindCodeValue(text, 'vis_type')}</>), width: 120,
render: text => <>{this.bindCodeValue(text, 'vis_type')}</>,
sorter: true, sorter: true,
}, },
{ {
title: '是否成功', title: '是否成功',
dataIndex: 'success', dataIndex: 'success',
render: text => (<> {text ? '是' : '否'}</>), width: 120,
render: text => (
<>
{text ? (
<span className="text-success"></span>
) : (
<span className="text-error"></span>
)}
</>
),
sorter: true, sorter: true,
}, },
{ {
title: 'ip', title: 'ip',
dataIndex: 'ip', dataIndex: 'ip',
width: 180,
sorter: true, sorter: true,
}, },
{ {
title: '浏览器', title: '浏览器',
dataIndex: 'browser', dataIndex: 'browser',
width: 180,
sorter: true, sorter: true,
}, },
{ {
title: '访问时间', title: '访问时间',
dataIndex: 'visTime', dataIndex: 'visTime',
width: 180,
sorter: true, sorter: true,
defaultSortOrder: 'descend',
}, },
{ {
title: '访问人', title: '访问人',
dataIndex: 'account', dataIndex: 'account',
width: 180,
sorter: true, sorter: true,
}, },
] ]
@@ -66,9 +93,9 @@ export default class index extends Component {
* 阻止外部组件引发的渲染,提升性能 * 阻止外部组件引发的渲染,提升性能
* 可自行添加渲染条件 * 可自行添加渲染条件
* [必要] * [必要]
* @param {*} props * @param {*} props
* @param {*} state * @param {*} state
* @returns * @returns
*/ */
shouldComponentUpdate(props, state) { shouldComponentUpdate(props, state) {
return !isEqual(this.state, state) return !isEqual(this.state, state)
@@ -81,26 +108,29 @@ export default class index extends Component {
componentDidMount() { componentDidMount() {
this.table.current.onLoading() this.table.current.onLoading()
getDictData('vis_type').then(res => { getDictData('vis_type').then(res => {
this.setState({ this.setState(
codes: res {
}, () => { codes: res,
this.table.current.onLoadData() },
}) () => {
this.table.current.onLoadData()
}
)
}) })
} }
/** /**
* 调用加载数据接口,可在调用前对query进行处理 * 调用加载数据接口,可在调用前对query进行处理
* [异步,必要] * [异步,必要]
* @param {*} params * @param {*} params
* @param {*} query * @param {*} query
* @returns * @returns
*/ */
loadData = async (params, query) => { loadData = async (params, query) => {
if (query.dates && query.dates.length) { if (query.dates && query.dates.length) {
query.searchBeginTime = moment(query.dates[0]).format('YYYY-MM-DD HH:mm:ss'); query.searchBeginTime = moment(query.dates[0]).format('YYYY-MM-DD HH:mm:ss')
query.searchEndTime = moment(query.dates[1]).format('YYYY-MM-DD HH:mm:ss'); query.searchEndTime = moment(query.dates[1]).format('YYYY-MM-DD HH:mm:ss')
delete query.dates; delete query.dates
} }
const { data } = await apiAction.page({ const { data } = await apiAction.page({
...params, ...params,
@@ -109,16 +139,16 @@ export default class index extends Component {
return data return data
} }
/** /**
* 绑定字典数据 * 绑定字典数据
* @param {*} code * @param {*} code
* @param {*} name * @param {*} name
* @returns * @returns
*/ */
bindCodeValue(code, name) { bindCodeValue(code, name) {
name = toCamelCase(name) name = toCamelCase(name)
const codes = this.state.codes[name] const codes = this.state.codes[name]
if (codes) { if (codes) {
const c = codes.find((p) => +p.code === code) const c = codes.find(p => +p.code === code)
if (c) { if (c) {
return c.value return c.value
} }
@@ -129,8 +159,8 @@ export default class index extends Component {
/** /**
* 对表格上的操作进行统一处理 * 对表格上的操作进行统一处理
* [异步] * [异步]
* @param {*} action * @param {*} action
* @param {*} successMessage * @param {*} successMessage
*/ */
async onAction(action, successMessage) { async onAction(action, successMessage) {
this.table.current.onLoading() this.table.current.onLoading()
@@ -144,17 +174,18 @@ export default class index extends Component {
} }
onVisLogClear() { onVisLogClear() {
this.onAction( this.onAction(apiAction.delete(), '清空成功')
apiAction.delete(),
'清空成功'
)
} }
render() { render() {
return ( return (
<Container mode="fluid"> <Container mode="fluid">
<br /> <br />
<Alert closable type="error" message="页面刷新的时候也会有保存登录日志但是没有ip显示" /> <Alert
closable
type="error"
message="页面刷新的时候也会有保存登录日志但是没有ip显示"
/>
<br /> <br />
<Card bordered={false}> <Card bordered={false}>
<QueryTable <QueryTable
@@ -168,43 +199,37 @@ export default class index extends Component {
<Input autoComplete="off" placeholder="请输入日志名称" /> <Input autoComplete="off" placeholder="请输入日志名称" />
</Form.Item> </Form.Item>
<Form.Item label="访问类型" name="visType"> <Form.Item label="访问类型" name="visType">
<Select placeholder="请选择访问类型" <Select
placeholder="请选择访问类型"
allow-clear allow-clear
style={{ width: '170px' }} style={{ width: '170px' }}
> >
{ {this.state.codes.visType.map(item => {
this.state.codes.visType.map(item => { return (
return <Select.Option <Select.Option key={item.code} value={+item.code}>
key={item.code} {item.value}
value={+item.code} </Select.Option>
>{item.value}</Select.Option> )
}) })}
}
</Select> </Select>
</Form.Item> </Form.Item>
<Form.Item label="是否成功" name="success"> <Form.Item label="是否成功" name="success">
<Select placeholder="请选择是否成功" style={{ width: '170px' }}> <Select placeholder="请选择是否成功" style={{ width: '170px' }}>
<Select.Option <Select.Option key="true"></Select.Option>
key='true' <Select.Option key="false"></Select.Option>
>
</Select.Option>
<Select.Option
key='false'
>
</Select.Option>
</Select> </Select>
</Form.Item> </Form.Item>
<Form.Item label="访问时间" name="dates"> <Form.Item label="访问时间" name="dates">
<RangePicker <RangePicker
showTime={ showTime={{
{ hideDisabledOptions: true,
hideDisabledOptions: true, defaultValue: [
defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')] moment('00:00:00', 'HH:mm:ss'),
} moment('23:59:59', 'HH:mm:ss'),
} ],
}}
format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
> ></RangePicker>
</RangePicker>
</Form.Item> </Form.Item>
</Auth> </Auth>
} }
@@ -220,16 +245,22 @@ export default class index extends Component {
</Auth> </Auth>
} }
expandable={{ expandable={{
expandedRowRender: record => expandedRowRender: record => (
<Descriptions bordered size="small"> <Descriptions
<Descriptions.Item span="3" label="具体消息"> bordered
size="small"
columns={1}
labelStyle={{ width: '150px' }}
>
<Descriptions.Item label="具体消息">
{record.message} {record.message}
</Descriptions.Item> </Descriptions.Item>
</Descriptions> </Descriptions>
),
}} }}
/> />
</Card> </Card>
</Container> </Container>
) )
} }
} }

View File

@@ -7,29 +7,31 @@ import { api } from 'common/api'
import { EMPTY_ID } from 'util/global' import { EMPTY_ID } from 'util/global'
const initialValues = { const initialValues = {
type: '1', type: 1,
openType: '1', openType: 1,
weight: '2',
visible: true, visible: true,
sort: 100 sort: 100,
} }
export default class form extends Component { export default class form extends Component {
state = { state = {
// 加载状态 // 加载状态
loading: true, loading: true,
codes: { codes: {
menuType: [], menuType: [],
openType: [] openType: [],
menuWeight: [],
}, },
options: { options: {
appList: [], appList: [],
parentTreeData: [] parentTreeData: [],
}, },
addType: [],
type: initialValues.type, type: initialValues.type,
openType: initialValues.openType, openType: initialValues.openType,
icon: '' icon: '',
} }
// 表单实例 // 表单实例
@@ -51,45 +53,49 @@ export default class form extends Component {
* 填充数据 * 填充数据
* 可以在设置this.record之后对其作出数据结构调整 * 可以在设置this.record之后对其作出数据结构调整
* [异步,必要] * [异步,必要]
* @param {*} params * @param {*} params
*/ */
async fillData(params) { async fillData(params) {
const form = this.form.current
this.record = cloneDeep(params.record) this.record = cloneDeep(params.record)
//#region 从后端转换成前段所需格式 //#region 从后端转换成前段所需格式
const { menuType, openType } = await getDictData('menu_type', 'open_type') const codes = await getDictData('menu_type', 'open_type', 'menu_weight')
const appList = await this.onLoadSysApplist() const appList = await this.onLoadSysApplist()
let parentTreeData = [] let parentTreeData = []
if (params.isParent) { if (params.isParent) {
parentTreeData = await this.onLoadMenuTree(params.parent.application) parentTreeData = await this.onLoadMenuTree(params.parent.application)
} else if (params.record) { }
if (params.record) {
parentTreeData = await this.onLoadMenuTree(params.record.application) parentTreeData = await this.onLoadMenuTree(params.record.application)
} else {
this.setState({ addType: params.addType })
if (params.addType.length) {
form.setFieldsValue({
type: params.addType[0],
})
}
} }
const icon = params.record && params.record.icon const icon = params.record && params.record.icon
this.setState({ this.setState({
codes: { codes,
menuType,
openType
},
options: { options: {
appList, appList,
parentTreeData parentTreeData,
}, },
icon icon,
}) })
//#endregion //#endregion
const form = this.form.current
if (params.isParent) { if (params.isParent) {
form.setFieldsValue({ form.setFieldsValue({
pid: params.parent.id, pid: params.parent.id,
application: params.parent.application application: params.parent.application,
}) })
} else { } else {
form.setFieldsValue(this.record) form.setFieldsValue(this.record)
} }
this.setState({ this.setState({ loading: false })
loading: false
})
this.onTypeChange() this.onTypeChange()
} }
@@ -98,7 +104,7 @@ export default class form extends Component {
* 获取数据 * 获取数据
* 可以对postData进行数据结构调整 * 可以对postData进行数据结构调整
* [异步,必要] * [异步,必要]
* @returns * @returns
*/ */
async getData() { async getData() {
const form = this.form.current const form = this.form.current
@@ -123,30 +129,31 @@ export default class form extends Component {
async onLoadMenuTree(application) { async onLoadMenuTree(application) {
const { data } = await api.getMenuTree({ application }) const { data } = await api.getMenuTree({ application })
return [{ return [
id: EMPTY_ID, {
parentId: undefined, id: EMPTY_ID,
title: '顶级', parentId: undefined,
value: EMPTY_ID, title: '顶级',
pid: undefined, value: EMPTY_ID,
children: data, pid: undefined,
}] children: data,
},
]
} }
onTypeChange() { onTypeChange() {
this.onTypeChangeGroup() this.onTypeChangeGroup()
const form = this.form.current // const form = this.form.current
const { type } = form.getFieldsValue() // const { type } = form.getFieldsValue()
if (['0', '2'].includes(type)) { // if ([0, 2].includes(type)) {
form.setFieldsValue({ // form.setFieldsValue({
openType: '0' // openType: 0,
}) // })
} else { // } else {
form.setFieldsValue({ // form.setFieldsValue({
openType: '1' // openType: 1,
}) // })
} // }
} }
onOpenTypeChange() { onOpenTypeChange() {
@@ -168,178 +175,221 @@ export default class form extends Component {
this.setState({ this.setState({
type, type,
openType openType,
}) })
} }
async onApplicationChange(value) { async onApplicationChange(value) {
this.setState({ this.setState({
loading: true loading: true,
}) })
const parentTreeData = await this.onLoadMenuTree(value) const parentTreeData = await this.onLoadMenuTree(value)
this.setState({ this.setState({
loading: false, loading: false,
options: { options: {
...this.state.options, ...this.state.options,
parentTreeData parentTreeData,
} },
}) })
this.form.current.setFieldsValue({ this.form.current.setFieldsValue({
pid: undefined pid: undefined,
}) })
} }
onSelectIcon(icon) { onSelectIcon(icon) {
this.form.current.setFieldsValue({ this.form.current.setFieldsValue({
icon icon,
}) })
this.setState({ icon }) this.setState({ icon })
} }
//#endregion //#endregion
render() { render() {
const { loading, codes, options, addType, type, openType, icon } = this.state
return ( return (
<Form <Form initialValues={initialValues} ref={this.form} className="yo-form">
initialValues={initialValues} <Spin spinning={loading} indicator={<AntIcon type="loading" />}>
ref={this.form}
className="yo-form"
>
<Spin spinning={this.state.loading} indicator={<AntIcon type="loading" />}>
<div className="yo-form-group"> <div className="yo-form-group">
<h3 className="h3">基本信息</h3> <h3 className="h3">基本信息</h3>
<div className="yo-form-group"> <div className="yo-form-group">
<Form.Item <Form.Item
label="菜单类型" label="菜单类型"
name="type" name="type"
help={ tooltip={
<> <>
目录默认添加在顶级 目录一级菜单默认添加在顶级
<br />菜单 <br />
<br />按钮 菜单二级菜单
<br />
按钮菜单中对应到接口的功能
</> </>
} }
rules={[{ required: true, message: '请选择菜单类型' }]} rules={[{ required: true, message: '请选择菜单类型' }]}
> >
<Radio.Group onChange={(e) => this.onTypeChange(e)}> <Radio.Group onChange={e => this.onTypeChange(e)}>
{ {codes.menuType.map(item => {
this.state.codes.menuType.map(item => { return (
return ( <Radio.Button
<Radio.Button key={item.code}
key={item.code} value={+item.code}
value={item.code} disabled={!addType.includes(+item.code)}
>{item.value}</Radio.Button> >
) {item.value}
}) </Radio.Button>
} )
})}
</Radio.Group> </Radio.Group>
</Form.Item> </Form.Item>
<Form.Item label="名称" name="name" rules={[{ required: true, message: '请输入名称' }]}> <Form.Item
label="名称"
name="name"
rules={[{ required: true, message: '请输入名称' }]}
>
<Input autoComplete="off" placeholder="请输入名称" /> <Input autoComplete="off" placeholder="请输入名称" />
</Form.Item> </Form.Item>
<Form.Item label="唯一编码" name="code"> <Form.Item label="唯一编码" name="code">
<Input autoComplete="off" placeholder="请输入唯一编码" /> <Input autoComplete="off" placeholder="请输入唯一编码" />
</Form.Item> </Form.Item>
<Form.Item label="所属应用" name="application" rules={[{ required: true, message: '请选择所属应用' }]}> <Form.Item
<Select placeholder="请选择所属应用" onChange={(value) => this.onApplicationChange(value)}> label="所属应用"
{ name="application"
this.state.options.appList.map(item => { rules={[{ required: true, message: '请选择所属应用' }]}
return ( >
<Select.Option <Select
key={item.code} placeholder="请选择所属应用"
value={item.code} onChange={value => this.onApplicationChange(value)}
>{item.name}</Select.Option> >
) {options.appList.map(item => {
}) return (
} <Select.Option key={item.code} value={item.code}>
{item.name}
</Select.Option>
)
})}
</Select> </Select>
</Form.Item> </Form.Item>
{ {type != 0 && (
this.state.type != 0 && <Form.Item
<Form.Item label="父级菜单" name="pid" rules={[{ required: true, message: '请选择父级' }]}> label="父级菜单"
name="pid"
rules={[{ required: true, message: '请选择父级' }]}
>
<TreeSelect <TreeSelect
dropdownStyle={{ maxHeight: '300px', overflow: 'auto' }} dropdownStyle={{ maxHeight: '300px', overflow: 'auto' }}
treeData={this.state.options.parentTreeData} treeData={options.parentTreeData}
placeholder="请选择父级菜单" placeholder="请选择父级菜单"
/> />
</Form.Item> </Form.Item>
} )}
<Form.Item
label="权重"
name="weight"
tooltip={
<>
系统权重菜单/功能任何角色可用
<br />
业务权重菜单/功能为超级管理员不可用可防止管理员误操作
</>
}
rules={[{ required: true, message: '请选择权重' }]}
>
<Radio.Group>
{codes.menuWeight.map(item => {
return (
<Radio.Button key={item.code} value={item.code}>
{item.value}
</Radio.Button>
)
})}
</Radio.Group>
</Form.Item>
</div> </div>
<h3 className="h3">扩展信息</h3> <h3 className="h3">扩展信息</h3>
<div className="yo-form-group"> <div className="yo-form-group">
{ {type == 1 && (
this.state.type == 1 &&
<Form.Item label="打开方式" name="openType"> <Form.Item label="打开方式" name="openType">
<Radio.Group onChange={(e) => this.onOpenTypeChange(e)}> <Radio.Group onChange={e => this.onOpenTypeChange(e)}>
{ {codes.openType.map(item => {
this.state.codes.openType.map(item => { return (
return ( <Radio.Button key={item.code} value={+item.code}>
<Radio.Button {item.value}
key={item.code} </Radio.Button>
value={item.code} )
>{item.value}</Radio.Button> })}
)
})
}
</Radio.Group> </Radio.Group>
</Form.Item> </Form.Item>
} )}
{ {type == 1 && openType == 1 && (
this.state.type == 1 && this.state.openType == 1 && <Form.Item
<Form.Item label="前端组件" name="component" rules={[{ required: true, message: '请输入前端组件' }]}> label="前端组件"
name="component"
tooltip="打开新页签并渲染前端组件"
rules={[{ required: true, message: '请输入前端组件' }]}
>
<Input autoComplete="off" placeholder="请输入前端组件" /> <Input autoComplete="off" placeholder="请输入前端组件" />
</Form.Item> </Form.Item>
} )}
{ {type == 1 && openType == 2 && (
this.state.type == 1 && this.state.openType == 2 && <Form.Item
<Form.Item label="内链地址" name="router" rules={[{ required: true, message: '请输入内链地址' }]}> label="内链地址"
name="link"
tooltip="打开新页签并使用iframe加载页面"
rules={[{ required: true, message: '请输入内链地址' }]}
>
<Input autoComplete="off" placeholder="请输入内链地址" /> <Input autoComplete="off" placeholder="请输入内链地址" />
</Form.Item> </Form.Item>
} )}
{ {type == 1 && openType == 3 && (
this.state.type == 1 && this.state.openType == 3 && <Form.Item
<Form.Item label="外链地址" name="link" rules={[{ required: true, message: '请输入外链地址' }]}> label="外链地址"
name="redirect"
tooltip="打开新的浏览器窗口"
rules={[{ required: true, message: '请输入外链地址' }]}
>
<Input autoComplete="off" placeholder="请输入外链地址" /> <Input autoComplete="off" placeholder="请输入外链地址" />
</Form.Item> </Form.Item>
} )}
{ {type == 2 && (
this.state.type == 2 && <Form.Item
<Form.Item label="权限标识" name="permission" rules={[{ required: true, message: '请输入权限标识' }]}> label="权限标识"
name="permission"
rules={[{ required: true, message: '请输入权限标识' }]}
>
<Input autoComplete="off" placeholder="请输入权限标识" /> <Input autoComplete="off" placeholder="请输入权限标识" />
</Form.Item> </Form.Item>
} )}
{ {type == 2 && (
this.state.type == 2 && <Form.Item
<Form.Item label="关联上级菜单显示" name="visibleParent" valuePropName="checked"> label="关联上级菜单显示"
name="visibleParent"
valuePropName="checked"
>
<Switch /> <Switch />
</Form.Item> </Form.Item>
} )}
<Form.Item label="可见性" name="visible" valuePropName="checked"> <Form.Item label="可见性" name="visible" valuePropName="checked">
<Switch /> <Switch />
</Form.Item> </Form.Item>
{ {type != 2 && (
this.state.type != 2 &&
<Form.Item label="图标" name="icon"> <Form.Item label="图标" name="icon">
<Input <Input
disabled disabled
placeholder="请选择图标" placeholder="请选择图标"
addonBefore={ addonBefore={icon && <AntIcon type={icon} />}
this.state.icon &&
<AntIcon type={this.state.icon} />
}
addonAfter={ addonAfter={
<AntIcon <AntIcon
type="setting" type="setting"
onClick={() => onClick={() =>
this this.iconSelector.current.open(
.iconSelector this.form.current.getFieldValue('icon')
.current )
.open(this.form.current.getFieldValue('icon'))
} }
/> />
} }
/> />
</Form.Item> </Form.Item>
} )}
<Form.Item label="排序" name="sort"> <Form.Item label="排序" name="sort">
<InputNumber <InputNumber
max={1000} max={1000}
@@ -355,7 +405,7 @@ export default class form extends Component {
</div> </div>
</Spin> </Spin>
<IconSelector ref={this.iconSelector} onSelect={(icon) => this.onSelectIcon(icon)} /> <IconSelector ref={this.iconSelector} onSelect={icon => this.onSelectIcon(icon)} />
</Form> </Form>
) )
} }

View File

@@ -1,5 +1,5 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Button, Table, Card, Popconfirm, message as Message, Row, Col, Tooltip } from 'antd' import { Button, Table, Card, Popconfirm, message as Message, Row, Col, Tooltip, Tag } from 'antd'
import { isEqual } from 'lodash' import { isEqual } from 'lodash'
import { AntIcon, Auth, Container, ModalForm, QueryTable, QueryTableActions } from 'components' import { AntIcon, Auth, Container, ModalForm, QueryTable, QueryTableActions } from 'components'
import { api } from 'common/api' import { api } from 'common/api'
@@ -24,6 +24,7 @@ export default class index extends Component {
codes: { codes: {
menuType: [], menuType: [],
menuWeight: [], menuWeight: [],
openType: [],
}, },
} }
@@ -55,9 +56,36 @@ export default class index extends Component {
render: text => text && <AntIcon type={text} />, render: text => text && <AntIcon type={text} />,
}, },
{ {
title: '前端组件', title: '连接',
width: 220, width: 220,
dataIndex: 'component', dataIndex: 'openType',
render: (text, record) => {
switch (text) {
case 1:
return (
<>
<Tag color="green">{this.bindCodeValue(text, 'open_type')}</Tag>{' '}
{record.component}
</>
)
case 2:
return (
<>
<Tag color="orange">{this.bindCodeValue(text, 'open_type')}</Tag>{' '}
{record.link}
</>
)
case 3:
return (
<>
<Tag color="red">{this.bindCodeValue(text, 'open_type')}</Tag>{' '}
{record.redirect}
</>
)
default:
return ''
}
},
}, },
{ {
title: '排序', title: '排序',
@@ -83,7 +111,9 @@ export default class index extends Component {
render: (text, record) => ( render: (text, record) => (
<QueryTableActions> <QueryTableActions>
<Auth auth="sysMenu:edit"> <Auth auth="sysMenu:edit">
<a onClick={() => this.onOpen(this.editForm, record)}>编辑</a> <a onClick={() => this.onOpen({ modal: this.editForm, record })}>
编辑
</a>
</Auth> </Auth>
<Auth auth="sysMenu:delete"> <Auth auth="sysMenu:delete">
<Popconfirm <Popconfirm
@@ -96,7 +126,16 @@ export default class index extends Component {
</Auth> </Auth>
{record.type < 2 && ( {record.type < 2 && (
<Auth auth="sysMenu:add"> <Auth auth="sysMenu:add">
<a onClick={() => this.onOpen(this.addForm, record, true)}> <a
onClick={() =>
this.onOpen({
modal: this.addForm,
record,
isParent: true,
addType: record.type == 0 ? [1] : [2],
})
}
>
{record.type == 0 ? '新增子菜单' : '新增功能'} {record.type == 0 ? '新增子菜单' : '新增功能'}
</a> </a>
</Auth> </Auth>
@@ -125,7 +164,7 @@ export default class index extends Component {
*/ */
componentDidMount() { componentDidMount() {
this.table.current.onLoading() this.table.current.onLoading()
getDictData('menu_type', 'menu_weight').then(res => { getDictData('menu_type', 'menu_weight', 'open_type').then(res => {
this.setState( this.setState(
{ {
codes: res, codes: res,
@@ -162,7 +201,7 @@ export default class index extends Component {
name = toCamelCase(name) name = toCamelCase(name)
const codes = this.state.codes[name] const codes = this.state.codes[name]
if (codes) { if (codes) {
const c = codes.find(p => p.code === code) const c = codes.find(p => p.code == code)
if (c) { if (c) {
return c.value return c.value
} }
@@ -175,15 +214,17 @@ export default class index extends Component {
* @param {*} modal * @param {*} modal
* @param {*} record * @param {*} record
*/ */
onOpen(modal, record, isParent = false) { onOpen({ modal, record, isParent = false, addType = [] }) {
const params = isParent const params = isParent
? { ? {
parent: record, parent: record,
isParent, isParent,
addType,
} }
: { : {
record, record,
isParent, isParent,
addType,
} }
modal.current.open(params) modal.current.open(params)
@@ -246,7 +287,9 @@ export default class index extends Component {
<Tooltip title="编辑"> <Tooltip title="编辑">
<a <a
className="link-gray" className="link-gray"
onClick={() => this.onOpen(this.editForm, item)} onClick={() =>
this.onOpen({ modal: this.editForm, record: item })
}
> >
<AntIcon type="edit" /> <AntIcon type="edit" />
</a> </a>
@@ -280,9 +323,12 @@ export default class index extends Component {
if (isFunction) { if (isFunction) {
grids.push( grids.push(
<Card.Grid <Card.Grid
key={0}
style={{ padding: '18px 12px', cursor: 'pointer' }} style={{ padding: '18px 12px', cursor: 'pointer' }}
className="text-center" className="text-center"
onClick={() => this.onOpen(this.addForm, record, true)} onClick={() =>
this.onOpen({ modal: this.addForm, record, isParent: true, addType: [2] })
}
> >
<div> <div>
<AntIcon type="plus" className="text-normal h2" /> <AntIcon type="plus" className="text-normal h2" />
@@ -331,9 +377,11 @@ export default class index extends Component {
<Auth auth="sysMenu:add"> <Auth auth="sysMenu:add">
<Button <Button
icon={<AntIcon type="plus" />} icon={<AntIcon type="plus" />}
onClick={() => this.onOpen(this.addForm)} onClick={() =>
this.onOpen({ modal: this.addForm, addType: [0, 1] })
}
> >
新增{name} 新增目录/菜单
</Button> </Button>
</Auth> </Auth>
} }

View File

@@ -1,6 +1,14 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Button, Card, Form, Input, message as Message, Popconfirm } from 'antd' import { Button, Card, Form, Input, message as Message, Popconfirm } from 'antd'
import { AntIcon, Auth, Container, ModalForm, QueryTable, QueryTableActions, QueryTreeLayout } from 'components' import {
AntIcon,
Auth,
Container,
ModalForm,
QueryTable,
QueryTableActions,
QueryTreeLayout,
} from 'components'
import { api } from 'common/api' import { api } from 'common/api'
import auth from 'components/authorized/handler' import auth from 'components/authorized/handler'
import { toCamelCase } from 'util/format' import { toCamelCase } from 'util/format'
@@ -13,17 +21,16 @@ const apiAction = {
page: api.getOrgPage, page: api.getOrgPage,
add: api.sysOrgAdd, add: api.sysOrgAdd,
edit: api.sysOrgEdit, edit: api.sysOrgEdit,
delete: api.sysOrgDelete delete: api.sysOrgDelete,
} }
const name = '机构' const name = '机构'
export default class index extends Component { export default class index extends Component {
state = { state = {
codes: { codes: {
orgType: [] orgType: [],
} },
} }
// 树框架实例 // 树框架实例
@@ -44,13 +51,13 @@ export default class index extends Component {
columns = [ columns = [
{ {
title: '机构名称', title: '机构名称',
width: '400px', width: 400,
dataIndex: 'name', dataIndex: 'name',
sorter: true, sorter: true,
}, },
{ {
title: '唯一编码', title: '唯一编码',
width: '200px', width: 200,
dataIndex: 'code', dataIndex: 'code',
sorter: true, sorter: true,
}, },
@@ -58,24 +65,26 @@ export default class index extends Component {
title: '机构类型', title: '机构类型',
dataIndex: 'type', dataIndex: 'type',
sorter: true, sorter: true,
render: text => (<>{this.bindCodeValue(text, 'org_type')}</>) render: text => <>{this.bindCodeValue(text, 'org_type')}</>,
}, },
{ {
title: '排序', title: '排序',
width: '80px', width: 80,
dataIndex: 'sort', dataIndex: 'sort',
sorter: true, sorter: true,
defaultSortOrder: 'ascend',
}, },
{ {
title: '备注', title: '备注',
dataIndex: 'remark', dataIndex: 'remark',
width: 400,
sorter: true, sorter: true,
}, },
] ]
/** /**
* 构造函数,在渲染前动态添加操作字段等 * 构造函数,在渲染前动态添加操作字段等
* @param {*} props * @param {*} props
*/ */
constructor(props) { constructor(props) {
super(props) super(props)
@@ -87,20 +96,22 @@ export default class index extends Component {
title: '操作', title: '操作',
width: 150, width: 150,
dataIndex: 'actions', dataIndex: 'actions',
render: (text, record) => (<QueryTableActions> render: (text, record) => (
<Auth auth="sysOrg:edit"> <QueryTableActions>
<a onClick={() => this.onOpen(this.editForm, record)}>编辑</a> <Auth auth="sysOrg:edit">
</Auth> <a onClick={() => this.onOpen(this.editForm, record)}>编辑</a>
<Auth auth="sysOrg:delete"> </Auth>
<Popconfirm <Auth auth="sysOrg:delete">
placement="topRight" <Popconfirm
title="是否确认删除" placement="topRight"
onConfirm={() => this.onDelete(record)} title="是否确认删除"
> onConfirm={() => this.onDelete(record)}
<a>删除</a> >
</Popconfirm> <a>删除</a>
</Auth> </Popconfirm>
</QueryTableActions>) </Auth>
</QueryTableActions>
),
}) })
} }
} }
@@ -109,9 +120,9 @@ export default class index extends Component {
* 阻止外部组件引发的渲染,提升性能 * 阻止外部组件引发的渲染,提升性能
* 可自行添加渲染条件 * 可自行添加渲染条件
* [必要] * [必要]
* @param {*} props * @param {*} props
* @param {*} state * @param {*} state
* @returns * @returns
*/ */
shouldComponentUpdate(props, state) { shouldComponentUpdate(props, state) {
return !isEqual(this.state, state) return !isEqual(this.state, state)
@@ -124,26 +135,28 @@ export default class index extends Component {
componentDidMount() { componentDidMount() {
this.table.current.onLoading() this.table.current.onLoading()
getDictData('org_type').then(res => { getDictData('org_type').then(res => {
this.setState({ this.setState(
codes: res {
}, () => { codes: res,
this.table.current.onLoadData() },
}) () => {
this.table.current.onLoadData()
}
)
}) })
} }
/** /**
* 调用加载数据接口,可在调用前对query进行处理 * 调用加载数据接口,可在调用前对query进行处理
* [异步,必要] * [异步,必要]
* @param {*} params * @param {*} params
* @param {*} query * @param {*} query
* @returns * @returns
*/ */
loadData = async (params, query) => { loadData = async (params, query) => {
query = { query = {
...query, ...query,
pid: this.selectId pid: this.selectId,
} }
const { data } = await apiAction.page({ const { data } = await apiAction.page({
@@ -166,7 +179,7 @@ export default class index extends Component {
/** /**
* 树节点选中事件 * 树节点选中事件
* [必要] * [必要]
* @param {*} id * @param {*} id
*/ */
onSelectTree(id) { onSelectTree(id) {
this.selectId = id this.selectId = id
@@ -175,15 +188,15 @@ export default class index extends Component {
/** /**
* 绑定字典数据 * 绑定字典数据
* @param {*} code * @param {*} code
* @param {*} name * @param {*} name
* @returns * @returns
*/ */
bindCodeValue(code, name) { bindCodeValue(code, name) {
name = toCamelCase(name) name = toCamelCase(name)
const codes = this.state.codes[name] const codes = this.state.codes[name]
if (codes) { if (codes) {
const c = codes.find((p) => p.code === code) const c = codes.find(p => p.code == code)
if (c) { if (c) {
return c.value return c.value
} }
@@ -193,21 +206,21 @@ export default class index extends Component {
/** /**
* 打开新增/编辑弹窗 * 打开新增/编辑弹窗
* @param {*} modal * @param {*} modal
* @param {*} record * @param {*} record
*/ */
onOpen(modal, record) { onOpen(modal, record) {
modal.current.open({ modal.current.open({
orgId: this.selectId, orgId: this.selectId,
record record,
}) })
} }
/** /**
* 对表格上的操作进行统一处理 * 对表格上的操作进行统一处理
* [异步] * [异步]
* @param {*} action * @param {*} action
* @param {*} successMessage * @param {*} successMessage
*/ */
async onAction(action, successMessage) { async onAction(action, successMessage) {
this.table.current.onLoading() this.table.current.onLoading()
@@ -227,13 +240,10 @@ export default class index extends Component {
/** /**
* 删除 * 删除
* @param {*} record * @param {*} record
*/ */
onDelete(record) { onDelete(record) {
this.onAction( this.onAction(apiAction.delete(record), '删除成功')
apiAction.delete(record),
'删除成功'
)
} }
//#region 自定义方法 //#region 自定义方法
@@ -245,7 +255,7 @@ export default class index extends Component {
ref={this.treeLayout} ref={this.treeLayout}
loadData={this.loadTreeData} loadData={this.loadTreeData}
defaultExpanded={true} defaultExpanded={true}
onSelect={(key) => this.onSelectTree(key)} onSelect={key => this.onSelectTree(key)}
> >
<Container mode="fluid"> <Container mode="fluid">
<Card bordered={false}> <Card bordered={false}>
@@ -265,7 +275,9 @@ export default class index extends Component {
<Button <Button
icon={<AntIcon type="plus" />} icon={<AntIcon type="plus" />}
onClick={() => this.onOpen(this.addForm)} onClick={() => this.onOpen(this.addForm)}
>新增{name}</Button> >
新增{name}
</Button>
} }
/> />
</Card> </Card>

View File

@@ -2,24 +2,22 @@ import React, { Component } from 'react'
import { Button, Card, Form, Input, Popconfirm, message as Message } from 'antd' import { Button, Card, Form, Input, Popconfirm, message as Message } from 'antd'
import { isEqual } from 'lodash' import { isEqual } from 'lodash'
import { AntIcon, Auth, Container, ModalForm, QueryTable, QueryTableActions } from 'components' import { AntIcon, Auth, Container, ModalForm, QueryTable, QueryTableActions } from 'components'
import { api } from "common/api" import { api } from 'common/api'
import auth from 'components/authorized/handler' import auth from 'components/authorized/handler'
import FormBody from './form' import FormBody from './form'
// 配置页面所需接口函数 // 配置页面所需接口函数
const apiAction = { const apiAction = {
page: api.sysPosPage, page: api.sysPosPage,
add: api.sysPosAdd, add: api.sysPosAdd,
edit: api.sysPosEdit, edit: api.sysPosEdit,
delete: api.sysPosDelete delete: api.sysPosDelete,
} }
// 用于弹窗标题 // 用于弹窗标题
const name = '职位' const name = '职位'
export default class index extends Component { export default class index extends Component {
// 表格实例 // 表格实例
table = React.createRef() table = React.createRef()
@@ -32,29 +30,34 @@ export default class index extends Component {
{ {
title: '职位名称', title: '职位名称',
dataIndex: 'name', dataIndex: 'name',
width: 400,
sorter: true, sorter: true,
}, },
{ {
title: '唯一编码', title: '唯一编码',
dataIndex: 'code', dataIndex: 'code',
width: 400,
sorter: true, sorter: true,
}, },
{ {
title: '排序', title: '排序',
dataIndex: 'sort', dataIndex: 'sort',
width: 80,
sorter: true, sorter: true,
defaultSortOrder: 'ascend',
}, },
{ {
title: '备注', title: '备注',
dataIndex: 'remark', dataIndex: 'remark',
width: 400,
sorter: true, sorter: true,
}, },
] ]
/** /**
* 构造函数,在渲染前动态添加操作字段等 * 构造函数,在渲染前动态添加操作字段等
* @param {*} props * @param {*} props
*/ */
constructor(props) { constructor(props) {
super(props) super(props)
@@ -65,20 +68,22 @@ export default class index extends Component {
title: '操作', title: '操作',
width: 150, width: 150,
dataIndex: 'actions', dataIndex: 'actions',
render: (text, record) => (<QueryTableActions> render: (text, record) => (
<Auth auth="sysApp:edit"> <QueryTableActions>
<a onClick={() => this.onOpen(this.editForm, record)}>编辑</a> <Auth auth="sysApp:edit">
</Auth> <a onClick={() => this.onOpen(this.editForm, record)}>编辑</a>
<Auth auth="sysApp:delete"> </Auth>
<Popconfirm <Auth auth="sysApp:delete">
placement="topRight" <Popconfirm
title="是否确认删除" placement="topRight"
onConfirm={() => this.onDelete(record)} title="是否确认删除"
> onConfirm={() => this.onDelete(record)}
<a>删除</a> >
</Popconfirm> <a>删除</a>
</Auth> </Popconfirm>
</QueryTableActions>) </Auth>
</QueryTableActions>
),
}) })
} }
} }
@@ -87,9 +92,9 @@ export default class index extends Component {
* 阻止外部组件引发的渲染,提升性能 * 阻止外部组件引发的渲染,提升性能
* 可自行添加渲染条件 * 可自行添加渲染条件
* [必要] * [必要]
* @param {*} props * @param {*} props
* @param {*} state * @param {*} state
* @returns * @returns
*/ */
shouldComponentUpdate(props, state) { shouldComponentUpdate(props, state) {
return !isEqual(this.state, state) return !isEqual(this.state, state)
@@ -98,9 +103,9 @@ export default class index extends Component {
/** /**
* 调用加载数据接口,可在调用前对query进行处理 * 调用加载数据接口,可在调用前对query进行处理
* [异步,必要] * [异步,必要]
* @param {*} params * @param {*} params
* @param {*} query * @param {*} query
* @returns * @returns
*/ */
loadData = async (params, query) => { loadData = async (params, query) => {
const { data } = await apiAction.page({ const { data } = await apiAction.page({
@@ -111,21 +116,21 @@ export default class index extends Component {
} }
/** /**
* 打开新增/编辑弹窗 * 打开新增/编辑弹窗
* @param {*} modal * @param {*} modal
* @param {*} record * @param {*} record
*/ */
onOpen(modal, record) { onOpen(modal, record) {
modal.current.open({ modal.current.open({
record record,
}) })
} }
/** /**
* 对表格上的操作进行统一处理 * 对表格上的操作进行统一处理
* [异步] * [异步]
* @param {*} action * @param {*} action
* @param {*} successMessage * @param {*} successMessage
*/ */
async onAction(action, successMessage) { async onAction(action, successMessage) {
this.table.current.onLoading() this.table.current.onLoading()
@@ -140,13 +145,10 @@ export default class index extends Component {
/** /**
* 删除 * 删除
* @param {*} record * @param {*} record
*/ */
onDelete(record) { onDelete(record) {
this.onAction( this.onAction(apiAction.delete(record), '删除成功')
apiAction.delete(record),
'删除成功'
)
} }
render() { render() {
@@ -172,11 +174,11 @@ export default class index extends Component {
<Button <Button
icon={<AntIcon type="plus" />} icon={<AntIcon type="plus" />}
onClick={() => this.onOpen(this.addForm)} onClick={() => this.onOpen(this.addForm)}
>新增{name}</Button> >
新增{name}
</Button>
} }
> ></QueryTable>
</QueryTable>
</Card> </Card>
<ModalForm <ModalForm
title={`新增${name}`} title={`新增${name}`}
@@ -198,4 +200,4 @@ export default class index extends Component {
</Container> </Container>
) )
} }
} }

View File

@@ -16,14 +16,13 @@ const apiAction = {
delete: api.sysRoleDelete, delete: api.sysRoleDelete,
grantMenu: api.sysRoleGrantMenu, grantMenu: api.sysRoleGrantMenu,
grantData: api.sysRoleGrantData grantData: api.sysRoleGrantData,
} }
// 用于弹窗标题 // 用于弹窗标题
const name = '角色' const name = '角色'
export default class index extends Component { export default class index extends Component {
// 表格实例 // 表格实例
table = React.createRef() table = React.createRef()
@@ -39,23 +38,27 @@ export default class index extends Component {
{ {
title: '角色名', title: '角色名',
dataIndex: 'name', dataIndex: 'name',
width: 400,
sorter: true, sorter: true,
}, },
{ {
title: '唯一编码', title: '唯一编码',
dataIndex: 'code', dataIndex: 'code',
width: 400,
sorter: true, sorter: true,
}, },
{ {
title: '排序', title: '排序',
dataIndex: 'sort', dataIndex: 'sort',
width: 80,
sorter: true, sorter: true,
} defaultSortOrder: 'ascend',
},
] ]
/** /**
* 构造函数,在渲染前动态添加操作字段等 * 构造函数,在渲染前动态添加操作字段等
* @param {*} props * @param {*} props
*/ */
constructor(props) { constructor(props) {
super(props) super(props)
@@ -67,44 +70,58 @@ export default class index extends Component {
title: '操作', title: '操作',
width: 150, width: 150,
dataIndex: 'actions', dataIndex: 'actions',
render: (text, record) => (<QueryTableActions> render: (text, record) => (
<Auth auth="sysRole:edit"> <QueryTableActions>
<a onClick={() => this.onOpen(this.editForm, record)}>编辑</a> <Auth auth="sysRole:edit">
</Auth> <a onClick={() => this.onOpen(this.editForm, record)}>编辑</a>
<Auth auth="sysRole:delete"> </Auth>
<Popconfirm <Auth auth="sysRole:delete">
placement="topRight" <Popconfirm
title="是否确认删除" placement="topRight"
onConfirm={() => this.onDelete(record)} title="是否确认删除"
> onConfirm={() => this.onDelete(record)}
<a>删除</a> >
</Popconfirm> <a>删除</a>
</Auth> </Popconfirm>
<Auth auth={{ sysRole: [['grantMenu'], ['grantData']] }}> </Auth>
<Dropdown <Auth auth={{ sysRole: [['grantMenu'], ['grantData']] }}>
placement="bottomRight" <Dropdown
overlay={ placement="bottomRight"
<Menu> overlay={
<Auth auth="sysRole:grantMenu"> <Menu>
<Menu.Item> <Auth auth="sysRole:grantMenu">
<a onClick={() => this.onOpen(this.menuForm, record)}>授权菜单</a> <Menu.Item>
</Menu.Item> <a
</Auth> onClick={() =>
<Auth auth="sysRole:grantData"> this.onOpen(this.menuForm, record)
<Menu.Item> }
<a onClick={() => this.onOpen(this.dataForm, record)}>授权数据</a> >
</Menu.Item> 授权菜单
</Auth> </a>
</Menu> </Menu.Item>
} </Auth>
> <Auth auth="sysRole:grantData">
<a className="ant-dropdown-link"> <Menu.Item>
授权 <a
<AntIcon type="down" /> onClick={() =>
</a> this.onOpen(this.dataForm, record)
</Dropdown> }
</Auth> >
</QueryTableActions>) 授权数据
</a>
</Menu.Item>
</Auth>
</Menu>
}
>
<a className="ant-dropdown-link">
授权
<AntIcon type="down" />
</a>
</Dropdown>
</Auth>
</QueryTableActions>
),
}) })
} }
} }
@@ -113,9 +130,9 @@ export default class index extends Component {
* 阻止外部组件引发的渲染,提升性能 * 阻止外部组件引发的渲染,提升性能
* 可自行添加渲染条件 * 可自行添加渲染条件
* [必要] * [必要]
* @param {*} props * @param {*} props
* @param {*} state * @param {*} state
* @returns * @returns
*/ */
shouldComponentUpdate(props, state) { shouldComponentUpdate(props, state) {
return !isEqual(this.state, state) return !isEqual(this.state, state)
@@ -124,9 +141,9 @@ export default class index extends Component {
/** /**
* 调用加载数据接口,可在调用前对query进行处理 * 调用加载数据接口,可在调用前对query进行处理
* [异步,必要] * [异步,必要]
* @param {*} params * @param {*} params
* @param {*} query * @param {*} query
* @returns * @returns
*/ */
loadData = async (params, query) => { loadData = async (params, query) => {
const { data } = await apiAction.page({ const { data } = await apiAction.page({
@@ -138,20 +155,20 @@ export default class index extends Component {
/** /**
* 打开新增/编辑弹窗 * 打开新增/编辑弹窗
* @param {*} modal * @param {*} modal
* @param {*} record * @param {*} record
*/ */
onOpen(modal, record) { onOpen(modal, record) {
modal.current.open({ modal.current.open({
record record,
}) })
} }
/** /**
* 对表格上的操作进行统一处理 * 对表格上的操作进行统一处理
* [异步] * [异步]
* @param {*} action * @param {*} action
* @param {*} successMessage * @param {*} successMessage
*/ */
async onAction(action, successMessage) { async onAction(action, successMessage) {
this.table.current.onLoading() this.table.current.onLoading()
@@ -166,13 +183,10 @@ export default class index extends Component {
/** /**
* 删除 * 删除
* @param {*} record * @param {*} record
*/ */
onDelete(record) { onDelete(record) {
this.onAction( this.onAction(apiAction.delete(record), '删除成功')
apiAction.delete(record),
'删除成功'
)
} }
//#region 自定义方法 //#region 自定义方法
@@ -202,7 +216,9 @@ export default class index extends Component {
<Button <Button
icon={<AntIcon type="plus" />} icon={<AntIcon type="plus" />}
onClick={() => this.onOpen(this.addForm)} onClick={() => this.onOpen(this.addForm)}
>新增{name}</Button> >
新增{name}
</Button>
</Auth> </Auth>
} }
/> />

View File

@@ -20,7 +20,7 @@ export default class data extends Component {
form = React.createRef() form = React.createRef()
// 初始化数据 // 初始化数据
record = {} id = ''
/** /**
* mount后回调 * mount后回调
@@ -29,11 +29,11 @@ export default class data extends Component {
this.props.created && this.props.created(this) this.props.created && this.props.created(this)
} }
async fillData(params) { async fillData(params) {
this.record = cloneDeep(params.record) this.id = params.id
//#region 从后端转换成前段所需格式 //#region 从后端转换成前段所需格式
const orgData = await this.loadOrgData() const orgData = await this.loadOrgData()
const areaData = await this.loadAreaData() const areaData = await this.loadAreaData()
const orgCheckedKeys = await this.loadMemberOwn(this.record.id) const orgCheckedKeys = await this.loadMemberOwn(this.id)
this.setState({ this.setState({
options: { options: {
orgData, orgData,
@@ -42,7 +42,7 @@ export default class data extends Component {
}, },
}) })
this.form.current.setFieldsValue({ this.form.current.setFieldsValue({
id: this.record.id, id: this.id,
grantOrgIdList: orgCheckedKeys, grantOrgIdList: orgCheckedKeys,
grantAreaCodeList: [], grantAreaCodeList: [],
}) })
@@ -63,8 +63,8 @@ export default class data extends Component {
const valid = await form.validateFields() const valid = await form.validateFields()
if (valid) { if (valid) {
const postData = form.getFieldsValue() const postData = form.getFieldsValue()
if (this.record) { if (this.id) {
postData.id = this.record.id postData.id = this.id
} }
//#region 从前段转换后端所需格式 //#region 从前段转换后端所需格式
//#endregion //#endregion

View File

@@ -1,5 +1,17 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Button, Row, Col, Form, Input, DatePicker, Radio, Table, Select, Spin, TreeSelect } from 'antd' import {
Button,
Row,
Col,
Form,
Input,
DatePicker,
Radio,
Table,
Select,
Spin,
TreeSelect,
} from 'antd'
import { AntIcon } from 'components' import { AntIcon } from 'components'
import { cloneDeep } from 'lodash' import { cloneDeep } from 'lodash'
import getDictData from 'util/dic' import getDictData from 'util/dic'
@@ -9,25 +21,24 @@ import moment from 'moment'
const initialValues = { const initialValues = {
sex: 0, sex: 0,
sysEmpParam: {} sysEmpParam: {},
} }
export default class form extends Component { export default class form extends Component {
state = { state = {
// 加载状态 // 加载状态
loading: true, loading: true,
codes: { codes: {
orgType: [] orgType: [],
}, },
options: { options: {
orgData: [], orgData: [],
posData: [] posData: [],
}, },
sysEmpParam: { sysEmpParam: {
extIds: [] extIds: [],
} },
} }
extColumns = [ extColumns = [
{ {
@@ -45,7 +56,7 @@ export default class form extends Component {
placeholder="请选择附加组织机构" placeholder="请选择附加组织机构"
/> />
</Form.Item> </Form.Item>
) ),
}, },
{ {
title: '附属岗位', title: '附属岗位',
@@ -56,33 +67,28 @@ export default class form extends Component {
<Select <Select
defaultValue={text} defaultValue={text}
className="w-100-p" className="w-100-p"
placeholder="请选择附加职位信息"> placeholder="请选择附加职位信息"
{ >
this.state.options.posData.map(item => { {this.state.options.posData.map(item => {
return <Select.Option return (
key={item.id} <Select.Option key={item.id} value={item.id}>
value={item.id} {item.name}
> </Select.Option>
{item.name}</Select.Option> )
}) })}
}
</Select> </Select>
</Form.Item> </Form.Item>
) ),
}, },
{ {
title: '操作', title: '操作',
key: 'action', key: 'action',
width: '70px', width: '70px',
render: (text, record) => ( render: (text, record) => (
<Button <Button onClick={() => this.onRemoveExtData(record)} size="small" danger>
onClick={() => this.onRemoveExtData(record)}
size="small"
danger
>
删除 删除
</Button> </Button>
) ),
}, },
] ]
// 表单实例 // 表单实例
@@ -102,11 +108,13 @@ export default class form extends Component {
* 填充数据 * 填充数据
* 可以在设置this.record之后对其作出数据结构调整 * 可以在设置this.record之后对其作出数据结构调整
* [异步,必要] * [异步,必要]
* @param {*} params * @param {*} params
*/ */
async fillData(params) { async fillData(params) {
this.record = cloneDeep(params.record || {})
//#region 从后端转换成前段所需格式 //#region 从后端转换成前段所需格式
if (params.id) {
this.record = (await api.sysUserDetail({ id: params.id })).data
}
const orgData = await this.loadOrgData() const orgData = await this.loadOrgData()
const posData = await this.loadPosData() const posData = await this.loadPosData()
const codes = await getDictData('org_type') const codes = await getDictData('org_type')
@@ -118,17 +126,17 @@ export default class form extends Component {
// 提交的时候是"param",而获取下来却是"info",在这里转换一下 // 提交的时候是"param",而获取下来却是"info",在这里转换一下
if (this.record.sysEmpInfo) { if (this.record.sysEmpInfo) {
this.record.sysEmpParam = this.record.sysEmpInfo; this.record.sysEmpParam = this.record.sysEmpInfo
delete this.record.sysEmpInfo; delete this.record.sysEmpInfo
} else if (!this.record.sysEmpParam) { } else if (!this.record.sysEmpParam) {
this.record.sysEmpParam = { this.record.sysEmpParam = {
extIds: [], extIds: [],
}; }
} }
// 转换职位信息列表 // 转换职位信息列表
if (this.record.sysEmpParam.positions) { if (this.record.sysEmpParam.positions) {
this.record.sysEmpParam.posIdList = this.record.sysEmpParam.positions.map((p) => p.posId); this.record.sysEmpParam.posIdList = this.record.sysEmpParam.positions.map(p => p.posId)
} }
// 附加信息 // 附加信息
@@ -138,12 +146,12 @@ export default class form extends Component {
key: i, key: i,
orgId: p.orgId, orgId: p.orgId,
posId: p.posId, posId: p.posId,
}; }
}); })
} }
if (params.orgId) { if (params.orgId) {
this.record.sysEmpParam.orgId = params.orgId; this.record.sysEmpParam.orgId = params.orgId
} }
this.setState({ this.setState({
@@ -154,18 +162,18 @@ export default class form extends Component {
posData, posData,
}, },
sysEmpParam: { sysEmpParam: {
...this.record.sysEmpParam ...this.record.sysEmpParam,
} },
}) })
this.record = { this.record = {
...this.record ...this.record,
} }
//#endregion //#endregion
this.form.current.setFieldsValue(this.record) this.form.current.setFieldsValue(this.record)
this.setState({ this.setState({
loading: false loading: false,
}) })
} }
@@ -173,7 +181,7 @@ export default class form extends Component {
* 获取数据 * 获取数据
* 可以对postData进行数据结构调整 * 可以对postData进行数据结构调整
* [异步,必要] * [异步,必要]
* @returns * @returns
*/ */
async getData() { async getData() {
const form = this.form.current const form = this.form.current
@@ -206,24 +214,26 @@ export default class form extends Component {
const record = { const record = {
key: extIds.length > 0 ? extIds[extIds.length - 1].key + 1 : 0, key: extIds.length > 0 ? extIds[extIds.length - 1].key + 1 : 0,
orgId: undefined, orgId: undefined,
posId: undefined posId: undefined,
} }
this.setState({ this.setState(
sysEmpParam: { {
extIds: [...extIds, record] sysEmpParam: {
extIds: [...extIds, record],
},
},
() => {
console.log(this.form.current.getFieldsValue())
} }
}, () => { )
console.log(this.form.current.getFieldsValue())
})
} }
onRemoveExtData(record) { onRemoveExtData(record) {
const ext = this.state.sysEmpParam.extIds, const ext = this.state.sysEmpParam.extIds,
remove = ext.find((p) => p.key === record.key), remove = ext.find(p => p.key === record.key),
index = ext.indexOf(remove); index = ext.indexOf(remove)
ext.splice(index, 1); ext.splice(index, 1)
console.log(ext) console.log(ext)
// this.form.current.setFieldsValue({ // this.form.current.setFieldsValue({
@@ -232,14 +242,16 @@ export default class form extends Component {
// } // }
// }) // })
this.setState({ this.setState(
sysEmpParam: { {
extIds: ext sysEmpParam: {
extIds: ext,
},
},
() => {
//console.log(this.form.current.getFieldsValue())
} }
}, () => { )
//console.log(this.form.current.getFieldsValue())
})
} }
//#endregion //#endregion
renderExtInfoTable() { renderExtInfoTable() {
@@ -251,79 +263,100 @@ export default class form extends Component {
pagination={false} pagination={false}
size="small" size="small"
bordered bordered
rowKey={(record) => record.key} rowKey={record => record.key}
footer={ footer={() => (
() => <Button
<Button block
block icon={<AntIcon type="plus" />}
icon={ type="dashed"
<AntIcon type="plus" /> onClick={() => this.onAddExtData()}
} >
type="dashed" 新增一项
onClick={() => this.onAddExtData()}> </Button>
新增一项</Button> )}
} ></Table>
>
</Table>
) )
} }
render() { render() {
return ( return (
<Form <Form initialValues={initialValues} ref={this.form} className="yo-form">
initialValues={initialValues} <Spin spinning={this.state.loading} indicator={<AntIcon type="loading" />}>
ref={this.form}
className="yo-form"
>
<Spin
spinning={this.state.loading}
indicator={<AntIcon type="loading" />}>
<h3 className="h3">基本信息</h3> <h3 className="h3">基本信息</h3>
<div className="yo-form-group"> <div className="yo-form-group">
<Form.Item label="账号" name="account" rules={[{ required: true, message: '请输入账号', trigger: 'blur' }]}> <Form.Item
label="账号"
name="account"
rules={[{ required: true, message: '请输入账号', trigger: 'blur' }]}
>
<Input autoComplete="off" placeholder="请输入账号" /> <Input autoComplete="off" placeholder="请输入账号" />
</Form.Item> </Form.Item>
<Form.Item label="姓名" name="name" rules={[{ required: true, message: '请输入姓名', trigger: 'blur' }]}> <Form.Item
label="姓名"
name="name"
rules={[{ required: true, message: '请输入姓名', trigger: 'blur' }]}
>
<Input autoComplete="off" placeholder="请输入姓名" /> <Input autoComplete="off" placeholder="请输入姓名" />
</Form.Item> </Form.Item>
{this.props.mode == 'add' && <> {this.props.mode == 'add' && (
<Form.Item label="密码" name="password" rules={[{ required: true, message: '请输入密码', trigger: 'blur' }]}> <>
<Input.Password autoComplete="off" placeholder="请输入密码" /> <Form.Item
</Form.Item> label="密码"
<Form.Item label="确认密码" name="confirm" rules={[{ required: true, message: '请确认密码', trigger: 'blur' }]}> name="password"
<Input.Password autoComplete="off" placeholder="请确认密码" /> rules={[
</Form.Item> { required: true, message: '请输入密码', trigger: 'blur' },
</> ]}
} >
<Form.Item label="昵称" name="nickName" > <Input.Password autoComplete="off" placeholder="请输入密码" />
</Form.Item>
<Form.Item
label="确认密码"
name="confirm"
rules={[
{ required: true, message: '请确认密码', trigger: 'blur' },
]}
>
<Input.Password autoComplete="off" placeholder="请确认密码" />
</Form.Item>
</>
)}
<Form.Item label="昵称" name="nickName">
<Input autoComplete="off" placeholder="请输入昵称" /> <Input autoComplete="off" placeholder="请输入昵称" />
</Form.Item> </Form.Item>
<Form.Item label="生日" name="birthday" > <Form.Item label="生日" name="birthday">
<DatePicker className="w-100-p" /> <DatePicker className="w-100-p" />
</Form.Item> </Form.Item>
<Form.Item label="性别" name="sex" > <Form.Item label="性别" name="sex">
<Radio.Group > <Radio.Group>
<Radio.Button value={0}> <Radio.Button value={0}>
<AntIcon className="mr-xxs" type="stop" /> <AntIcon className="mr-xxs" type="stop" />
<span>保密</span> <span>保密</span>
</Radio.Button> </Radio.Button>
<Radio.Button value={1}> <Radio.Button value={1}>
<AntIcon style={{ color: '#1890ff' }} className="mr-xxs" type="man" /> <AntIcon
style={{ color: '#1890ff' }}
className="mr-xxs"
type="man"
/>
<span></span> <span></span>
</Radio.Button> </Radio.Button>
<Radio.Button value={2}> <Radio.Button value={2}>
<AntIcon style={{ color: '#eb2f96' }} className="mr-xxs" type="woman" /> <AntIcon
style={{ color: '#eb2f96' }}
className="mr-xxs"
type="woman"
/>
<span></span> <span></span>
</Radio.Button> </Radio.Button>
</Radio.Group> </Radio.Group>
</Form.Item> </Form.Item>
<Form.Item label="邮箱" name="email" > <Form.Item label="邮箱" name="email">
<Input autoComplete="off" placeholder="请输入邮箱" /> <Input autoComplete="off" placeholder="请输入邮箱" />
</Form.Item> </Form.Item>
<Form.Item label="手机号" name="phone" > <Form.Item label="手机号" name="phone">
<Input autoComplete="off" placeholder="请输入手机号" /> <Input autoComplete="off" placeholder="请输入手机号" />
</Form.Item> </Form.Item>
<Form.Item label="电话" name="tel" > <Form.Item label="电话" name="tel">
<Input autoComplete="off" placeholder="请输入电话" /> <Input autoComplete="off" placeholder="请输入电话" />
</Form.Item> </Form.Item>
</div> </div>
@@ -332,7 +365,8 @@ export default class form extends Component {
<Form.Item <Form.Item
label="所属组织机构" label="所属组织机构"
name={['sysEmpParam', 'orgId']} name={['sysEmpParam', 'orgId']}
rules={[{ required: true, message: '所属组织机构' }]}> rules={[{ required: true, message: '所属组织机构' }]}
>
<TreeSelect <TreeSelect
treeData={this.state.options.orgData} treeData={this.state.options.orgData}
dropdownStyle={{ maxHeight: '300px', overflow: 'auto' }} dropdownStyle={{ maxHeight: '300px', overflow: 'auto' }}
@@ -340,26 +374,18 @@ export default class form extends Component {
placeholder="请选择所属组织机构" placeholder="请选择所属组织机构"
/> />
</Form.Item> </Form.Item>
<Form.Item <Form.Item label="工号" name={['sysEmpParam', 'jobNum']}>
label="工号" <Input autoComplete="off" placeholder="请输入工号" />
name={['sysEmpParam', 'jobNum']} >
<Input
autoComplete="off"
placeholder="请输入工号" />
</Form.Item> </Form.Item>
<Form.Item label="职位信息" name={['sysEmpParam', 'posIdList']}> <Form.Item label="职位信息" name={['sysEmpParam', 'posIdList']}>
<Select <Select mode="multiple" placeholder="请选择职位信息">
mode="multiple" {this.state.options.posData.map(item => {
placeholder="请选择职位信息"> return (
{ <Select.Option key={item.id} value={item.id}>
this.state.options.posData.map(item => { {item.name}
return <Select.Option </Select.Option>
key={item.id} )
value={item.id} })}
>
{item.name}</Select.Option>
})
}
</Select> </Select>
</Form.Item> </Form.Item>
</div> </div>

View File

@@ -21,6 +21,7 @@ import getDictData from 'util/dic'
import FormBody from './form' import FormBody from './form'
import RoleForm from './role' import RoleForm from './role'
import DataForm from './data' import DataForm from './data'
import auth from 'components/authorized/handler'
// 配置页面所需接口函数 // 配置页面所需接口函数
const apiAction = { const apiAction = {
@@ -154,12 +155,12 @@ export default class index extends Component {
/** /**
* 打开新增/编辑弹窗 * 打开新增/编辑弹窗
* @param {*} modal * @param {*} modal
* @param {*} record * @param {*} id
*/ */
onOpen(modal, record) { onOpen(modal, id) {
modal.current.open({ modal.current.open({
orgId: this.selectId, orgId: this.selectId,
record, id,
}) })
} }
@@ -190,44 +191,45 @@ export default class index extends Component {
//#region 自定义方法 //#region 自定义方法
renderItem(record) { renderItem(record) {
const { id, account, name, nickName, avatar, sex, phone, email, status } = record
return ( return (
<List.Item <List.Item
key={record.id} key={id}
actions={[ actions={[
<Auth auth="sysUser:edit"> <Auth auth="sysUser:edit">
<a onClick={() => this.onOpen(this.editForm, record)}>编辑</a> <a onClick={() => this.onOpen(this.editForm, id)}>编辑</a>
</Auth>, </Auth>,
<Auth auth="sysOrg:delete"> <Auth auth="sysOrg:delete">
<Popconfirm <Popconfirm
placement="topRight" placement="topRight"
title="是否确认删除" title="是否确认删除"
onConfirm={() => this.onDelete(record)} onConfirm={() => this.onDelete(id)}
> >
<a>删除</a> <a>删除</a>
</Popconfirm> </Popconfirm>
</Auth>, </Auth>,
<Auth aut="sysUser:resetPwd"> <Auth aut="sysUser:resetPwd">
<a onClick={() => this.onResetPassword(record)}>重置密码</a> <a onClick={() => this.onResetPassword(id)}>重置密码</a>
</Auth>, </Auth>,
<Auth auth={{ sysRole: [['grantRole'], ['grantData']] }}> <Auth auth={{ sysUser: [['grantRole'], ['grantData']] }}>
<Dropdown <Dropdown
placement="bottomRight" placement="bottomRight"
overlay={ overlay={
<Menu> <Menu>
<Auth auth="sysRole:grantRole"> {auth('sysUser:grantRole') && (
<Menu.Item> <Menu.Item key="1">
<a onClick={() => this.onOpen(this.roleForm, record)}> <a onClick={() => this.onOpen(this.roleForm, id)}>
授权角色 授权角色
</a> </a>
</Menu.Item> </Menu.Item>
</Auth> )}
<Auth auth="sysRole:grantData"> {auth('sysUser:grantData') && (
<Menu.Item> <Menu.Item key="2">
<a onClick={() => this.onOpen(this.dataForm, record)}> <a onClick={() => this.onOpen(this.dataForm, id)}>
授权额外数据 授权额外数据
</a> </a>
</Menu.Item> </Menu.Item>
</Auth> )}
</Menu> </Menu>
} }
> >
@@ -245,29 +247,28 @@ export default class index extends Component {
type="avatar" type="avatar"
shape="square" shape="square"
size={48} size={48}
id={record.avatar} id={avatar}
icon={<AntIcon type="user" />} icon={<AntIcon type="user" />}
/> />
} }
title={record.nickName || record.name} title={nickName || name}
description={record.account} description={account}
/> />
<Descriptions className="flex-1" column={2}> <Descriptions className="flex-1" column={2}>
<Descriptions.Item label="性别"> <Descriptions.Item label="性别">
{this.bindCodeValue(record.sex, 'sex')} {this.bindCodeValue(sex, 'sex')}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label="手机">{record.phone || '未设置'}</Descriptions.Item> <Descriptions.Item label="手机">{phone || '未设置'}</Descriptions.Item>
<Descriptions.Item label="邮箱">{record.email || '未设置'}</Descriptions.Item> <Descriptions.Item label="邮箱">{email || '未设置'}</Descriptions.Item>
</Descriptions> </Descriptions>
<div className="yo-list-content--h"> <div className="yo-list-content--h">
<Auth auth="sysUser:changeStatus"> <Auth auth="sysUser:changeStatus">
<div className="yo-list-content--h--item text-center"> <div className="yo-list-content--h--item text-center">
<Switch <Switch
checked={!record.status} checked={!status}
loading={record.statusChanging}
checkedChildren={this.bindCodeValue(0, 'common_status')} checkedChildren={this.bindCodeValue(0, 'common_status')}
unCheckedChildren={this.bindCodeValue(1, 'common_status')} unCheckedChildren={this.bindCodeValue(1, 'common_status')}
onChange={checked => this.onSetUserStatus(record, checked)} onChange={checked => this.onSetUserStatus(id, checked)}
/> />
</div> </div>
</Auth> </Auth>
@@ -276,12 +277,12 @@ export default class index extends Component {
) )
} }
onSetUserStatus(record, checked) { onSetUserStatus(id, checked) {
this.onAction(apiAction.changeStatus({ id: record.id, status: +!checked }), '设置成功') this.onAction(apiAction.changeStatus({ id, status: +!checked }), '设置成功')
} }
onResetPassword(record) { onResetPassword(id) {
this.onAction(apiAction.resetPwd(record), '重置成功') this.onAction(apiAction.resetPwd({ id }), '重置成功')
} }
//#endregion //#endregion

View File

@@ -19,7 +19,7 @@ export default class role extends Component {
form = React.createRef() form = React.createRef()
// 初始化数据 // 初始化数据
record = {} id = ''
/** /**
* mount后回调 * mount后回调
@@ -28,10 +28,10 @@ export default class role extends Component {
this.props.created && this.props.created(this) this.props.created && this.props.created(this)
} }
async fillData(params) { async fillData(params) {
this.record = cloneDeep(params.record) this.id = params.id
//#region 从后端转换成前段所需格式 //#region 从后端转换成前段所需格式
const roleData = await this.loadRoleData() const roleData = await this.loadRoleData()
const roles = await this.loadRole(this.record.id) const roles = await this.loadRole(this.id)
this.setState({ this.setState({
options: { options: {
roleData, roleData,
@@ -39,7 +39,7 @@ export default class role extends Component {
roles, roles,
}) })
this.form.current.setFieldsValue({ this.form.current.setFieldsValue({
id: this.record.id, id: this.id,
grantRoleIdList: roles, grantRoleIdList: roles,
}) })
@@ -59,8 +59,8 @@ export default class role extends Component {
const valid = await form.validateFields() const valid = await form.validateFields()
if (valid) { if (valid) {
const postData = form.getFieldsValue() const postData = form.getFieldsValue()
if (this.record) { if (this.id) {
postData.id = this.record.id postData.id = this.id
} }
//#region 从前段转换后端所需格式 //#region 从前段转换后端所需格式
//#endregion //#endregion

View File

@@ -1,6 +1,21 @@
const layout = (state = { import { SETTING_KEY } from "common/storage"
siderCollapsed: false import { SIDER_BREAK_POINT } from "util/global"
}, action) => {
const defaultState = {
siderCollapsed: false,
allowSiderCollapsed: true
}
const localStorageState = () => {
return JSON.parse(window.localStorage.getItem(SETTING_KEY)) || {}
}
const mergeState = {
...defaultState,
...localStorageState()
}
const layout = (state = mergeState, action) => {
switch (action.type) { switch (action.type) {
// 打开窗口 // 打开窗口
case 'OPEN_WINDOW': case 'OPEN_WINDOW':
@@ -13,8 +28,23 @@ const layout = (state = {
return state return state
// 侧边收起状态 // 侧边收起状态
case 'TOGGLE_COLLAPSED': case 'TOGGLE_COLLAPSED':
const _state = { ...state, siderCollapsed: action.siderCollapsed } {
return _state if (window.innerWidth <= SIDER_BREAK_POINT) {
return state
}
const _state = { ...state, siderCollapsed: action.siderCollapsed }
window.localStorage.setItem(SETTING_KEY, JSON.stringify(_state))
return _state
}
case 'AUTO_TOGGLE_COLLAPSED':
{
const _state = {
...state,
siderCollapsed: localStorageState().siderCollapsed || action.siderCollapsed,
allowSiderCollapsed: !action.siderCollapsed
}
return _state
}
default: default:
return state return state
} }

View File

@@ -36,4 +36,6 @@ export const RSA_PUBLIC_KEY = '-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQU
/** /**
* 城市名称 * 城市名称
*/ */
export const CITY = '黄石市' export const CITY = '黄石市'
export const SIDER_BREAK_POINT = 1366

View File

@@ -20,7 +20,6 @@ class ComponentDynamic extends Component {
if (this.props.onRef) { if (this.props.onRef) {
this.props.onRef(this) this.props.onRef(this)
} }
return true return true
} }
@@ -73,6 +72,40 @@ class ComponentDynamic extends Component {
} }
} }
class Iframe extends Component {
shouldComponentUpdate() {
if (this.props.onRef) {
this.props.onRef(this)
}
return true
}
componentDidMount() {
if (this.props.onRef) {
this.props.onRef(this)
}
this.loadComponent()
}
loadComponent() {
NProgress.start()
const iframe = this.refs.content
iframe.onload = () => {
NProgress.done()
}
iframe.onerror = () => {
NProgress.done()
}
iframe.src = this.props.src
}
render() {
const { title } = this.props
return <iframe ref="content" title={title} />
}
}
export default class index extends Component { export default class index extends Component {
state = { state = {
actived: '', actived: '',
@@ -191,14 +224,23 @@ export default class index extends Component {
' yo-tab-external-tabpane' ' yo-tab-external-tabpane'
} }
> >
<ComponentDynamic {pane.openType === 1 ? (
path={pane.path} <ComponentDynamic
id={pane.key} path={pane.path}
key={pane.key} id={pane.key}
param={pane.param} key={pane.key}
paneActived={pane.key === actived} param={pane.param}
onRef={p => this.panes.push(p)} paneActived={pane.key === actived}
/> onRef={p => this.panes.push(p)}
/>
) : pane.openType === 2 ? (
<Iframe
src={pane.path}
title={pane.key}
id={pane.key}
onRef={p => this.panes.push(p)}
/>
) : null}
</div> </div>
) )
})} })}

View File

@@ -33,13 +33,20 @@ export default class index extends Component {
} }
render() { render() {
const { allowSiderCollapsed } = this.state
return ( return (
<Layout.Header> <Layout.Header>
<Container mode="fluid"> <Container mode="fluid">
<div className="header-actions"> <div className="header-actions">
<span className="header-action mr-md" onClick={() => this.onCollapsed()}> {allowSiderCollapsed && (
<AntIcon type="menu" /> <span
</span> className="header-action mr-md"
onClick={() => this.onCollapsed()}
>
<AntIcon type="menu" />
</span>
)}
<Logo /> <Logo />
<Search /> <Search />
</div> </div>

View File

@@ -78,7 +78,7 @@ export default class search extends Component {
} }
onSelect(value, option) { onSelect(value, option) {
const { id, meta, component } = option.menu const { id, meta, component, link, redirect, openType } = option.menu
// 选中时清空输入框内容,并失去焦点 // 选中时清空输入框内容,并失去焦点
this.setState({ searchValue: '' }) this.setState({ searchValue: '' })
@@ -88,7 +88,19 @@ export default class search extends Component {
key: id, key: id,
title: meta.title, title: meta.title,
icon: meta.icon, icon: meta.icon,
path: component, path: (() => {
switch (openType) {
case 1:
return component
case 2:
return link
case 3:
return redirect
default:
return null
}
})(),
openType,
}) })
} }

View File

@@ -76,7 +76,7 @@ class User extends Component {
)} )}
{user.roles && {user.roles &&
user.roles.map(role => ( user.roles.map(role => (
<Tag color="purple" className="mb-xs"> <Tag key={role.id} color="purple" className="mb-xs">
{role.name} {role.name}
</Tag> </Tag>
))} ))}

View File

@@ -9,8 +9,7 @@ Swiper.use([Mousewheel, Scrollbar])
const { getState, subscribe } = store const { getState, subscribe } = store
let timer, let timer, swiper
swiper
const siderSwiperOptions = { const siderSwiperOptions = {
direction: 'vertical', direction: 'vertical',
@@ -31,17 +30,15 @@ const UpdateSwiper = () => {
}, 300) }, 300)
} }
export default class index extends Component { export default class index extends Component {
state = { state = {
...getState('layout') ...getState('layout'),
} }
constructor(props) { constructor(props) {
super(props) super(props)
this.unsubscribe = subscribe('layout', (state) => { this.unsubscribe = subscribe('layout', state => {
this.setState(state) this.setState(state)
}) })
} }
@@ -78,7 +75,10 @@ export default class index extends Component {
<div className="swiper-container" id="layout--swiper-container"> <div className="swiper-container" id="layout--swiper-container">
<div className="swiper-wrapper"> <div className="swiper-wrapper">
<div className="swiper-slide"> <div className="swiper-slide">
<Menu parent={this} menuStyle={{ height: '100%', borderRight: 0 }} /> <Menu
parent={this}
menuStyle={{ height: '100%', borderRight: 0 }}
/>
</div> </div>
</div> </div>
<div className="swiper-scrollbar" id="layout--swiper-scrollbar"></div> <div className="swiper-scrollbar" id="layout--swiper-scrollbar"></div>

View File

@@ -6,9 +6,8 @@ import store from 'store'
const { getState, subscribe } = store const { getState, subscribe } = store
export default class index extends Component { export default class index extends Component {
state = { state = {
...getState('nav') ...getState('nav'),
} }
constructor(props) { constructor(props) {
@@ -23,21 +22,25 @@ export default class index extends Component {
this.unsubscribe() this.unsubscribe()
} }
renderMenu = (menu) => { renderMenu = menu => {
return menu.map((p) => { return menu.map(p => {
return p.children ? this.renderSubMenu(p) : this.renderMenuItem(p) return p.children ? this.renderSubMenu(p) : this.renderMenuItem(p)
}) })
} }
renderSubMenu = (menu) => { renderSubMenu = menu => {
return ( return (
<Menu.SubMenu key={menu.id} title={menu.meta.title} icon={menu.meta.icon && <AntIcon type={menu.meta.icon} />}> <Menu.SubMenu
key={menu.id}
title={menu.meta.title}
icon={menu.meta.icon && <AntIcon type={menu.meta.icon} />}
>
{this.renderMenu(menu.children)} {this.renderMenu(menu.children)}
</Menu.SubMenu> </Menu.SubMenu>
) )
} }
renderMenuItem = (menu) => { renderMenuItem = menu => {
return ( return (
<Menu.Item key={menu.id} onClick={() => this.onOpenContentWindow(menu)}> <Menu.Item key={menu.id} onClick={() => this.onOpenContentWindow(menu)}>
{menu.meta.icon && <AntIcon type={menu.meta.icon} />} {menu.meta.icon && <AntIcon type={menu.meta.icon} />}
@@ -46,12 +49,26 @@ export default class index extends Component {
) )
} }
onOpenContentWindow = (menu) => { onOpenContentWindow = menu => {
const { id, meta, component, link, redirect, openType } = menu
window.openContentWindow({ window.openContentWindow({
key: menu.id, key: id,
title: menu.meta.title, title: meta.title,
icon: menu.meta.icon, icon: meta.icon,
path: menu.component path: (() => {
switch (openType) {
case 1:
return component
case 2:
return link
case 3:
return redirect
default:
return null
}
})(),
openType,
}) })
} }
@@ -60,12 +77,11 @@ export default class index extends Component {
} }
render() { render() {
const props = { const props = {
mode: 'inline', mode: 'inline',
selectable: false, selectable: false,
style: this.props.menuStyle, style: this.props.menuStyle,
theme: 'light' theme: 'light',
} }
const on = { const on = {
@@ -74,16 +90,20 @@ export default class index extends Component {
return ( return (
<> <>
{ {this.state.nav.map((item, i) => {
this.state.nav.map((item, i) => { if (item.menu.length) {
return ( return (
<section key={i}> <section key={i}>
<div className="yo-sider-nav--app">{item.app.name}</div> <div className="yo-sider-nav--app">{item.app.name}</div>
<Menu {...props} {...on}>{this.renderMenu(item.menu)}</Menu> <Menu {...props} {...on}>
{this.renderMenu(item.menu)}
</Menu>
</section> </section>
) )
}) } else {
} return false
}
})}
</> </>
) )
} }

View File

@@ -1,10 +1,9 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Spin, Layout } from 'antd' import { Spin, Layout } from 'antd'
import { LoadingOutlined } from '@ant-design/icons'
import { api } from 'common/api' import { api } from 'common/api'
import { cloneDeep, groupBy, findIndex, last } from 'lodash' import { cloneDeep, groupBy, findIndex, last } from 'lodash'
import store from 'store' import store from 'store'
import { EMPTY_ID } from 'util/global' import { EMPTY_ID, SIDER_BREAK_POINT } from 'util/global'
import Header from './_layout/header' import Header from './_layout/header'
import Sider from './_layout/sider' import Sider from './_layout/sider'
@@ -83,6 +82,9 @@ export default class index extends Component {
}) })
}) })
}) })
window.addEventListener('resize', this.onResizeSider)
this.onResizeSider()
} }
/** /**
@@ -103,7 +105,31 @@ export default class index extends Component {
return return
} }
const path = settings.path.startsWith('/') ? settings.path : `/${settings.path}` let path = (p => {
if (p.startsWith('http')) return p
if (p.startsWith('/')) return p
else return `/${p}`
})(settings.path)
if ([2, 3].includes(settings.openType)) {
const param = (p => {
const arr = []
if (p && p.constructor === Object) {
Object.keys(p).forEach(key => {
arr.push(`${key}=${(p[key] || '').toString()}`)
})
}
return arr.join('&')
})(settings.param)
path += param ? `?${param}` : ''
if (settings.openType === 3) {
// 打开新的浏览器窗口
window.open(path)
return
}
}
/** /**
* 向标签页队列中添加一个新的标签页 * 向标签页队列中添加一个新的标签页
@@ -118,7 +144,9 @@ export default class index extends Component {
path, path,
param: settings.param, param: settings.param,
loaded: false, loaded: false,
openType: settings.openType || 1,
} }
this.setState({ this.setState({
panes: [...this.state.panes, newPane], panes: [...this.state.panes, newPane],
}) })
@@ -231,6 +259,13 @@ export default class index extends Component {
}) })
} }
onResizeSider = () => {
dispatch({
type: 'AUTO_TOGGLE_COLLAPSED',
siderCollapsed: window.innerWidth <= SIDER_BREAK_POINT,
})
}
render() { render() {
const { loading, panes, actived } = this.state const { loading, panes, actived } = this.state

View File

@@ -2554,7 +2554,7 @@ arrify@^2.0.1:
resolved "https://registry.nlark.com/arrify/download/arrify-2.0.1.tgz?cache=0&sync_timestamp=1619599497996&other_urls=https%3A%2F%2Fregistry.nlark.com%2Farrify%2Fdownload%2Farrify-2.0.1.tgz#c9655e9331e0abcd588d2a7cad7e9956f66701fa" resolved "https://registry.nlark.com/arrify/download/arrify-2.0.1.tgz?cache=0&sync_timestamp=1619599497996&other_urls=https%3A%2F%2Fregistry.nlark.com%2Farrify%2Fdownload%2Farrify-2.0.1.tgz#c9655e9331e0abcd588d2a7cad7e9956f66701fa"
integrity sha1-yWVekzHgq81YjSp8rX6ZVvZnAfo= integrity sha1-yWVekzHgq81YjSp8rX6ZVvZnAfo=
asap@~2.0.6: asap@~2.0.3, asap@~2.0.6:
version "2.0.6" version "2.0.6"
resolved "https://registry.nlark.com/asap/download/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" resolved "https://registry.nlark.com/asap/download/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY= integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=
@@ -2852,6 +2852,11 @@ balanced-match@^1.0.0:
resolved "https://registry.npm.taobao.org/balanced-match/download/balanced-match-1.0.2.tgz?cache=0&sync_timestamp=1617714233441&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbalanced-match%2Fdownload%2Fbalanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" resolved "https://registry.npm.taobao.org/balanced-match/download/balanced-match-1.0.2.tgz?cache=0&sync_timestamp=1617714233441&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbalanced-match%2Fdownload%2Fbalanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha1-6D46fj8wCzTLnYf2FfoMvzV2kO4= integrity sha1-6D46fj8wCzTLnYf2FfoMvzV2kO4=
base16@^1.0.0:
version "1.0.0"
resolved "https://registry.npm.taobao.org/base16/download/base16-1.0.0.tgz#e297f60d7ec1014a7a971a39ebc8a98c0b681e70"
integrity sha1-4pf2DX7BAUp6lxo568ipjAtoHnA=
base64-js@^1.0.2: base64-js@^1.0.2:
version "1.5.1" version "1.5.1"
resolved "https://registry.nlark.com/base64-js/download/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" resolved "https://registry.nlark.com/base64-js/download/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
@@ -3752,6 +3757,13 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7:
safe-buffer "^5.0.1" safe-buffer "^5.0.1"
sha.js "^2.4.8" sha.js "^2.4.8"
cross-fetch@^3.0.4:
version "3.1.4"
resolved "https://registry.npm.taobao.org/cross-fetch/download/cross-fetch-3.1.4.tgz#9723f3a3a247bf8b89039f3a380a9244e8fa2f39"
integrity sha1-lyPzo6JHv4uJA586OAqSROj6Lzk=
dependencies:
node-fetch "2.6.1"
cross-spawn@7.0.3, cross-spawn@^7.0.0, cross-spawn@^7.0.2: cross-spawn@7.0.3, cross-spawn@^7.0.0, cross-spawn@^7.0.2:
version "7.0.3" version "7.0.3"
resolved "https://registry.npm.taobao.org/cross-spawn/download/cross-spawn-7.0.3.tgz?cache=0&sync_timestamp=1606748073153&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcross-spawn%2Fdownload%2Fcross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" resolved "https://registry.npm.taobao.org/cross-spawn/download/cross-spawn-7.0.3.tgz?cache=0&sync_timestamp=1606748073153&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcross-spawn%2Fdownload%2Fcross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
@@ -5086,6 +5098,31 @@ fb-watchman@^2.0.0:
dependencies: dependencies:
bser "2.1.1" bser "2.1.1"
fbemitter@^3.0.0:
version "3.0.0"
resolved "https://registry.npm.taobao.org/fbemitter/download/fbemitter-3.0.0.tgz#00b2a1af5411254aab416cd75f9e6289bee4bff3"
integrity sha1-ALKhr1QRJUqrQWzXX55iib7kv/M=
dependencies:
fbjs "^3.0.0"
fbjs-css-vars@^1.0.0:
version "1.0.2"
resolved "https://registry.npm.taobao.org/fbjs-css-vars/download/fbjs-css-vars-1.0.2.tgz#216551136ae02fe255932c3ec8775f18e2c078b8"
integrity sha1-IWVRE2rgL+JVkyw+yHdfGOLAeLg=
fbjs@^3.0.0:
version "3.0.0"
resolved "https://registry.npm.taobao.org/fbjs/download/fbjs-3.0.0.tgz?cache=0&sync_timestamp=1602048886093&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffbjs%2Fdownload%2Ffbjs-3.0.0.tgz#0907067fb3f57a78f45d95f1eacffcacd623c165"
integrity sha1-CQcGf7P1enj0XZXx6s/8rNYjwWU=
dependencies:
cross-fetch "^3.0.4"
fbjs-css-vars "^1.0.0"
loose-envify "^1.0.0"
object-assign "^4.1.0"
promise "^7.1.1"
setimmediate "^1.0.5"
ua-parser-js "^0.7.18"
figgy-pudding@^3.5.1: figgy-pudding@^3.5.1:
version "3.5.2" version "3.5.2"
resolved "https://registry.nlark.com/figgy-pudding/download/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e" resolved "https://registry.nlark.com/figgy-pudding/download/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e"
@@ -5212,6 +5249,14 @@ flush-write-stream@^1.0.0:
inherits "^2.0.3" inherits "^2.0.3"
readable-stream "^2.3.6" readable-stream "^2.3.6"
flux@^4.0.1:
version "4.0.1"
resolved "https://registry.npm.taobao.org/flux/download/flux-4.0.1.tgz#7843502b02841d4aaa534af0b373034a1f75ee5c"
integrity sha1-eENQKwKEHUqqU0rws3MDSh917lw=
dependencies:
fbemitter "^3.0.0"
fbjs "^3.0.0"
follow-redirects@^1.0.0, follow-redirects@^1.10.0: follow-redirects@^1.0.0, follow-redirects@^1.10.0:
version "1.14.1" version "1.14.1"
resolved "https://registry.nlark.com/follow-redirects/download/follow-redirects-1.14.1.tgz#d9114ded0a1cfdd334e164e6662ad02bfd91ff43" resolved "https://registry.nlark.com/follow-redirects/download/follow-redirects-1.14.1.tgz#d9114ded0a1cfdd334e164e6662ad02bfd91ff43"
@@ -7137,11 +7182,21 @@ lodash.clonedeep@^4.5.0:
resolved "https://registry.nlark.com/lodash.clonedeep/download/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" resolved "https://registry.nlark.com/lodash.clonedeep/download/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8= integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=
lodash.curry@^4.0.1:
version "4.1.1"
resolved "https://registry.npm.taobao.org/lodash.curry/download/lodash.curry-4.1.1.tgz#248e36072ede906501d75966200a86dab8b23170"
integrity sha1-JI42By7ekGUB11lmIAqG2riyMXA=
lodash.debounce@^4.0.8: lodash.debounce@^4.0.8:
version "4.0.8" version "4.0.8"
resolved "https://registry.npm.taobao.org/lodash.debounce/download/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" resolved "https://registry.npm.taobao.org/lodash.debounce/download/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168= integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168=
lodash.flow@^3.3.0:
version "3.5.0"
resolved "https://registry.npm.taobao.org/lodash.flow/download/lodash.flow-3.5.0.tgz#87bf40292b8cf83e4e8ce1a3ae4209e20071675a"
integrity sha1-h79AKSuM+D5OjOGjrkIJ4gBxZ1o=
lodash.memoize@^4.1.2: lodash.memoize@^4.1.2:
version "4.1.2" version "4.1.2"
resolved "https://registry.nlark.com/lodash.memoize/download/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" resolved "https://registry.nlark.com/lodash.memoize/download/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
@@ -7639,6 +7694,11 @@ no-case@^3.0.4:
lower-case "^2.0.2" lower-case "^2.0.2"
tslib "^2.0.3" tslib "^2.0.3"
node-fetch@2.6.1:
version "2.6.1"
resolved "https://registry.nlark.com/node-fetch/download/node-fetch-2.6.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fnode-fetch%2Fdownload%2Fnode-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
integrity sha1-BFvTI2Mfdu0uK1VXM5RBa2OaAFI=
node-forge@^0.10.0: node-forge@^0.10.0:
version "0.10.0" version "0.10.0"
resolved "https://registry.npm.taobao.org/node-forge/download/node-forge-0.10.0.tgz?cache=0&sync_timestamp=1599010726129&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnode-forge%2Fdownload%2Fnode-forge-0.10.0.tgz#32dea2afb3e9926f02ee5ce8794902691a676bf3" resolved "https://registry.npm.taobao.org/node-forge/download/node-forge-0.10.0.tgz?cache=0&sync_timestamp=1599010726129&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnode-forge%2Fdownload%2Fnode-forge-0.10.0.tgz#32dea2afb3e9926f02ee5ce8794902691a676bf3"
@@ -9040,6 +9100,13 @@ promise-inflight@^1.0.1:
resolved "https://registry.nlark.com/promise-inflight/download/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" resolved "https://registry.nlark.com/promise-inflight/download/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3"
integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM= integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM=
promise@^7.1.1:
version "7.3.1"
resolved "https://registry.npm.taobao.org/promise/download/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
integrity sha1-BktyYCsY+Q8pGSuLG8QY/9Hr078=
dependencies:
asap "~2.0.3"
promise@^8.1.0: promise@^8.1.0:
version "8.1.0" version "8.1.0"
resolved "https://registry.npm.taobao.org/promise/download/promise-8.1.0.tgz#697c25c3dfe7435dd79fcd58c38a135888eaf05e" resolved "https://registry.npm.taobao.org/promise/download/promise-8.1.0.tgz#697c25c3dfe7435dd79fcd58c38a135888eaf05e"
@@ -9142,6 +9209,11 @@ punycode@^2.1.0, punycode@^2.1.1:
resolved "https://registry.nlark.com/punycode/download/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" resolved "https://registry.nlark.com/punycode/download/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha1-tYsBCsQMIsVldhbI0sLALHv0eew= integrity sha1-tYsBCsQMIsVldhbI0sLALHv0eew=
pure-color@^1.2.0:
version "1.3.0"
resolved "https://registry.npm.taobao.org/pure-color/download/pure-color-1.3.0.tgz#1fe064fb0ac851f0de61320a8bf796836422f33e"
integrity sha1-H+Bk+wrIUfDeYTIKi/eWg2Qi8z4=
q@^1.1.2: q@^1.1.2:
version "1.5.1" version "1.5.1"
resolved "https://registry.nlark.com/q/download/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" resolved "https://registry.nlark.com/q/download/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
@@ -9576,6 +9648,16 @@ react-app-polyfill@^2.0.0:
regenerator-runtime "^0.13.7" regenerator-runtime "^0.13.7"
whatwg-fetch "^3.4.1" whatwg-fetch "^3.4.1"
react-base16-styling@^0.6.0:
version "0.6.0"
resolved "https://registry.npm.taobao.org/react-base16-styling/download/react-base16-styling-0.6.0.tgz#ef2156d66cf4139695c8a167886cb69ea660792c"
integrity sha1-7yFW1mz0E5aVyKFniGy2nqZgeSw=
dependencies:
base16 "^1.0.0"
lodash.curry "^4.0.1"
lodash.flow "^3.3.0"
pure-color "^1.2.0"
react-dev-utils@^11.0.3: react-dev-utils@^11.0.3:
version "11.0.4" version "11.0.4"
resolved "https://registry.npm.taobao.org/react-dev-utils/download/react-dev-utils-11.0.4.tgz?cache=0&sync_timestamp=1615231838520&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freact-dev-utils%2Fdownload%2Freact-dev-utils-11.0.4.tgz#a7ccb60257a1ca2e0efe7a83e38e6700d17aa37a" resolved "https://registry.npm.taobao.org/react-dev-utils/download/react-dev-utils-11.0.4.tgz?cache=0&sync_timestamp=1615231838520&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freact-dev-utils%2Fdownload%2Freact-dev-utils-11.0.4.tgz#a7ccb60257a1ca2e0efe7a83e38e6700d17aa37a"
@@ -9630,6 +9712,21 @@ react-is@^17.0.1:
resolved "https://registry.nlark.com/react-is/download/react-is-17.0.2.tgz?cache=0&sync_timestamp=1623273254569&other_urls=https%3A%2F%2Fregistry.nlark.com%2Freact-is%2Fdownload%2Freact-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" resolved "https://registry.nlark.com/react-is/download/react-is-17.0.2.tgz?cache=0&sync_timestamp=1623273254569&other_urls=https%3A%2F%2Fregistry.nlark.com%2Freact-is%2Fdownload%2Freact-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
integrity sha1-5pHUqOnHiTZWVVOas3J2Kw77VPA= integrity sha1-5pHUqOnHiTZWVVOas3J2Kw77VPA=
react-json-view@^1.21.3:
version "1.21.3"
resolved "https://registry.npm.taobao.org/react-json-view/download/react-json-view-1.21.3.tgz#f184209ee8f1bf374fb0c41b0813cff54549c475"
integrity sha1-8YQgnujxvzdPsMQbCBPP9UVJxHU=
dependencies:
flux "^4.0.1"
react-base16-styling "^0.6.0"
react-lifecycles-compat "^3.0.4"
react-textarea-autosize "^8.3.2"
react-lifecycles-compat@^3.0.4:
version "3.0.4"
resolved "https://registry.npm.taobao.org/react-lifecycles-compat/download/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
integrity sha1-TxonOv38jzSIqMUWv9p4+HI1I2I=
react-monaco-editor@^0.43.0: react-monaco-editor@^0.43.0:
version "0.43.0" version "0.43.0"
resolved "https://registry.npm.taobao.org/react-monaco-editor/download/react-monaco-editor-0.43.0.tgz#495578470db7b27ab306af813b31f206a6bf9d1c" resolved "https://registry.npm.taobao.org/react-monaco-editor/download/react-monaco-editor-0.43.0.tgz#495578470db7b27ab306af813b31f206a6bf9d1c"
@@ -9738,6 +9835,15 @@ react-scripts@4.0.3:
optionalDependencies: optionalDependencies:
fsevents "^2.1.3" fsevents "^2.1.3"
react-textarea-autosize@^8.3.2:
version "8.3.3"
resolved "https://registry.nlark.com/react-textarea-autosize/download/react-textarea-autosize-8.3.3.tgz?cache=0&sync_timestamp=1622628433420&other_urls=https%3A%2F%2Fregistry.nlark.com%2Freact-textarea-autosize%2Fdownload%2Freact-textarea-autosize-8.3.3.tgz#f70913945369da453fd554c168f6baacd1fa04d8"
integrity sha1-9wkTlFNp2kU/1VTBaPa6rNH6BNg=
dependencies:
"@babel/runtime" "^7.10.2"
use-composed-ref "^1.0.0"
use-latest "^1.0.0"
react@^17.0.2: react@^17.0.2:
version "17.0.2" version "17.0.2"
resolved "https://registry.nlark.com/react/download/react-17.0.2.tgz?cache=0&sync_timestamp=1623272232595&other_urls=https%3A%2F%2Fregistry.nlark.com%2Freact%2Fdownload%2Freact-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037" resolved "https://registry.nlark.com/react/download/react-17.0.2.tgz?cache=0&sync_timestamp=1623272232595&other_urls=https%3A%2F%2Fregistry.nlark.com%2Freact%2Fdownload%2Freact-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037"
@@ -10387,7 +10493,7 @@ set-value@^2.0.0, set-value@^2.0.1:
is-plain-object "^2.0.3" is-plain-object "^2.0.3"
split-string "^3.0.1" split-string "^3.0.1"
setimmediate@^1.0.4: setimmediate@^1.0.4, setimmediate@^1.0.5:
version "1.0.5" version "1.0.5"
resolved "https://registry.nlark.com/setimmediate/download/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" resolved "https://registry.nlark.com/setimmediate/download/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=
@@ -11220,6 +11326,11 @@ tryer@^1.0.1:
resolved "https://registry.npm.taobao.org/tryer/download/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8" resolved "https://registry.npm.taobao.org/tryer/download/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
integrity sha1-8shUBoALmw90yfdGW4HqrSQSUvg= integrity sha1-8shUBoALmw90yfdGW4HqrSQSUvg=
ts-essentials@^2.0.3:
version "2.0.12"
resolved "https://registry.nlark.com/ts-essentials/download/ts-essentials-2.0.12.tgz#c9303f3d74f75fa7528c3d49b80e089ab09d8745"
integrity sha1-yTA/PXT3X6dSjD1JuA4ImrCdh0U=
ts-pnp@1.2.0, ts-pnp@^1.1.6: ts-pnp@1.2.0, ts-pnp@^1.1.6:
version "1.2.0" version "1.2.0"
resolved "https://registry.npm.taobao.org/ts-pnp/download/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92" resolved "https://registry.npm.taobao.org/ts-pnp/download/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92"
@@ -11336,6 +11447,11 @@ typedarray@^0.0.6:
resolved "https://registry.nlark.com/typedarray/download/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" resolved "https://registry.nlark.com/typedarray/download/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
ua-parser-js@^0.7.18:
version "0.7.28"
resolved "https://registry.nlark.com/ua-parser-js/download/ua-parser-js-0.7.28.tgz#8ba04e653f35ce210239c64661685bf9121dec31"
integrity sha1-i6BOZT81ziECOcZGYWhb+RId7DE=
unbox-primitive@^1.0.1: unbox-primitive@^1.0.1:
version "1.0.1" version "1.0.1"
resolved "https://registry.npm.taobao.org/unbox-primitive/download/unbox-primitive-1.0.1.tgz?cache=0&sync_timestamp=1616706302651&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Funbox-primitive%2Fdownload%2Funbox-primitive-1.0.1.tgz#085e215625ec3162574dc8859abee78a59b14471" resolved "https://registry.npm.taobao.org/unbox-primitive/download/unbox-primitive-1.0.1.tgz?cache=0&sync_timestamp=1616706302651&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Funbox-primitive%2Fdownload%2Funbox-primitive-1.0.1.tgz#085e215625ec3162574dc8859abee78a59b14471"
@@ -11480,6 +11596,25 @@ url@^0.11.0:
punycode "1.3.2" punycode "1.3.2"
querystring "0.2.0" querystring "0.2.0"
use-composed-ref@^1.0.0:
version "1.1.0"
resolved "https://registry.npm.taobao.org/use-composed-ref/download/use-composed-ref-1.1.0.tgz#9220e4e94a97b7b02d7d27eaeab0b37034438bbc"
integrity sha1-kiDk6UqXt7AtfSfq6rCzcDRDi7w=
dependencies:
ts-essentials "^2.0.3"
use-isomorphic-layout-effect@^1.0.0:
version "1.1.1"
resolved "https://registry.npm.taobao.org/use-isomorphic-layout-effect/download/use-isomorphic-layout-effect-1.1.1.tgz#7bb6589170cd2987a152042f9084f9effb75c225"
integrity sha1-e7ZYkXDNKYehUgQvkIT57/t1wiU=
use-latest@^1.0.0:
version "1.2.0"
resolved "https://registry.npm.taobao.org/use-latest/download/use-latest-1.2.0.tgz#a44f6572b8288e0972ec411bdd0840ada366f232"
integrity sha1-pE9lcrgojgly7EEb3QhAraNm8jI=
dependencies:
use-isomorphic-layout-effect "^1.0.0"
use@^3.1.0: use@^3.1.0:
version "3.1.1" version "3.1.1"
resolved "https://registry.nlark.com/use/download/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" resolved "https://registry.nlark.com/use/download/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"