From dc242420f8017f90bbbd27c69c140664517391ec Mon Sep 17 00:00:00 2001 From: daxiongok <571115139@qq.com> Date: Sun, 18 Aug 2024 10:48:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E6=94=AF=E6=8C=81=E5=92=8C=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: daxiongok <571115139@qq.com> --- .../PagedAllResultRequestDto.cs | 32 ++++++++++++++++++- .../Services/RecordLog/LoginLogService.cs | 5 +-- .../Services/RecordLog/OperationLogService.cs | 4 ++- .../src/views/monitor/logininfor/index.vue | 10 ++++-- .../src/views/monitor/operlog/index.vue | 11 +++++-- 5 files changed, 52 insertions(+), 10 deletions(-) diff --git a/Yi.Abp.Net8/framework/Yi.Framework.Ddd.Application.Contracts/PagedAllResultRequestDto.cs b/Yi.Abp.Net8/framework/Yi.Framework.Ddd.Application.Contracts/PagedAllResultRequestDto.cs index a4e90f33..494caceb 100644 --- a/Yi.Abp.Net8/framework/Yi.Framework.Ddd.Application.Contracts/PagedAllResultRequestDto.cs +++ b/Yi.Abp.Net8/framework/Yi.Framework.Ddd.Application.Contracts/PagedAllResultRequestDto.cs @@ -13,5 +13,35 @@ namespace Yi.Framework.Ddd.Application.Contracts /// 查询结束时间条件 /// public DateTime? EndTime { get; set; } + + /// + /// 排序列名,字段名对应前端 + /// + public string? OrderByColumn { get; set; } + /// + /// 是否顺序,字段名对应前端 + /// + public string? IsAsc { get; set; } + + /// + /// 是否顺序 + /// + public bool CanAsc => IsAsc?.ToLower() == "ascending" ? true : false; + private string _sorting; + //排序引用 + public new string? Sorting + { + get + { + if (!OrderByColumn.IsNullOrWhiteSpace()) + { + return $"{OrderByColumn} {(CanAsc ? "ASC" : "DESC")}"; + } + else + { + return _sorting; + } + } + set => _sorting = value; + } } -} diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/RecordLog/LoginLogService.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/RecordLog/LoginLogService.cs index 9286316e..8a30b299 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/RecordLog/LoginLogService.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/RecordLog/LoginLogService.cs @@ -20,11 +20,12 @@ namespace Yi.Framework.Rbac.Application.Services.RecordLog public override async Task> GetListAsync(LoginLogGetListInputVo input) { RefAsync total = 0; - + if (input.Sorting.IsNullOrWhiteSpace()) + input.Sorting = $"{nameof(LoginLogAggregateRoot.CreationTime)} Desc"; var entities = await _repository._DbQueryable.WhereIF(!string.IsNullOrEmpty(input.LoginIp), x => x.LoginIp.Contains(input.LoginIp!)) .WhereIF(!string.IsNullOrEmpty(input.LoginUser), x => x.LoginUser!.Contains(input.LoginUser!)) .WhereIF(input.StartTime is not null && input.EndTime is not null, x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime) - .OrderByDescending(x => x.CreationTime) + .OrderBy(input.Sorting) .ToPageListAsync(input.SkipCount, input.MaxResultCount, total); return new PagedResultDto(total, await MapToGetListOutputDtosAsync(entities)); } diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/RecordLog/OperationLogService.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/RecordLog/OperationLogService.cs index d386b3d3..4e70b58a 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/RecordLog/OperationLogService.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/RecordLog/OperationLogService.cs @@ -24,10 +24,12 @@ namespace Yi.Framework.Rbac.Application.Services.RecordLog public override async Task> GetListAsync(OperationLogGetListInputVo input) { RefAsync total = 0; + if (input.Sorting.IsNullOrWhiteSpace()) + input.Sorting = $"{nameof(OperationLogEntity.CreationTime)} Desc"; var entities = await _repository._DbQueryable.WhereIF(!string.IsNullOrEmpty(input.OperUser), x => x.OperUser.Contains(input.OperUser!)) .WhereIF(input.OperType is not null, x => x.OperType == input.OperType) .WhereIF(input.StartTime is not null && input.EndTime is not null, x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime) - .OrderByDescending(x => x.CreationTime) + .OrderBy(input.Sorting) .ToPageListAsync(input.SkipCount, input.MaxResultCount, total); return new PagedResultDto(total, await MapToGetListOutputDtosAsync(entities)); } diff --git a/Yi.RuoYi.Vue3/src/views/monitor/logininfor/index.vue b/Yi.RuoYi.Vue3/src/views/monitor/logininfor/index.vue index 382e1801..ef08d825 100644 --- a/Yi.RuoYi.Vue3/src/views/monitor/logininfor/index.vue +++ b/Yi.RuoYi.Vue3/src/views/monitor/logininfor/index.vue @@ -181,9 +181,13 @@ function handleSelectionChange(selection) { } /** 排序触发事件 */ function handleSortChange(column, prop, order) { - queryParams.value.orderByColumn = column.prop; - queryParams.value.isAsc = column.order; - getList(); + if (!column.order) { + queryParams.value.orderByColumn = null; + } else { + queryParams.value.orderByColumn = column.prop; + } + queryParams.value.isAsc = column.order; + getList(); } /** 删除按钮操作 */ function handleDelete(row) { diff --git a/Yi.RuoYi.Vue3/src/views/monitor/operlog/index.vue b/Yi.RuoYi.Vue3/src/views/monitor/operlog/index.vue index e19e663d..c8829d7c 100644 --- a/Yi.RuoYi.Vue3/src/views/monitor/operlog/index.vue +++ b/Yi.RuoYi.Vue3/src/views/monitor/operlog/index.vue @@ -202,7 +202,8 @@ const data = reactive({ title: undefined, operUser: undefined, operType: undefined, - state: undefined + state: undefined, + orderByColumn: undefined } }); @@ -240,8 +241,12 @@ function handleSelectionChange(selection) { } /** 排序触发事件 */ function handleSortChange(column, prop, order) { - queryParams.value.orderByColumn = column.prop; - queryParams.value.isAsc = column.order; + if (!column.order) { + queryParams.value.orderByColumn = null; + } else { + queryParams.value.orderByColumn = column.prop; + } + queryParams.value.isAsc = column.order; getList(); } /** 详细按钮操作 */