diff --git a/netcore/src/Modularity/Extend/NCC.Extend/LqKhxxService.cs b/netcore/src/Modularity/Extend/NCC.Extend/LqKhxxService.cs index 7d1d0d6..3951230 100644 --- a/netcore/src/Modularity/Extend/NCC.Extend/LqKhxxService.cs +++ b/netcore/src/Modularity/Extend/NCC.Extend/LqKhxxService.cs @@ -603,9 +603,26 @@ namespace NCC.Extend.LqKhxx // 构建查询条件 var sidx = input.sidx == null ? "F_Id" : input.sidx; // 将前端字段名映射到数据库字段名 - if (sidx == "id") sidx = "F_Id"; - if (sidx == "khmc") sidx = "khmc"; - if (sidx == "zcsj") sidx = "zcsj"; + var fieldMapping = new Dictionary + { + { "id", "F_Id" }, + { "khmc", "khmc" }, + { "sjh", "sjh" }, + { "dah", "dah" }, + { "xb", "xb" }, + { "zcsj", "zcsj" }, + { "khlx", "khlx" }, + { "khjd", "khjd" }, + { "khxf", "khxf" }, + { "xfpc", "xfpc" }, + { "yanglsr", "yanglsr" } + }; + if (fieldMapping.ContainsKey(sidx)) + { + sidx = fieldMapping[sidx]; + } + // 确保 sort 参数不为空 + var sortOrder = string.IsNullOrEmpty(input.sort) ? "desc" : input.sort; List queryZcsj = input.zcsj != null ? input.zcsj.Split(',').ToObeject>() : null; DateTime? startZcsj = queryZcsj != null ? Ext.GetDateTime(queryZcsj.First()) : null; DateTime? endZcsj = queryZcsj != null ? Ext.GetDateTime(queryZcsj.Last()) : null; @@ -634,7 +651,7 @@ namespace NCC.Extend.LqKhxx .WhereIF(queryYanglsr != null, p => p.Yanglsr >= new DateTime(startYanglsr.ToDate().Year, startYanglsr.ToDate().Month, startYanglsr.ToDate().Day, 0, 0, 0)) .WhereIF(queryYanglsr != null, p => p.Yanglsr <= new DateTime(endYanglsr.ToDate().Year, endYanglsr.ToDate().Month, endYanglsr.ToDate().Day, 23, 59, 59)) .Where(p => p.IsEffective == StatusEnum.有效.GetHashCode()) - .OrderBy(sidx + " " + input.sort) + .OrderBy(sidx + " " + sortOrder) .ToListAsync(); if (customerList == null || !customerList.Any())