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(); } /** 详细按钮操作 */